STM32H7 buffer underrun and speculative reads
We have Cortex-M7 STM32H7 (STM32H753) system and we are experiencing buffer underrun.
We have read application note AN4861 which describes issues that can cause buffer underrun. I think we have implemented all the recommendations in AN4861, however, we are still seeing buffer underrun.
Our display is 480x272 24bpp (RGB888).
We are using two framebuffers located in FMC controlled SDRAM. One framebuffer in bank 3 and the other in bank 4.
We set the buffer pitch to be 512 to ensure 1-Kbyte boundary for LTDC burst read.
We set the pixel clock to be 8 MHz (the lowest value recommended by the LCD manufacturer).
We are currently only using 1-layer.
We have also configured MPU regions for memory regions disabling execution.
The application note talks about speculative read potentially causing buffer underrun issue. How can I tell if my buffer underrun errors are cause by speculative reads? Is there anyway to tell which memory regions are being accessed by the bus when the buffer underrun occurs?
We don't always see buffer underruns. Seemly unrelated code can cause the buffer underrun issue to appear and disappear.
Disabling the DCache seems to make the buffer underrun issue go away. e.g. SCB_DisableDCache();
If disabling the DCache makes the buffer underrun go away, does that mean our buffer underrun is likely caused by speculative reads?
Do you recommend turning off the DCache to prevent speculative read buffer underruns?
Can both DCache and ICache speculative reads cause buffer underrun? If so, do you recommend turning off both DCache and ICache?
In order to prevent speculative DCache reads to memory region, my understanding is that we need to set the following MPU attribute:
MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
Correct?
When we set MPU_ACCESS_NOT_CACHEABLE to a memory region with unaligned static variables, we get a hard fault. (HardFault_Handler() is called). Is this expected? If we turn off caching, do we need to align all static variable accesses?
Any other suggestions or recommendations?
