Posts Tagged ‘fpga flash discover’
Finding the Flash on a Board: Three Ways to Watch Boot
The first task on an unfamiliar board is not reading anything. It is working out which of the packages holds the code. A modern board carries a microcontroller, a memory device, a power management chip, a radio, and possibly a second memory device for data, all in packages that can be the same size and the same pin count.
The reliable way to distinguish them is to watch what happens at power-up. Only the code storage is read first, in bulk, before anything else happens.
Method one: a logic analyser on the likely pins
The direct approach is to attach a logic analyser to the pins that a serial flash would use and trigger on the release of reset.
Serial flash uses a small command set on four wires: clock, chip select, and two data lines for the single-lane mode, four for the quad mode. At boot the controller asserts chip select, clocks out a read command, sends a twenty-four or thirty-two bit address, and then clocks in a continuous stream of data.
| Signal | Behaviour at boot | Why it identifies the device |
|---|---|---|
| Chip select | Goes low, stays low for milliseconds | Long assertion means bulk read |
| Clock | Bursts at a fixed frequency | Only a memory read is this regular |
| Data out | Command then address then stream | The command byte is 0x03, 0x0B, or 0xEB |
| Data in | Silent during the read | Distinguishes master from slave |
The third row is the identification. A device that receives a command byte and an address and then emits a long stream is a memory. A device that emits short irregular bursts is a peripheral. The distinction is visible in one capture.
The practical constraint is probing. Fine-pitch packages need a fixture or a set of soldered whiskers, and the clock line at fifty megahertz needs a probe with low capacitance. A capture taken with a long ground lead will show ringing that looks like data and is not.
Method two: passive sniffing
The second method does not drive anything. A sniffer taps the four lines in parallel with the existing devices and records what passes between them.
The advantage is that the board does not need to be modified and the boot proceeds normally, which matters when the device is a customer’s only unit. The disadvantage is loading: every probe adds capacitance to a bus that was designed for two devices, and a marginal bus will fail to boot once sniffed.
| Property | Logic analyser | Passive sniffer |
|---|---|---|
| Connection | Probe or fixture | Tap, often a socket |
| Bus loading | Low with good probing | Higher, accumulates |
| Board modification | Usually none | Sometimes a soldered tap |
| Risk of preventing boot | Low | Moderate on fast buses |
| Setup time | Minutes | Tens of minutes |
The loading problem is worth planning for. If the device fails to boot with the sniffer attached, the fix is a shorter tap and a higher-impedance probe rather than a different method, and a board that boots at half the clock rate is often enough to identify the part.
Method three: boundary scan
The third method works when the pins cannot be reached, which is the case on boards with the memory in a package under a shield or on the far side of a dense assembly.
If the microcontroller supports boundary scan and the board exposes the test access port, the pin states of every ball can be read and driven from the scan chain. The boot sequence can be observed without a physical probe on the memory at all, because the controller’s own outputs are visible from inside.
| Requirement | Why it matters |
|---|---|
| Test access port accessible | Otherwise the chain cannot be reached |
| BSDL file for the controller | Describes which cell maps to which ball |
| Memory on a scanned net | Otherwise there is nothing to observe |
| Chain not disabled by fuse | Production parts often disable it |
The fourth row is the usual blocker. Boundary scan is a development feature, and a device that shipped with the port fused off offers no access. Checking for the port costs a few minutes and saves an afternoon of probing.
Reading the capture
A boot read has a shape, and recognising it is faster than decoding it.
The sequence begins with chip select falling. Within a few clock cycles the command byte appears on the data line, most significant bit first. For a standard read the command is 0x03, for a fast read 0x0B, for a quad read 0xEB or 0x6B. Then comes the address, usually 0x000000 on the first access, followed by a continuous stream that ends only when chip select rises.
| Byte | Value | Meaning |
|---|---|---|
| 1 | 0x03 | Read, single lane |
| 1 | 0x0B | Fast read, one dummy byte |
| 1 | 0xEB | Quad read, mode bits then dummy cycles |
| 2 to 4 | 0x00 0x00 0x00 | Boot vector fetch |
| 5 onward | Data | The first instructions or the vector table |
The address in the third row is the giveaway. A first read from address zero that lasts for hundreds of bytes is a boot fetch. A read from a scattered address for eight bytes is a register access in some other device.
A second read often follows at an offset a few kilobytes in, which is the boot loader checking an application header. The gap between the first and second read is usually the boot loader’s own size, and it is a free measurement of where the application begins.
When none of the three works
Four situations defeat board-level discovery, and each has a different answer.
The first is a microcontroller with internal flash. There is no external bus to watch, and the code never crosses a pin. The part is identified from its package marking and its pinout instead, and the work moves to the internal array — the situation covered in MCU attack.
The second is an encrypted bus. The traffic is visible and the command bytes are visible, but the data is ciphertext, so the capture identifies the part without yielding contents. That limit is the one in bus encryption.
| Situation | Discovery | Extraction |
|---|---|---|
| Internal flash | Marking and pinout | Device-level, not board-level |
| Encrypted bus | Capture works | Capture is worthless |
| Non-standard boot mode | Difficult to trigger | Needs a mode pin analysis |
| Memory under a shield | Boundary scan or X-ray | Destructive or scan-based |
The third is a device that boots from a source other than the obvious memory — a second chip, a socket, or an interface that loads code from outside. The capture shows no boot read at all, which is itself informative.
The fourth is a memory in a package that cannot be probed, where X-ray gives the connection map and boundary scan gives the logic, and the two together substitute for a probe.
Confirming the identification
Once a candidate is found, the confirmation is a single command. Serial flash responds to 0x9F with a manufacturer byte, a device byte, and a capacity byte, and the three together identify the part family and its size.
| Response | Field | Use |
|---|---|---|
| Byte 1 | Manufacturer | Narrows to a vendor |
| Byte 2 | Device type | Memory density and interface |
| Byte 3 | Capacity | Size in bytes, as a power of two |
| Byte 4 to 20 | Vendor specific | Often a unique identifier |
Reading that response requires the device to be accessible, either through the board’s own controller or with a clip on the package. Where the clip is possible, the identification takes a minute and the capacity tells you what a full read should contain — a useful check that the reader is configured correctly.
From discovery to extraction
Discovery produces three facts: which package, which interface, and how large. Those three determine the extraction route.
A device that is accessible and unencrypted is read directly. A device that is accessible and encrypted needs a route that goes through the controller. A device that is not accessible needs the array imaged rather than read.
| Discovery result | Extraction route |
|---|---|
| External, unencrypted, accessible | Direct read with a clip |
| External, encrypted, accessible | Read through the controller |
| External, inaccessible | Destructive or scan-based |
| Internal to the MCU | Device-level extraction |
The route ranking by cost is the one in three physical routes into flash, and the read margin questions that decide whether a direct read will be reliable on an aged part are in floating gate margins.
What the service does
We identify the memory device on an unfamiliar board as a standalone step, and report the three facts that determine everything after it.
| Deliverable | Content |
|---|---|
| Device identification | Manufacturer, type, capacity, from the identifier response |
| Interface | Lane count, clock rate, command set in use |
| Boot map | Which addresses are read at power-up, in what order |
| Extraction route | Which of the four routes applies, with cost |
The boot map is often the most useful output even when the customer already knew which chip held the code, because it shows where the boot loader ends and the application begins, which is the first question any later analysis asks. Where the board-level search itself is part of a wider investigation, the equivalent work for an on-chip array is in discover IC firmware.