Can be SCB_CleanDCache_by_Addr / SCB_InvalidateDCache_by_Addr safely called when cache is disabled ?
I'm working with an STM32H753II on an HMI application.
I use Keil IDE and middlewares to access filesystem data. So i end up using the SD card CMSIS driver developed by ARM Ltd.
With data and instruction cache disabled, i'm experiencing an IMPRECISERR bus fault reading from the SD card. The same software works without any issue with ICache and DCache enabled. Searching around for the cause, i see that the CMSIS driver (MCI_STM32H7xx.c) calls cache maintenance functions SCB_CleanDCache_by_Addr / SCB_InvalidateDCache_by_Addr without checking if cache is enabled.
SCB_CleanDCache_by_Addr ((uint32_t *)daddr, (int32_t)(block_count * block_size));I modify the driver to call SCB_CleanDCache_by_Addr / SCB_InvalidateDCache_by_Addr only if cache enabled. Like this:
if ((SCB->CCR & SCB_CCR_DC_Msk) != 0U)
{ // If Data Cache is enabled
SCB_CleanDCache_by_Addr ((uint32_t *)daddr, (int32_t)(block_count * block_size));
}Other drivers also written by ARM Ltd., like USB Driver (USBH_H2_STM32H7xx.c), performs the same check before calling SCB_CleanDCache_by_Addr / SCB_InvalidateDCache_by_Addr.
With this modification all seems to work fine. No IMPRECISERR also with cache disabled. Now, looking around in Cortex-M7 User Guide and MCU documentation i can't find explicit statement that says SCB->DCCMVAC / SCB->DCIMVAC should not be written when DCache is disabled.
So reach my question: can be SCB_CleanDCache_by_Addr / SCB_InvalidateDCache_by_Addr safely called when cache is disabled ? If yes, the cause may be another ?
Thanks
