Creating Chaos and Hard Faults
Creating Chaos and Hard Faults Video Presentation
The best way to understand why the processor is sending you love letters (exceptions) is to see what they look like when you aren’t also frantically trying to fix your code. This talk goes over the code necessary to cause (and debug) divide by zero, bus errors, stack overflows, and buffer overflows.
For each one, Elecia looks at the information the Cortex-M processor provides and how to use that to determine the cause of the fault. She describes how to use the information in a hard fault handler to create small core dumps to be stored after a system reboot.
This presentation is based on Chapter 9: Getting into Trouble, one of the new chapters in the second edition of Making Embedded Systems.
The slides are available in the Making Embedded Systems github repository.
The resources mentioned:
Code used in the demo: https://github.com/eleciawhite/making-embedded-systems/blob/main/Ch09_Debugging/
Introduction to Hard Faults:
First handler shown from FreeRTOS: Debugging and diagnosing hard faults on ARM Cortex-M CPUs
Second handler shown from Memfault’s Interrupt: How to debug a HardFault on an ARM Cortex-M MCU | Interrupt (this is the most in-depth resource )
Adding NULL identification: Setting up the Cortex-M3/4 (ARMv7-M) Memory Protection Unit (MPU) - Sticky Bits
Smashing the Stack for Fun and Profit describes how to manipulate the stack
Buried Treasure and Map Files (and Linker Files) talk and map: https://embedded.fm/blog/mapfiles
This talk was originally presented as a keynote at the Embedded Online Conference in 2024. All of the excellent talks are available there with paid registration.