Posts Tagged ‘crack mcu attiny48a’

PostHeaderIcon ATtiny48A: Workarounds Are a Record of What Changed

Silicon revisions are documented unevenly. Some arrive with a change list and a revised errata; others arrive with a new suffix and nothing else. In both cases the firmware often documents the change better than the vendor did, because whoever wrote it had to work around the problem.

Reading an image for workarounds is therefore a way of reading the die’s history. Three patterns recur, and each points at a different kind of defect.

Pattern one: the redundant write

A register is written twice with the same value, with nothing in between that could have changed it. On a modern compiler that is not an optimisation failure — it is an instruction to the hardware, usually because the first write did not take effect reliably.

The distance between the two writes is informative. A few cycles apart suggests a synchroniser that needed time. A separate function suggests the workaround was applied at a call site rather than at the driver.

Pattern two: the delay that does nothing useful

A loop with no side effects, sitting between two register operations. Delay loops exist for legitimate reasons — start-up time, analogue settling, protocol spacing — and they also exist because a peripheral needed longer than the datasheet said.

Distinguishing the two requires context. A delay after enabling an oscillator is legitimate. A delay after writing a control register that has no start-up requirement is a workaround, and it names the peripheral that misbehaved.

Pattern three: reading a status bit twice

The code polls a flag, sees it set, and polls again before acting. That pattern appears in firmware written against a part where the flag was known to glitch, and it is close to conclusive evidence of a silicon defect in that path.

Pattern Likely cause What it names
Duplicate register write Write did not take That peripheral
Unexplained delay loop Operation slower than specified Whatever the delay precedes
Double status poll Flag unreliable Whatever the flag reports
Value written then masked Register reserved bits behave unexpectedly Register-level behaviour

The fourth row is subtler and shows up in code that writes a value, then immediately rewrites it with a mask applied. That is a response to reserved bits that do not read back as written.

Why this matters for a reproduction

A reconstruction that strips the workarounds produces code that is cleaner and, on the original die, wrong. It will fail intermittently, and the failure will appear in exactly the place the workaround was protecting.

Keeping them has the opposite cost: on a newer die they are harmless but they obscure the logic. The right answer is to keep them and annotate them, so that a later reader knows which parts of the code are the design and which are the design’s response to a defect.

Annotation is the part that gets skipped. An image with comments like “this delay is for the errata” is worth considerably more than the same image without them, and the cost of adding them is minutes.

What the revision changes at the observable level

Three things are visible without any errata:

The signature byte may differ. The fuse map does not. The lock bit state machine does not.

That combination means the recovery procedure is identical and only the interpretation changes, which is the useful split: method is portable across revisions, timing and thresholds are not.

Reading order for a revision-aware reconstruction

  1. Read signature and record it with the date code from the package.
  2. Read fuses and lock byte.
  3. Read the array, verified.
  4. Locate the three workaround patterns in the code.
  5. For each, record what it protects and which peripheral it names.

Step 5 produces something unusual and valuable: a per-peripheral list of suspected silicon quirks, derived from the firmware rather than from documentation. For anyone maintaining a product across a revision change, that list is the practical answer to “what do we have to be careful about”.

Related notes

FAQ

Can workarounds be identified without symbols? Yes. They are structural patterns, and they do not depend on names.

Should workarounds be removed from a reconstruction? No. Annotate them instead. Removing one that is still needed creates an intermittent fault.

Does the A revision change the lock bits? No. The state machine is stable across the family.

Is a duplicated register write always a workaround? Not always. It can be a compiler artefact from a volatile access. Context decides.

Conclusion

A revision leaves two records: the vendor’s, which may be terse, and the firmware’s, which is detailed and specific. Reading the second is a matter of recognising three patterns and asking what each one protects. Doing so turns an image into a change log for the silicon it was written against.