Skip to content
This repository was archived by the owner on Jan 24, 2022. It is now read-only.

Commit 70f39b7

Browse files
committed
Try #77:
2 parents 939d68f + 13f9849 commit 70f39b7

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

asm.s

-5
This file was deleted.

build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn main() {
1212
let is_armv6m = is_armv6m(&target);
1313

1414
if target.starts_with("thumbv") {
15-
cc::Build::new().file("asm.s").compile("asm");
15+
cc::Build::new().file("hardfault.s").compile("asm");
1616
}
1717

1818
// Put the linker script somewhere the linker can find it

hardfault.s

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.global HardFault
2+
.thumb_func
3+
HardFault:
4+
movs r0, #4
5+
mov r1, lr
6+
tst r0, r1 // Test bit[3] of EXC_RETURN to determine thread mode
7+
8+
beq HardFault.MSP
9+
10+
HardFault.PSP:
11+
mrs r0, PSP // Use Process Stack Pointer (if in user mode)
12+
bl UserHardFault // Jump to hard fault handler
13+
14+
HardFault.MSP:
15+
mrs r0, MSP // Use Main Stack Pointer (if in privileged mode)
16+
bl UserHardFault // Jump to hard fault handler

0 commit comments

Comments
 (0)