-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Data corruption in STM32 SPI driver in Slave Mode #43115
Comments
Could the cs control, change the tx timing during DMA transfer like on #43411 |
Not really because |
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time. |
@FRASTM any chance to go forward? |
I have a branch here https://github.com/FRASTM/zephyr/tree/spi_using_dma @kborowski2, @r2r0 Could you try if it changes your transmission ? |
It still does not work as expected. I suspect that now we have a problem that transmission can be started when NSS is already active, which causes data corruption. Is there any hardware mechanism, which prevent that kind of behavior? |
Could we fall in one pb with the BSY flag as we can read in the ES0394. Especially in the ll_func_spi_dma_busy the BSY flag is monitored ANDed with the TXE.
|
@kborowski2 Would you be able to provide more details (bus configuration: mode, polarity, ..)? Also any ready to use sample would help investigations |
Still doesn't work as expected ->
About spi configuration:
The rest of the configuration remains with default values. |
Could you please share your zephyr application for the slave. |
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time. |
We have successfully solved our problem making some small changes in the zephyr source code. Additionally we had to add the extra feature, which is the software NSS control in the Slave mode. This allows us to stop the transmission if the master device changes NSS state. Thanks to that we are able to pass a big data buffer to the driver so we can receive either small or large data streams and we do not have to wait for a timeout to detect the end of the transmission. This was very ineffective in case of receiving small data streams. |
Thanks for the head's up !
For sure! |
@kborowski3 can you tell if the issue you faced is similar to #50501 ? |
For me using the interrupt mode wasn't working as well but I don't remember the exact problem. |
Describe the bug
There is a problem with STM32 SPI driver using SLAVE mode with DMA. We can observe 2 problematic cases:
We are using STM32WB55.
To Reproduce
To reproduce this behavior extra device is needed, which will be in the role of SPI master device.
Bug can be seen when master device sends frame to the slave device and then is polling (with very small period) for an answer.
Expected behavior
Logs and console output
We have captured our problem on oscillograms.
Channels description:
transceive_dma
function. It is set to 1 when callingLL_SPI_Enable(spi);
and set to 0 when callingLL_SPI_EnableDMAReq_RX(spi);
andLL_SPI_EnableDMAReq_TX(spi);
Thanks to that signal we can observe what is happening between enabling SPI and DMA and also we can notice if DMA is enabled during active transmission.Case 1: DMA is enabled during active transmission
Result: Data shifted to right by 1 byte - we expected 0001000000010010 and received 0000000000010000
Figure 1: Enabling DMA during active transmission
Case 2. We can observe strange data shift by 5 bits - it can be caused by enabling SPI before DMA
Figure 2: Whole transmission appear between enabling SPI and enabling DMA
Figure 3: Enabling DMA and receiving data shifted by 5 bits - we expected 0001000000010010 and received 0000000010000000
Additional context
SPI settings:
CONFIG_SPI=y
CONFIG_SPI_ASYNC=y
CONFIG_SPI_STM32=y
CONFIG_SPI_STM32_USE_HW_SS=y
CONFIG_SPI_STM32_INTERRUPT=n
The text was updated successfully, but these errors were encountered: