cyw43_driver only works with SM0 #1077

Closed
opened 2022-10-26 11:22:25 -05:00 by Lord-Lucan · 5 comments
Lord-Lucan commented 2022-10-26 11:22:25 -05:00 (Migrated from github.com)

The cyw43_driver (see cyw43_bus_pio_spi.c) only supports SM0. It tries to play nice by allocating a free PIO and requesting a SM but if it gets an SM other than 0 it doesn't work.

The workaround is to make sure that you keep SM 0 free on a PIO for this driver.

In cyw43_bus_pio_spi.c (line 263) we have code like this ....
dma_channel_configure(bus_data->dma_out, &out_config, &bus_data->pio->txf[0], tx, tx_length / 4, true);
Which is hardwiring the DMA to pio SM 0 fifo.

Have tried to fix, but not completely working yet :(

The cyw43_driver (see cyw43_bus_pio_spi.c) only supports SM0. It tries to play nice by allocating a free PIO and requesting a SM but if it gets an SM other than 0 it doesn't work. The workaround is to make sure that you keep SM 0 free on a PIO for this driver. In cyw43_bus_pio_spi.c (line 263) we have code like this .... ` dma_channel_configure(bus_data->dma_out, &out_config, &bus_data->pio->txf[0], tx, tx_length / 4, true);` Which is hardwiring the DMA to pio SM 0 fifo. Have tried to fix, but not completely working yet :(
kilograham commented 2022-10-26 11:45:11 -05:00 (Migrated from github.com)

I would thing just changing from txf[0] to txf[bus_data->pio_sm] should do it, no? (also for the other txf[0]/rxf[0])

I would thing just changing from `txf[0]` to `txf[bus_data->pio_sm]` should do it, no? (also for the other `txf[0]/rxf[0]`)
Lord-Lucan commented 2022-10-26 11:53:56 -05:00 (Migrated from github.com)

Hi, thanks for the reply. Yes tried all of that, there are other places in the code where it's hard coded as well. But it still doesn't transfer properly. So it's a bit more deep rooted. I'll take a deeper look at the weekend. At the moment I've just made sure my SM is not claiming 0.

Hi, thanks for the reply. Yes tried all of that, there are other places in the code where it's hard coded as well. But it still doesn't transfer properly. So it's a bit more deep rooted. I'll take a deeper look at the weekend. At the moment I've just made sure my SM is not claiming 0.
Lord-Lucan commented 2022-10-26 11:56:16 -05:00 (Migrated from github.com)

I was wondering if it might have to do with the offset in the SM memory. Because I bet it's never had to share with another program.

I was wondering if it might have to do with the offset in the SM memory. Because I bet it's never had to share with another program.
Lord-Lucan commented 2022-10-26 15:42:33 -05:00 (Migrated from github.com)

Worked out what the final issue was, there needed to be a change to the fdebug flag for the SM in use, see PR.

Worked out what the final issue was, there needed to be a change to the fdebug flag for the SM in use, see PR.
kilograham commented 2022-10-27 16:06:54 -05:00 (Migrated from github.com)

merged into develop

merged into develop
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-raspberrypi/pico-sdk#1077
No description provided.