2021-03-15 12:29 AM
Hello, I am using STM32F746 with Touchgfx. I generated project with STM32CUBEMX. I notice that during first boot STM gets reset multiple times before running stable.
I try to debug issue and found that ound out its getting reset at function SCB_CleanInvalidateDCache () ( PC : 0x08011420 or 0x08011410 ).
And SCB_CleanInvalidateDCache() is getting called by TouchGFXGeneratedHAL::flushFrameBuffer()
I didn't enable cache in cubemx project, Not sure about issue, Any suggestion ?
Thanks
2021-03-15 12:30 AM
@Martin KJELDSEN Any suggestions ?
2021-03-15 02:41 PM
Also SCB_CleanInvalidateDCache() is inefficient and mostly dangerous. Flushing buffers before passing them to DMA should be done by SCB_CleanDCache_by_Addr().
2021-03-15 03:03 PM
I had this out with some chap last week.
You're using GNU, and an OLD version of the CMSIS library that doesn't check the current cache state, and it's trashing the pending stack flush to memory.
The function is supposed to in-line completely, so it's not pushing on the stack. And it should be aware if the cache is currently enabled or not.
2021-03-15 03:14 PM
Going to be an absolute sloth with no caches enabled. The function expects the cache to be enabled, and doesn't check further
2021-03-15 11:59 PM
This code is generated by Touchgfx
2021-03-15 11:59 PM
I enabled both I and D cache. Do I need to enable MPU too ?
2021-03-16 12:00 AM
I enabled both I and D cache. Do I need to enable MPU too ?
2024-03-11 05:34 AM - edited 2024-03-11 05:57 AM
In the example of TouchGFX for the stm32h735g-dk devkit they enable the MPU for specific regions.
It works without the MPU, but it might be better to enable it so you have control over which regions are cached.
In "Table 6. Memory map and default device memory area attributes" of RM0468 you can see that many regions (including internal SRAM) have D-cache attribute set by default, but this may not be desirable?
According to Msolinas "the MPU is very important for RAM settings": https://community.st.com/t5/stm32-mcus-touchgfx-and-gui/problem-when-i-use-external-sram-in-touchgfx-wrong-pixels/td-p/592117/page/2
Below is the configuration generated by TouchGFX:
This is how I invalidate cache:
if (SCB->CCR & SCB_CCR_DC_Msk)
{
//https://community.st.com/t5/stm32-mcus-touchgfx-and-gui/stm-keep-getting-reset-at-scb-cleaninvalidatedcache-like-15-25/td-p/205024
//"also SCB_CleanInvalidateDCache() is inefficient and mostly dangerous. Flushing buffers before passing them to DMA should be done by SCB_CleanDCache_by_Addr()."
uint8_t bpp = lcdRef.bitDepth() / 8;
SCB_CleanDCache_by_Addr((uint32_t *)TouchGFXGeneratedHAL::getTFTFrameBuffer(), FRAME_BUFFER_WIDTH * FRAME_BUFFER_HEIGHT * bpp);
}