Expand description
This is a lightweight crate for obtaining backtraces on Espressif devices.
It provides an optional panic handler and supports a range of output options, all configurable through feature flags.
Please note that you need to force frame pointers (i.e. "-C", "force-frame-pointers", in your .cargo/config.toml).
Otherwise the panic handler will emit a stack dump which needs tooling to decode it.
You can get an array of backtrace addresses (limited to 10 entries by default) via
arch::backtrace() if you want to create a backtrace yourself (i.e. not using the panic
handler).
§Features
-
println— Useesp-println -
defmt— UsedefmtPlease note that
defmtdoes not provide MSRV guarantees with releases, and as such we are not able to make any MSRV guarantees when this feature is enabled. For more information refer to the MSRV section ofdefmt’s README: https://github.com/knurling-rs/defmt?tab=readme-ov-file#msrv -
colors(enabled by default) — Print messages in red -
custom-halt— Invoke the extern functioncustom_halt()instead of doing a loop {} in case of a panic. This feature does not imply thehalt-coresfeature. -
custom-pre-backtrace— Invoke the extern functioncustom_pre_backtrace()before handling a panic -
halt-cores— Halt both CPUs on ESP32 / ESP32-S3 instead of doing aloop {}in case of a panic -
semihosting— Exit with a semihosting call in case of a panic -
panic-handler— Include a panic handler
§Additional configuration
We’ve exposed some configuration options that don’t fit into cargo
features. These can be set via environment variables, or via cargo’s [env]
section inside .cargo/config.toml. Below is a table of tunable parameters
for this crate:
| Option | Stability | Default value | Allowed values |
|---|---|---|---|
ESP_BACKTRACE_CONFIG_BACKTRACE_FRAMES The maximum number of frames that will be printed in a backtrace. | ⚠️ Unstable | 10 | |
ESP_BACKTRACE_CONFIG_STACK_DUMP_MAX_SIZE Max amount of stack to dump. | ⚠️ Unstable | 8K | One of:
|