Skip to content
Tech Interview Prep
Technical interview guide

Embedded Debugging & Toolchains

How embedded engineers actually find bugs when there's no stdout, no OS, and sometimes no working UART to print through.

Minutes to read
3
Practice MCQs
25
Interview Q&A
25
Edition
v4
Editorial status
Reviewed

Scope: Current GDB remote debugging and GCC debug guidance; current OpenOCD user guide; CMSIS 6 SVD/DAP/CoreDebug reviewed 2026-09-04.

Overview

Curated: · Written: · Reviewed:

Embedded Debugging & Toolchains

In one line

Embedded debugging finds bugs with no stdout, no OS and often no UART, by tracing a chain of evidence from source revision to what the silicon actually did. Reach for it whenever the answer depends on the exact binary, the reset state or the run-control state.

Key definitions

  • ELF with symbols: the build output whose symbols and line tables must match the bytes programmed into flash.
  • Observation-to-binary fidelity: every claim names the binary, target, reset state, observation mechanism and its perturbation.
  • Exception frame: the eight words (r0-r3, r12, LR, PC, xPSR) the hardware stacks on a fault, plus FP context when active.
  • FPB and DWT: the breakpoint unit (instruction comparators) and the watchpoint unit (data comparators).
  • RDP: flash readout protection. Level 2 is irreversible on many STM32 parts.
  • Halt is not a camera: halting the core leaves timers, DMA and other cores running.

Formulas and complexity

8×4=32 bytes8 \times 4 = 32\ \text{bytes}

The basic exception frame. Lazy FP stacking adds more words.

A 256-byte no-init region holding r0-r3, r12, LR, PC, xPSR, CFSR, HFSR, MMFAR, BFAR, reset cause, SP, eight extra stacked words and a 16-bit CRC is enough to classify most field faults. It survives reset only if the bootloader does not zero it, so exclude it from BSS. A 64-byte breadcrumb (stacked PC, CFSR, HFSR, reset cause and a 32-byte ring) is the fleet-scale alternative.

How it works

  • The toolchain turns source into an ELF and a map file. The linker script decides where .text, .data, .bss, the vector table and the no-init region land.
  • The programmed image must hash-match the ELF's load segments, or the symbols name the wrong functions.
  • On a precise fault the stacked PC is the faulting instruction, and the stacked LR holds the caller's return address.
  • Read CFSR (0xE000ED28), HFSR (0xE000ED2C), MMFAR (0xE000ED34) and BFAR (0xE000ED38) before clearing them. Validate the stacked SP before dereferencing it.
  • Every observation travels probe, transport, debug server, then debugger UI, and each link can fail silently.
Source revision Toolchain: ELF and map Programmed image Target silicon and board Debug probe Transport: SWD or JTAG Debug server: OpenOCD or GDB Debugger UI

When to use and when not to

SituationAttach a debugger?Use instead
Logic bug on a reproducible bench unitYesHalt, read, step
Timing or race bugNo, the halt changes itGPIO plus logic analyzer, ITM/SWO timestamps
Field fault on one unit, port sealedNot possibleFault dump in no-init RAM, breadcrumb
Fleet statisticsNoRetained crash records and counters
Port fused or pins remuxedNot possibleTrace, counters, recovery reflash

Traps interviewers probe

  1. Trusting a backtrace from the wrong ELF. Fix: hash the programmed load segments against the ELF before trusting any stack.
  2. Reading the source line as what the CPU did. Fix: optimized code reorders, merges and inlines. Cross-check disassembly, line tables and registers.
  3. Ignoring what kept running during a halt. Fix: list the peripherals and cores still active, then reproduce with a non-halting instrument.
  4. Accepting a stack scan hit as the PC. Fix: use the stacked frame. Check that SP lies in the stack region and is 8-byte aligned first.
  5. Assuming all resets are identical. Fix: POR, NRST and a debugger reset-init script leave different states. Reproduce with a power cycle.

Interview tips

Open with the chain: "I'd first confirm the binary matches the flash, then the reset state, then pick the least perturbing instrument."

Expect these follow-ups:

  • Bring-up order: power rails, clock, reset-cause register, is the CPU executing, is the image at the boot address.
  • Why a watchpoint on a DMA-written variable shows the wrong value.
  • How you know ITM dropped packets, and what you do about it.
  • Debugger reset versus power cycle.
  • How the debug port is secured across the lifecycle.

30-second answer outline:

  1. Name the binary and the hash check that ties it to flash (5 s).
  2. State the reset state and the observation mechanism (10 s).
  3. Name the least intrusive instrument and what it perturbs (10 s).
  4. Name the evidence that would falsify the hypothesis (5 s).

Feedback on this overview

Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.