cancel
Showing results for 
Search instead for 
Did you mean: 

How to debug different types of Hardfaults in STM32. How to understand and recover the faults

Hari.52
Associate II
 
5 REPLIES 5
Cartu38 OpenDev
Lead II

Have a look to STM32CubeIDE user manual: https://www.st.com/resource/en/user_manual/dm00629856-stm32cubeide-user-guide-stmicroelectronics.pdf

See 'Fault Analyzer' section.

The Hard Fault mechanism is standard for Cortex-M - there's a lot of info available online; eg,

https://community.arm.com/developer/ip-products/system/f/embedded-forum/3257/debugging-a-cortex-m0-hard-fault

and follow all the links.

In particular, I'd emphasise the recommendation of Joseph Yiu's Definitive Guide books.

Hari.52
Associate II

I want to understand more how to recover from the hardfault after understanding the line of error

Recover how? In the sense of fixing the source code, or continuing execution?

Usually you should be able to relate the failing assembler code to something you were doing in C, ie accessing a pointer, touching memory incorrectly, returning from a subroutine, etc. Several diagnostic dumping routines have been posted here over the years, review some of those.

Continuing execution would take some serious skillz, you'd have to unpack the instruction flow and figure out how to remediate the situation before returning and rerunning the code, or advancing the code. It might be easier to use some try/catch exception code where you could at least manage and contain the failure.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Ya ok thank you for the suggestion