Skip to content

Commit

Permalink
Fix ESP32-C2 trap handler
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoernQ authored and jessebraham committed Dec 9, 2022
1 parent 0000d46 commit cc3c291
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions esp32c2-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ global_asm!(
.align 6
_start_trap_hal:
addi sp, sp, -32*4
addi sp, sp, -40*4
sw ra, 0*4(sp)
sw t0, 1*4(sp)
Expand Down Expand Up @@ -112,13 +112,27 @@ _start_trap_hal:
sw s11, 27*4(sp)
sw gp, 28*4(sp)
sw tp, 29*4(sp)
addi s0, sp, 32*4
csrrs t1, mepc, x0
sw t1, 31*4(sp)
csrrs t1, mstatus, x0
sw t1, 32*4(sp)
csrrs t1, mcause, x0
sw t1, 33*4(sp)
csrrs t1, mtval, x0
sw t1, 34*4(sp)
addi s0, sp, 40*4
sw s0, 30*4(sp)
add a0, sp, zero
jal ra, _start_trap_rust_hal
lw t1, 31*4(sp)
csrrw x0, mepc, t1
lw t1, 32*4(sp)
csrrw x0, mstatus, t1
lw ra, 0*4(sp)
lw t0, 1*4(sp)
lw t1, 2*4(sp)
Expand Down

0 comments on commit cc3c291

Please sign in to comment.