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:40 UTC

[incubator-nuttx] 04/04: stm32h7: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 e1a0a1188e6e524bdee71ec6c2f5993ed4072321
Author: David Sidrane <Da...@NscDg.com>
AuthorDate: Wed Sep 22 10:48:18 2021 -0700

    stm32h7:Support CONFIG_MPU_RESET and CONFIG_ARM_MPU_EARLY_RESET
---
 arch/arm/src/stm32h7/Make.defs       | 2 +-
 arch/arm/src/stm32h7/stm32_mpuinit.c | 4 ++++
 arch/arm/src/stm32h7/stm32_start.c   | 7 ++++++-
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/arch/arm/src/stm32h7/Make.defs b/arch/arm/src/stm32h7/Make.defs
index f78faa6..2085559 100644
--- a/arch/arm/src/stm32h7/Make.defs
+++ b/arch/arm/src/stm32h7/Make.defs
@@ -66,7 +66,7 @@ ifeq ($(CONFIG_STM32H7_PROGMEM),y)
 CMN_CSRCS += stm32_flash.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/stm32h7/stm32_mpuinit.c b/arch/arm/src/stm32h7/stm32_mpuinit.c
index 12c02e9..7194aaf 100644
--- a/arch/arm/src/stm32h7/stm32_mpuinit.c
+++ b/arch/arm/src/stm32h7/stm32_mpuinit.c
@@ -70,6 +70,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/stm32h7/stm32_start.c b/arch/arm/src/stm32h7/stm32_start.c
index 5b33d03..b1c1535 100644
--- a/arch/arm/src/stm32h7/stm32_start.c
+++ b/arch/arm/src/stm32h7/stm32_start.c
@@ -36,6 +36,7 @@
 #include "arm_internal.h"
 #include "barriers.h"
 #include "nvic.h"
+#include "mpu.h"
 
 #include "stm32_rcc.h"
 #include "stm32_userspace.h"
@@ -276,7 +277,11 @@ void __start(void)
                    "r"(CONFIG_IDLETHREAD_STACKSIZE - 64) :);
 #endif
 
-  /* Clear .bss.  We'll do this inline (vs. calling memset) just to be
+  /* 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.
    */