STM32 hardfaulthandler does not invoke

milanvk wrote on Thursday, October 12, 2017:

I am facing a hardfault with one of my freertos task on STM32(Register r2 contains 3 on a default handler). I have implemented a hardfault handler as give in Debug level is kept as -g3 in the IDE, but these hardfault hanlders functions are never invoked (I put a breakpoint at for( ;; ); in prvGetRegistersFromStack() function). As the hardfault handlers are never invoked I am not able to debug what the actual issue is. Any help will be appreciated.



rtel wrote on Thursday, October 12, 2017:

If you are ending up in the default handler rather than your own handler
that contains the debug code it sounds like you have not actually
installed your handler. You need to find the place in the code that
sets up the vector table and ensure your handler is installed as the
hardfault handler - by default it will probably install the default
handler for all the exceptions.

milanvk wrote on Friday, October 13, 2017:

Thank your for the help. May be in my case the Watchdog interrupts are called before reaching the vector tables for hardfault and hardfaultHandler is never invoked. I tried with multiple examples, which may induce a hardfault and in all the cases, the result is the same. So I guess I need to find a way to resolve this WWDG_IRQHandler before.

milanvk wrote on Thursday, November 16, 2017:


Just an update, in my case the issue was that due to the project structure, the hardfault handler defined as a static function as given was not working. When I changed the function to a normal one, it started working and I could finally catch the culprit.