How to debug a HardFault on an ARM Cortex-M MCU | Interrupt

Faults happen on embedded devices all the time for a variety of reasons – ranging from something as simple as a NULL pointer dereference to something more unexpected like running a faulty code path only when in a zero-g environment on the Tower of Terror in Disneyland. It’s important for any embedded engineer to understand how to debug and resolve this class of issue quickly.


This is a companion discussion topic for the original entry at https://interrupt.memfault.com/blog/cortex-m-hardfault-debug

hey,
im not sure if i missed something when I saw this gdb command in this blog where you find out which stack pointer was being used prior to exception by looking at the 2nd bit of lr register. how can you say if it is psp or msp by looking at lr register? doesn’t it just hold the return address?