Posts Tagged ‘break secured mcu hex’

PostHeaderIcon Break Secured MCU PIC16F72 Data: Where Data Hides on a Part With No EEPROM

Requests usually ask for code, and occasionally they ask for data. On a mid-range part with a data EEPROM the second request has an obvious answer: read the EEPROM, deliver 256 bytes, done. The PIC16F72 does not have one. It has 2048 words of program flash, 128 bytes of RAM that lose everything at power-down, and no byte-writable non-volatile memory of any kind.

So when a customer asks for the data on this device, the question has to be turned around: which data, and where did the designer put it. There are exactly three places it can be, and each one is reached differently and protected differently.

Three places, one of them free

location size what it typically holds readable when protected
ID locations 4 words serial number, build date, hardware revision, calibration offset often yes, worth testing first
program array, table region tens to hundreds of words thresholds, linearisation curves, message strings, key tables no, the array is the protected object
configuration word 1 word oscillator mode, watchdog, power-up timer, brown-out, protect bits often yes

The ID locations deserve the emphasis. Four fourteen-bit words sit outside the program array at a reserved address range, they are written by the production programmer rather than by the code, and on many units of this family they remain readable while the array does not. That makes them the cheapest possible first step on a data request: two minutes of work that can answer the question without touching the die.

The part in numbers

2048 by 14 bits of flash, 128 bytes of RAM, 22 I/O pins across three ports, five analogue inputs into an eight-bit converter, two timers with a capture-compare module, a synchronous serial port, an eight-level hardware stack, and interrupts. The package is a 28-pin body, which is why this part appears in appliance controllers, small motor drives and instrument front ends rather than in eight-pin gadgets.

The eight-level stack is a quiet advantage for recovery work. On the twelve-bit baseline parts a two-level stack limits nesting so severely that the call graph itself becomes a verification instrument; here eight levels means normal structured code, and the call graph is correspondingly less informative and more ordinary. What replaces it as a check is the interrupt structure: two vectors, one at the reset address and one at the interrupt address, and both must decode.

What the ID locations actually contain

Designers use the four words for whatever the production line needed. In practice four patterns recur.

A serial number, either as a binary counter or as a packed decimal. This is the most common use and the easiest to recognise, because consecutive units differ in the low word and agree in the high ones.

A build date in some private encoding, often year and week packed into a byte and a half. Recognisable by falling inside a plausible range when decoded as binary-coded decimal, and by changing in steps of one across a batch.

A hardware revision letter, usually one word holding a single ASCII character, which is the easiest of the four to spot and the most useful to a customer trying to match a recovered image to a board variant.

A calibration offset written by a test fixture, which is the valuable one. On a design that trims an analogue channel per unit, this word is the only record of how that particular board was adjusted, and losing it turns a recoverable unit into a recalibration job.

Data hidden in the program array

With no EEPROM, thresholds and curves live in the code as literal tables. On a fourteen-bit core the idiom is a block of RETLW instructions reached by adding an index to the program counter, exactly as on the smaller parts but with more room.

Two consequences follow for a data request. First, the table has to be identified before it can be extracted, and identifying it needs the indexing code, not the table. An image delivered as a flat disassembly in which forty consecutive RETLW words appear as forty tiny subroutines is technically correct and practically useless.

Second, the table boundaries matter. A block of thirty-two entries that spills into a block of sixteen produces a curve with a step in it when extracted carelessly, and on a linearisation table that step is invisible until the product is calibrated against a reference.

The extraction that works is a small amount of tracing: find the CALL whose target is computed from a register, find the register’s range, and cut the block at exactly that length. That produces a table with the right number of entries and a comment stating the index range, which is what a customer can actually use.

The configuration word as a design record

The configuration word is one word and it is dense with information about the product rather than the program. It states which oscillator the board expects, whether a watchdog is running, whether a power-up timer delays the first instruction, at what supply the brown-out reset trips, whether low-voltage programming is enabled, and whether the array is protected.

Read alone it answers questions that otherwise require a schematic: why the product takes a moment to start, why it resets on a sagging supply, why an in-circuit programmer cannot talk to it. For a data request it often explains where the data went — a design that enables brown-out at a high threshold is a design that cares about supply integrity, which usually means an analogue channel that needed guarding, which usually means a calibration word in the ID locations.

Why secured changes the answer

If the array is protected, the ID locations and the configuration word may still answer, and the table region does not. That asymmetry decides the shape of the job: try the cheap reads first, report what they returned, and let the customer decide whether the embedded tables justify die-level work.

Delivering the cheap part first is also good practice commercially. A customer who receives four ID words, a configuration word and an honest statement that the tables require opening the package can make a decision with real information. A customer who receives a quotation for decapsulation without knowing that the serial number was readable all along tends to go elsewhere.

For the wider family where the same request meets an EEPROM, PIC16F73 memory opening shows the four-array version. For the smaller part with no interrupts and no EEPROM at all, PIC16F506 firmware recovery is the direct comparison. And where the stack rather than the data is the structural constraint, PIC12C509A firmware recovery takes the baseline view.

FAQ

Does the PIC16F72 have any EEPROM? No. That is the single fact that reorganises every data request on this device.

Are the ID locations always readable when the code is protected? Not always, and the behaviour varies by die revision. It is worth testing because it takes minutes, and the answer is worth recording because it decides whether the rest of the job is needed.

Is the RAM worth capturing? Only if the unit is powered and running. RAM contents are volatile and are not part of a memory recovery; they are part of a live debugging session, which is a different service.

The short version

No EEPROM, three places, two of them cheap. Read the ID locations and the configuration word before proposing anything expensive, expect the thresholds to be sitting in the program array as literal tables, and cut those tables by tracing the indexing code rather than by guessing a length. The data a customer wants is usually in the first two, and the honest answer that it is not in the third is worth more than a quotation built on hope.