arch: arm: cortex_m: z_arm_mpu_init: fix D-Cache invalidation
In case CONFIG_NOCACHE_MEMORY=y, the D-Cache need to be clean and invalidated before enabling the MPU to make sure no data from a __nocache__ region is present in the D-Cache. If the D-Cache is disabled, SCB_CleanInvalidateDCache() shall not be used as it might contains random data for random addresses, and this might just create a bus fault. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
This commit is contained in:
parent
1a583e44ba
commit
be49df628f
1 changed files with 4 additions and 2 deletions
|
@ -326,11 +326,13 @@ int z_arm_mpu_init(void)
|
||||||
arm_core_mpu_disable();
|
arm_core_mpu_disable();
|
||||||
|
|
||||||
#if defined(CONFIG_NOCACHE_MEMORY)
|
#if defined(CONFIG_NOCACHE_MEMORY)
|
||||||
/* Clean and invalidate data cache if
|
/* Clean and invalidate data cache if it is enabled and
|
||||||
* that was not already done at boot
|
* that was not already done at boot
|
||||||
*/
|
*/
|
||||||
#if !defined(CONFIG_INIT_ARCH_HW_AT_BOOT)
|
#if !defined(CONFIG_INIT_ARCH_HW_AT_BOOT)
|
||||||
SCB_CleanInvalidateDCache();
|
if (SCB->CCR & SCB_CCR_DC_Msk) {
|
||||||
|
SCB_CleanInvalidateDCache();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif /* CONFIG_NOCACHE_MEMORY */
|
#endif /* CONFIG_NOCACHE_MEMORY */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue