MSP430G2544: What Changes When the Program Fills the Device
At the small end of this family the program occupies a fraction of the array and the extraction is a short event. At the top end the array is full, and fullness changes the character of both halves of the job: the transfer becomes long enough that its reliability dominates, and the analysis becomes large enough that it stops being comprehension and starts being search.
Neither change is a matter of degree. They are the points at which the method has to change.
The transfer is now a process, not an event
A full array over a slow serial link is minutes of continuous transfer, and minutes of continuous transfer on a bench with a flying probe, a breadboard and a bench supply is enough time for something to go wrong.
What goes wrong is not usually dramatic. A device resets because its watchdog was left running. A supply sags when a neighbouring instrument switches. A host application garbage-collects and misses a byte. The transfer does not fail; it stops, and what arrives afterwards is shifted by one byte and looks like data.
Three design decisions follow.
Address every block. The receiver must be able to place each block at its address rather than at its position in the stream, so that a gap is a gap rather than a corruption.
Checksum every block, and request retransmission rather than aborting. A transfer that can recover from one lost block finishes; a transfer that restarts on any error does not.
Keep the reset line under control. If the program’s watchdog can reset the device mid-transfer, the routine has to hold the device in a state where it cannot — by keeping the core halted and moving data through the debug interface, or by running a monitor that disables the watchdog first.
Alignment with the erase granularity
The device erases in small segments and programs in words. A transfer plan that ignores that grain produces an image that cannot be reprogrammed cleanly later, because the block boundaries do not match the erase boundaries.
| Granularity | Size | Consequence of ignoring it |
|---|---|---|
| Programming unit | A word | Unaligned writes are rejected or split |
| Erase unit | A segment | Re-erasing to correct one location destroys its neighbours |
| Transfer block | Chosen | Should be a multiple of the erase unit |
The practical rule is to make the transfer block an exact multiple of the erase unit and to align its start address to one. Then any block can be corrected by erasing exactly that block’s worth of segments and rewriting it, without touching anything else.
The analysis changes kind, not amount
Reading a full array is not sixteen times the work of reading a small one. It crosses three thresholds, each of which changes the technique.
The library threshold. A full program includes support code: memory copy, division, formatted output, sometimes a floating-point emulation. Those routines are generic, and identifying them by signature removes a large fraction of the image from the analysis before it starts.
The indirection threshold. A large program uses function pointers, dispatch tables and virtual interfaces, because it was written by people managing complexity. A disassembler cannot follow a call through a table, so the call graph has holes that have to be filled by reading the table.
The data threshold. A large program has structures, and structures appear in the image as offsets from a base register. Recovering the field layout of those structures is the work that turns a listing into an understanding.
What to do about the indirection
The tables are the key, and they are findable.
A dispatch table is a run of consecutive addresses that all point into the code region, usually aligned, usually near the code that indexes it. Searching the image for runs of plausible code addresses finds them quickly, and each one is a switch statement or a state machine.
Once found, annotate the table by name and the call graph closes. That is an hour of work that converts an unreadable region into a readable one.
Carrying the peripheral configuration with the image
A program that fills the device usually uses most of the peripherals, and the configuration of those peripherals is part of the program’s behaviour in a way that a small program’s is not.
On a device with several analog channels, two serial modules, a comparator and multiple timers, the initialisation sequence is a specification of the product’s signal path. It should be extracted as a table — register, value, meaning — and delivered with the image, because a restored device with the right code and the wrong peripheral configuration behaves like a different product.
When it is not worth it
A full array is also a signal about the product: it is the flagship of whatever family it belongs to, which usually means it is still in production or recently discontinued, which usually means the manufacturer still supports it and spares exist.
That changes the commercial calculation. A device that can be bought new does not need to be duplicated, and a device whose program is large is expensive to analyse. The projects that make sense at this end of the family are the ones where the program is the asset — a control algorithm, a proprietary protocol — rather than the hardware.
Related reading
- MSP430G2101 and the density where reading everything by hand is possible — the other end of the same trade-off.
- MSP430G2252 and what the deliverable should be — how to scope work on an image this size.
- MSP430G2444 and the analysis that follows extraction — the second half of the job described here.
FAQ
How long does a full array take over serial? Minutes at the rates these devices support, which is why resumable transfer matters.
Why align blocks to the erase unit? So a single block can be corrected without disturbing its neighbours.
Are library routines really identifiable? Yes, and finding them removes a large fraction of the image from the analysis.
Is a larger image always harder? Harder to analyse, not harder to extract. The protection is the same.
Conclusion
A full device changes both halves of the work. The transfer becomes a reliability problem that needs addressing, checksums and reset control, and the analysis becomes a search problem that needs signature libraries and table discovery. Plan for both before starting, because neither can be fixed halfway.