diff --git a/Cargo.toml b/Cargo.toml index 3d73e22..f6d0681 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" ] diff --git a/README.md b/README.md index 58069e0..d3d537e 100644 --- a/README.md +++ b/README.md @@ -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_ diff --git a/src/lib.rs b/src/lib.rs index 206895f..46b98b0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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(); } @@ -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(); } @@ -212,6 +218,9 @@ fn exception_handler(context: &arch::TrapFrame) -> ! { #[cfg(feature = "colors")] set_color_code(RESET); + #[cfg(feature = "semihosting")] + semihosting::process::abort(); + halt(); }