Archive for the ‘Recover Chip’ Category

PostHeaderIcon Read AVR Firmware at Speed: Where the Clock Limit Comes From

A bulk read of an AVR feels like it should take seconds and sometimes takes minutes, and the temptation is always to raise the clock. Sometimes that works. Sometimes it produces a file that is 99.9 percent correct, which is worse than a file that fails outright, because the error is invisible until the firmware misbehaves in one specific mode.

The clock ceiling is worth understanding rather than discovering, because it is not a single published number. It is a property of the whole arrangement: the device’s own clock, the programmer’s drive strength, the cable’s impedance, and how the device samples the incoming clock.

Where the limit comes from

Serial programming is synchronous in name and not quite in practice. The programmer drives a clock, and the device samples it against an internal clock that is running asynchronously.

Factor Effect on the limit
Device clock frequency The device must oversample the programming clock
Programmer output drive Weak drive plus cable capacitance slows edges
Cable length and return path Long cables ring and shift thresholds
Target supply voltage Lower supply reduces noise margin
Presence of other devices on the lines Adds capacitance and leakage

The first row is why the published limit is usually expressed as a fraction of the device clock rather than an absolute frequency. A device running from a slow internal oscillator cannot accept a fast programming clock, and the constraint is fundamental.

What going too fast looks like

The errors are structured, which is what makes them detectable and also what makes them deceptive.

Error pattern Mechanism
Isolated single-bit flips Marginal sampling on one edge
Whole bytes wrong in a repeating position A command/dataphase boundary misalignment
Errors clustered at high addresses Timing drift over a long transaction
Consistent errors on one data line That line’s termination is worse
Occasional errors that vanish on retry Temperature or supply drift

The fourth row is a fixture problem rather than a clock problem, and it is diagnosable by its consistency: the same bit position fails regardless of what is being read.

Reading twice is not optional

The single most effective practice in this work is to read the device at least twice and compare. It costs a second pass and it converts an unknown into a measurement.

Comparison Conclusion
Two reads identical Either correct, or a repeatable error
Two reads differ in a few bytes Timing margin problem
Two reads differ widely Contact problem, or the device is not stable
Two reads identical at reduced clock, different at high The clock was too high

The first row is not a proof, which is why a third read at a different clock is worth doing on anything important. Three identical reads at three clock rates is strong evidence; one read is a hope.

The fixture matters more than the programmer

A great deal of effort goes into choosing a programmer and very little into the connection to the device. In practice the connection dominates.

Fixture Typical reliable clock Note
Device socketed, ribbon under 10 cm Near the device maximum The reference case
In-system header, 10 to 20 cm Reduced Ground returns matter
Test clips on a populated board Substantially reduced Capacitance and shared nets
Flying leads Lowest Use only when nothing else is possible

The third row is the common case in repair work, and it is where most marginal reads happen: a clip on a device that is still connected to its board is loaded by everything else on those nets.

Reducing the clock without wasting time

Slowing down does not have to mean a linear increase in duration, because the overhead is not all in the data transfer.

Strategy Effect
Lower the clock only for the read phase Keeps command overhead low
Read in blocks with verification between Localises a fault to one block
Retry a failing block at a lower clock Recovers without restarting
Increase the supply within specification Improves margin at the pins

The fourth row is a legitimate technique and one to use carefully: operating the target at the top of its specified range improves noise margin at the cost of nothing except adherence to the datasheet.

When errors are not timing

Some errors look like timing and are not, and distinguishing them saves a lot of clock experimentation.

Observation Alternative explanation
Errors only above a certain address The device’s memory is smaller than assumed
Reads of some regions always return the same value Protection covers those regions
Blank regions interleaved with good data The image was never fully written
Errors that move when the board is touched Contact, not clock
Consistent errors in one chip, none in another Chip damage

The second row is worth checking early. A device whose upper region reads as all ones may be smaller than the part number suggests, or may be protected in a way that covers only that region.

Where the surrounding steps are

The choice between the two programming interfaces, and their different overheads, is in reading AVR chip firmware. The identity check that should accompany any read is in reading Atmel AVR firmware, and the reproducibility problem in a broader sense is treated in extracting AVR firmware repeatedly.

Services at this boundary

Work covers fixture design for marginal boards, clock characterisation with repeated reads, error classification, block-level retry strategies, and delivery of an image with a stated confidence based on multiple reads. It does not cover reading through a fixture whose contact is unreliable, and it does not cover reconstructing bytes that differ between reads without further evidence.

The practical statement is that a read is a measurement, and a measurement without a repeat is an anecdote.

PostHeaderIcon Read Atmel AVR Firmware: Record the Signature, Not the Filename

Files arrive named after what somebody believed the device was. Markings on the package say what the assembler was told to place. Neither is evidence. The evidence is three bytes that the device itself reports when asked, and they are readable in almost every state, including the state where the program memory is locked.

This matters because the AVR family is large, the members differ in ways that affect how an image must be interpreted, and the labels attached to files are frequently wrong by the time a project reaches the bench.

What the signature bytes contain

Three bytes identify the device: a manufacturer byte and two device bytes. The combination is unique within the family, and the vendor publishes the values.

Byte Meaning Notes
Byte 0 Manufacturer or family code Often the same across a whole family
Byte 1 Device code, high Part of the specific device number
Byte 2 Device code, low Completes the identification

The values are stable across revisions of the same device, which is what makes them useful: a signature match confirms the family member, not the batch.

Why the signature survives locking

The lock bits protect program memory and, on some devices, EEPROM. They do not hide the signature, because the signature is part of the device’s identity and the programming interface needs it to select the correct algorithm.

State Signature readable Program readable
Unlocked Yes Yes
Read protected Yes No
Read and write protected Yes No
Blank Yes Yes, and empty

The second and third rows are the practically important ones. A locked device still answers the identity question, which means an assessment can begin with confirmation rather than assumption.

Why identity matters before anything else

The same instruction stream can be interpreted differently depending on which member of the family produced it, and the differences are not cosmetic.

Difference Consequence of a wrong assumption
Memory size Image truncated, or padded wrongly
Boot section size Bootloader boundary in the wrong place
Vector count Interrupt table misread
Peripheral set Addresses in code point at nothing
Instruction variant Disassembly contains invalid opcodes

The fifth row is the sharpest: a device from a different sub-family may use an extension to the instruction set, and a disassembler configured for the base set will produce nonsense in exactly the routines that use it.

Markings versus signatures

The package marking and the signature should agree. When they do not, the part is remarked or the marking has been misread.

Situation Likely cause
Signature matches a smaller device than the marking Remarked part
Signature matches a different family entirely Wrong part fitted, or a clone
Signature reads as all zeros or all ones Interface problem, not identity
Signature correct, program blank Erased, or protection with an empty array

The first row is common enough in repair work to be worth checking every time. A board built with a remarked part will behave in ways the schematic does not explain, and the explanation is in the signature.

The calibration and user rows

Some devices provide additional rows beyond the signature, and they carry information that affects behaviour.

Row Content Readable when locked
Signature Identity Yes
Calibration Factory oscillator trim Sometimes
User signature A designer-supplied identifier No, if in locked flash
Lock and fuse Configuration Yes, on most devices

The second row is the one that matters for cloning. A device whose calibration value cannot be read will need recalibration, and recalibration requires measuring the oscillator against a reference.

Recording identity in the deliverable

The identity should travel with the image, because an image separated from its identity is a file of bytes with a confident name.

Field Value
Signature bytes As read
Inferred part Across the family table
Marking observed As printed on the package
Agreement Yes, or the discrepancy stated
Read method Interface and clock
Date and fixture For reproducibility

The fourth row is the one that makes a report useful when something goes wrong later. A report that records a discrepancy is a report that anticipated the problem.

The naming history

There is a further source of confusion that has nothing to do with silicon. The AVR family was designed by Atmel, which was acquired by Microchip, and the documentation, the part numbering and the tooling have been reorganised since.

Era Naming convention Note
Atmel era ATmega, ATtiny, AT90 The classic names
Transition Both names in circulation Same silicon, two document sets
Microchip era Same device names, new document numbers Packaging and ordering codes changed

The consequence for this work is that the same device can appear under two documentation sets with slightly different electrical specifications and identical silicon. A signature match settles the identity; the document number does not.

Where the adjacent steps are

The two programming interfaces and their different behaviours on a locked device are in reading AVR chip firmware. The clock and fixture limits that determine whether a read is reliable are in reading AVR firmware at speed. The full set of areas that must be captured to reproduce a device is in extracting an AVR microcontroller.

Services at this boundary

Work covers signature readout on locked and unlocked devices, part identification across the family, marking verification, calibration row recovery where available, and identity recording in the deliverable. It does not cover reading a program array that is locked, and it does not cover establishing a part number from a package marking alone.

The habit worth adopting is to read the signature before reading anything else, and to put it in the report whether or not it agrees with the filename.

PostHeaderIcon Read ARM Firmware: Most of It Is Not Inside the Chip

When a board carries an ARM-based device, the instinct is to attack the device. That instinct is often wrong, and the reason is architectural: ARM cores are designed to run code from memory that is frequently not on the same die.

A large share of ARM systems use a microcontroller with internal flash, and a large share use a microprocessor or a ROM-based microcontroller that boots from an external SPI or parallel flash. In the second case the firmware is sitting in a commodity part with a datasheet, and the ARM device is merely the thing that executes it.

The two architectures

Architecture Where the image is Access route
Microcontroller with internal flash On the die Debug interface, or physical
Microprocessor with external boot device In a separate flash part Read the flash directly
Microcontroller with external QSPI flash In the external part, executed in place Read the flash, or capture the bus
SoC with ROM boot and encrypted image External, encrypted Key problem, not a read problem

The second and third rows are where most of the easy work is, and they are frequently overlooked because the ARM device is the conspicuous component.

Why the debug interface is closed

On a production device, the debug access port is either disabled by a protection setting or by blowing a one-time configuration. This is not a bug or a manufacturing mistake; it is the standard production procedure.

State Debug access Flash access
Fully open Read, halt, step Read and write
Read protection level one Refused, or restricted Refused, with an erase path
Read protection level two Refused permanently Refused permanently
Debug port fused off No response No route

The fourth row is the one that ends the conversation about the device itself. It does not end the conversation about the system, because the image may still be outside.

Reading the external device

An external flash on an ARM board is usually a standard part with a standard command set, and reading it requires no cleverness.

Package Method Note
SOIC or SOP8 Clip, in circuit Fastest; the bus must be quiet
WSON or BGA Desolder and read Requires rework equipment
QSPI in a multi-die package Desolder or probe Often shares a package with the ARM
On-package PoP Probe, or read through the ARM The most awkward case

The first row covers a surprising share of real boards, and it is worth trying before anything else. A clip on a SOIC flash takes seconds and requires no desoldering.

What the external image looks like

The image is not a raw copy of what the ARM executes. It has a structure defined by the boot mechanism and the linker.

Region Content
Boot header Entry point, image length, checksum
Vector table Initial stack pointer and exception vectors
Code Instructions
Read-only data Constants and tables
Initialised data Values copied to RAM at startup
Signature or digest If secure boot is used

The second row is the first thing to check, and it doubles as a validity test: the first word should be a plausible stack pointer, which on most ARM systems means an address in RAM near the top of the region.

Executed in place versus copied

This distinction determines whether the image can be used as-is.

Mode Where code runs Image requirement
Execute in place over QSPI From the external device Must be directly addressable
Copy to internal RAM then run From RAM Any format the loader understands
Copy to SDRAM then run From external RAM Requires SDRAM initialisation first
Staged by a boot ROM Depends on the ROM Format defined by the vendor

The second row produces images that are compressed or encrypted, because the loader is going to decompress them anyway. A high-entropy external image is a hint that the loader does more than copy.

The bus as an alternative route

Where the external device cannot be desoldered and cannot be clipped, the bus is often accessible, and a capture during boot reveals the image as it is fetched.

Situation Bus capture value
Execute in place, unencrypted The image, verbatim
Execute in place, encrypted in hardware Ciphertext only
Copy to RAM, unencrypted The image, as copied
Copy to RAM, decrypted by the ARM Plaintext, if decryption is on the external side

The fourth row is the useful one: if the ARM decrypts after fetching, the bus carries ciphertext. If a separate device decrypts before the ARM, the bus carries plaintext.

When the internal image is the only option

If the ARM device holds the only copy, the routes narrow to the ones that do not need cooperation.

Route Applicability
Debug interface, if left open Rare on production parts
Bootloader with a read command Occasional
Physical readout of internal flash General, expensive
Side channel against the copy routine Research-grade

The third row is the general answer, and its cost depends on the package and the process node. Extracting ARM MCU flash covers the protection levels and what each one costs to defeat.

What comes next

Once an image exists, validating it is the next step, and the two-word check described in reading ARM Cortex-M firmware settles whether it is loadable. The disassembly problems that follow are in reading ARM software.

Services at this boundary

Work covers architecture identification, external flash readout in circuit or in a socket, bus capture during boot, image validation, and internal readout where a route exists. It does not cover reading a device with the debug port fused off without a physical route, and it does not cover decrypting an image whose key is held inside a protected device.

The first question about an ARM board should be where the image lives, not how to open the chip.

PostHeaderIcon Read ARM Software: Thumb-2, Literal Pools and Call Graphs

ARM images look easier to reverse than they are. The instruction set is regular, the encoding is documented, and the toolchain support is mature, so a disassembler produces output immediately. The output is frequently wrong in ways that are not obvious, because three features of real ARM code break the assumptions a linear sweep depends on.

The three are: two instruction encodings that can be mixed at function granularity, constant pools embedded in the middle of functions, and calls that go through tables rather than through direct branch instructions.

The mixing problem

ARM cores support a 32-bit encoding and a 16-bit encoding. A function can be written in either, and both can appear in the same image, with the choice recorded in the low bit of the address rather than in the code.

Transition Encoded by Consequence for decoding
ARM to Thumb Branch with exchange, or a return to an odd address The target starts in 16-bit mode
Thumb to ARM Branch with exchange The target starts in 32-bit mode
Function pointer Low bit of the pointer The callee’s encoding is in the data
Exception return Status register bit The resumption encoding may differ

The third row is why a call graph built from direct branches alone is incomplete. Many real systems dispatch through tables of function pointers, and the table entries carry the encoding bit, which means the disassembler has to consult the data to know how to decode the target.

Literal pools

A constant pool is a block of data placed inside or immediately after a function, loaded with a PC-relative instruction. On architectures with a large addressing range this would be unnecessary; on ARM it is the standard way to load a 32-bit constant cheaply.

What it looks like What it is
A load from an address a few bytes ahead of the PC A literal load
A block of 32-bit values inside the code A literal pool
Instructions that decode validly after a return Often pool data
A branch over a block of data A pool skip

The third row is the failure mode: pool data frequently decodes as valid-looking instructions, so a linear sweep continues through it and produces nonsense that looks like code. The disassembler needs to know where the pool starts and ends, which is derivable from the literal-load offsets but not from the instruction stream alone.

Recovering the function map

The workable sequence builds the map from anchors and validates by structure.

Step Method
Find the vector table Fixed location, or a register that points at it
Identify the reset handler First meaningful vector
Follow direct branches Record targets as candidate entries
Collect literal pool ranges From PC-relative load offsets
Collect pointer tables From data regions referenced by code
Validate candidates Alignment, prologue shape, reachability

The fourth row must be done before the third can be trusted, because a direct branch that lands inside a pool is not a call. On ARM this is common: the pool sits after an unconditional branch, and a misidentified target inside it produces a phantom function.

Prologues exist, unlike on 8-bit parts

One thing ARM gives back is a recognisable function prologue. Most compiled functions begin by pushing a set of registers and, often, adjusting the stack pointer.

Prologue shape Meaning
Push of several registers including the link register A normal function call
Push of the link register alone A leaf-ish function that makes calls
Subtraction from the stack pointer before any store A frame with a large local area
No push at all A leaf function, or a tail-called continuation

The fourth row is the ambiguous case, and it is where a reconstruction can lose a function boundary: a leaf function has no prologue, so the only evidence of its existence is a branch to it.

Indirect calls and the tables behind them

Function pointer tables are the hardest part of the map, because the target is data.

Table pattern Recognition
Consecutive words in the code address range A dispatch table
Words with the low bit set Thumb targets
A table whose entries are all in one region A driver or handler table
A table indexed by a small integer constant A state or command dispatch

The second row is a useful tell: on a mixed image, a table of entries with odd addresses is unambiguously a Thumb function table, which both confirms the table and identifies the encoding of its targets.

Where the reconstruction goes from the map

Once functions are bounded, the reconstruction work is the general problem of source recovery, with ARM-specific severity: a large register file and aggressive scheduling widen the gap between the source and the binary.

Loss Severity on ARM
Register allocation High; many registers, many choices
Inlining High; compilers inline aggressively at -O2
Instruction scheduling High; dual-issue and pipeline filling
Macro expansion High; hardware access idioms are everywhere

The comparison with other architectures is useful and is treated in cracking microcontroller source code, where the four losses are set out generally.

The validation that closes the loop

A function map can be checked without the original source, and the checks are cheap.

Check Detects
Every branch target is inside a known function Missed entries
Every function is reachable from the vector table or a table Phantom entries
No instruction overlaps a pool Pool range errors
Recompiled reconstruction matches behaviour Reconstruction errors

The third row is a strong internal consistency test. If the map is right, no instruction should reference an address inside a declared pool except through a literal load.

Where the adjacent steps are

The image itself usually comes from outside the chip, and reading ARM firmware explains why. The two-word validity check that should precede any disassembly is in reading ARM Cortex-M firmware. Rebuilding a loadable image around the binary is in extracting an ARM embedded program.

Services at this boundary

Work covers function map recovery with pool and table handling, mixed-encoding disassembly, call graph reconstruction including indirect calls, and reconstruction at an agreed level. It does not cover recovering original identifiers, and it does not cover producing a byte-identical rebuild.

The practical statement is that the instruction set is the easy part of ARM; the structure is what takes the time.

PostHeaderIcon Read ARM Cortex-M Firmware: Two Words Validate the Whole Image

A Cortex-M image has a property that most other architectures lack: its first two words are self-describing and mutually constraining. The first word is the initial value of the stack pointer, and the second is the reset vector. Both are addresses, and both must fall in plausible regions for the image to be valid.

This gives a free integrity check on any extraction. It costs two reads of memory and it catches offset errors, base address errors, byte-swapped reads, and images that are not code at all.

What the two words mean

Word Content Plausibility test
0 Initial stack pointer Points near the top of a RAM region, aligned
1 Reset vector Points into the code region, with the Thumb bit set
2 onward Exception vectors Each points into the code region

The second row carries a detail that is easy to miss: on Cortex-M, function addresses in the vector table have the least significant bit set to indicate Thumb state. A reset vector with an even value is therefore either an error or a device that only supports a non-Thumb encoding, which is unusual.

Why these two words are a good test

The values are not arbitrary. They are generated by the linker from the memory map, so they encode the map.

Property What it implies
Stack pointer in the top quarter of a RAM region The linker placed the stack at the top of RAM
Stack pointer aligned to eight bytes The ABI requires it
Reset vector within the first part of the image The reset handler is early in the code
Reset vector with bit zero set Thumb encoding
All vectors pointing into the same region A single code region
Vectors clustered at one address An unhandled-exception stub

The fourth row is the fastest possible check for the byte-swapping error that plagues extraction: a byte-swapped image produces a reset vector with implausible alignment, and the check fails immediately.

The base address question

The vector table does not have to be at address zero. It can be relocated, and on Cortex-M the relocation is controlled by a register rather than by a pin.

Configuration Vector table location Consequence
Default Address zero, aliased to flash or RAM The image starts at zero
Relocated by register Any aligned address in the code region The image may start elsewhere
Bootloader plus application Two tables, one switched in Two images in one device
Remapped by a memory controller The alias changes after boot Address zero is not flash

The third row is extremely common: an application built to be started by a bootloader is linked at an offset, and its vector table sits at that offset. An extraction that assumes zero produces an image whose first word is not a stack pointer, and the check that makes this page useful is exactly the check that failing image fails.

Two images in one device

The bootloader arrangement produces a device with two valid images and one active vector table.

Region Content Vector table
Bootloader Update logic, no application At zero, active after reset
Application The product firmware At an offset, or copied to RAM
Configuration Settings, sometimes a copy of the table None

Reading such a device produces a file that contains both images, and the analysis has to separate them. The separation is usually obvious from the two vector tables, each of which looks like a valid table.

Other checks worth doing

The two-word test is the cheapest and it is not the only one.

Check Catches
Image length is a multiple of the page size Truncated reads
All vectors point inside the image Base address errors
The reset handler disassembles plausibly Wrong encoding assumption
A pool of strings exists and decodes An image that is not code
The region beyond the image is erased A read that ran past the end

The fifth row is a useful confirmation that the image boundary is real. If the bytes after the last vector-referenced function continue as valid code for megabytes, either the device is much larger than assumed or the read is returning something other than flash contents.

Where the validation fits in a workflow

The validation belongs immediately after the read and before any analysis, because everything downstream depends on it.

Step Output
Read the image Bytes
Check the two words Whether the base is right
Check the vectors Whether the image is coherent
Disassemble the reset handler Whether the encoding assumption holds
Proceed to function mapping Analysis

The third step is where a byte-swap or an offset error is caught. The fourth is where a wrong encoding assumption is caught, because a Thumb reset handler decoded as ARM produces immediate nonsense.

Protection and what it does to the image

The two-word check also distinguishes a refused read from a real one.

Read result First word Interpretation
Real image Plausible stack pointer Valid
All zeros Zero Refused, or blank
All ones All ones Refused, or blank
Scrambled Implausible Refused with a pattern, or wrong base

The fourth row is the one that requires care, because a scrambled image sometimes contains a plausible-looking word by chance. Checking all the vectors, not just the first two, is what makes the test reliable.

Where the next steps are

The protection levels that decide whether a read is possible at all are in extracting ARM MCU flash. The disassembly work that follows validation is in reading ARM software. Where the image has to be turned back into a loadable artefact with its segments, extracting an ARM chip covers the reconstruction.

Services at this boundary

Work covers readout, two-word and full vector validation, base address determination, bootloader and application separation, and encoding confirmation. It does not cover recovering an image from a device whose protection blocks the read, and it does not cover guessing a base address that cannot be derived from the image.

The habit worth adopting is to check the first two words before doing anything else with an ARM image, because the check takes a second and the errors it finds take days.

PostHeaderIcon Read FPGA Firmware: It Is Usually in the Flash Next Door

The question “can you read the firmware out of this FPGA” contains an assumption that is false more often than true. Most FPGAs in volume production are SRAM-based, which means the configuration is loaded at every power-up from somewhere else, and the device holds it in volatile memory. There is nothing in the FPGA to read while it is powered off, and while it is powered on the configuration is in the same place the designer put it.

The implication is pleasant: the thing to read is the device that holds the configuration, and that device is usually a commodity flash part with a datasheet and no meaningful protection.

Three FPGA technologies

Technology Configuration storage Power-off state
SRAM-based External, or internal flash loaded to SRAM Lost
Flash-based Internal flash, non-volatile Retained
Antifuse Programmed once, non-volatile Retained

The first row describes the overwhelming majority of designs, including the large logic devices used for real work. Its consequence is that a read of the FPGA die would return whatever happens to be in the SRAM, which is the same data the external flash holds, plus nothing.

Where the configuration actually is

Board arrangement Configuration source Read method
FPGA with a dedicated SPI flash External flash Read the flash directly
FPGA with a parallel flash External flash Read the flash directly
FPGA loaded by a microcontroller Microcontroller’s memory Read the microcontroller
Flash-based FPGA Internal flash Read through the FPGA’s interface
Antifuse FPGA Programmed structure Not readable in the usual sense

The third row is more common than people expect on small boards: the FPGA is configured by the product’s own microcontroller, which holds the bitstream in its own firmware. Reading the microcontroller is then the whole job, and it may also give the surrounding software.

The external flash is a normal part

A configuration flash is an ordinary SPI NOR device. Its protection options are limited and none of them is a secret.

Protection Effect Effort to bypass
None Full read via the flash command set None
Status register block protect Blocks writes, not reads None
Read inhibit on some parts Blocks reads Low; often a register write
Encrypted content The FPGA decrypts it Depends on key handling

The third row appears on a few parts and is not a meaningful obstacle, because the inhibit is a register rather than a fuse, and the register is writable by anyone who can talk to the device.

Why the bitstream is the point

Reading the flash gives a bitstream, and a bitstream is the complete definition of the configured FPGA. It can be loaded into a blank device of the same type and the system will behave identically.

Property Value
Length Fixed for the device, so truncation is detectable
Content Configuration frames, in device order
Header Sometimes a small preamble, sometimes none
Integrity Sometimes a CRC, sometimes not
Meaning Not human readable

The first row is genuinely useful: an image whose length does not match the device’s configuration size has been truncated or has come from a different device, and the check costs nothing.

Copying an FPGA

Because the bitstream is the configuration, copying is straightforward once it is read.

Step Requirement
Read the bitstream Access to the flash
Confirm device type Bitstream length and header
Program a blank flash Any programmer that speaks the flash’s protocol
Boot the board Nothing else needed

The fourth row is where copying differs from other device classes: there is no lock state to reproduce, no calibration, and no per-device identity. A bitstream is device-independent within a part number.

When the FPGA is flash-based

Microchip’s flash-based families and Lattice’s non-volatile parts keep the configuration internally, which changes the route.

Situation Route
Flash-based FPGA, unprotected Read through the vendor interface
Flash-based FPGA, security bit set Physical readout
Either, with an external configuration device Read the external device instead

The second row is where the two technologies converge: a security bit in an internal flash behaves like any other flash protection. What differs is the cost, because the arrays in these devices are large.

When the FPGA is antifuse

Antifuse devices are programmed by physically creating links, and the programming is irreversible. Reading them is possible in principle and requires physical access to the programmed structure.

Property Consequence
One-time programmable No erase, no reuse
Programmed links are physical Visible under imaging
Small arrays by modern standards Feasible to image
Used in space and defence Often unavailable commercially

The second row is the interesting one for extraction: an antifuse array can sometimes be read by imaging the programmed links, which yields the configuration without any electrical access.

Reading rather than reverse engineering

It is worth separating two requests that sound alike. Reading the bitstream is a copy operation with a clear success criterion. Understanding the design inside it is a different problem with a much lower ceiling, treated in reading FPGA bitstream. Where the device is a combined processor and fabric, the two halves need different treatment, which is covered in reading SoC FPGA firmware.

A third request is frequently implied and never stated: reading the configuration so that the design can be modified. That is the case where the difference between copying and understanding becomes a commercial problem, because a bitstream can be copied in an afternoon and cannot be edited at all. Extracting FPGA configuration sets out the three storage technologies and what each one costs to read, which is the practical starting point for a project that has not yet decided which of the three requests it is.

Where the route involves making the device malfunction deliberately, rather than reading its configuration, the techniques are collected under FPGA crack — voltage and clock excursions aimed at forcing an error the design did not anticipate.

Services at this boundary

Work covers configuration source identification, external flash readout, bitstream validation, device type confirmation, and programming of replacement devices. It does not cover reading an SRAM FPGA’s internal state, because there is nothing there to read, and it does not cover recovering a design description from a bitstream.

The reframing that saves the most time is that an SRAM FPGA does not have firmware in the sense the word usually carries. It has a configuration that lives elsewhere.

PostHeaderIcon Read FPGA Bitstream: Why There Is No Software Inside

A bitstream is often described as the FPGA’s software. The metaphor is convenient and it misleads in a specific way: it suggests that the bitstream is a program, that it has a structure analogous to instructions, and that recovering the design is a matter of applying the right decompiler.

None of that is true. A bitstream is a configuration of physical resources. It says which lookup table implements which function, which switch connects which wire to which, and which flip-flop is enabled. There is no instruction stream, no execution order, and no variables in the software sense.

What a bitstream actually specifies

Resource What the bits configure
Lookup table A truth table, as a bit mask
Flip-flop Whether the output is registered, and its initial state
Routing multiplexer Which of several inputs reaches an output
Clock network Which clock drives which region
I/O block Drive strength, standard, and direction
Block memory Width, depth, and port configuration
DSP block Mode and pipelining

The third row is the one that makes recovery hard. A routing multiplexer’s configuration is a selection among alternatives, and knowing which alternative was selected tells you the connection but not why. A netlist recovered from routing is a valid graph and a poor explanation.

Why the LUT is not a program

A lookup table with four inputs stores sixteen bits: the output for each combination. Those sixteen bits are a truth table, and any function of four variables can be represented.

Property Consequence
Sixteen bits per four-input LUT The function is arbitrary, not structured
Any function fits The original expression is not recoverable
Cascaded LUTs implement wider functions The decomposition is a synthesis choice
The same function has many LUT decompositions Recovery is not unique

The fourth row is the fundamental obstacle, and it is the same obstacle as in CPLD work but larger. Synthesis chooses a decomposition; many decompositions produce identical behaviour; the bitstream records only the chosen one.

The recoverable ceiling

There is a hierarchy of what can be obtained, and the levels are far apart.

Level Achievable Effort
The bitstream itself Yes, exactly Low
Resource utilisation counts Yes Low
A netlist of LUTs and routes Partly, with vendor-specific knowledge Very high
A gate-level netlist Sometimes, by re-mapping Very high
RTL No Not achievable
Original HDL No Not achievable

The third row deserves a caveat: recovering the routing is possible in principle and requires a detailed model of the device’s configuration frame format, which vendors do not publish. The information exists in reverse-engineering projects for some families and not for others.

The scale problem

Even where the frame format is known, the volume is the obstacle.

Device size LUTs Routing bits Practical recovery
Small Hundreds Thousands Feasible
Medium Tens of thousands Hundreds of thousands Difficult
Large Hundreds of thousands Millions Not practical by hand
Largest Millions Tens of millions Not practical at all

This is the practical answer to most requests. A design in a large device has more routing bits than a person can examine, and the recovered graph would be too large to be useful even if it were correct.

What is actually useful

The techniques that produce value on a real project are not netlist recovery. They are behavioural.

Approach What it yields
Stimulate inputs, capture outputs A truth table for the implemented interface
Capture internal signals with a logic analyser Protocol and timing
Use the vendor’s debug tools if present Internal signal visibility
Compare two bitstreams Which regions changed between builds

The fourth row is underused and often decisive. Two bitstreams from the same project, differing by one feature, differ in a bounded set of frames, and that localisation answers questions that a full recovery cannot.

Bitstream comparison in practice

Comparison Interpretation
Identical Same build, or a rebuild with no functional change
Small frame differences A localised logic change
Large differences with the same function A different synthesis run or a different tool version
Differences only in memory initialisation frames A changed constant table

The fourth row is genuinely informative: block memory contents appear in identifiable frames, and a change there is a change to a table rather than to logic. That is often exactly what a project needs to know.

The one structural thing that does survive

Amid the losses there is one property that comes through intact and is genuinely useful: the partitioning of the design into clock domains. Clock networks are configured explicitly and their routing is identifiable, which means the number of clocks and the regions each one serves can be recovered from the bitstream with modest effort.

Observation Meaning
A clock net spanning most of the fabric A global clock, probably the system clock
Several disjoint clock regions Multiple domains, likely asynchronous
A clock derived from another through a configured buffer A divided or gated domain
Clock regions that never interact A genuine domain boundary, useful for timing analysis

The fourth row is the practical payoff. Knowing where the domain boundaries are tells an engineer where the timing risk is, and that is usually the question behind a request to understand a bitstream: not what the logic does, but why the design is marginal.

Where the container and the copy sit

The bitstream’s home is usually an external flash, and reading FPGA firmware explains why. Copying a bitstream into a blank device is covered in extracting FPGA configuration, which also compares the three physical routes. Where the device combines a processor with fabric, the software half is genuinely decompilable and the split is described in reading SoC FPGA firmware.

Services at this boundary

Work covers bitstream acquisition and validation, utilisation analysis, build-to-build comparison with frame localisation, interface-level behavioural extraction, and documented statements of what could not be recovered. It does not cover producing RTL from a bitstream, and it does not cover full netlist recovery on large devices.

The honest framing is that a bitstream can be copied exactly and understood approximately, and the approximation is at the level of behaviour rather than structure.

PostHeaderIcon Read SoC FPGA Firmware: PS Software, PL Bitstream, Two Deliverables

Devices that combine a processor subsystem with programmable logic have become the default for anything that needs both control and high-throughput processing. They also have the distinction of containing two completely different classes of content behind one part number, which means a single request to extract the firmware is actually two projects.

The processor side holds software: instructions, data, stacks, and everything that implies. It can be disassembled, its functions can be bounded, and its behaviour can be described. The fabric side holds a bitstream: lookup table masks and routing, with no instructions at all. It can be copied exactly and understood only behaviourally.

The two halves

Aspect Processing system Programmable logic
Content Instructions and data Configuration frames
Unit of meaning Operation LUT mask, routing switch
Decompilable Yes, to a degree No
Copyable Yes Yes
Behaviour recoverable Yes Yes, at the interface
Structure recoverable Partly Rarely

The third and fourth rows are the practical distinction: both halves can be copied, and only one can be understood structurally.

How the two halves boot

The relationship between the halves is defined by the boot sequence, and the sequence is where the two projects meet.

Boot mode Who configures the fabric Implication
Processor boots first, then loads the bitstream Processor software The bitstream may be inside the boot image
Fabric configured first, then processor released Boot ROM The bitstream is a separate artefact
Both from one image Boot ROM reads a container A single file holds two payloads
Fabric configured by an external device Neither A third device holds the bitstream

The first and third rows are the most common in practice, and they determine whether the bitstream is a separate file or a section inside the processor’s boot image.

Where the content lives

Storage Content Access
External flash Boot image, possibly containing both Read the flash
SD card Boot image Read the card
Internal ROM Boot code only Not readable
Fabric configuration memory Volatile Nothing to read
Processor internal RAM Transient Nothing to read

The first row covers most designs, and it is the good case: one flash read yields both payloads, and the container format tells you where each begins. A combined boot image has a header that describes its parts, and the header is readable.

Header field Purpose
Magic or identifier Confirms the container format
Partition table Offset and length of each payload
Payload type Processor image, bitstream, or data
Checksum per partition Integrity
Encryption flag Whether a partition is encrypted

The third row is what makes the separation mechanical: the partition types are declared, so the bitstream can be extracted without knowing anything about the fabric.

The processor half

Once separated, the processor image is ordinary ARM software and the usual methods apply.

Step Output
Validate the image Plausible entry and vectors
Identify the load map Regions and addresses
Recover functions Boundaries and call graph
Reconstruct Compilable code at an agreed level

The first step is the two-word check described in reading ARM Cortex-M firmware for microcontrollers, adapted to the core in question. On application-class cores the check is different but the principle is the same: the image should be self-consistent before it is analysed.

The fabric half

The bitstream gets a different treatment entirely.

Task Method
Copy it Program a blank device
Validate it Length and header against the device
Compare builds Frame-level diff
Understand it Interface-level behaviour

The fourth row is the only route to understanding, and it is worth being explicit about what it yields: a description of what the logic does at its pins, not of how it is built. That is usually sufficient for a replacement, and it is never sufficient for a modification that changes internal structure.

Why the split matters commercially

The two halves have different costs, different risks and different definitions of done, and a single quotation for both is a quotation that will be wrong in one direction.

Half Typical effort Typical risk
Processor software Weeks, depending on scope Reconstruction quality arguments
Bitstream copy Days Almost none
Bitstream understanding Months, and bounded Expectations

The third row is where projects fail. A customer who expects RTL from a bitstream is expecting something that does not exist, and the expectation is usually formed before any technical conversation.

The interface between them

There is a deliverable that belongs to neither half: the interface specification. How does the processor talk to the fabric, through which registers, with what handshakes.

Interface element Where to find it
Register map Constants in the processor code
Access width Load and store instructions
Handshake Polling loops, interrupt handlers
DMA descriptors Structures in memory
Timing assumptions Delay loops, timeouts

Recovering this is often more valuable than either half alone, because it is the part that a replacement design must reproduce exactly. It is also the part that exists in no document on most projects.

Where the adjacent work is

The bitstream’s storage and the reason it is usually in an external flash are in reading FPGA firmware. Its limits as an object of understanding are in reading FPGA bitstream. The physical routes for the fabric configuration are compared in extracting FPGA configuration.

Services at this boundary

Work covers boot container parsing, payload separation, processor image reconstruction, bitstream validation and copying, interface specification, and interface-level behavioural description of the fabric. It does not cover producing RTL from a bitstream, and it does not cover modifying fabric logic without the original source.

The framing worth using is that an SoC FPGA is two devices in one package, and a request that treats it as one will produce one good half and one disappointment.

PostHeaderIcon Read DSP Chip Program: Harvard Memory Means Half an Image

A request to read a DSP’s program is a request for half of what the customer needs, and the half that is missing is often the more valuable one. The reason is architectural: DSPs separate program memory from data memory so that an instruction fetch and a data access can happen in the same cycle. That separation is the defining feature of the class, and it means the address spaces are distinct.

On a von Neumann machine, reading memory returns everything, because instructions and data share an address space. On a DSP, reading the program space returns instructions. The tables those instructions operate on — filter coefficients, window functions, lookup tables, calibration constants — live in the data space, at different addresses, reachable by different instructions.

What lives where

Content Space Accessed by
Instructions Program Instruction fetch
Immediate constants Inside the instruction Nothing; they are part of the opcode
Coefficient tables Data Load instructions
Delay lines and state Data Load and store
Stack Data, usually Push and pop
Memory-mapped registers Data Load and store

The third row is where the money is. A finite impulse response filter is a loop over a coefficient array, and the loop is generic while the coefficients define the product. An extracted program with no coefficients describes an algorithm; an extracted program with its coefficients reproduces the device.

Why the tables are not in the program space

Some DSP architectures allow constants to be stored in program memory and read as data through a special addressing mode. This is a real feature and it is used, because it keeps constants out of the smaller data space and lets them be fetched in parallel with instruction fetch.

Storage choice Where the table goes Consequence for extraction
Table in data space Initialised data region Requires a data-space read
Table in program space, read as data Program memory, at a data address Captured by a program read
Table in external memory Off chip Requires reading the external device
Table computed at runtime Nowhere; generated by code Recoverable by running the code

The fourth row describes designs that store a formula rather than a table. Those are the easiest to reproduce and the hardest to notice: the extracted image contains a short routine and no table, and the coefficients only exist while the device runs.

Reading the data space

The data space is harder to read than the program space for a mundane reason: it is partly volatile. A read of data memory returns whatever the program had put there at the moment of the read, not the initialised values the linker placed in the image.

Data region Content at rest How to recover initial values
Initialised data Values copied from a load image at boot Read the load image, not the RAM
Zero-initialised data Zeros Nothing to recover
Stack and heap Transient Nothing useful, usually
Persistent state Last written values A read at the right moment

The first row is the important one and it is frequently misunderstood. The initial values of initialised data are stored in the program image, in a section that the startup code copies to RAM. So a program-space read does capture the initial tables, provided the tool includes that section.

Tool behaviour Result
Program read includes initialised data section Tables recovered
Program read excludes it Only the copy routine is present
Tool reads both spaces Complete image
Tool reads program only, and the table is in data Coefficients missing

Recognising a missing table

The symptom of an incomplete read is a filter loop that is correct and an output that is wrong. In the extracted code, the loop loads from an address that is inside the data space and unremarkable; nothing about the instruction says what should be there.

Clue in the code What it implies
Loop with a pointer into high data addresses Coefficient table expected there
Immediate value used as a table length Table size is known to the code
Address computed from a base register set at startup The base is a section address
No writes to the table region anywhere The table is initialised from a load image

The fourth row is the diagnostic: if nothing in the program ever writes to the region being read, the values must have been placed there by the loader, which means they are in the image and the extraction missed them.

The wider consequence for reconstruction

An incomplete image produces a reconstruction that compiles and does not match. The usual response is to spend time on the algorithm, looking for a bug that is not there, when the actual problem is that a constant is zero.

Deliverable Complete image Program-only image
Disassembly Full Full, for instructions
Coefficient tables Present Missing
Behavioural match Achievable Not achievable for filters
Rebuild on new hardware Possible Needs re-derivation of coefficients

The last row is the practical cost. Re-deriving coefficients is possible when the filter specification is known and impossible when it was tuned empirically, which is common in audio and motor control.

On a device with two cores sharing memory, the data space is not private to the DSP, and a table that appears to be missing may simply be living where the other core can see it. That case is treated in reading a DSP plus MCU program.

Where the other half comes from

The segment-level view of a DSP image, which is what tells you whether the initialised data section was included, is in reading DSP embedded source code. Where the device also has a companion logic device on the bus, the joint read is covered in reading DSP and CPLD dump information, and where the tables live in an external memory, attacking DSP flash content covers reading it.

The two general approaches to a DSP’s protection, intrusive and non-intrusive, are summarised under crack DSP; the choice between them is usually settled by whether the device still runs.

Services at this boundary

Work covers both address spaces, identification of whether a given read included initialised data, coefficient table recovery, and reconstruction of tables that are generated at runtime by executing the code in an instrumented environment. It does not cover recovering coefficients that were never stored anywhere, and it does not cover reconstructing a filter specification from an incomplete table.

The question to ask before any DSP read is which spaces the tool covers, because a program-only read is a real result and an incomplete one at the same time.

PostHeaderIcon Read DSP Source Code: Segments Before Instructions

DSP toolchains do not produce flat binaries. They produce object files with sections, each of which has a load address, a run address, possibly an alignment requirement, and a section type that determines what the loader does with it. The final flash image is a concatenation produced by a linker script, and the linker script is not in the image.

This matters because DSP programs frequently relocate themselves. Code that executes from fast internal RAM may be stored in slower external memory and copied at boot. Data marked as uninitialised occupies no space in the image but must be zeroed at startup. A reader who treats the image as a contiguous block of instructions will decode the copy routine as if it were the application, and the result will be plausible and wrong.

The sections that matter

Section type Load address Run address Contents
Text In the image Same as load, usually Instructions
Initialised data In the image Possibly different, if in RAM Constants and tables
Uninitialised data Absent from the image RAM Nothing; zeroed at boot
Overlay or far text In the image Copied to another region Instructions that run relocated
Initialisation table In the image Read by the startup code Copy and zero descriptors

The fourth row is the one that most often defeats a naive read. Overlay sections exist so that a large program can run in a small fast memory, with different overlays swapped in. The instructions are all present in the image, but only one overlay is resident at a time, and the code at a given run address changes during execution.

The initialisation table is the map

The startup code reads a table of descriptors that say what to copy where and what to zero. That table is the single most useful structure in the image, because it encodes the linker’s decisions.

Field in a descriptor Meaning
Source address Where the initialised bytes are in the load image
Destination address Where they must be at run time
Length How many bytes to copy
Zero flag, or a separate entry Whether the region is zeroed rather than copied

Finding the table is a pattern-matching exercise: a sequence of records with regular stride, source addresses inside the image, destination addresses in RAM, and lengths that match the sizes of the data sections.

Observation Conclusion
Source addresses within the image span The table describes copies from flash
Destinations in a contiguous RAM range The run-time data layout
Lengths that sum to the data section size Consistency check on the table
No table at all The program runs from load address; image is flat

The fourth row describes the simple case, and confirming it is valuable: if there is no initialisation table, the image really is flat and instruction decoding can begin immediately.

Why load and run addresses differ

The distinction exists because memory is not uniform. Fast memory is small and expensive, slow memory is large and cheap, and the linker’s job is to place things where they perform while keeping the image in non-volatile storage.

Memory Typical role Consequence
External flash Holds the load image Slow, non-volatile, large
Internal RAM Holds run-time code and data Fast, volatile, small
Internal flash Holds both, on some parts Requires no copy
External RAM Holds large buffers Slower than internal, still faster than flash

On a system where code runs from internal RAM, the address in the image is not the address the instruction executes at, and every absolute address inside the code refers to the run address. Decoding with the load address produces a disassembly full of references to the wrong locations.

Recovering the layout

The workable sequence is bottom-up and does not skip the table.

Step Output Check
Identify the entry point Reset vector target The first instruction is plausible
Locate the initialisation table Copy descriptors Descriptors are self-consistent
Reconstruct the memory map Regions with attributes Regions do not overlap
Apply relocations mentally Run-time addresses Absolute references land in known regions
Decode instructions Disassembly Control flow stays within regions

The fourth step is the one that turns a disassembly into something readable. An instruction that loads from an address inside a known data region is a table access; the same instruction with an address in an unknown region is either a bug or a sign that a region was missed.

Overlays and the address that means two things

An overlay section is the most confusing structure in a DSP image and the one most likely to be misread as a bug. The same run-time address holds different instructions at different moments, because the program copies a new overlay in when it needs it. In the image, all the overlays are present, at distinct load addresses. In execution, only one is visible at a time.

Observation in the image Meaning
Several code blocks whose destinations are identical Overlays sharing a run address
Copy routine called with a constant argument Overlay selection
Code at a run address that does not match its callers The image shows a different overlay than the call expects
A table of load addresses near the copy routine The overlay directory

The third row is what makes a static analysis disagree with the running system, and it explains a class of bug reports that reach this work: a disassembly shows a function doing something the device demonstrably does not do, because the disassembly is looking at the wrong overlay.

The instruction-level work that follows

Once the layout is known, DSP instruction decoding is a specialised but tractable discipline. The features that make DSPs fast — delayed branches, parallel issue, circular addressing — are exactly the features that make a naive decoder wrong.

Feature Decoding requirement
Delayed branch Instructions after the branch belong to the previous block
Parallel packet Operations in one packet share issue constraints
Circular addressing Effective address depends on a register-held buffer length
Bit-reversed addressing Index order is not linear
Multiple accumulators Data flow spans several destinations

These are covered in the context of mixed-device work in reversing DSP and CPLD programs, and the data-space half of the image is the subject of reading DSP chip program. Where the same board carries a logic device whose decode defines the memory map, reading DSP and CPLD dump information covers the reconciliation.

Services at this boundary

Work covers entry point identification, initialisation table recovery, memory map reconstruction with load and run addresses, overlay identification, and disassembly that respects the pipeline and addressing modes. It does not cover recovering the original linker script, and it does not cover producing C without the section layout being established first.

The practical rule is that segments come before instructions. A disassembly produced without a memory map is a hypothesis, and it is usually a wrong one.