Esp-backtrace - backtrace for ESP32 bare-metal

Overview

esp-backtrace - backtrace for ESP32 bare-metal

  • supports ESP32, ESP32C3, ESP32S2, ESP32S3
  • optional features: panic-handler, exception-handler (will enable esp-println depdendency)
  • work-in-progress, yet already useable

Please note: On RISCV you need to force frame pointers (i.e. "-C", "force-frame-pointers", in your .cargo/config.toml)

You can get an array of backtrace addresses (currently limited to 10) via arch::backtrace() if you want to create a backtrace yourself (i.e. not using the panic or exception handler).

When using the panic and/or exception handler make sure to include use esp_backtrace as _;.

When using this together with esp-println make sure to use the same output kind for both dependencies. (Or don't specify the output for esp-backtrace)

Features

Feature Description
esp32 Target ESP32
esp32c3 Target ESP32C3
esp32s2 Target ESP32S2
esp32s3 Target ESP32S3
panic-handler Include a panic handler, will add esp-println as a dependency
exception-handler Include an exception handler, will add esp-println as a dependency
print-uart Use UART to print messages (*)
print-jtag-serial Use JTAG-Serial to print messages (*)
print-rtt Use RTT to print messages (*)

(*) only used for panic and exception handlers

License

Licensed under either of:

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Comments
  • Prettier panic formatting?

    Prettier panic formatting?

    Hello,

    started using this crate today after it got pulled in by the no_std application template. I see that currently it just debug-prints the PanicInfo, but would you accept a PR that adds some prettier formatting around it?

    In a minimal esp32 code that prints "Hello" and then panics, the serial output is pretty crowded imo:

    load:0x3fff0054,len:4800
    load:0x40078000 [_stack_end_cpu0:??:??],len:17448
    load:0x4007c428 [_stack_end_cpu0:??:??],len:4840
    entry 0x4007c6a0 [_stack_end_cpu0:??:??]
    Hello
    PanicInfo { payload: Any { .. }, message: Some(Help me, I'm dying!), location: Location { file: "src/main.rs", line: 30, col: 9 }, can_unwind: true }
    0x400d1bb8 [half_duplex_uart::__xtensa_lx_rt_main:/var/home/ahartmann/repos/mt/playground/half-duplex-uart/src/main.rs:30]
    0x400d5816 [Reset:/usr/local/share/cargo/registry/src/github.com-1ecc6299db9ec823/xtensa-lx-rt-0.13.0/src/lib.rs:77]
    0x400d29af [ESP32Reset:/usr/local/share/cargo/git/checkouts/esp-hal-42ec44e8c6943228/6e037b0/esp32-hal/src/lib.rs:78]
    

    I was thinking about maybe something like this:

    load:0x3fff0054,len:4800
    load:0x40078000 [_stack_end_cpu0:??:??],len:17448
    load:0x4007c428 [_stack_end_cpu0:??:??],len:4840
    entry 0x4007c6a0 [_stack_end_cpu0:??:??]
    Hello
    
    !! A panic occured at "src/main.rs", line 30, column 9
    
      Message: Help me, I'm dying!
      Payload: ??
    Backtrace:
    
    0x400d1bb8 [half_duplex_uart::__xtensa_lx_rt_main:/var/home/ahartmann/repos/mt/playground/half-duplex-uart/src/main.rs:30]
    0x400d5816 [Reset:/usr/local/share/cargo/registry/src/github.com-1ecc6299db9ec823/xtensa-lx-rt-0.13.0/src/lib.rs:77]
    0x400d29af [ESP32Reset:/usr/local/share/cargo/git/checkouts/esp-hal-42ec44e8c6943228/6e037b0/esp32-hal/src/lib.rs:78]
    

    Or in accordance with the default rust panic handler:

    !! A panic occured at src/main.rs:30:9
    
    opened by har7an 4
  • lib: Pretty-print `PanicInfo`

    lib: Pretty-print `PanicInfo`

    instead of relying solely on the Debug trait for printing. Also add some more space to the output, so the Panic is easily recognized between application text and the backtrace.

    Currently, accessing the panic message is an unstable feature in core, see this tracking issue: https://github.com/rust-lang/rust/issues/66745

    So unless this lands, the current debug print actually contains more useful information than this PR...

    opened by har7an 3
  • Update xtensa-lx-rt to 0.14.0

    Update xtensa-lx-rt to 0.14.0

    In order to prepare a small change in esp-hal ( https://github.com/esp-rs/xtensa-lx-rt/pull/50 ) we first need to update all its dependencies

    When this is merged, we need to bump this crate's version and release it

    opened by bjoernQ 0
  • Adapt to changed ESP32-C3 trap frame

    Adapt to changed ESP32-C3 trap frame

    In https://github.com/esp-rs/esp-hal/pull/207 the trap frame struct changed. We should adapt our copy of the trap frame struct here.

    Nothing bad should happen if we keep it like this so it's not an urgent task

    opened by bjoernQ 0
  • Update the CI to check all combinations of chip/printer

    Update the CI to check all combinations of chip/printer

    I figured out how to accomplish this, so here it is. The RISC-V job looks a little strange due to only having one chip, but once esp-println has a new release I will be PRing ESP32-C2 support here.

    opened by jessebraham 0
  • Add a CI workflow to check (as extensively as possible) various feature combinations

    Add a CI workflow to check (as extensively as possible) various feature combinations

    Doesn't cover every possible combination, but much better than nothing.

    Successful run here:
    https://github.com/jessebraham/esp-backtrace/actions/runs/2890318205

    opened by jessebraham 0
  • Give a hint if there are no backtrace entries on RISCV

    Give a hint if there are no backtrace entries on RISCV

    To make backtraces work on RISCV the user needs to force frame-pointers. We can give a hint in case there are no backtrace entries when running on a RISCV target instead of printing nothing

    enhancement good first issue 
    opened by bjoernQ 0
  • Add support for the ESP32-C6 and ESP32-H2

    Add support for the ESP32-C6 and ESP32-H2

    Keeping this as a draft until esp-println has a new release, but the work is otherwise done. I added some comments for the features and updated our build script to match esp-println as well.

    Closes #12 Closes #13

    opened by jessebraham 1
  • Add a feature for logging panics with defmt

    Add a feature for logging panics with defmt

    In line with the print-uart and print-rtt features, perhaps a print-defmt would make sense?

    I am happy to submit a PR for this, however I have a question. The current implementation calls several println!() functions. In most defmt log printers, the contents of the log statement gets printed along with the location in the source code that the log statement was called.

    Would this mean that we would have only one error!() invocation in the panic_handler? Or should we still call error!() each time we call println().

    Also, due to this quirk of defmt vs println style printing, should I add this functionality to esp-println? Because it may be a mismatch of expected output format.

    opened by TheButlah 2
  • Custom printer feature

    Custom printer feature

    The stack walking code isn't specific to esp's, only the printing methods. This crate maybe useful to other chip vendors if we had a custom printing feature.

    This isn't something we'll implement but maybe a good contribution from the community :).

    enhancement help wanted 
    opened by MabezDev 0
Owner
Björn Quentin
💖 Rust everywhere 💖
Björn Quentin
ESP32-C3 interfacing to a PS/2 Keyboard (bare-metal Rust)

ESP32-C3 interfacing to a PS/2 Keyboard (bare-metal Rust) Very simplified example of connecting a PS/2 keyboard to ESP32-C3 You need to build it with

Björn Quentin 3 Dec 5, 2022
Demo of tokio running on esp32 using esp-idf

Tokio running on esp32! This repo demonstrates a working hello world utilizing upstreamed tokio support for esp32. The tokio executor and I/O reactor

Josh Guilfoyle 9 Aug 7, 2023
An example project demonstrating integration with Rust for the ESP32-S2 and ESP32-C3 microcontrollers.

Rust ESP32 Example An example project demonstrating integration with Rust for the ESP32-S2 and ESP32-C3 microcontrollers.

Espressif Systems 303 Jan 4, 2023
A (mostly) drop-in replacement for Rust's Result that provides backtrace support

Errant A (mostly) drop-in replacement for Rust's Result that provides backtrace support. Please note that Errant is still very early in development an

Joshua Barretto 17 Dec 26, 2022
A library for parsing and generating ESP-IDF partition tables

esp-idf-part A library for parsing and generating ESP-IDF partition tables. Supports parsing from and generating to both CSV and binary formats. This

esp-rs 5 Nov 16, 2022
Shows my Spotify status on a small screen. Powered by ESP-IDF & built with 🧡 in Rust! 🦀

ESP Display A small embedded project that shows what I'm listening to on Spotify by using my Spotify service. Example Notable Features ESP32-S3 board

Isaiah Gamble 3 Apr 10, 2024
Rust implementation of ESP32 NVS partition generator.

Simple ESP32 NVS writer library for Rust Overview A library for Rust to generate NVS partitions for ESP32. How to use See examples/write_simple.rs. Ma

Kenta IDA 4 Dec 29, 2022
Embedded demo based on esp32-c3

wot-esp-demo Demo Hygro-Thermometer based on the esp-rust-board. http version based on std-training Deploy Rust prerequisites Install espflash, ldprox

null 3 Dec 1, 2023
Example of reading the BME280 sensor on an ESP32-C3 using Rust

Rust ESP32-C3 BME280 Example of reading the BME280 sensor on an ESP32-C3 using Rust Hardware: ESP32-C3 microcontroller BME280 sensor Breadboard Jump w

Wei-ying Chen 21 Mar 9, 2024
Rust bindings to llama.cpp, using metal on macOS

llama-rs Rust bindings to llama.cpp, for macOS, with metal support, for testing and evaluating whether it would be worthwhile to run an Llama model lo

Max Brunsfeld 7 Aug 31, 2023
Backtrace for ESP32 bare-metal

esp-backtrace - backtrace for ESP32 bare-metal supports ESP32, ESP32C3, ESP32S2, ESP32S3 optional features: panic-handler, exception-handler (will ena

esp-rs 10 Dec 14, 2022
Rust on ESP32 STD "Hello, World" app. A "Hello, world!" STD binary crate for the ESP32[XX] and ESP-IDF.

Rust on ESP32 STD "Hello, World" app A "Hello, world!" STD binary crate for the ESP32[XX] and ESP-IDF. This is the crate you get when running cargo ne

Ivan Markov 138 Jan 1, 2023
WIP / POC for using the ESP32C3 and ESP32 wifi drivers in bare-metal Rust

Wifi on ESP32C3 and ESP32 (on bare-metal Rust) About This is experimental and work-in-progress! You are welcome to experiment with it and contribute b

esp-rs 135 Jan 2, 2023
ESP32-C3 interfacing to a PS/2 Keyboard (bare-metal Rust)

ESP32-C3 interfacing to a PS/2 Keyboard (bare-metal Rust) Very simplified example of connecting a PS/2 keyboard to ESP32-C3 You need to build it with

Björn Quentin 3 Dec 5, 2022
INA219 and ESP32-C3 / bare-metal Rust

ESP32-C3 Current Sensing with INA219 Read the current measured by INA219 (Adafruit breakout board) on ESP32-C3 (bare-metal Rust) and print it to be vi

Björn Quentin 5 Oct 1, 2023
esp-serial-dbg - debugging of esp-hal based applications via serial

esp-serial-dbg - debugging of esp-hal based applications via serial About This is still work in progress! At least the contained examples should work

Björn Quentin 3 Aug 23, 2022
Demo of tokio running on esp32 using esp-idf

Tokio running on esp32! This repo demonstrates a working hello world utilizing upstreamed tokio support for esp32. The tokio executor and I/O reactor

Josh Guilfoyle 9 Aug 7, 2023
Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋

Rust S̵̓i̸̓n̵̉ I̴n̴f̶e̸r̵n̷a̴l mutability! Howdy, friendly Rust developer! Ever had a value get m̵̯̅ð̶͊v̴̮̾ê̴̼͘d away right under your nose just when

null 294 Dec 23, 2022
An example project demonstrating integration with Rust for the ESP32-S2 and ESP32-C3 microcontrollers.

Rust ESP32 Example An example project demonstrating integration with Rust for the ESP32-S2 and ESP32-C3 microcontrollers.

Espressif Systems 303 Jan 4, 2023
ESP32 implementation of RustZX Spectrum emulator for ESP32-USB-OTG

RustZX for ESP32 - experimental version Goal of the project: Run ZX Spectrum on ESP32 HW: ESP32 OTG USB with ST7789 display References Rust code for E

Juraj Michálek 22 Nov 9, 2022