Engineering

Reading JTAG Output When You've Locked Yourself Out

by Vik Thomas · April 28, 2026 · 6 min read

The board is on the bench, it enumerates nothing, and the debugger reports the target as unavailable. You set the readout protection yourself, three sprints ago, because a checklist told you to. Now you need to know what the firmware did before it stopped, and the one interface designed to tell you is the interface you disabled.

This is a recoverable situation more often than people assume, but only if you triage in the right order. Every invasive step you take closes doors behind you.

Know which lock you actually set

"Locked out" covers at least four different states, and they have different exits. Before touching anything, establish which one you are in:

  1. Soft readout protection. A flag in option bytes or a config word. Debug is refused, but a full chip erase clears the flag and restores access. You lose flash contents, not the part.
  2. Debug authentication. Debug is gated behind a challenge-response against a key. If you hold the key, you are not locked out at all — you are missing a step in your tooling.
  3. Fused permanent disable. An OTP fuse or one-time-writable word that removes the debug port from the die's behaviour. No erase recovers this. The part is a production part forever.
  4. Firmware-level lockout. The port works, but your application reconfigures the pins, disables the debug clock domain, or sleeps before the debugger can attach. This one masquerades as the others and is the most common.

Case 4 is worth ruling out first because it costs nothing. If the part supports connect-under-reset, use it: the debugger asserts reset, attaches during the window before your code reconfigures anything, and halts at the reset vector. A large share of "bricked, debug dead" boards are live parts whose firmware simply wins the race.

What still leaks when the port is genuinely gone

A debug port is not the only thing on the die that talks. In rough order of cost:

The boot ROM

Most modern MCUs ship an immutable boot ROM that predates your code and is not affected by your readout settings. It typically exposes a serial download or recovery mode, entered by strapping a pin or holding a pattern at reset. It will not hand you flash contents on a protected part — that is the point of the protection — but it will answer, and its responses are informative. A boot ROM that responds tells you the silicon is alive, the clock tree is viable, and the power rails are good. That eliminates half the plausible causes of a dead board.

Boot ROMs also emit version banners and structured error codes. Those codes distinguish "image signature invalid" from "flash uninitialised" from "device locked" — three very different diagnoses that look identical from the debugger's side.

Whatever you left printing

Any UART, RTT, or trace output your firmware wrote before the failure is still being written, and reading it does not require debug access. This is the single strongest argument for keeping a boot-time log that prints before the application configures anything: peripheral init results, the reset cause register, and the image version. A three-line banner at the top of main costs nothing in production and is the difference between a diagnosis and a guess.

The reset cause register in particular is worth its silicon. Watchdog, brown-out, software reset and pin reset produce completely different investigations, and the register survives the reset that it describes.

The behaviour of the part itself

Current draw over time is a coarse but real signal. A part stuck in a tight fault handler, a part in deep sleep, and a part that never left reset have visibly different consumption profiles on a bench supply with a current readout. You are not doing side-channel analysis here, you are checking whether the thing is executing at all.

What does not work, and wastes a day

  • Trying other debug transports on the same locked port. If SWD is refused by the protection logic, JTAG on the same pins is refused by the same logic. They are two protocols into one debug access port.
  • Reflashing over a protected part and expecting a merge. On most parts, a write attempt against active readout protection triggers a mass erase. That is the designed behaviour, not a bug, and it destroys the evidence you were trying to read.
  • Boundary scan as a firmware-debug tool. Boundary scan tests interconnect. It will find your cracked BGA ball. It will not tell you what the application was doing.
‹FILL› — One concrete brick from your own bench: which part, which lock state you were actually in, what you tried in what order, and what finally told you the answer. Two or three paragraphs. This is the section a reader cannot get anywhere else, and the reason the post exists.

Design so you never come back here

The locked-out situation is a design problem that presents as a debugging problem. Four things prevent it:

  • Separate development and production provisioning. Dev parts get debug open and unsigned images. Production parts get locked and signed. If one firmware build and one provisioning script serve both, you will eventually lock a board you needed open.
  • Prefer debug authentication over debug disable. Challenge-response debug gives you an auditable way back in that an attacker without the key does not have. It satisfies the same threat model as a blown fuse and leaves you a door. Where the part supports it, this is close to a free win.
  • Keep a recovery path that does not depend on the application. A boot ROM recovery mode you have actually tested, with the strapping documented and the pin brought to a pad or test point you can reach with a probe.
  • Log before you lock. The boot banner described above, unconditionally, in production.

The compliance angle, briefly

Debug lockdown is not optional under a regime that expects you to ship a product without exploitable debug interfaces. But the CRA also expects you to handle vulnerabilities on a clock, which means you must be able to diagnose your own fielded firmware quickly. A permanently fused debug port plus no logging is compliant with the first obligation and actively hostile to the second. Debug authentication plus a boot log satisfies both, and that tension is worth raising before someone writes "blow all debug fuses" into a hardening checklist.

What to do on Monday

  • Take a production-configured board and deliberately try to attach. Write down what the failure looks like, so that when it happens for real you recognise which of the four states you are in.
  • Test your boot ROM recovery path once, now, and document the strapping in the board file rather than in someone's memory.
  • Add the three-line boot banner if it is not there: reset cause, image version, peripheral init result.
  • Check whether your part supports debug authentication. If it does and you are using permanent disable instead, you gave up recoverability for nothing.

Shipping before December 2027? Grab the CRA Compliance Checklist for Embedded Engineers — free, 3 pages, no marketing.

FAQ

What I'm writing about next

A bench walkthrough of CRA Annex I, requirement by requirement, against a real ESP32-based product — what passes, what fails, and what an auditor will probably argue about.

One post a week, plus the CRA checklist on signup.

No marketing.

If this was useful, the best compliment is forwarding it to a teammate.