Skip to content
Tech Interview Prep
Technical interview guide

Firmware & Bootloaders

What runs before application code, how a device updates itself in the field, and the linker script details that decide where everything ends up in memory.

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

Scope: Current MCUboot design/imgtool/recovery guidance; RFC 9019 and RFC 9124; NIST SP 800-193; CMSIS-Core 6 reviewed 2026-09-04.

Overview

Curated: · Written: · Reviewed:

Firmware & Bootloaders

In one line

The bootloader decides which firmware may run, how the device recovers from an interrupted or faulty update, and where every image lives in flash and RAM. Reach for it whenever a question involves secure boot, A/B or swap updates, rollback, or the handoff into application code.

Key definitions

  • Root of trust: the immutable first stage (mask ROM or protected flash) that verifies the next stage against a key or hash fixed at manufacture.
  • Authentication vs. integrity: a signature proves the signing key holder produced the image; a checksum or CRC only detects accidental corruption and an attacker can recompute it.
  • Anti-rollback counter: a monotonic value in OTP, eFuse or a wear-leveled protected region, raised only after a confirmed boot. A counter in RAM is not anti-rollback.
  • Confirm window: the period (30 s in the reference design) after which the new image must pass sensor and comms health checks, or the bootloader reverts.
  • Handoff contract: the state the application expects at entry: VTOR, MSP, interrupts disabled, SYSCLK, watchdog, cache and MPU.

Formulas and complexity

CRC32 collision probability against accidental flash errors, for any image:

Pcollision≈2−32P_{\text{collision}} \approx 2^{-32}

That figure holds only against random corruption. An attacker who recomputes the CRC defeats it completely.

How it works

  • The ROM checks the second-stage bootloader against the burned-in key or hash and jumps only on success; otherwise it enters recovery.
  • The second stage parses the manifest bounds-checked, verifies the hash and signature, then checks hardware identity, version, dependencies and the anti-rollback counter.
  • It selects the slot named by power-fail-safe metadata and sets VTOR, MSP and the clock state the application expects.
  • After boot, the application must pass its health checks inside the confirm window; only then does the slot become confirmed and the counter advance.
  • Any failure at any step falls back to the last confirmed slot or to bounded, authenticated recovery.
fail pass fail pass fail pass pass fail or reset Power-on reset ROM verifies stage 2 hash and key Authenticated recovery Stage 2 verifies manifest signature Last confirmed slot Version, identity, anti-rollback check Set VTOR, MSP, clocks and jump Health checks inside 30 s Confirm and advance counter

When to use and when not to

ChoiceUse whenAvoid when
A/B (dual bank)Flash allows a second full slot and you need a bootable image intact through power lossFlash is too small for two images
Swap with stagingFlash is tight and you can reserve scratch at least the largest erase unit plus a trailerScratch is smaller than the erase unit being moved
Overwrite, XIP or recovery-onlyRecoverability is not a requirementAny field update that must survive a bad image
Confirm after health checksThe app can measure sensor and comms healthYou only know main() was reached
Transport trust (TLS, signed CDN)Added to device-side verificationUsed as a replacement for it

Traps interviewers probe

  • CRC as authentication. An attacker who edits the payload recomputes the CRC and passes. Fix: verify an ECDSA or RSA signature over a hash of the image, with the key in ROM or a secure element.
  • Integer wrap in manifest bounds. offset + length in uint32_t wraps past 2^32. Fix: check length <= total_size and offset <= total_size - length before the addition, and validate against the containing object.
  • Anti-rollback in RAM or in a writable version string. A glitch reboot restores the old value. Fix: keep the counter in OTP, eFuse or a protected wear-leveled region and advance it only after a confirmed boot.
  • Confirm on main(). A firmware that hard-faults in the 31st second loops on an unconfirmed slot. Fix: confirm after 30 s of explicit sensor and comms checks.
  • Handoff by a bare branch. The application inherits the bootloader's stack and clocks. Fix: set MSP and VTOR to the application's values, disable interrupts, and normalize the PLL, caches and watchdog before the jump.

Interview tips

Opening. Name the trust boundary first: root of trust, signature verification, anti-rollback, and the production invariant that after any reset the device runs only authorized, compatible firmware or enters bounded recovery.

Expected follow-ups.

  • Where does the anti-rollback counter physically live, and when is it advanced?
  • What happens on power loss at each program and erase boundary?
  • How do you rotate a key without bricking devices that missed the first update?
  • How does the bootloader update itself safely?
  • Why does the linker script have to agree with the image header and the bootloader?

30-second outline. Verification is a signature over a hash of the manifest and image, checked on device before every boot. Rollback is a separate monotonic counter in OTP, advanced only after a health-checked confirm. A/B keeps the last good slot intact, and power-fail-safe metadata names the active slot. The handoff sets VTOR, MSP and clocks explicitly. Failures fall back to the last confirmed slot or to authenticated recovery, and retained evidence records each decision.

Feedback on this overview

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