Skip to content

Conversation

@lukash
Copy link
Contributor

@lukash lukash commented Dec 20, 2025

Changes the fault handlers so that on a fault all the relevant registers (those dumped on the stack by the MCU and the fault information registers) are stored in a RAM struct (in the .noinit section) before resetting. Same with the Chibios halt, stores the pointer to the reason string before resetting.

On a bootup, the RAM struct is only initialized if Power On reset flag is set, and the reset flags are also stored in the struct.

This is all the possible information about why a reset could have occurred, which is then exposed via the crash_diag terminal command. Example output:

-> crash_diag 

Reset flags: Reset Pin,Software
System crashed, registers:
r0: 0x00000000
r1: 0x080728a6
r2: 0x00000000
r3: 0x20000800
r12: 0x50000020
lr: 0x080145a5
pc: 0x080145a8
psr: 0x61000000

cfsr: 0x00010000
hfsr: 0x40000000
mmfar: 0xe000ed34
bfar: 0xe000ed38
afsr: 0x00000000
shcsr: 0x00000000

With this output and the firmware .elf file (and in case of a package crash the package .elf) it should be possible to find the causes of a lot of in-the-field crashes and resets in general.

So they can be retrieved after a reset. The reset machanic of stopping
the motor and resetting is preserved for both cases.
It prints the reset flags, in case of a crash it prints the crash
registers and in case of a Chibios halt it prints the reason.
Sets a distinct reason which will be printed in crash diagnostics.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant