cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U5 + HAL_FLASH_Program() + DCACHE?

JE
Associate III

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 

3 REPLIES 3
TDK
Super User

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.

If you feel a post has answered your question, please click "Accept as Solution".
JE
Associate III

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

TDK
Super User

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.

If you feel a post has answered your question, please click "Accept as Solution".