PIC18F2458 Read-Out: 24 KB of Flash Behind Four Config Bits

Most enquiries about this part arrive with the same two wrong numbers. The PIC18F2458 is usually called a “24 KB” device when its datasheet states 24,576 bytes, and the protection is usually described as a fuse when it is four configuration bits in flash-backed memory. Both errors are small. Both change the plan: the first decides how large a dump should be, the second decides whether the sample survives.

The device is a 28-pin member of the PIC18F2455/2550/4455/4550 family, documented in DS39887. Alongside the flash it carries 2,048 bytes of SRAM, 256 bytes of data EEPROM, a 12-bit A/D converter with ten channels, and a full-speed USB 2.0 engine.

Sizes, in the Units the Datasheet Uses

Microchip lists program memory twice on PIC18 parts: once in bytes and once in single-word instructions. For the PIC18F2458 those are 24,576 and 12,288. A programmer reporting “12K” is not wrong, it is counting instructions of 16 bits. A dump of 24,576 bytes and a dump of 12,288 words describe the same array, and a file that stops at 0x3000 is half a part. Flash occupies byte addresses 0x000000 to 0x005FFF.

What Actually Blocks a Read

Protection lives in the configuration space, not in the array. CONFIG5L holds CP0 through CP3, one bit per quarter of the flash. The family splits its array into four equal blocks regardless of density, so on a 24 KB part each block is 6 KB — addresses 0x0000–0x17FF, 0x1800–0x2FFF, 0x3000–0x47FF, 0x4800–0x5FFF. CONFIG5H adds CPB for the boot block and CPD for the data EEPROM. CONFIG7L holds the EBTR bits, which stop running code from reading the array through TBLRD.

Set any of them and the in-circuit programmer still connects, the device ID at 0x3FFFFE still answers, and the buffer comes back as a constant. Nothing is scrambled. The array simply declines to answer, which is the distinction between a copy protection scheme and encryption: here there is a gate, not a key.

These bits are rewritable. That is the practical difference from the OTP generation, where protection was a link physically blown once. A programmer with access can clear them again, so a read-out does not have to end with a dead sample.

What the Read Returns

A complete image is three regions, not one. The array itself gives 1,536 Intel HEX data records at 16 bytes each. The configuration words sit at 0x300000 and above, which is outside the range a naïve linear read covers. The data EEPROM sits at 0xF00000 with 256 bytes.

The config region is where a recovered file most often goes wrong, because it is invisible when the file is opened and decisive when it is programmed. Oscillator selection, the USB clock source, brown-out threshold and the watchdog setting all live there.

256 bytes of EEPROM sounds negligible next to 24 KB of code. In USB products it is usually where the calibration constants, the serial number and the endpoint configuration live, so its absence shows up as a device that enumerates but behaves unlike the original.

Reading the program memory properly means all three regions, taken twice, and compared.

The Substitution Question

The PIC18F2553 shares this family and offers 32,768 bytes instead of 24,576 — see our PIC18F2553 note. An image from a 2458 fits a 2553 with room to spare, and config and EEPROM copy across unchanged. The reverse does not work: anything a 2553 stores above 0x5FFF has nowhere to go on a 2458.

When the original part is unobtainable, the upward move is usually cheaper than waiting on allocation. Confirm which device you are holding first — the same package carries both, and only the marking or the ID read tells them apart.

Where the Schedule Goes

The electrical step is quick. The slow part is chip extraction analysis: checking the dump for filler holes, confirming the reset vector resolves to real code, and reconciling two independent reads. On a USB device, one more check earns its keep — whether the endpoint descriptors in the image match what the host expects, since a firmware that enumerates in 8 ms and drops out after 200 ms looks like a hardware fault and is usually a config word.

Send the ordering suffix and a photograph of the marking. The services page lists what a delivered image contains.