STM32F101C4: Small Array, No Room for a Second Copy
Most recovery planning assumes the device is mostly empty. A 128 KB part carrying a 60 KB program has room to be clever: a staging area, a backup region, a scratch buffer, a second copy of the vector table. The 16 KB device offers none of that. Everything the product is fits in one region, and that region is exactly what the protection covers.
This changes the character of the job. On a large device, a wrong guess costs time. On this one, a wrong guess costs the firmware, because the one operation that reliably removes protection also erases the array.
What sixteen kilobytes forces
Three consequences follow from the density, and all three are structural rather than incidental.
There is no staging region. Any procedure that copies the array elsewhere before working on it has nowhere to copy to. The array must be read where it is.
There is no redundancy. A large program often carries a backup copy of its calibration or its configuration in a second sector. At this density that redundancy is the first thing removed to make room.
There is no separation of concerns. The vector table, the startup code, the application, the constants and any stored parameters share one contiguous region with no boundary that the hardware enforces. Everything is one artifact.
| Property of a 16 KB device | Effect on recovery |
|---|---|
| No staging region | Nothing can be copied aside before the risky step |
| No redundancy | One damaged sector is a lost product |
| Vector table in the same region | Losing the array loses the entry point |
| Options in a separate page | The protection state is not part of the image |
The decision that comes before the technique
Because the preserving route and the erasing route are mutually exclusive, the useful work happens before any tool is connected. Three questions decide the plan.
First, does the product have any external path that reads its own memory? A serial bootloader, a service port, an update protocol with a verify command, a diagnostic frame that returns more than it needs to. If one exists, the recovery is a protocol exercise and the protection is not an obstacle.
Second, is the content worth more than the device? A 16 KB program on an obsolete board is often replaceable by reimplementation, and reimplementation does not risk the original. If the firmware is a small state machine driving a documented interface, rebuilding it may be cheaper and safer than any extraction route.
Third, is there a second unit? Two identical locked devices change the calculus, because one can be sacrificed to establish what a procedure does before the other is touched.
What the protection transition costs here
The transition from the protected state to the unprotected state erases the array. On a large device this is annoying because the array is large. Here it is total, because the array is the product. There is no region that survives, no bootloader in a protected area that keeps running, no secondary store that still holds the calibration.
That single fact rules out a whole class of approaches that people propose: read a little, unlock, read the rest. The unlock is not incremental, and the read must therefore be complete before it, which means it must happen through a path that does not require unlocking.
Where the content actually lives
A useful observation about small devices: the value is concentrated. Sixteen kilobytes is not sixteen thousand equally important bytes. Typically a few hundred bytes hold the parameters that make the product work — the keys, the calibration, the protocol constants — and the rest is ordinary compiled C.
If a partial path exists that reaches only a small region, that may be enough. A service command that returns a configuration block, a calibration export, a diagnostic dump of a parameter table: any of these delivers the concentrated value without the array.
This is why the question to ask a customer is what they actually need. The answer is often a parameter table rather than a program, and the two have very different accessibility.
Verifying a small image
When an image is obtained, it is small enough to verify by inspection rather than by statistics.
- Check that the initial stack pointer is a plausible RAM address.
- Check that the reset vector points inside the array and at an address that is not erased.
- Disassemble the first few dozen instructions and confirm they look like startup code rather than data.
- Confirm the vector table entries all point inside the array.
- Compare the erased-byte count against the expected image size; a fully erased region reads as all ones and indicates a failed read rather than an empty program.
Step five catches the most common false positive. A read that returns all ones looks like a successful transfer of an empty region, and the mistake is expensive when it is discovered after a device has been sacrificed.
The board is part of the device
On a product this small the microcontroller is rarely alone. There is usually a serial memory, a sensor with a factory calibration, or an identity chip on the same board. Those parts are frequently unprotected and frequently hold data that would otherwise have to come out of the protected array.
Reading the whole board before attacking the microcontroller is not a detour. On several occasions the board’s other devices have contained enough of the product’s parameters that the protected array no longer needed to be read at all.
Related reading
- STM32F101RB and reading the identity before planning — the same family with room to work in.
- STM32F101CB and programming a destination device — what a duplicate needs when the source is readable.
- STM32F103CB and checking whether an image is genuine — the verification routine in full.
FAQ
Can the array be backed up before unlocking? No. Reading it is what the protection prevents; that is the whole difficulty.
Is a 16 KB device easier to attack physically? Smaller geometry helps probe work and does not help anything else.
What if the read returns all ones? It failed. All ones is erased flash, not a program.
Is reimplementation ever the right answer? When the interface is documented and the program is small, often yes.
Conclusion
On a small device the technique is the easy part and the decision is the hard part. Establish whether an existing data path can deliver the value, establish whether the content is worth the one irreversible step, and read the rest of the board before touching the protected part. Sixteen kilobytes leaves no room for a second attempt.