2025-10-09 5:12 PM
Hi,
I am currently developing a small application with a STM32U5 where I write a few bytes into flash using HAL_FLASH_Program(). All seems to work fine. Except I can only read the data back after I do a reset. I suspect that DCACHE is playing a trick on me? But I am not sure how to invalidate the DCache (preferably only for a small section)
SCB_InvalidateDCache();
Seems to have some problems on the STM32U5? At least, I was unable to include the prober h-file w/o getting tons of errors.
What is the new strategy for cache invalidation?
Thanks,
Juergen
2025-10-09 5:16 PM
SCB_InvalidateDCache or SCB_InvalidateDCache_by_Addr are the correct ways to invalidate a section of memory. What problems are you running into? Should be able to call those with code generated from an IOC file by STM32CubeMX.
2025-10-09 5:24 PM
Thanks for your VERY quick reply.
What file do i need to include?
I tried directly in main.c (code generated from IOC file):
../Core/Src/main.c:385:3: error: implicit declaration of function 'SCB_InvalidateDCache' [-Werror=implicit-function-declaration]
385 | SCB_InvalidateDCache();
| ^~~~~~~~~~~~~~~~~~~~
I once used a STM32H7, there everything worked fine. But the STM32U5 and the departure from CMSIS are making things a bit harder :)
Thanks,
Juergen
2025-10-09 6:18 PM - edited 2025-10-09 6:19 PM
What chip do you have? Are you starting from an IOC file?
In a random STM32U5 chip, the compiler has no problem with "SCB_InvalidateDCache" for me.