Posts Tagged ‘brechen verschlüsseltes Mikrocontroller-Hexmalprogramm’
TMS320F240: Security in a Part Designed Before It Was a Feature
Parts of this generation predate the assumption that every microcontroller has a security module. Flash was a recent addition, the array was modest, and protection was implemented as an option applied during programming rather than as an architectural feature of the memory system. The documentation treats it accordingly: a short section, a few paragraphs, and no state diagram.
That makes the F240 a different kind of problem from a modern part. There is no zone configuration to read, no OTP block to consult, and no field of lock bits to decode. There is a device in some state, and the work begins with establishing which state.
What protection means here
The array can be configured so that reads from an external master return something other than the program. The configuration is applied at programming time, and it lives in the array itself rather than in a separate OTP region.
Two properties follow, and both are useful:
- Erasing removes the protection along with the contents, because both are in the same memory.
- The protected state cannot be told apart from a blank array by reading, because both return the same thing.
The second property is the one that costs time. A device read as all-zeros or all-FFFF might be protected, might be erased, or might have failed. On this generation the only way to distinguish those is through behaviour.
| Observation | Consistent with |
|---|---|
| Boots and runs | Programmed, and the CPU can reach its own code |
| Serial interface active after reset | Boot loader mode, array may be blank |
| No activity at all | Failed, or waiting on a clock that is not present |
| Runs, but reads return uniform values | Protected; execution path differs from data path |
The CPU fetches, the interface reads
The distinction between the instruction fetch path and the data read path is what makes a protected device still functional. The core executes from the array; an external master asking for the same bytes is refused. On this generation the refusal is a substitution, exactly as on later parts, though the mechanism is simpler.
This is why “it does not read” and “it does not work” are separate diagnoses. A device that runs is a device whose array contains valid code, regardless of what a reader sees.
Getting the device into a known state
Before any other work, three things need to be established:
- Power and clock. This generation expects an external clock or a crystal, and a device without its clock does nothing readable. Confirm the oscillator is running before drawing conclusions.
- Boot mode. Pin states at reset select between executing the array and entering a loader. A device held in loader mode looks blank no matter what it contains.
- Reset behaviour. Watch the address lines or the bus, if accessible, during the first few hundred cycles after reset. An array access in the first cycles is direct evidence that code is being fetched.
The second item resolves a surprising number of cases. Boards that strap the boot pins for a production loader, and products whose loader interface was never implemented, produce devices that appear dead and are in fact waiting.
Programming and erasing on this generation
The programming interface is parallel, and it is not the in-circuit serial interface that later parts use. That has two consequences for anyone working on a board:
- Access requires the address and data bus, which usually means removing the device or using a dedicated fixture.
- The erase operation is the whole array, because sector granularity on this generation is coarse.
Coarse granularity changes strategy. On a part where the array erases as a unit, there is no possibility of protecting a boot region and updating the rest — a limitation that also means no partial image can exist. Recovered images from these devices are either whole or absent.
Reconstructing firmware for a part this age
The practical situation with a 1990s motor-control device is usually that the product is still in service, the vendor is gone, and no source exists. In that setting the useful work is not extraction but specification:
- What does the device control, and to what accuracy?
- What is its control law, inferred from its response to step and ramp inputs?
- What are its safety limits, inferred from where it stops?
- What does it communicate, and in what format?
A reconstructed implementation that meets those observations is a valid replacement, and on a device of this generation it is often a better outcome than an exact copy — because the replacement can be written with modern tooling and documented.
Where an exact copy is needed, the route is the array: erase protection by erasing the device, then rebuild from whatever record exists. On a part whose protection and contents share one memory, there is no way to remove one and keep the other.
What to expect
Honest expectations for this part:
- A protected, programmed device will not yield its image electrically.
- A device removed from service is as likely to be erased as programmed.
- The behaviour of a working device is a richer source of information than the state of its array.
- The documentation for the security mechanism is thin, and much of what is known comes from the programming specification rather than the datasheet.
The last point is not a complaint. It is a warning that the datasheet’s silence on a topic should not be read as absence of the feature.
Related reading
- TMS320F243 and how the package changes the analysis — the sibling part with a different peripheral set.
- TMS320F2809 and the modern unlock sequence — what the mechanism became a generation later.
- TMS320F280230 and the boot ROM’s role — where loading logic moved once it left the array.
FAQ
Does erasing the device remove the protection? Yes. On this generation protection lives in the array, so erasing removes both.
Can a protected F240 still execute its program? Yes. The core’s fetch path is permitted; external data reads are not.
Is there sector-level erase? Effectively not. The granularity is coarse, so images are whole or absent.
Why does a device appear blank? Because it is erased, because it is protected, or because it is held in loader mode by its boot pins.
Is the programming interface serial? No. It is a parallel interface, which is why in-circuit work on this generation is limited.
Conclusion
The F240’s protection is a programming-time option in an era before security modules had names. There is no configuration to read and no state diagram to follow, so the work begins with the device: clock, boot mode, and whether it executes. From there, behaviour is the reliable source, and a functional replacement the realistic goal.