From dd69967934106cec32fd9e281b10083d59c15fde Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 7 Nov 2015 09:35:23 -0600 Subject: [PATCH] SAMV7 protected mode: Don't enable D-Cache until userspace data has been initialized --- arch/arm/src/samv7/sam_start.c | 24 ++++++++++++------------ arch/arm/src/samv7/sam_userspace.c | 3 +++ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/arch/arm/src/samv7/sam_start.c b/arch/arm/src/samv7/sam_start.c index 985e24e181d..285e429b6b4 100644 --- a/arch/arm/src/samv7/sam_start.c +++ b/arch/arm/src/samv7/sam_start.c @@ -367,18 +367,6 @@ void __start(void) sam_boardinitialize(); - /* Enable I- and D-Caches */ - - arch_dcache_writethrough(); - arch_enable_icache(); - arch_enable_dcache(); - - /* Perform early serial initialization */ - -#ifdef USE_EARLYSERIALINIT - up_earlyserialinit(); -#endif - #ifdef CONFIG_ARMV7M_MPU /* For the case of the separate user-/kernel-space build, perform whatever * platform specific initialization of the user memory is required. @@ -398,6 +386,18 @@ void __start(void) sam_mpu_initialize(); #endif + /* Enable I- and D-Caches */ + + arch_dcache_writethrough(); + arch_enable_icache(); + arch_enable_dcache(); + + /* Perform early serial initialization */ + +#ifdef USE_EARLYSERIALINIT + up_earlyserialinit(); +#endif + /* Then start NuttX */ #ifdef CONFIG_STACK_COLORATION diff --git a/arch/arm/src/samv7/sam_userspace.c b/arch/arm/src/samv7/sam_userspace.c index 136c5ac1d75..255d59919a1 100644 --- a/arch/arm/src/samv7/sam_userspace.c +++ b/arch/arm/src/samv7/sam_userspace.c @@ -62,6 +62,9 @@ * Normally this just means initializing the user space .data and .bss * segments. * + * Assumptions: + * The D-Cache has not yet been enabled. + * ****************************************************************************/ void sam_userspace(void)