Posts Tagged ‘break locked chip flash’

PostHeaderIcon PIC16F74 Data: CP and CPD Are Two Different Locks

The word data in a request about this part is doing real work. A PIC16F74 holds four thousand words of program flash and two hundred and fifty-six bytes of data EEPROM, in two arrays with two protection bits, and the two can be locked independently. A job that recovers the code and stops there has answered a question the customer may not have asked.

Break Locked Chip PIC16F74 program memory and readout MCU Data from eeprom memory, the heximal file can be rewritten to the new microcontroller PIC16F74 for IC cloning

Two bits, two arrays

The code-protect bit stops the program array from being read out. The data-protect bit stops the EEPROM array. They are separate fields in the configuration word, and clearing one has no effect on the other, which is why a part can be read successfully and still be a closed book. Both are reached by the same programming command that reads the configuration word, so establishing the pair of states costs nothing and should be the first measurement on any bench.

Why the two bits are checked together

Because the customer’s answer changes depending on the pair, and because the pair is free to measure. A device with clear code protection and set data protection is a device whose program can be read today and whose EEPROM cannot, which means the field layout has to be derived from the code rather than observed. A device with the reverse is one where the numbers come out directly and the program has to be inferred from how they are used. Neither state is unusual, and each leads to a different work plan.

The package does not change the problem

Forty pins and a wide body make this part easier to probe and no easier to read. The protection bits are the same bits, the two arrays are the same two arrays, and the zeros that come back from a protected read are the same zeros. What the larger package buys is room: more I/O to observe, more space between the array and the pad ring, and a socket that is easier to work in. It does not buy access. A bigger part is often assumed to be a softer target, and on this family it is not.

The four states

Code protect Data protect What a read returns
Clear Clear Everything
Clear Set Code, and zeros for the data
Set Clear Zeros for code, and the data
Set Set Zeros for both

The third row is the one most often missed: a customer who has written off the code may still get the calibration, the serial number and the hour meter out of the EEPROM. Finding that out is a five-minute test that changes the scope of the job, and it is the cheapest useful thing anyone can do with this part.

Why the data is often the whole requirement

Products built on a mid-range part usually keep the per-unit numbers in the EEPROM: an offset measured at final test, a serial number, an accumulated count. The code, by contrast, is often available from the customer’s own archive or from a later revision of the same firmware. When that is the situation, the project is a 256-byte recovery and not an extraction, and the price differs by an order of magnitude. Ask which of the two is actually needed before designing a route.

The order to test

Read the configuration word and record both bits. Attempt a normal read of the program array and note whether it returns content or zeros. Attempt a read of the data array and do the same. That sequence establishes the state of the device without opening anything, and it takes a minute. Everything after it is a decision rather than a discovery.

What the deliverable looks like

For the data array, a byte image with the field layout inferred from how the code uses it, or stated as unknown when the code is not available. For the code, a word image plus the configuration word. Both are small enough that verification is cheap: the EEPROM against the device’s own display, the code by reprogramming a blank part. A 256-byte image delivered without a field map is a deliverable that will come back with questions, so the map belongs in the report.

Where this goes wrong

The common failure is treating a zeroed read as a blank device. A protected array returns zeros, and a blank array returns all ones, and a technician who has seen the first case will not necessarily recognise the second. The distinction, and what each means, is set out in PIC12C509 code. The file-level questions that follow a successful read are in PIC16F57 hex data, and the wider decision tree is in breaking an IC. A 40-pin part with a host bus is covered in PIC16F77 flash, and the same two locks on a newer array in PIC18F2480 EEPROM.