STM32CubeF7 icon indicating copy to clipboard operation
STM32CubeF7 copied to clipboard

SD_read - SCB_InvalidateDCache_by_Addr issue

Open Jason0926Ni opened this issue 2 years ago • 2 comments

When Buffer is not 32-byte aligned, SD_Read will invalidate the Data Cache according to the following code. When calculating alignedAddr, the program will add some extra memory addresses to the front, which will cause problems with the data in those memory addresses.

\Middlewares\Third_Party\FatFs\src\drivers\sd_diskio_dma_rtos_template_bspv1.c \Middlewares\Third_Party\FatFs\src\drivers\sd_diskio_dma_rtos_template_bspv2.c


#if (ENABLE_SD_DMA_CACHE_MAINTENANCE == 1)
                /*
                the SCB_InvalidateDCache_by_Addr() requires a 32-Byte aligned address,
                adjust the address and the D-Cache size to invalidate accordingly.
                */
                alignedAddr = (uint32_t)buff & ~0x1F;
                SCB_InvalidateDCache_by_Addr((uint32_t*)alignedAddr, count*BLOCKSIZE + ((uint32_t)buff - alignedAddr));
#endif

Jason0926Ni avatar Jun 02 '23 06:06 Jason0926Ni

Hello @Jason0926Ni ,

Thank you for this report. We will get back to you as soon as we analyze it further. This may take some time. Thank you for your comprehension.

With regards,

TOUNSTM avatar Jun 02 '23 13:06 TOUNSTM

ST Internal Reference: 157163

ASELSTM avatar Jul 12 '23 15:07 ASELSTM

Hello @Jason0926Ni,

First we would like to thank you for your report. In fact, alignedAddr is used only for cache invalidation, it is not used for buffer data read/write.

As this issue is invalid, please allow me thus to close this thread. Thank you for your comprehension.

With regards,

TOUNSTM avatar Jun 06 '24 15:06 TOUNSTM