Posts Tagged ‘eprom firmware recovery’
Rebuilding From a Reference Part: Batch, Revision, Calibration
The worst case in recovery is not a device that is locked. It is a device that is dead: a failed regulator, a cracked package, a broken bond wire. The array may be perfectly intact and completely unreachable, and the customer needs the code.
Two routes exist. One is a physical read of the die, which recovers everything and destroys the device. The other is comparison against a second part of the same type, which recovers what is common between them and requires understanding what is not.
What a reference part can supply
A second device of the same product carries the same application, because it was programmed with the same image. What it carries that the first does not is its own calibration, its own identifier and its own production data.
So a comparison yields two kinds of difference: regions that should be identical and are not, which are errors in one of the two images, and regions that are expected to differ, which are per-unit data.
| Region | Expected between two units | What a difference means |
|---|---|---|
| Application code | Identical | One image is damaged |
| Read-only data | Identical | One image is damaged |
| Configuration bytes | Identical for the same product | One was reconfigured |
| Calibration | Different | Both are correct |
| Identifier | Different | Both are correct |
| Usage counters | Different | Both are correct |
The distinction is the whole method. An analyst who treats every difference as an error will “correct” the calibration and produce an image that is wrong for both units.
Condition one: the same product
The reference must be the same product, not merely the same part number.
The same microcontroller appears in several products with different applications. A reference taken from a different product built on the same silicon supplies an image of the wrong program, and the comparison produces a difference in every code region, which is informative only in the sense that it proves the mistake.
| Reference source | Usable | Why |
|---|---|---|
| Same product, same revision | Yes | The intended case |
| Same product, different revision | Yes, with care | Code may differ |
| Same part number, different product | No | Different application |
| Same family, different part | No | Different memory map |
Condition two: the same silicon revision
A revision change is a mask change, and a mask change often means a code change. Errata workarounds are added, timing loops are adjusted, and occasionally a peripheral’s behaviour changes enough that the application differs.
Two units of the same product built a year apart may carry different revisions and different firmware, and the difference is legitimate. Comparing them produces a set of differences that look like damage and are not.
| Difference | Likely cause |
|---|---|
| A block of code present in one, absent in the other | An errata workaround added |
| A timing constant changed | A clock or peripheral correction |
| A version string differs | A firmware update |
| Everything differs | Different product |
The first row is the one to look for, because an added workaround appears as a contiguous inserted block, which shifts everything after it and makes a byte-level comparison useless. An analysis that reports “the images differ from offset 0x1A00 onwards” has found a version difference, not damage.
Condition three: the calibration is per-unit
Calibration values are measured on each device and are not transferable. They compensate for the specific oscillator, the specific reference and the specific analog path, and using one unit’s values on another produces an error that is small and systematic.
This has two consequences for recovery. The first is that the calibration region from the reference must not be used as a source of truth; it must be recognised as different and left as it is, with a note. The second is that the recovered image’s calibration is unknown, so the device built from it will need its own calibration performed.
| Value | Transferable | What to do |
|---|---|---|
| Oscillator trim | No | Calibrate the new unit |
| ADC gain and offset | No | Calibrate |
| Reference voltage trim | No | Calibrate |
| Product configuration | Yes | Copy |
| Application constants | Yes | Copy |
Classifying the differences
With a reference in hand, the analysis is a comparison plus a classification, and the classification is what makes the output usable.
| Difference class | Size | Handling |
|---|---|---|
| Identical | Most of the image | Copy |
| Per-unit data | Tens of bytes | Copy the structure, not the values |
| Version difference | A block or a set of blocks | Use the original’s version |
| Damage | Isolated bytes or a region | Use the reference’s version |
| Unknown | Anything else | Report, do not guess |
The fourth row is the one that requires care, because damage and version difference look similar in a byte comparison. The distinguishing evidence is structure: damaged bytes usually form an incoherent pattern within an otherwise coherent region, while version differences form coherent blocks that correspond to functions.
The fifth row is the honest output. A region that differs and cannot be classified is reported with both candidate values and the reason for the uncertainty, and the customer decides.
When there is no reference part
If no second unit exists, the physical read is the only route, and it is worth knowing what it costs before it is chosen.
A physical read of the die recovers everything, including the per-unit calibration, and it does not require any assumptions. Its cost is the decapsulation, the imaging, and the fact that the device does not survive — which in this case it already has not.
| Situation | Route | Assumption required |
|---|---|---|
| Dead device, reference available | Comparison | Same product, same revision |
| Dead device, no reference | Physical read | None |
| Live device, locked | Depends on protection | The surface analysis |
| Dead device, damaged array | Physical read plus confidence labelling | None |
The second row is the reason a physical read is sometimes cheaper than a comparison: the comparison requires a reference part that may cost more than the read, and it requires the analyst’s judgement on every difference.
What the deliverable contains
The image, a region map with the source of each region noted, and a list of differences with their classification. For each per-unit region the report says what it is, that it was not transferred, and what has to be done on the new unit.
That last item is the one that prevents a failure six months later. A device built from a recovered image with the reference’s calibration will work, and it will be slightly out of specification, and nobody will connect the two facts.
The physical route that avoids all of this is described in extracting IC flash, and the confidence labelling that applies when the recovered image has gaps is in restoring MCU code. The calibration problem in its copying form, which is the same problem seen from the other direction, is in copy failures.
What we will not do is deliver a comparison result without the classification, because a list of byte differences between two devices is data and not a finding.