Open japaric opened 3 years ago
Open question: How to differentiate a panic from a hard fault?
Detecting the hard fault
When your system is hung up, the first step is to detect the cause for the hang up. To detect the cause for system hang up, first execute your program in debugging mode and allow the system to run until the system hangs up again, then halt the debugger. There are two ways to determine whether the hang up is due to the hard fault. The first is to watch the Program Counter (PC) register. If this is a hard fault, the PC register will indicate operation in the hard fault handler. The second method is to watch the Interrupt Program Status Register (IPSR). A value of 0x3 indicates a hard fault.
(https://www.embedded.com/debugging-hard-faults-in-arm-cortex-m0-based-socs/)
STR
Start from
app-template
and create asrc/bin/udf.rs
file that contains thismain
functionOutput is incorrect because the program didn't panicked. A hard fault != panic.
panic_probe
uses UDF to terminate theprobe-run
process so right now we classify 'hit UDF' as 'program panicked' but this is not accurate.Ideally we want "program panicked" if
panic-probe
was used and the program panicked and "program hit a hard fault exception" otherwise