Posts Tagged ‘read fpga chip binary file’
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.