Hard fault handler

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
dismirlian
Posts: 65
Joined: Fri Dec 20, 2013 3:59 pm
Location: Buenos Aires, Argentina
Has thanked: 1 time
Been thanked: 16 times

Hard fault handler

Postby dismirlian » Wed Oct 02, 2019 9:23 pm

Hi, I've contributed a generic fault handler mechanism, particularly for ARMv7m (Cortex M3/M4(F)/M7).

The fault handlers include:
- HardFault handler, which decodes the fault registers and generates a description string.
- _unhandled_exception handler, which decodes the active vector, so you can effectively see which interrupt was triggered.

The HardFault handler (here) does the following:
- Switches to a separate stack (in case of a corrupt SP).
- Decodes the hard fault registers (done in C).
- Calls an application-defined hook
- Creates an artificial stack frame for the debugger and causes a breakpoint, in order for GDB to show a meaningful stack unwind, so you can see the whereabouts of the instruction that caused the fault.
- If no debugger is attached, restores the separate stack and calls chSysHalt("hard fault")

hardfault.png



The _unhandled_exception handler:
- Decodes the active vector, so you can effectively see which interrupt was triggered.
- If no debugger is attached, calls chSysHalt("unhandled exception")

Also, I included a demo project (here). Any suggestions are welcome!

Cheers,
Diego.

JSStabl
Posts: 78
Joined: Tue Feb 25, 2020 4:06 pm
Has thanked: 3 times
Been thanked: 2 times

Re: Hard fault handler

Postby JSStabl » Tue Nov 30, 2021 2:03 pm

Hi Diego,

I'm recently a nasty unhandled exception currently and found your handler! I was able to make it work, however the only thing that doesn't work is the backtrace.I get:

Code: Select all

#0  _hardfault_epilogue () at stablChibiOS/os/common/ports/ARMCMx/compilers/GCC/utils/fault_handlers_v7m.c:191
#1  0x00000000 in ?? ()


Do you have any idea what I can do to make it work? I'm using chibiOS 20.x


Return to “Development and Feedback”

Who is online

Users browsing this forum: No registered users and 18 guests