Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Commit

Permalink
optionally semihosting::abort() on panic (#57)
Browse files Browse the repository at this point in the history
* optionally semihosting::abort() on panic

* document semihosting feature
  • Loading branch information
MabezDev authored Apr 2, 2024
1 parent f1d2b73 commit 31f54a1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ features = ["esp32c3", "panic-handler", "exception-handler", "println", "esp-pri
[dependencies]
esp-println = { version = "0.9.1", optional = true, default-features = false }
defmt = { version = "0.3.6", optional = true }
semihosting = { version = "0.1.7", optional = true }

[features]
default = [ "colors" ]

# You must enable exactly one of the below features to support the correct chip:
esp32 = ["esp-println?/esp32"]
esp32 = ["esp-println?/esp32", "semihosting?/openocd-semihosting"]
esp32c2 = ["esp-println?/esp32c2"]
esp32c3 = ["esp-println?/esp32c3"]
esp32c6 = ["esp-println?/esp32c6"]
esp32h2 = ["esp-println?/esp32h2"]
esp32p4 = ["esp-println?/esp32p4"]
esp32s2 = ["esp-println?/esp32s2"]
esp32s3 = ["esp-println?/esp32s3"]
esp32s2 = ["esp-println?/esp32s2", "semihosting?/openocd-semihosting"]
esp32s3 = ["esp-println?/esp32s3", "semihosting?/openocd-semihosting"]

# Use esp-println
println = [ "dep:esp-println" ]
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ When using the panic and/or exception handler make sure to include `use esp_back
| defmt | Use `defmt` logging to print messages\* (check [example](https://github.com/playfulFence/backtrace-defmt-example)) |
| colors | Print messages in red\* |
| halt-cores | Halt both CPUs on ESP32 / ESP32-S3 in case of a panic or exception |
| semihosting | Call `semihosting::process::abort()` on panic. |

\* _only used for panic and exception handlers_

Expand Down
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ fn panic_handler(info: &core::panic::PanicInfo) -> ! {
#[cfg(feature = "colors")]
set_color_code(RESET);

#[cfg(feature = "semihosting")]
semihosting::process::abort();

halt();
}

Expand Down Expand Up @@ -139,6 +142,9 @@ unsafe fn __user_exception(cause: arch::ExceptionCause, context: arch::Context)
#[cfg(feature = "colors")]
set_color_code(RESET);

#[cfg(feature = "semihosting")]
semihosting::process::abort();

halt();
}

Expand Down Expand Up @@ -212,6 +218,9 @@ fn exception_handler(context: &arch::TrapFrame) -> ! {
#[cfg(feature = "colors")]
set_color_code(RESET);

#[cfg(feature = "semihosting")]
semihosting::process::abort();

halt();
}

Expand Down

0 comments on commit 31f54a1

Please sign in to comment.