main: reboot on panic
This commit is contained in:
parent
17b84d9aec
commit
4583ad8322
2 changed files with 21 additions and 2 deletions
|
|
@ -90,7 +90,6 @@ embedded-io-async = { version = "0.7.0", optional = true }
|
||||||
esp-alloc = { version = "0.10.0", optional = true }
|
esp-alloc = { version = "0.10.0", optional = true }
|
||||||
esp-backtrace = { version = "0.19.0", optional = true, features = [
|
esp-backtrace = { version = "0.19.0", optional = true, features = [
|
||||||
"esp32c5",
|
"esp32c5",
|
||||||
"panic-handler",
|
|
||||||
"println",
|
"println",
|
||||||
] }
|
] }
|
||||||
esp-println = { version = "0.17.0", optional = true, default-features = false, features = ["colors", "critical-section", "jtag-serial", "esp32c5", "log-04"] }
|
esp-println = { version = "0.17.0", optional = true, default-features = false, features = ["colors", "critical-section", "jtag-serial", "esp32c5", "log-04"] }
|
||||||
|
|
|
||||||
22
src/main.rs
22
src/main.rs
|
|
@ -39,7 +39,7 @@ use embassy_gps::gps::l76k;
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::clock::CpuClock;
|
use esp_hal::clock::CpuClock;
|
||||||
use esp_hal::timer::timg::TimerGroup;
|
use esp_hal::timer::timg::TimerGroup;
|
||||||
#[cfg(all(target_arch = "riscv32", feature = "spat"))]
|
#[cfg(target_arch = "riscv32")]
|
||||||
use esp_println::println;
|
use esp_println::println;
|
||||||
use esp32_cits_core::radio;
|
use esp32_cits_core::radio;
|
||||||
use geonetworking::Decode as _;
|
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>
|
// 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!();
|
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")]
|
#[cfg(feature = "_gnss")]
|
||||||
static GNSS_UPDATE: Mutex<RefCell<Option<applogic::GnssFix>>> = Mutex::new(RefCell::new(None));
|
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));
|
static WIFI_RX_QUEUE: Mutex<RefCell<Option<ArrayQueue<Vec<u8>>>>> = Mutex::new(RefCell::new(None));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue