Posts Tagged ‘hack ATtiny88 mcu’

PostHeaderIcon ATtiny88: Page Boundaries and the Partial Write Fingerprint

A flash page is the unit of both erasure and programming. The controller erases the page, the code fills a buffer with the words that belong there, and a commit transfers the buffer into the array. Power lost between the erase and the commit leaves a page of nothing. Power lost during the fill leaves a page that is part data and part erased.

On a large array those artefacts are needles. On an array this small they are conspicuous, because there are few enough pages that each one can be examined individually.

The three artefacts and what each means

Appearance Mechanism Reading
Whole page of FF Erased, never committed An interruption, or a build that does not fill the array
Partial page, then FF Committed before the buffer was full An update interrupted mid-page
Page with a single anomalous word Read margin, not content Re-read at a lower clock

The second row is the informative one, because the position of the boundary within the page is a measure of progress. If the update was interrupted after filling three quarters of a page, three quarters of that page holds new data and the rest holds the erased state.

That is a narrow but real forensic result: it establishes not only that an update failed, but approximately where.

Why this differs from a large part

On a device with a quarter megabyte of flash, one partial page among thousands is invisible unless you are looking for it. On a device with a few kilobytes, every page is a candidate for individual inspection, and the pattern across pages becomes legible.

Two patterns are worth knowing:

A run of FF pages starting at a clean boundary. The build is smaller than the array, or the application ends and a reserved region begins. Normal.

A run starting mid-page. The array was being written and something stopped it. Not normal, and worth investigating because the device may still be running code that was never fully written.

The distinction is the boundary alignment, and it costs one pass over the page map to establish.

What a small array implies about the program

A few kilobytes of flash with a page granularity of a few dozen bytes means a program of a few hundred instructions. There is no room for abstraction: no runtime library to speak of, no layered drivers, no dynamic dispatch.

What there is instead is directness. The code writes to registers, waits for flags, and moves on. On a device this size, the disassembly reads like the schematic it implements, which makes the analysis tractable in an afternoon rather than a week.

That is not a limitation of the method. It is a property of the artefact: a small program has fewer ways to hide.

Reading it

  1. Signature, fuses, lock byte. Clock configuration first, because a part waiting for a crystal does not answer.
  2. Full array read, page by page, each page twice.
  3. Build a page map: for each page, the number of non-FF words.
  4. Identify boundary discontinuities in that map.
  5. Disassemble from the vector table and follow the reset path.

Step 3 is the one that is cheap here and expensive elsewhere. On a few kilobytes, a page map is a small table and it makes the structure of the image visible instantly: where code ends, whether there is a gap, and whether the gap is aligned.

The protection layer, briefly

Two lock bits, four states, one erase. No boot section, no self-programming. The array is readable or it is not, and the only thing that changes the answer destroys the content.

Because the array is small, the erase is fast and the temptation to “just erase and start over” is stronger than it should be. That instinct costs the content, and the content is the only reason the device is on the bench.

Related notes

FAQ

Does a page of FF mean the chip is damaged? No. It means an erased page with nothing committed to it.

Can the position within a page be interpreted? Yes, as progress through the buffer at the moment of interruption.

Is a partial page still executable? The remainder is FF, which is an invalid instruction. Execution reaching it will not do what the source intended.

Why build a page map? Because it makes the image’s structure visible in one table, which is the fastest route to understanding an unfamiliar device.

Conclusion

Page granularity is the mechanism, and a small array makes its fingerprints legible. A page map plus boundary alignment distinguishes a small build from a failed update, and on a device this size the distinction is established in one pass instead of argued about.