All jobs / Embedded / hardware / Debugging
Embedded / hardware interview question · 1–3 years
HardFault on Cortex-M. What do you capture before you “add a print”?
The strongest answer
Stacked PC/LR and the fault status registers — then reproduce — I do not reset-in-a-loop to hide it
Why it works
Exactly. The stacked PC is the clue. Empty handlers and -O roulette waste a day.
What a good answer covers
- Capture stacked PC and fault regs.
- Then reproduce.
- Do not empty-loop the handler.
- Do not start with -O roulette.
Answers that fall short
- Close, but not the strongest: I disable the fault handler
No handler, no story. - Weak: I ship a while(1) empty handler
while(1) is a silent brick. - Red flag: I blame the compiler and change -O
-O can change it; it is not the first read.
Who gets asked this
More Debugging questions
- What should a field build do on a failed assert?
- Datasheet says 400 kHz I2C; the line looks filthy at 100. What wins?
- A struct field changes value minutes into a run, and nothing in the code writes to it. How do you find the…
- What do you log in the field when flash is tiny?
- A fleet starts resetting in the wild. First staff hour?
- What is SWD, and how does it differ from JTAG?
- A bug vanishes when you add printf. What did you learn?
- When do you reach for a logic analyser, and when for an oscilloscope?