Cortex-M fault decoder

HardFault analysis: CFSR, HFSR, BFAR, MMFAR, stacked PC/LR, EXC_RETURN.

How to use it

  1. After a HardFault, read CFSR, HFSR, MMFAR and BFAR from the debugger, and the stacked registers.
  2. Paste them in.
  3. Read which fault happened, at which address, and where the code was (PC and LR).

Questions

Where do I find these registers?

CFSR is at 0xE000ED28, HFSR at 0xE000ED2C, MMFAR at 0xE000ED34 and BFAR at 0xE000ED38. The stacked PC and LR are on the stack the EXC_RETURN value points to.

Why is BFAR not valid?

BFAR holds an address only when CFSR’s BFARVALID bit is set; imprecise bus faults do not record one.

Related tools

  • Cortex-M debugger in the browser (ST-LINK, CMSIS-DAP): Halt, step and reset an Arm Cortex-M; watch and write global variables from the ELF live with plots; SEGGER RTT terminal; live SVD peripheral registers; breakpoints, watchpoints and HardFault capture. Over WebUSB, nothing to install.
  • Memory usage analyzer (MAP / ELF): Flash/RAM per region, module and symbol from GNU ld map files and ELF; compare two builds.
  • Register viewer (SVD): CMSIS-SVD peripherals, registers and bit fields; decode a value; find the register at an address; C defines.
  • Serial terminal (Web Serial): UART console in the browser: baud, parity, text/hex, timestamps, log to file, macros, DTR/RTS; a live plotter and send/expect scripts.
  • Number converter: Hex, decimal, binary, signed and ASCII, in either byte order.

Lessons that explain it

Also useful for: hardfault, hard fault, cfsr, hfsr, bfar, mmfar, busfault, usagefault, memmanage, crash.