boot: zephyr: cleanup NXP MPU configuration before boot
Cleanup the NXP MPU configuration before chain-loading the
application.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
diff --git a/boot/zephyr/arm_cleanup.c b/boot/zephyr/arm_cleanup.c
index ff4b42e..c6f738b 100644
--- a/boot/zephyr/arm_cleanup.c
+++ b/boot/zephyr/arm_cleanup.c
@@ -5,6 +5,11 @@
*/
#include <arch/arm/aarch32/cortex_m/cmsis.h>
+#include <toolchain.h>
+
+#if CONFIG_CPU_HAS_NXP_MPU
+#include <fsl_sysmpu.h>
+#endif
void cleanup_arm_nvic(void) {
/* Allow any pending interrupts to be recognized */
@@ -33,4 +38,18 @@
ARM_MPU_ClrRegion(i);
}
}
+#elif CONFIG_CPU_HAS_NXP_MPU
+__weak void z_arm_clear_arm_mpu_config(void)
+{
+ int i;
+
+ int num_regions = FSL_FEATURE_SYSMPU_DESCRIPTOR_COUNT;
+
+ SYSMPU_Enable(SYSMPU, false);
+
+ /* NXP MPU region 0 is reserved for the debugger */
+ for (i = 1; i < num_regions; i++) {
+ SYSMPU_RegionEnable(SYSMPU, i, false);
+ }
+}
#endif