Posts Tagged ‘wiederherstellen Mikrochip MCU-Flash-Speichercode’
TMS320LF2403: Using the Boot ROM When the Array Will Not Open
A locked device is not a dead device. It is a device whose flash cannot be read, which is a much narrower statement. Everything outside the protected array still works: the core executes, the peripherals run, the RAM is ordinary RAM, and the mask ROM that holds the boot loaders is present and readable.
That last item is the one worth building on. The boot ROM is code that the device runs before it runs anything from flash, and by definition it is not inside the region the security module guards. If the ROM contains a loader that accepts code over a serial port, then a program can be made to run on a locked device without touching flash at all.
What the boot pins actually select
At reset the device samples a small number of pins and uses their levels to choose where to begin. The choices are typically flash, the ROM loader over one of several serial interfaces, and a wait state where the core halts and an external master takes over.
The order in which those pins are sampled is the detail that matters. They are read after a short delay that allows the supplies to settle, which means the pull resistors on those pins have to hold the intended level against whatever else is connected to them. On a populated board the external circuit often overrides the pull, and the device boots from flash no matter what the intended setting was.
| Boot source | What it gives you on a locked part |
|---|---|
| Flash | The original program runs; nothing else is available |
| ROM loader over serial | A path to run new code from RAM |
| Wait state / external master | Direct core control if the interface is accessible |
| Boot pins overridden by the board | Whatever the board forces, not what you wanted |
Why a RAM program is still useful
A program loaded into RAM cannot read the protected array — the security module blocks that regardless of where the request comes from. It is important to be clear about this, because the intuition that a fresh program on the device must be able to see everything is wrong.
What it can do is everything else:
- read the state of the security module and confirm whether it is locked,
- read the peripheral registers and report how the original design configured them,
- measure the clock, the watchdog period, and the reset behaviour,
- inspect the RAM contents that the previous run left behind,
- exercise the serial ports, including any the original design did not use,
- verify whether the password location is erasable, which tells you whether a mass erase would clear the lock.
That list is diagnostic rather than extractive, and it is what turns an unknown device into a characterised one. A great many projects that begin as an extraction turn out to be solved by knowing exactly which state the device is in.
RAM contents after a reset
One item on that list deserves its own section. The RAM is not cleared by a warm reset on many of these parts, and the program that was running may have left a useful fragment behind: a copy of a table it was using, a stack with return addresses into flash, or a buffer holding the last data it computed.
A RAM image taken immediately after reset, before any new code writes to it, is therefore a legitimate source of information about the program that ran. It is a fragment rather than an image, and it is frequently enough to identify the compiler, the main loop structure, or a checksum constant.
The rule is to dump RAM before loading anything. Every loader that runs destroys part of what you came to read.
Structural limits of the approach
Three limits should be stated plainly, because ignoring them wastes days.
First, the ROM loader writes to memory and does not read the array. It is a one-way path for code, not a path for data.
Second, the loader’s protocol is fixed. It expects a particular frame format and a particular handshake, and the ROM version on the device determines which. Mask ROM contents differ between die revisions, so the loader on the bench is not guaranteed to be the loader in the handbook.
Third, the device still needs its clock and its supply in spec. A board whose power sequencing is marginal will boot from flash reliably enough to run a product and fail to accept a loader transfer, because the transfer happens in a window the product never uses.
The sequence
- Identify the boot pin locations from the package and the board schematic, not from the pinout table.
- Determine whether the board’s external circuit overrides the pull resistors; if it does, isolate the pins or lift them.
- Read the mask ROM if any path allows it — the loader version tells you the frame format.
- Power up in ROM loader mode and confirm the device answers the handshake.
- Dump RAM before loading a program.
- Load a minimal monitor and use it to characterise the device: clock, module state, peripherals, password region erasability.
- Only then decide whether the project is an unlock, a password recovery, or a physical job.
Step three is often skipped and always regretted. The documentation describes the loader as it exists in one revision; the device in front of you may answer a slightly different protocol, and knowing which revision you have saves a day of unexplained timeouts.
Reconstructing a program around a locked array
A customer sometimes does not need the original image at all. They need a device that behaves the same way, and they own the hardware that the program drives.
In that case the ROM loader path leads somewhere concrete: the monitor can be used to characterise the peripherals completely, the protocol on the external buses can be captured from a working unit, and a replacement program can be written against that specification. The result is an equivalent rather than a copy, and the effort is in the specification work rather than in the extraction.
That is a different project with a different price, and it is worth identifying early which of the two the customer actually wants. A device with a conventional design and a documented interface is often cheaper to reimplement than to extract.
Related reading
- TMS320LF2402AP and the password state question — the decision that follows the diagnosis described here.
- TMS320F240, an earlier map of the same core — useful for comparing where the ROM sits.
- TMS320LF2406 and what the peripheral configuration tells you — the next step once the device is characterised.
FAQ
Can code in RAM read the protected array? No. The restriction applies to the array, not to the requester.
Is the boot ROM ever protected? It is outside the array the module guards, which is why it remains executable on a locked device.
Does loading a program destroy the RAM evidence? Yes, partially. Dump RAM first.
Why does the device ignore the boot pin setting? Because the board drives the pin. Measure the level at the pin, not at the connector.
Conclusion
The boot ROM is the part of a locked device that still cooperates. Use it to run a monitor from RAM, characterise the device completely, and identify its state before committing to an extraction method. It will not produce an image, and it will tell you exactly which of the remaining routes is worth the effort.