drivers/flash: stm32h7: fix fault when cache disabled

Add a check to avoid invalidating the cache when the latter is disabled.
Indeed, doing so can lead to a bus fault.

Signed-off-by: Thomas Altenbach <taltenbach@witekio.com>
This commit is contained in:
Thomas Altenbach 2021-11-25 13:49:17 +01:00 committed by Carles Cufí
commit c5ebea590f

View file

@ -449,6 +449,11 @@ static void flash_stm32h7_flush_caches(const struct device *dev,
off_t offset, size_t len)
{
ARG_UNUSED(dev);
if (!(SCB->CCR & SCB_CCR_DC_Msk)) {
return; /* Cache not enabled */
}
SCB_InvalidateDCache_by_Addr((uint32_t *)(CONFIG_FLASH_BASE_ADDRESS
+ offset), len);
}