[PATCH] bsps/arm: Set MSP in ARMv7-M start code

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Apr 20 05:28:09 UTC 2021


This helps if applications are started by a boot loader.
---
 bsps/arm/shared/start/start.S | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/bsps/arm/shared/start/start.S b/bsps/arm/shared/start/start.S
index 50bf1d4841..bd623178ed 100644
--- a/bsps/arm/shared/start/start.S
+++ b/bsps/arm/shared/start/start.S
@@ -553,6 +553,14 @@ _start:
 #endif
 
 	ldr	sp, =_ISR_Stack_area_end
+
+	/*
+	 * Set the Main Stack Pointer (MSP) to the ISR stack area end just in
+	 * case we run using the Process Stack Pointer (PSP).
+	 */
+	mov	r0, sp
+	msr	msp, r0
+
 	ldr	lr, =bsp_start_hook_0_done + 1
 	b	bsp_start_hook_0
 
-- 
2.26.2



More information about the devel mailing list