Posts Tagged ‘pld flash break’
Unlocking a Block Erases It: The Binding You Cannot Break
The most common request we receive about a locked flash is a contradiction, and it arrives in good faith. The customer wants the block protection removed and the contents kept. On the majority of devices that have block protection at all, these two things cannot both happen, because removing the protection is the erase.
That is not a policy or a licensing decision. It is how the cell array is wired.
Why the lock cannot be changed in place
A protection bit has to live somewhere, and on a flash device the only memory that survives a power cycle is the flash itself. So the lock state is stored in the array, in a location the programming interface treats specially.
Changing a bit inside a flash array requires an erase first. A program operation can only move a cell from the erased state to the programmed state; it cannot move it back. To take a programmed lock bit and clear it, the containing block must be erased, and the block that contains the lock bits is by design either the same block that holds the code or a dedicated configuration block that the erase command reaches through the same path.
| Implementation | Where the lock lives | What clearing it costs |
|---|---|---|
| Security fuse plus chip erase | A dedicated fuse row | Full chip erase by definition |
| Protection register in a config block | The config block itself | Erase of the config block, and often of everything |
| Debug-level field | A one-way counter | Descending a level triggers mass erase |
| Per-sector lock bits | Sector headers | Erase of each sector whose bit changes |
Every row ends in an erase. The variation is only in how much is lost.
Three implementations of the same binding
The first implementation is the oldest and the bluntest. A security fuse is programmed once the firmware is final, and the only documented way to clear it is a full chip erase, which the vendor’s programming tool performs as a single command. The fuse does not get cleared separately; the erase clears it as a side effect, then the erase clears everything else.
The second is the debug level. A device ships with a debug port open at level zero. Setting level one closes the port but leaves the flash readable through the core. Setting level two closes both. Returning from level two to level one is documented as triggering a mass erase, on the reasoning that a party who could close the port must be the same party who can afford to lose the contents.
| Transition | Erase triggered | Data kept |
|---|---|---|
| Level 0 to 1 | No | Yes |
| Level 1 to 2 | No | Yes |
| Level 2 to 1 | Yes, mass | No |
| Level 2 to 0 | Yes, mass | No |
The third is per-sector locking on parallel NOR devices. Here the lock bits genuinely are per sector, and in a few families they can be set and cleared with a command sequence rather than an erase. But those parts are the exception, they are usually the older ones, and even they require the device to be in a state where the command sequence is accepted — which on a production board means the write-protect pin is already asserted and cannot be released without the same authority the lock was meant to deny.
What the datasheets say, and where
The binding is always documented, and it is always in a footnote rather than in the feature list. Search the datasheet for the word “erase” inside the section on protection, not the section on memory organisation.
Typical wording is that clearing the protection “requires a device erase” or that the operation “will erase all memory contents”. Both phrases mean the same thing, and both are easy to miss because the feature list on page one says only that the device offers block protection.
| Document location | Phrase to look for | Meaning |
|---|---|---|
| Protection register description | “erased to clear” | The bits are cells; erase is the only clear |
| Debug chapter | “mass erase is performed” | Level change destroys contents |
| Programming manual | “chip erase before unlock” | Order is fixed, not a recommendation |
| Errata | “unexpected erase” | The binding bit them in silicon |
The errata entry is the one that surprises people. A small number of parts trigger the erase on a path the datasheet did not describe, usually a reset during a protection command, and the result is a device that was unlocked and empty when the engineer expected it to be unlocked and full.
Why the request keeps arriving
The request is reasonable from the customer’s point of view, because the marketing material describes protection as a lock rather than as a fuse. A lock implies a key. A fuse implies destruction. The distinction matters enormously when the goal is to read a device in order to repair it rather than to copy it.
We spend a disproportionate amount of the first conversation on this point, because a customer who expects data preservation will authorise a procedure that cannot deliver it, and then judge the result as a failure of technique. The honest framing is that the block protection worked exactly as designed.
The narrow cases where data does survive
There are three, and none of them is common.
The first is a device with two independent protection layers, where the outer layer is a register that resets on power cycle and the inner layer is the fuse. Clearing the register costs nothing, and if the code was only protected by the register, the data is intact. This is a design mistake rather than a feature, and it is worth testing for, because it costs one power cycle to check.
The second is a device where the locked region is a small parameter block and the code sits in unlocked sectors. Erasing the parameter block to clear its lock leaves the code readable. The customer loses calibration and keeps the program.
The third is a device whose lock is enforced by the boot loader rather than by the array. The array has no protection at all; the loader simply refuses to expose it. That is not a block lock in the hardware sense and it falls to the routes described in three physical routes into flash rather than to an unlock procedure.
What to do instead
When the binding is real, the planning question becomes which of three outcomes is acceptable.
If the contents are still wanted, the only route is to read them while the lock is in place, which means attacking the read path rather than the lock. That is the block-level protection question: which blocks the design left open, and whether the open ones are enough.
If the contents are not wanted and the goal is a working device, the unlock is trivial: perform the erase, accept the loss, and program a known image, which is the rebuild problem covered in three sources for rebuilding flash.
If neither is acceptable, the device is a candidate for destructive reading, where the lock is irrelevant because the array is imaged directly rather than read through the interface.
| Goal | Route | Contents after |
|---|---|---|
| Read the code | Attack the read path | Intact |
| Working device | Erase, then program | Replaced |
| Code from a dead unit | Image the array | Intact, device lost |
Half-erased states
One final note, because it changes the arithmetic. An erase that is interrupted does not always complete. A device that lost power midway through a mass erase can end up with some blocks cleared and others untouched, and the untouched ones may still be readable — a state examined in interrupted erase.
This is not a reliable unlock method. It is, however, a reason to attempt a read before declaring a device empty, because “the erase ran” and “the erase finished” are different statements and only the second one guarantees that nothing is left.
What the service does
We identify which of the four lock implementations the device uses, and state plainly what clearing it will cost before any work begins.
| Deliverable | Content |
|---|---|
| Lock classification | Which of the four mechanisms is present |
| Data consequence | What the documented unlock destroys |
| Alternative route | Whether the read path can be attacked instead |
| Recommendation | Read-in-place, rebuild, or destructive imaging |
The classification is usually answerable from the datasheet and a bench measurement, and it takes less time than the conversation about expectations. Where the answer is that the data cannot survive an unlock, we say so at that point rather than after the device has been erased.