You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/10/23 08:58:38 UTC

[incubator-nuttx] 02/04: stm32:Support CONFIG_MPU_RESET and CONFIG_ARM_MPU_EARLY_RESET

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit fd2c1cb2160e7bdc233d0266e563d3d071470b81
Author: David Sidrane <Da...@NscDg.com>
AuthorDate: Wed Sep 22 10:48:00 2021 -0700

    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 72830c9..ee7a9a0 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 d608715..0c93e33 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 5182f0f..026ae5e 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();