From e66423229a1581001f630f4b5615a2ed969c1ea7 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Wed, 22 Sep 2021 10:48:09 -0700 Subject: [PATCH] stm32f7:Support CONFIG_MPU_RESET and CONFIG_ARM_MPU_EARLY_RESET --- arch/arm/src/stm32f7/Make.defs | 2 +- arch/arm/src/stm32f7/stm32_mpuinit.c | 4 ++++ arch/arm/src/stm32f7/stm32_start.c | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/arm/src/stm32f7/Make.defs b/arch/arm/src/stm32f7/Make.defs index 73f01e1457..5ed5c2ff2f 100644 --- a/arch/arm/src/stm32f7/Make.defs +++ b/arch/arm/src/stm32f7/Make.defs @@ -67,7 +67,7 @@ ifeq ($(CONFIG_ARMV7M_ITMSYSLOG),y) CMN_CSRCS += arm_itm_syslog.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/stm32f7/stm32_mpuinit.c b/arch/arm/src/stm32f7/stm32_mpuinit.c index f0564cb056..3f26945b48 100644 --- a/arch/arm/src/stm32f7/stm32_mpuinit.c +++ b/arch/arm/src/stm32f7/stm32_mpuinit.c @@ -70,6 +70,10 @@ void stm32_mpuinitialize(void) mpu_showtype(); + /* Reset MPU if enabled */ + + mpu_reset(); + /* Configure user flash space */ mpu_user_flash(USERSPACE->us_textstart, diff --git a/arch/arm/src/stm32f7/stm32_start.c b/arch/arm/src/stm32f7/stm32_start.c index 162fc98f62..ab30641c3a 100644 --- a/arch/arm/src/stm32f7/stm32_start.c +++ b/arch/arm/src/stm32f7/stm32_start.c @@ -35,6 +35,7 @@ #include "arm_arch.h" #include "arm_internal.h" #include "nvic.h" +#include "mpu.h" #include "barriers.h" #include "stm32_rcc.h" @@ -261,6 +262,10 @@ void __start(void) "r"(CONFIG_IDLETHREAD_STACKSIZE - 64) :); #endif + /* If enabled reset the MPU */ + + mpu_early_reset(); + /* Clear .bss. We'll do this inline (vs. calling memset) just to be * certain that there are no issues with the state of global variables. */