cancel
Showing results for 
Search instead for 
Did you mean: 

How to disable data cache on stm32H743?

SKS2CNC
Associate II

I'm using STM32H743 in my project.
If anyone knows how to disable D-cache, please help!
D-cache really interferes with my work - I'm tired of fighting it!
SCB_DisableDCache() - leads to nothing.

18 REPLIES 18
Pavel A.
Evangelist III

Try LL_MPU_CTRL_HFNMI_PRIVDEF instead of LL_MPU_CTRL_HFNMI_PRIVDEF_NONE.

 

LCE
Principal

I don't see that any cache is enabled by default, neither in the AN4839 (see 4 Mistakes to avoid and tips, the advice to invalidate cache before enabling it sounds like it's OFF at CPU start), nor in my H723/733/735 source code (not using HAL). I'm not using any cache, and I'm not disabling it.

Hello,

First, in next time, please use </> button to paste your code. I'm updating your last post.

Second, Table 2 shows the default MPU memory region attributes for Cortex-M. So, this does not mean the cache is enabled by default but the region is cacheable. For example for the regions defined by default as device or strongly ordered and even you enable the cache using SCB_EnableXCache(), that region will not be cacheable.

Third, the difference between what I provided as MPU config is the MPU control mode: MPU privileged default:

 

  /* Enable the MPU */
  HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);

 

Your code: MPU HFNMI privileged none:

 

/* Enables the MPU */
LL_MPU_Enable(LL_MPU_CTRL_HFNMI_PRIVDEF_NONE);

 

So set it to MPU privileged default.

In CubeMx:

SofLit_0-1725438182491.png

You need also to look at the Cortex-M7 programming manual PM0253 STM32F7 Series and STM32H7 Series Cortex®-M7 processor

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Sorry for the long answer - I was testing!
Thanks to everyone - advice with LL_MPU_CTRL_HFNMI_PRIVDEF - the cache is disabled for the necessary memory areas - this is what you need!

This is how it was configured in the cube, but this is not the first bug of the cube - I don’t pay attention anymore - I use the cube only for setting up pins and clocking  
Thank you!

Hello @SKS2CNC  if your question has been answered please mark Accepted as Solution the comment that answered your question.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
SKS2CNC
Associate II

Thanks for the links to AN4839 and PM0253 - it helped for general understanding.

Did the config I provided solved your issue? 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

I don't use the cube much - it was enough for me to solve
LL_MPU_Enable(LL_MPU_CTRL_HFNMI_PRIVDEF);
By the way, for some reason I didn’t find these LowLevel functions in the UM2217