Disable caching of H7 DMA memory using the MPU.
@@ -39,6 +39,31 @@ void HAL_MspInit(void)
/* Set the system clock */
SystemClock_Config();
+ #if defined(OMV_DMA_REGION_BASE)
+ __DSB(); __ISB();
+ HAL_MPU_Disable();
+
+ /* Configure the MPU attributes to disable caching DMA buffers */
+ MPU_Region_InitTypeDef MPU_InitStruct;
+ MPU_InitStruct.Enable = MPU_REGION_ENABLE;
+ MPU_InitStruct.BaseAddress = OMV_DMA_REGION_BASE;
+ MPU_InitStruct.Size = OMV_DMA_REGION_SIZE;
+ MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
+ MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
+ MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
+ MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
+ MPU_InitStruct.Number = MPU_REGION_NUMBER0;
+ MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL1;
+ MPU_InitStruct.SubRegionDisable = 0x00;
+ MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
+ HAL_MPU_ConfigRegion(&MPU_InitStruct);
+
+ /* Enable the MPU */
+ HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
+ __DSB(); __ISB();
+ #endif
+
+ /* Enable I/D cache */
#if defined(MCU_SERIES_F7) ||\
defined(MCU_SERIES_H7)
// Invalidate CPU cache
