diff --git a/Cargo.toml b/Cargo.toml index aae53d0..0136b8e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -90,7 +90,6 @@ embedded-io-async = { version = "0.7.0", optional = true } esp-alloc = { version = "0.10.0", optional = true } esp-backtrace = { version = "0.19.0", optional = true, features = [ "esp32c5", - "panic-handler", "println", ] } esp-println = { version = "0.17.0", optional = true, default-features = false, features = ["colors", "critical-section", "jtag-serial", "esp32c5", "log-04"] } diff --git a/src/main.rs b/src/main.rs index e37ba83..3b9f173 100644 --- a/src/main.rs +++ b/src/main.rs @@ -78,6 +78,44 @@ const SERIAL_FIFO_SIZE_THLD: u8 = 100; // hardware has max. 128 byte // For more information see: esp_bootloader_esp_idf::esp_app_desc!(); +// TODO: do the equivalent of CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT please +#[panic_handler] +fn panic_handler(info: &core::panic::PanicInfo) -> ! { + esp_println::println!(""); + esp_println::println!("====================== PANIC ======================"); + + esp_println::println!("{}", info); + + // cfg_if::cfg_if! { + // if #[cfg(not(stack_dump))] + // { + // println!(""); + // println!("Backtrace:"); + // println!(""); + + // let backtrace = Backtrace::capture(); + // #[cfg(target_arch = "riscv32")] + // if backtrace.frames().is_empty() { + // println!( + // "No backtrace available - make sure to force frame-pointers. (see https://crates.io/crates/esp-backtrace)" + // ); + // } + // for frame in backtrace.frames() { + // println!("0x{:x}", frame.program_counter()); + // } + // } else { + // arch::dump_stack(); + // } + // } + + esp_println::println!(""); + esp_println::println!(""); + esp_println::println!(""); + + // reboot + esp_hal::system::software_reset(); +} + #[cfg(feature = "_gnss")] static GNSS_UPDATE: Mutex>> = Mutex::new(RefCell::new(None)); static WIFI_RX_QUEUE: Mutex>>>> = Mutex::new(RefCell::new(None));