diff --git a/arch/arm/src/stm32/Make.defs b/arch/arm/src/stm32/Make.defs index 72830c924e6..ee7a9a00de1 100644 --- a/arch/arm/src/stm32/Make.defs +++ b/arch/arm/src/stm32/Make.defs @@ -53,7 +53,7 @@ ifeq ($(CONFIG_ARCH_RAMVECTORS),y) CMN_CSRCS += arm_ramvec_initialize.c arm_ramvec_attach.c endif -ifeq ($(CONFIG_ARM_MPU),y) +ifneq ($(filter y,$(CONFIG_ARM_MPU) $(CONFIG_ARM_MPU_EARLY_RESET)),) CMN_CSRCS += arm_mpu.c endif diff --git a/arch/arm/src/stm32/stm32_mpuinit.c b/arch/arm/src/stm32/stm32_mpuinit.c index d6087157b3f..0c93e332d4e 100644 --- a/arch/arm/src/stm32/stm32_mpuinit.c +++ b/arch/arm/src/stm32/stm32_mpuinit.c @@ -78,6 +78,10 @@ void stm32_mpuinitialize(void) mpu_showtype(); + /* Reset MPU if enabled */ + + mpu_reset(); + /* Configure user flash and SRAM space */ mpu_user_flash(USERSPACE->us_textstart, diff --git a/arch/arm/src/stm32/stm32_start.c b/arch/arm/src/stm32/stm32_start.c index 5182f0f7c2d..026ae5eb286 100644 --- a/arch/arm/src/stm32/stm32_start.c +++ b/arch/arm/src/stm32/stm32_start.c @@ -33,6 +33,7 @@ #include "arm_arch.h" #include "arm_internal.h" #include "nvic.h" +#include "mpu.h" #include "stm32.h" #include "stm32_gpio.h" @@ -217,6 +218,10 @@ void __start(void) "r"(CONFIG_IDLETHREAD_STACKSIZE - 64) :); #endif + /* If enabled reset the MPU */ + + mpu_early_reset(); + /* Configure the UART so that we can get debug output as soon as possible */ stm32_clockconfig();