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
stm32/...hal_dma.c: Use the -O2 option for the F7 MCU DMA driver. #13549
Conversation
Using the default -Os option causes SPI transactions to fail at e.g. a PYBD_SF6 if the source and destination in memory are identical. That is always the case for spi.read() and spi.readinto(). Instead of the data to read the data in the transmit buffer was returned. Signed-off-by: robert-hh <robert@hammelrath.com>
Thanks for the patch. It may seem to fix the issue but I'd like to fully understand what is going on. For example it could be related to the following: in RM0410 rev 2 section 8.3.11 (Single and Burst transfers) it says: We are using burst mode for SPI DMA with the constants |
This could be a different problem. The actual behavior happens with transfers >= 2 byte length. If works is source and destination buffers are different, so it seems not to be related to crossing a 1k boundary. Edit: This error does not show at a PYB_V11, which has the same restriction in the reference manual. |
So I understand that the bursts have a length of 4, and the item size is 4 = burst length 4 bytes. These 4 bytes must not cross a 1k memory boundary. In MicroPython buffers seems to be allocated at 16 byte boundaries. Thus, there should be no problem with the above restriction. |
Considering the issue didn't exist in 1.18 and seems to be attributed to the HAL_DMA_Start_IT() function, was there a hal library update around then this function can be looked at before & after to narrow down a root cause? |
V1.18 was published Jan 17, 2022. The most recent commit for
I compared the F7xx version of the file also to the F4xx version, which is used by the Pyboard V1.1, which does not show the behavior. Differences exist only in comments and integer constants written e.g. like 10 vs. 10U. Besides that the code is identical. |
@dpgeorge |
Let's close this PR then. |
I was not sure whether I should close it or keep it visible for people seeking a temporary fix. And so I had set it to the draft state. |
@dpgeorge |
The delay suggestion was from @projectgus but regardless that's an interesting finding. |
Sorry @projectgus. The other aspect: SPI using DMA work fine if the memory addresses for read and write are different. So it looks like a DMA config problem. |
Just an additional note. The call to HAL_Delay() can be placed in the function |
Another observation: If spi.read() is called with larger sizes it can be seen, that the number of wrong bytes seems always to be a power of 2 less or equal to 32, regardless of the requested size. |
Using the default -Os option causes SPI transactions to fail at e.g. a PYBD_SF6 if the source and destination in memory are identical. That is always the case for spi.read() and spi.readinto(). Instead of the data to read the data in the transmit buffer was returned.