ATmega169A: Finding a Segment Table in a Flat File
A flat binary has no sections, no labels, no boundaries. Everything that a linker knew has been thrown away, and what remains is bytes in order. Finding a table in that is a matter of recognising shape rather than of reading a header.
On a display product the largest table has a distinctive shape, and learning to see it makes the rest of the image legible.
The shape of a segment table
A character table maps an index to a bit pattern. Three properties make it findable:
Fixed stride. Entries are the same size, because the register layout does not change between characters. A stride of a few bytes repeated a few dozen times is a table.
Low entropy in the high bits. Only some bits of each entry correspond to connected segments. The rest are zero, which makes the entries look like small numbers with a regular spacing.
Monotone index nearby. The code that reads the table increments an index, which appears as a short loop with a bounded counter.
| Property | What it looks like in a hex view |
|---|---|
| Fixed stride | Repeating pattern every N bytes |
| Sparse bits | Many 00 bytes interleaved with small values |
| Bounded values | Most entries below a threshold |
| Neighbouring index | A loop counter with a small limit |
Why display tables are larger than they need to be
A digit needs perhaps seven segments. A display with four digits, several annunciators and a couple of icons needs a table of a few dozen entries, each holding a pattern spread across backplane phases.
Because the pattern is distributed rather than contiguous, each entry is wider than the visible information requires. That is what produces the sparse, regular look — and it is also why the table is bigger than an outsider would expect.
Reading around the table
Once a candidate is found, three checks confirm it:
- The number of entries matches the number of displayable symbols, including blanks and error states.
- Extracting the entries and rendering them reproduces the visible characters.
- The code that indexes it also handles the decimal point or a leading-zero blanking case.
The third is the strongest. A table used for a display has special-case handling for the blank and for the decimal point, and that handling is code adjacent to the lookup.
What the flat file hides and what it cannot hide
It hides addresses, section order, and the distinction between code and data. It cannot hide the internal structure of data, because the structure is what the data is.
That is the general principle for reading a binary: look for repetition, look for stride, look for bounded values, and look for the code that indexes them. Those four signals find tables in any image, regardless of architecture.
The revision question
The A suffix marks a die revision. It may change the signature byte and a few analogue behaviours, and it does not change the table shape.
What it can change is the contrast constant that sits near the table, which is why a table extracted from one revision and applied to another may render correctly and look different. Recording the revision with the table prevents that being discovered in the field.
Reading order
- Signature, fuses, lock byte.
- Array read, verified — a flat file with one wrong byte corrupts a table silently.
- Locate repeated structures by stride.
- Confirm each candidate against the visible display.
- Record the table with the revision and the contrast constant.
Step 5 is the packaging that makes the result usable. A table without its revision and contrast is a fragment, and fragments get applied to the wrong device.
Related notes
- ATmega169PA and the driver — how the table is consumed.
- ATmega169PV and display fuses — the settings outside the file.
- ATmega640PV and binary offsets — the general problem of flat files.
FAQ
How do I know a table’s stride? By measuring the distance between repeated patterns in a hex view.
Can a table be mistaken for code? Rarely. Code has varied structure; tables repeat.
Why does one wrong byte matter so much? Because a table has no checksum and no redundancy. One bad entry renders one wrong character.
Does the revision change the table? Usually not. It can change the contrast value next to it.
Conclusion
A flat binary still contains structure, because structure is a property of the data rather than of the file. Fixed stride, sparse bits, bounded values and a nearby index are enough to find a segment table — and confirming it against the visible display turns a guess into a verified reconstruction.