From fd2c1cb2160e7bdc233d0266e563d3d071470b81 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Wed, 22 Sep 2021 10:48:00 -0700 Subject: [PATCH] stm32:Support CONFIG_MPU_RESET and CONFIG_ARM_MPU_EARLY_RESET --- arch/arm/src/stm32/Make.defs | 2 +- arch/arm/src/stm32/stm32_mpuinit.c | 4 ++++ arch/arm/src/stm32/stm32_start.c | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/arm/src/stm32/Make.defs b/arch/arm/src/stm32/Make.defs index 72830c924e..ee7a9a00de 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 d6087157b3..0c93e332d4 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 5182f0f7c2..026ae5eb28 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();