TMS320F2811: Sector Protection, and Why Complete Images Are Rare
Two protections on one array is a common arrangement, and they are usually discussed as if they were one thing. On this family they answer different questions and are configured in different places: one decides whether you may read what is there, the other decides whether you may change it. A device can be open for reading and closed for writing, or closed for reading and open for writing, and both states are common in shipped products.
The reason this matters for recovery is that the second gate leaves a permanent mark. A device whose boot sectors were write-protected during production carries an image whose low addresses and high addresses have different histories, and the seams show.
The two gates
The password gates reads. Without it, the array returns data. With it, reads from outside the secure region return zeros.
The per-sector write-protect bits gate erases and programs. They are separate bits, one per sector, held in a structure that is itself covered by the password. A sector that is write-protected cannot be erased through the normal command sequence; the flash controller rejects the operation.
| State | Reads | Erases | Typical product |
|---|---|---|---|
| Open / open | Yes | Yes | Development, unlocked production |
| Open / protected | Yes | Sector by sector | Field units with a fixed boot region |
| Locked / protected | No | No | Shipped product with a secure bootloader |
| Locked / open | No | Yes, by mass erase | Product expecting field reflash |
The fourth row is the awkward one. A part that is read-locked but not write-protected can be mass-erased, which destroys the image but returns a working part. That is the recovery path for the part, not for the program.
Where the seams come from
Consider a device whose boot sector was written once and then write-protected, while the application sector was left open for field updates. It has been through six updates. The application sector contains the current build; the boot sector contains the original.
Now read it. The image is internally inconsistent: the boot code expects an application interface that two revisions of the application no longer provide, or expects a version string that no longer matches. The disassembly contradicts itself at the boundary between the sectors.
This is not corruption. It is an accurate picture of a device whose two halves aged differently, and it is far more common than a pristine factory image.
Recovering something useful from a partial image
Three properties of the array make partial recovery practical:
Sectors are large and few. On this family a sector holds several kilobytes. A protected or unreadable sector therefore removes a large contiguous block, not a scatter of bytes. What remains is still contiguous and still disassemblable.
The boot sector is small and has a known shape. Its entry point, its vector table and its initialisation sequence are recognisable. Even a fragment of it is informative.
Code and data have different textures. Code sections disassemble cleanly; constant tables do not. A sector that will not decode as instructions is probably a table, and its role can be inferred from what indexes it.
What a recovered binary is
A recovered binary from a partially readable device is a file with holes. Two decisions apply to every hole:
- Represent it as absent, so that anything loading the file cannot mistake zeros for content.
- Represent it as zeros, so that the file is a valid image of the full address range.
The first is correct for analysis, the second for comparison against a known build. Using the second while analysing is how people conclude that a device contains large blocks of zeroed code that were never there.
Timing and voltage during the read
On this family the flash controller has a documented access time requirement that depends on clock frequency, and the clock is configured by the very firmware being read. A part read at the wrong assumed frequency returns data with occasional bit errors that are not reproducible at a different rate.
The practical rule: read the same region twice at two different speeds. Data that is identical in both is data. Data that differs is a sampling problem, and the slower read is the more likely truth. This costs one extra pass and eliminates an entire class of false findings — including the misleading one where a single flipped bit looks like a deliberate patch in the code.
The password, revisited
For completeness: the recovery of the array and the recovery of the password are separate objectives, and only the first is a reading problem.
If the password is known, the array is open and the per-sector bits are readable, which tells you exactly which sectors were protected during the device’s life. That history is often more valuable than the code: a sector that was write-protected at production and never changed identifies the part of the firmware that the vendor considered fixed.
If the password is not known, the array is closed and the write-protect bits are equally invisible. Then the analysis has to proceed from behaviour, and the seams described above are not available because there is no image to have seams in.
Assembling a working picture
The sequence that produces a usable result rather than a plausible file:
- Establish the clock configuration from the boot code, then read at the correct rate.
- Read the whole address range twice; discard values that do not agree.
- Map the holes. A hole at a sector boundary is protection; a hole in the middle of a sector is a read failure.
- Record the sector map with the image. Without it, the next person reads the file as a complete device.
- Reconstruct the configuration separately — clock, boot mode, peripheral muxing — because none of it is in the array in a form a disassembly reveals.
Step four is the discipline that makes the work reusable. A binary delivered without its sector map invites someone, eventually, to program it into a part and wonder why the device boots once and then stops.
Related reading
- TMS320F2809 and the unlock sequence — how the read gate is released in the first place.
- TMS320F2812 and program outside the array — when the recovered image is not the whole design.
- TMS320F2806 and file representation — how to record a holed image without corrupting it.
FAQ
Can a write-protected sector be erased? Not individually through the normal command sequence. A mass erase clears everything, including the protection.
Does write protection hide the sector’s contents? No. It is an independent gate; a part can be readable and write-protected at once.
Why do recovered images have holes at sector boundaries? Because the hole is the granularity of protection. Protection is granted per sector, not per byte.
Are bit errors in a read always damage? No. Reading at the wrong clock rate produces them. Re-read slowly before concluding anything.
Is the sector map part of the image? It is not in the image, and it must be recorded alongside it, or the file will be misread later.
Conclusion
Recovery on the F2811 is a map-making exercise as much as a reading one. Two gates, sector granularity and a clock that depends on the code being read all conspire to make a naive read incomplete and undiscoverably wrong. Reading twice, recording the holes and separating configuration from code turns a plausible file into a usable one.