🛡️ Secure your IP with 100% Air-Gapped Labs & Signed NDAs
WhatsApp: +86 18928482768 | sales@pcbdesignlab.com

Summary

Microcontroller firmware extraction — methods and tools for reading firmware from MCUs via SWD, JTAG, UART, and chip-off techniques.

Microcontroller firmware extraction is the physical and logical work of reading the program image out of a microcontroller’s non-volatile memory so it can be backed up, analyzed, or replicated. It’s the indispensable first step of any firmware recovery, clone, or security audit, and it’s where most projects live or die: get a clean, complete, verified read and everything downstream is straightforward; trip a protection fuse or read a corrupt image and the only copy of the firmware may be gone for good. This guide covers the real interfaces, the tools, and the disciplined procedure a lab uses to extract firmware from a microcontroller safely, whether the code sits in on-chip flash or in an external serial memory.

Where the Firmware Actually Lives

Before choosing a method, establish which memory holds the image:

  • Internal flash — the program lives inside the MCU itself, accessed through the debug port or a ROM bootloader. Common on STM32, AVR, PIC, and most single-chip designs.
  • External SPI NOR flash — a separate 8-pin (or larger) serial chip beside the MCU, often a Winbond W25Q, Macronix MX25, or Spansion S25 part. Common on Linux-based gateways, IoT hubs, and any design running an OS too large for on-chip flash.
  • External parallel flash or EEPROM — older or higher-density designs; read in-circuit or chip-off.
  • Mask ROM / OTP — factory-programmed and not re-readable in the field; only decapping can recover it.

The Four Extraction Interfaces

On-chip firmware gets read through one of four channels. What the board exposes, and whether the part is protected, dictates the choice.

InterfaceSignalsHow the read happensLimitation
SWDSWDIO, SWCLK (+GND, optional SWO)Probe drives the ARM debug port; a flash-loader algorithm runs on the core to copy flash out over the MEM-APBlocked by read-out protection; needs exposed pads
JTAGTDI, TDO, TCK, TMS (+TRST)TAP controller selects debug access; same flash-loader approach, plus boundary-scan on some partsMore pins; disabled by security fuses
UART bootloaderTX, RX (+GND)Mask-ROM ISP bootloader answers serial commands (Get, Read Memory, Go) and streams flash outBootloader may be disabled or seed/key locked
USB DFUD+, D- (+GND, VBUS)Device enters DFU mode; host issues control transfers to upload the imageOften limited to the application region, not the bootloader

SWD in detail

SWD is the default on modern ARM Cortex-M parts and needs only two wires: SWDIO carries bidirectional data, and SWCLK is the host-driven clock. After a line reset (at least 50 high clock cycles) the probe talks to the debug port, then to a memory access port (MEM-AP) that can read and write the target’s address space. To pull flash out, the probe uploads a small flash-programming algorithm into the target’s RAM, runs it, and shuttles the resulting bytes back over SWD. An optional SWO pin carries trace, but readback doesn’t need it.

JTAG in detail

JTAG predates SWD and uses four mandatory signals — TDI (data in), TDO (data out), TCK (clock), TMS (mode select) — plus an optional TRST. Its 16-state TAP controller shifts instruction and data registers, and ARM CoreSight debug is reached through DPACC/APACC instructions. JTAG’s extra trick is boundary scan (IEEE 1149.1), which can also observe pin activity, and it daisy-chains across multiple devices. Where both exist, SWD is usually preferred for extraction because it needs fewer pins, but JTAG stays essential for FPGAs, CPLDs, and older cores.

UART and USB bootloaders

When the debug port is fused off, the factory ROM bootloader is often still alive. STM32 parts, for example, enter their system-memory bootloader by booting with the BOOT0 pin high; the bootloader autobauds on a USART and accepts a documented command set that includes Read Memory (0x11) and Go (0x21). AVR devices offer serial bootloaders and SPI-based ISP (MOSI/MISO/SCK/RESET); PIC parts use ICSP on the PGC/PGD lines. USB DFU is the same idea over a USB cable. These paths read flash without the debug port, so they’re the first thing a lab tries on a locked device.

Chip-Off Extraction

When the firmware lives in an external serial flash — or when a locked MCU’s only readable memory is a companion chip — the cleanest route is to remove the memory and read it in a standalone programmer. The board is heated on a rework station, the flash is lifted with hot air, and the chip drops into a programmer socket; for an in-circuit read with no desoldering, an SOIC-8 test clip clamps straight onto the package instead. The programmer identifies the part with the JEDEC ID command (0x9F), then reads the full array. Tools range from cheap universal programmers (the TL866/Minipro family) to production-grade systems from Dediprog, and flashrom can drive all of them across a wide library of supported parts. The result is a bit-exact dump of the memory, including any bootloader, filesystem, and calibration regions.

Dealing With Protected Parts

Protection is the single biggest hazard in extraction, because the wrong command at the wrong moment can erase the only copy of the firmware. The rule: read the protection state before you attempt any readback. On an STM32 that means inspecting the RDP option byte. Level 0 is safe to read over SWD; Level 1 only allows a read after a mass erase that destroys the application; and Level 2 won’t yield flash through the debug port at all. AVR and PIC parts play the same role with their lock and code-protect bits. So a disciplined extraction begins with a non-destructive ID and option-byte read — never with an unlock or erase command fired off speculatively. If the part is protected and the bootloader route is closed, the job escalates from extraction into an unlock engagement (fault injection or chip-off), and the client should be told up front whether the firmware is expected to survive the process.

Output Formats and Verification

The extracted bytes have to be saved in a usable form, then proven correct:

  • Raw binary (.bin) — a byte-for-byte image; it carries no address information, so the base address must be recorded separately (for example 0x08000000 for STM32 internal flash).
  • Intel HEX (.hex) — ASCII lines with embedded addresses and per-line checksums; self-describing and the most portable for reprogramming.
  • S-record (.s19 / .srec) — Motorola’s equivalent ASCII format, common in automotive and Freescale/NXP toolchains.

Verification is mandatory, not optional. The lab reads the memory a second time and compares the two dumps byte for byte; a mismatch points to a bad contact, a marginal clip, or a part that’s changing state under read. A CRC-32 over the image is recorded so every later copy can be validated against the original. Option bytes, configuration fuses, and EEPROM contents are captured separately too — a firmware image without its configuration data won’t behave correctly when re-flashed.

Best Practices for a Clean Extraction

  1. Identify the part and its protection state first. Read the device ID and option bytes before issuing any erase or unlock command, so you know whether a read will trip a mass erase.
  2. Image twice and compare. Two identical reads are the minimum evidence of a reliable dump.
  3. Preserve everything. Capture internal flash, EEPROM, option bytes/fuses, and any external memory as separate, labeled images.
  4. Record the base address and checksum. A .bin without its load address is only half an image.
  5. Protect the hardware. Use ESD-safe handling, the correct clip or probe, and minimal heat when lifting a chip, so the source board survives the process.

The Extraction That Saved a Legacy Product Line

A customer had a legacy motor controller that had been in production for 12 years. The original design house was gone, and the firmware lived only in the STM32 chips on the boards. When a batch of controllers started failing in the field, they had no way to diagnose the problem or build replacements — the MCU was read-protected and the source code was gone.

We extracted the firmware through the UART bootloader — the SWD port was fused off, but the ROM bootloader was still alive. The image was read twice, verified byte for byte, and archived with a CRC-32 checksum. The option bytes were captured separately, confirming RDP Level 1. With the firmware safely out, the customer could analyze the failure mode, port the code to a current STM32 variant, and resume production. Extraction took two days; the alternative was scrapping a 12-year product line.

The first rule of firmware extraction is simple: read before you write, and read twice before you trust it. A single unverified dump is not a backup.

Frequently Asked Questions

Can I extract firmware from any microcontroller?

From any unprotected one, yes — via SWD, JTAG, or the ROM bootloader. From a read-protected part, the debug-port route is blocked and you must rely on a still-active bootloader or escalate to fault injection or chip-off techniques. The highest protection levels may be effectively unrecoverable without destructive physical attack.

What’s the difference between a .bin and a .hex file?

A .bin is a raw byte image with no address or checksum metadata, so you must know the base address to use it. An Intel HEX file embeds addresses and per-line checksums in ASCII, making it self-describing and safer to transfer and reprogram.

Do I need to desolder the chip to read it?

Not usually. On-chip flash is read in-circuit over the debug port or bootloader, and external SOIC-8 flash can often be read in-circuit with a test clip. Desoldering (chip-off) is a fallback when in-circuit reads are unreliable or the chip must be isolated from the rest of the board.

How do I know the extracted image is complete and correct?

Read the memory twice and confirm the two dumps are byte-identical, then compute and record a CRC-32 over the image. Any later copy can be validated against that checksum.

Extraction Is the Foundation — Get It Right

Analysis, reconstruction, reprogramming — every downstream step is only as good as the extraction that precedes it. That’s why PCBDesign Lab treats the read as a verified, documented procedure rather than a one-click operation. If you need a clean, validated firmware image from a working or protected board, see our firmware reverse engineering service or contact us with photos of the board and the main IC markings for an assessment.

References

  1. Serial Wire Debug reference: https://en.wikipedia.org/wiki/Serial_Wire_Debug
  2. JTAG (IEEE 1149.1) reference: https://en.wikipedia.org/wiki/JTAG
  3. Microcontroller reference: https://en.wikipedia.org/wiki/Microcontroller
  4. UART reference: https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter
  5. USB Device Firmware Upgrade reference: https://en.wikipedia.org/wiki/USB_device_firmware_upgrade
  6. Intel HEX reference: https://en.wikipedia.org/wiki/Intel_HEX
  7. flashrom — open-source flash programmer: https://www.flashrom.org/
  8. OpenOCD — open on-chip debugger: https://openocd.org/

Get Weekly PCB Engineering Insights!

Practical insights on PCB design, PCB reverse engineering, IC unlocking and hardware development from PCBDesign Lab.

One email each week. Unsubscribe anytime. Read our privacy policy for more info.

Get Started

PCBDesign Lab Has Helped 100+ Customers Build Their Products

Free Consulting