Skip to main content
Hari.52
Associate
February 22, 2021
Question

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

  • February 22, 2021
  • 3 replies
  • 2584 views

..

This topic has been closed for replies.

3 replies

Cartu38 OpenDev
Graduate II
February 22, 2021

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.

Andrew Neil
Super User
February 22, 2021

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.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Hari.52
Hari.52Author
Associate
February 22, 2021

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

Tesla DeLorean
Guru
February 22, 2021

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 VenmoUp vote any posts that you find helpful, it shows what's working..
Hari.52
Hari.52Author
Associate
February 23, 2021

Ya ok thank you for the suggestion