I've identified an arithmetic underflow in the SPI read routines which seems to lead a deadlock, at least in my application.
The repeatability code is raspberrypi/pico-examples#101, in the case that the SPI slave starts while the SPI master is in the middle of a transmission. The slave correctly transmits 8 bytes and then deadlocks.
The flaw is in
|
if (tx_remaining && spi_is_writable(spi) && rx_remaining - tx_remaining < fifo_depth) { |
and similar lines below. In the error condition,
tx_remaining is 248 while
rx_remaining is 247. The operation underflows and gives a result of
0xFF FF FF FF FF FF FF FF.
I'm not 100% clear on what happens next, and it probably depends on the timing of signals coming in anyway. Either way, I think the arithmetic underflow is not intended.
I've identified an arithmetic underflow in the SPI read routines which seems to lead a deadlock, at least in my application.
The repeatability code is raspberrypi/pico-examples#101, in the case that the SPI slave starts while the SPI master is in the middle of a transmission. The slave correctly transmits 8 bytes and then deadlocks.
The flaw is in
pico-sdk/src/rp2_common/hardware_spi/spi.c
Line 79 in fc10a97
tx_remainingis 248 whilerx_remainingis 247. The operation underflows and gives a result of0xFF FF FF FF FF FF FF FF.I'm not 100% clear on what happens next, and it probably depends on the timing of signals coming in anyway. Either way, I think the arithmetic underflow is not intended.