diff options
author | Dario Nieuwenhuis <dirbaio@dirbaio.net> | 2021-02-24 00:31:59 +0100 |
---|---|---|
committer | Dario Nieuwenhuis <dirbaio@dirbaio.net> | 2021-02-24 00:31:59 +0100 |
commit | 929ce945ef0c2a351b161769b7d04bb9a7b02d5c (patch) | |
tree | 2d34e82fbb0fbdf21e5593e09132746312e3bd54 /nrf-softdevice | |
parent | fa4810865c6268d5dcd592d7452d75ebf28ca6e5 (diff) | |
download | nrf-softdevice-929ce945ef0c2a351b161769b7d04bb9a7b02d5c.zip |
Improve panic messages on softdevice faults. Fixes #45
Diffstat (limited to 'nrf-softdevice')
-rw-r--r-- | nrf-softdevice/src/softdevice.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/nrf-softdevice/src/softdevice.rs b/nrf-softdevice/src/softdevice.rs index d62e014..3860334 100644 --- a/nrf-softdevice/src/softdevice.rs +++ b/nrf-softdevice/src/softdevice.rs @@ -10,7 +10,24 @@ use crate::raw; use crate::RawError; unsafe extern "C" fn fault_handler(id: u32, pc: u32, info: u32) { - panic!("fault_handler {:?} {:?} {:?}", id, pc, info); + match (id, info) { + (raw::NRF_FAULT_ID_SD_ASSERT, _) => panic!( + "Softdevice assertion failed: an assertion inside the softdevice's code has failed. Most common cause is disabling interrupts for too long. Make sure you're using nrf_softdevice::interrupt::free instead of cortex_m::interrupt::free, which disables non-softdevice interrupts only. PC={:?}", + pc + ), + (raw::NRF_FAULT_ID_APP_MEMACC, 0) => panic!( + "Softdevice memory access violation. Your program accessed RAM reserved to the softdevice. PC={:?}", + pc + ), + (raw::NRF_FAULT_ID_APP_MEMACC, _) => panic!( + "Softdevice memory access violation. Your program accessed registers for a peripheral reserved to the softdevice. PC={:?} PREGION={:?}", + pc, info + ), + _ => panic!( + "Softdevice unknown fault id={:?} pc={:?} info={:?}", + id, pc, info + ), + } } #[allow(non_snake_case)] |