Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ESP32-C2 trap handler #292

Merged
merged 1 commit into from
Dec 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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