2021-04-02 12:00 PM
I think the article here:
https://community.st.com/s/article/FAQ-DMA-is-not-working-on-STM32H7-devices
is wrong. In solution 3 it invalidate D-cache before reception. This doesn't make sense, it has to invalidate the D-cache after reception.
Solved! Go to Solution.
2021-04-02 03:58 PM
Regarding the before/after, the article is right - invalidation must be done before starting the reception. Read my post in this topic:
AN4839 page 4:
Detailed discussion:
https://community.st.com/s/question/0D50X0000C9hGoz/weird-cache-writeback-behavior-for-stm32f7508
But the article is wrong on other issues:
#define RX_LENGTH (16)
uint8_t rx_buffer[RX_LENGTH];
/* Make sure the address is 32-byte aligned and add 32-bytes to length, in case it overlaps cacheline */
SCB_InvalidateDCache_by_Addr((uint32_t*)(((uint32_t)rx_buffer) & ~(uint32_t)0x1F), RX_LENGTH+32);
2021-04-02 03:58 PM
Regarding the before/after, the article is right - invalidation must be done before starting the reception. Read my post in this topic:
AN4839 page 4:
Detailed discussion:
https://community.st.com/s/question/0D50X0000C9hGoz/weird-cache-writeback-behavior-for-stm32f7508
But the article is wrong on other issues:
#define RX_LENGTH (16)
uint8_t rx_buffer[RX_LENGTH];
/* Make sure the address is 32-byte aligned and add 32-bytes to length, in case it overlaps cacheline */
SCB_InvalidateDCache_by_Addr((uint32_t*)(((uint32_t)rx_buffer) & ~(uint32_t)0x1F), RX_LENGTH+32);
2021-04-02 04:47 PM
Thanks, that's tricky. And bugs actually happened when I tested it with an external flash, every few MB there were a few bytes wrong. Invalidating it before works now:
SCB_InvalidateDCache_by_Addr((uint32_t*)ramDestination, FLASH_PAGE_SIZE);
HAL_OSPI_Receive_DMA(&hospi1, ramDestination);
2021-04-02 05:01 PM
I added more details and a link to another detailed discussion to the initial post. Could be interesting read... :)