Posts Tagged ‘decap ic security bits’

PostHeaderIcon STM32G030F6: Where the Security Bits Went

The phrase “security bits” comes from a generation of small microcontrollers where protection was literally one bit, sometimes one fuse, with two or three meaningful states. Engineers who worked with those parts still use the phrase, and it still gets typed into search boxes, but the thing it refers to no longer exists in that form.

On a modern ARM part the protection is a block of option bytes — a small non-volatile configuration area with several independent fields, one of which happens to encode a protection level. Calling them “bits” is harmless. Treating them as one bit is how devices get destroyed.

One word, four different mechanisms

When a customer says the chip is “locked”, they may mean any of four things, and the four have different answers.

Mechanism What it protects What it stops Reversible
Read protection level The whole flash array Debug reads, bootloader reads Level 1 yes, level 2 no
Write protection Selected pages Accidental erase or programming Yes, by option byte change
Securable area A small region at the start Reads and writes even from running code Yes, with a full option reload
Boot configuration Where execution starts Nothing directly, but changes access Yes

Read protection is the one that matters for recovery, and it is the only one of the four that is a level rather than a flag.

Read protection has three states

Level zero is unprotected. The debug port can read the array directly, the ROM bootloader will hand over memory, and there is nothing to defeat.

Level one is protected. The debug port still connects, the core still runs, and every attempt to read flash through the debug interface returns either an error or meaningless data. What level one does not do is stop the code that is already in flash from reading it — the application can read its own constants freely, because it is not going through the debug port.

Level two is permanent. Debug access is disabled at the silicon level, the option bytes can no longer be changed, and there is no documented path back. A device at level two is not a recovery target by any software route.

The distinction between level one and level two is the single most important fact in this work, because the operation that “opens” a level one device also erases it, and the operation that attempts to open a level two device does nothing at all.

Write protection is not protection against reading

A frequent confusion: a device with write protection enabled is reported as “protected”, and it is — against modification. The array reads normally. If the goal is extraction, write protection is irrelevant, and mistaking it for read protection sends the job down a route that was never blocked.

The two are configured in the same option byte block, which is why they get conflated. They are evaluated by different logic and they answer different questions.

The small package does not simplify anything

The twenty-pin variant has the same protection hardware as its larger siblings. What it has less of is pins, and that changes the practical route rather than the protection.

With fewer pins, the debug interface shares signals with functions the application wants, and a product built around this package usually has very little board space for a probe. The result is that the electrical access is the harder half of the job, while the protection is the same puzzle as on a forty-eight pin part.

It also means a smaller array: at this flash size the entire image is a few dozen pages, and a full read is a matter of seconds once access exists.

Reading the option bytes first

Before any decision, read the option byte block and the status register that reports the current protection state. This costs one command and it prevents two expensive mistakes: attempting a read that was always going to fail, and issuing an unlock on a device that is already open.

The fields to record, in the order that matters:

  1. The read protection byte and therefore the level.
  2. The write protection bits, mapped to the pages they cover.
  3. The boot configuration, which decides where execution starts and whether a bootloader is in the path.
  4. The securable area size, if the option is present on this revision.

Record the raw values and the interpretation together. The interpretation is what you will check against behaviour later, and the raw value is what has to be programmed back.

What level one actually allows

Level one blocks the debug port from reading flash. It does not block:

  • Execution of the existing code, which is how the device still works normally.
  • Communication over the application’s own interfaces.
  • Reads of memory that is not flash, within the limits the debug port imposes.
  • Identification, which means the part number and the revision remain readable.

That last point is why a locked device can still be identified, and why the first question — which part is this — has an answer even before protection is considered.

The mistake to avoid

The unlock sequence for level one is documented and it works. It also erases the main flash as a security measure, which is the entire point: the protection is removed by removing what it protected.

So “opening” a protected device is not a recovery technique. It is a way to obtain a blank part. Any procedure that begins with an unlock has already decided to destroy the contents, and that decision belongs to the device owner, in writing, before it is executed.

Related reading

FAQ

How many security bits does this part have? Not one. The protection is a set of option byte fields, of which the read protection byte is the only one that carries a level.

Can a level one device be read without unlocking? Not through the debug port. Other routes depend on what the application itself exposes.

Is level two ever recoverable? No documented method exists. A level two device is treated as unrecoverable through software.

Does the twenty-pin package protect differently? The mechanism is identical. Only the physical access differs.

Conclusion

The word survived the architecture that produced it. What exists now is a block of option bytes with one field that encodes a level, and the level determines everything: what can be read, what must be destroyed to change it, and whether the device is a recovery target at all. Read the block before doing anything, and treat the word “unlock” as a synonym for “erase” until proven otherwise.

PostHeaderIcon PIC16C55 EEPROM: Why a Wide Die Is Opened for a Probe

Opening a package is a means, and on the PIC16C55 the end is usually electrical rather than optical. The part carries the same 512 words of twelve-bit program memory as its smaller relative, but it puts them on a die sized for 28 pins, and the extra area is mostly room: room for bond pads, room for bus routing, room to land a probe without touching anything that matters.

Decap IC PIC16C55 Eeprom and extract mcu pic16c55 heximal from flash memory, and clone firmware to new microcontroller pic16c55 to provide the same functions

A wide die is mostly periphery

Port expansion is not free in silicon, but it is cheap in area at this process node. The array stays the same size while the pad ring and the I/O logic grow, so a part built for 28 pins has generous spacing between the array and the edge. Every one of those pins has a driver, and every driver is fed by a bus that has to come from somewhere. When the array is protected, those buses are the next best thing to the array itself, because they carry what the array contains.

Why a probe beats a microscope here

An optical read is a per-cell measurement: one image per block, one classification per cell, and a stitching exercise afterwards. A probe read is a bus transaction: address on one set of lines, data on another, clock it and capture. On a die this size the pads are large enough to land on with a mechanical probe station, and the address and data paths are wide and slow by later standards, which means a capture does not need heroic timing. The result is the image with far less interpretation and a correspondingly smaller chance of a bit error.

The lines worth finding

Signal group Where it lives Why it helps
Program address Between PC logic and array Tells you where the read is
Program data Array output latches The word itself
Instruction clock Near the oscillator block Gives you a capture trigger
Reset and MCLR Edge of the pad ring Repeatable start point

The third row is the one that makes the work practical. Without a stable trigger the capture is a guess about alignment; with the instruction clock brought out to a pad, every fetch has a known boundary and the data lines can be sampled in the middle of their valid window.

Decap for a probe is not decap for a photo

The two jobs want different things from the opening. A photographic read wants the array clean, flat and free of any residue that would scatter light, which pushes towards a wide opening and a careful final clean. A probe read wants the bond pads exposed and the surface mechanically stable enough to take a touchdown, which pushes towards a narrower opening that leaves the passivation over the array intact. Doing both in one pass is possible and is usually a compromise: the pads get contaminated by the etch, or the array gets scratched by the probe.

The risks that decide the schedule

Mechanical contact is the obvious one and the least common. More often the damage is chemical: an etch that runs a few seconds long undercuts the passivation near the pad ring and lifts the metal that the probe is supposed to land on. The second risk is static, which on a part of this age is a real failure mode and not a formality. Both are reasons to open a spare unit first when one exists, and to accept that a single-unit job has no rehearsal.

The read that comes after

A probe capture is not a file. It is a stream sampled off the bus, with the alignment decided by the trigger and the word boundary decided by the address lines, and it has to be reconciled against the memory map before anyone calls it a program. The reconciliation is cheap: if the capture is right, the words disassemble into an instruction stream that runs to the reset vector and back. If it is wrong, the disassembly shows the same instruction repeating at a period equal to the misalignment, which is a distinctive failure and an easy one to correct.

When this is the right call

It is the right call when the array is protected, the die is large, and the customer needs a bit-exact image rather than a functional rebuild. It is the wrong call when the protection is clear, because a pin-level read costs minutes, and it is the wrong call when the part is a plastic OTP with the same die as an 18-pin sibling, where the smaller die is cheaper to work. The comparison to the 54A is in decap of the 54A and the smaller package variant in PIC16C58B; the technique itself belongs to the wider family described in attacking an MCU.