Commit 008f4a7a authored by Henrik Brix Andersen's avatar Henrik Brix Andersen Committed by Andrzej Puzdrowski
Browse files

boot: zephyr: cleanup NXP MPU configuration before boot



Cleanup the NXP MPU configuration before chain-loading the
application.

Signed-off-by: default avatarHenrik Brix Andersen <hebad@vestas.com>
parent 7cca88ab
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -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 @@ __weak void z_arm_clear_arm_mpu_config(void)
		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
+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@
 */
void cleanup_arm_nvic(void);

#if defined(CONFIG_CPU_HAS_ARM_MPU)
#if defined(CONFIG_CPU_HAS_ARM_MPU) || defined(CONFIG_CPU_HAS_NXP_MPU)
/**
 * Cleanup all ARM MPU region configuration
 */
+1 −1
Original line number Diff line number Diff line
@@ -148,7 +148,7 @@ static void do_boot(struct boot_rsp *rsp)
    SCB_DisableICache();
#endif

#if CONFIG_CPU_HAS_ARM_MPU
#if CONFIG_CPU_HAS_ARM_MPU || CONFIG_CPU_HAS_NXP_MPU
    z_arm_clear_arm_mpu_config();
#endif