Skip to content

Commit 0e61775

Browse files
committed
On HardFault entry use MSP/PSP depending on stack mode
1 parent 28f74ed commit 0e61775

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cortex-m-rt/asm.s

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,14 @@
66
.type HardFaultTrampoline,%function
77
.thumb_func
88
HardFaultTrampoline:
9+
# depending on the stack mode in EXC_RETURN, fetch stack pointer from
10+
# PSP or MSP
11+
mov r0, lr
12+
mov r1, #4
13+
tst r0, r1
14+
bne 0f
915
mrs r0, MSP
1016
b HardFault
17+
0:
18+
mrs r0, PSP
19+
b HardFault

0 commit comments

Comments
 (0)