PostHeaderIcon Three Sources for Rebuilding Flash, Ranked by Trust

When the contents of a flash device are gone and the device still has to work, the image has to be rebuilt from somewhere. There are exactly three sources, and they are not interchangeable. Each has a ceiling on what it can restore, and the ceiling is determined by what the source actually knew.

The ranking is not a preference. It follows from information theory: a source can only supply what it observed.

Source one: a backup from the same unit

The highest-trust source is a copy taken from the same device before the loss. Nothing else can restore per-unit data, because nothing else ever saw it.

The practical problem is that backups are rarely complete. A common pattern is a copy of the application region taken during a field update, which omits the boot loader and the parameter block. That copy restores the code and nothing else, and a customer who expected a full recovery is disappointed by a device that boots but reads incorrect calibration.

Backup type Covers Missing
Vendor release image Code only Boot loader, parameters
Field update package Code plus file system Boot loader, calibration
Full array dump Everything Nothing
Configuration export Parameters only Code

The trust is absolute where coverage exists. A full array dump from the same unit is a complete answer, and the only remaining work is verifying that it is the right version.

Source two: a reference device

The second source is an identical product, ideally from the same production batch. This restores code, boot loader, and file system, and it restores them exactly if the firmware versions match.

The ceiling appears in the per-unit data. Three categories of content differ between units of the same model and cannot be transferred.

Content Differs per unit Consequence of copying
Calibration constants Yes, from factory trim Measurement error
Serial number and keys Yes, unique Identity collision
MAC address or node ID Yes, unique Network conflict
Wear-levelling state Yes, from usage Shortened life
Application code No None

The third row is the one that causes field problems rather than bench problems. Two devices with the same network address on the same bus will both malfunction, and the failure appears weeks after the repair.

Version matching is the second constraint. A reference device that is one firmware revision newer may have a different flash layout, a different parameter record format, or a boot loader that will not accept the older application. The version is usually readable from a string in the image, and checking it takes a minute.

Source three: inference from behaviour

The third source rebuilds the image from what the device does rather than from what it stored. This is the only route when no backup exists and no sister unit is available, and it is the most expensive by a wide margin.

The method is to treat the device as a specification. Its inputs and outputs define what the code must do, and the code is then written to do that. For a small device with a handful of functions this is feasible. For a device with a display, a protocol stack, and a calibration procedure it is a software project.

Device complexity Inference effort Fidelity
Single-function controller Days High, if behaviour is fully observable
State machine with a few modes Weeks Moderate, edge cases uncertain
Protocol device Months Low without captures
Device with encrypted or authenticated links Not feasible None

The fidelity limit is not skill but observability. Behaviour that never appears in an observation cannot be inferred, and the resulting image will match on the tested paths and diverge on the untested ones. That divergence is invisible until it matters.

Ranking by trust, and by what breaks

The three sources rank cleanly on trust and less cleanly on cost, and the two rankings point in opposite directions.

Source Trust Cost What it cannot restore
Same-unit backup Absolute Lowest Anything not in the backup
Reference device High for code, zero for units Moderate Per-unit data
Inference Depends on observability Highest Unobserved behaviour
Original vendor image High, if the version matches Low Per-unit data

The fourth row is worth naming separately because it is not really a fourth source. A vendor release image is a reference-device source with better provenance, and it carries the same per-unit gap.

Verifying a rebuilt image

A rebuilt image is not trusted because of its source. It is trusted because the device accepts it, and the device’s own checks are the best available evidence.

The first check is the integrity value the boot loader computes. Most boot loaders verify a checksum or a CRC over the application before branching to it, and an image that passes that check is at least structurally correct.

Check What it proves What it misses
Boot loader CRC Length and content match the header Per-unit correctness
Boot to application Vectors and initial code are valid Runtime behaviour
Peripheral initialisation Register writes match intent Values derived from calibration
Full functional test The product works Wear and long-term drift

The third row is where reference-device rebuilds fail in a way that a functional test catches and a boot test does not. A device that initialises a radio with the wrong trim value still boots, still responds, and still fails in the field.

The order of operations

The order is fixed and reversing it wastes the best source.

The first action is always to look for a backup, including partial ones, because even a code-only copy is more trustworthy than a reference device. The second is to look for a sister unit and record its version. The third is inference, and it is only attempted when the first two produce nothing usable.

A common mistake is to begin with inference because it feels like the technically interesting path. It consumes the budget and produces an image that is worse than a partial backup that was available all along.

The legal line, briefly

The three sources differ in ownership as well as in trust, and the difference is not academic.

A backup of the customer’s own device is the customer’s data. A reference device belonging to the customer is the same. Inference from observation of the customer’s own hardware produces a new work whose status depends on jurisdiction and on how much of the original was reproduced.

Source Ownership question Risk
Customer’s own backup None Low
Customer’s second unit None, if both are theirs Low
Third-party unit Whether the copy is licensed High
Vendor image obtained elsewhere Distribution rights High

We work from the first two and decline the fourth. Where a customer’s only path is a third-party device, that is a conversation about licensing rather than about technique.

What the service does

We establish which sources exist before choosing a method, and we state the per-unit gap explicitly.

Deliverable Content
Source inventory Which of the three are available, and their coverage
Version match Whether the reference matches the target
Per-unit list What a rebuild cannot supply, and how to regenerate it
Verification plan Which device checks will be run

Where the per-unit data is genuinely unrecoverable, the honest deliverable is a working device with a documented deviation rather than a claim of exact restoration. The related problem of what a copy can and cannot carry between two flash technologies is in NAND and NOR copying, and the case where the original contents are partly recoverable rather than wholly lost is in interrupted erase. Where the rebuild is of a program rather than a flash image, the equivalent reasoning is in recover IC program.

Comments are closed.