Watch
0
0
Fork
You've already forked esp32-c_its-companion
0

main: reboot on panic

This commit is contained in:
Jannik Beyerstedt 2026-08-03 11:15:19 +02:00
commit 4583ad8322
2 changed files with 21 additions and 2 deletions

View file

@ -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"] }

View file

@ -39,7 +39,7 @@ use embassy_gps::gps::l76k;
use esp_backtrace as _;
use esp_hal::clock::CpuClock;
use esp_hal::timer::timg::TimerGroup;
#[cfg(all(target_arch = "riscv32", feature = "spat"))]
#[cfg(target_arch = "riscv32")]
use esp_println::println;
use esp32_cits_core::radio;
use geonetworking::Decode as _;
@ -78,6 +78,26 @@ const SERIAL_FIFO_SIZE_THLD: u8 = 100; // hardware has max. 128 byte
// For more information see: <https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/app_image_format.html#application-description>
esp_bootloader_esp_idf::esp_app_desc!();
// Print a backtrace and reset (instead of halting)
#[panic_handler]
fn panic_handler(info: &core::panic::PanicInfo) -> ! {
println!("");
println!("====================== PANIC ======================");
println!("{}", info);
println!("\nBacktrace:");
let backtrace = esp_backtrace::Backtrace::capture();
for frame in backtrace.frames() {
println!("- 0x{:x}", frame.program_counter());
}
println!("================== BACKTRACE END ==================");
// reboot
println!("-> Doing a SW reset after panic...\n");
esp_hal::system::software_reset();
}
#[cfg(feature = "_gnss")]
static GNSS_UPDATE: Mutex<RefCell<Option<applogic::GnssFix>>> = Mutex::new(RefCell::new(None));
static WIFI_RX_QUEUE: Mutex<RefCell<Option<ArrayQueue<Vec<u8>>>>> = Mutex::new(RefCell::new(None));