ARM Cortex-M
Cortex-M HardFault Decoder
Paste 32-bit hex dumps from SCB fault registers (0xE000ED28–0xE000ED38) to unpack active MemManage, BusFault, UsageFault and HardFault bits.
Configurable Fault Status Register (32-bit hex)
HardFault Status Register (32-bit hex)
Ignored unless MMARVALID (bit 7) is 1
VALID (BFARVALID=1)
Presets:
MMFSR [7:0]0x00MemManage byte
BFSR [15:8]0x82BFAR = 0x40005400
UFSR [31:16]0x0000UsageFault halfword
Active Flags3PRECISERR, BFARVALID, FORCED
| Register | Bit | Flag | Root cause | GDB check |
|---|---|---|---|---|
BFSR | 9 | PRECISERR Precise data bus error | Synchronous bus error on a data load/store: accessing an unclocked peripheral (RCC clock disabled), invalid MMIO offset, or bad pointer. Stacked PC points to the faulting instruction; BFAR holds the address when BFARVALID is set. | p/x *(uint32_t*)0xE000ED38 # BFAR; x/2i *(uint32_t*)($sp+24) |
BFSR | 15 | BFARVALID BFAR holds a valid faulting bus address | Hardware latched the exact faulting MMIO or memory address in SCB->BFAR (0xE000ED38). | p/x *(uint32_t*)0xE000ED38 |
HFSR | 30 | FORCED Forced HardFault (escalated configurable fault) | A MemManage, BusFault or UsageFault escalated to HardFault because its dedicated handler was disabled or priority was too low. Inspect CFSR bits above. | p/x *(uint32_t*)0xE000ED28 # CFSR |
SCB fault register map (ARMv7-M / ARMv8-M)
| Register | Address | Width | What it holds |
|---|---|---|---|
CFSR | 0xE000ED28 | 32-bit | Packed MMFSR [7:0], BFSR [15:8], UFSR [31:16]. Write 1 to clear bits. |
HFSR | 0xE000ED2C | 32-bit | Escalation status: bit 30 FORCED, bit 1 VECTTBL, bit 31 DEBUGEVT. |
MMFAR | 0xE000ED34 | 32-bit | Faulting data address for MemManage faults. Only trust when CFSR bit 7 (MMARVALID) is 1. |
BFAR | 0xE000ED38 | 32-bit | Faulting bus address for precise BusFaults. Only trust when CFSR bit 15 (BFARVALID) is 1. |
ACTLR | 0xE000E008 | 32-bit | Set bit 1 (DISDEFWBUF) to disable write buffering when chasing IMPRECISERR. |
Quick GDB dump snippet
arm-none-eabi-gdb
# Print CFSR, HFSR, DFSR, MMFAR, BFAR, AFSR in one shot
x/6wx 0xE000ED28
# Inspect stacked exception frame (r0, r1, r2, r3, r12, lr, pc, xpsr)
# Check EXC_RETURN bit 2 in $lr: 1 = PSP, 0 = MSP
x/8wx ($lr & 4) ? $psp : $msp
# Disassemble the exact faulting instruction at stacked PC (+24 bytes)
x/4i *(uint32_t*)((($lr & 4) ? $psp : $msp) + 24)Reproducing HardFaults deterministically
Hardware probes show the wreckage after the fault lands. Under CircuitTwin GDB, run reverse-stepi from HardFault_Handler to walk straight back to the store or branch that corrupted the stack or hit an unclocked peripheral.