LPC2131FBD64: Eight Sectors And Nothing Spare

Thirty-two kilobytes is eight 4 KB sectors, and that is the whole story of this part. The LPC2131FBD64 is the smallest member of the LPC213x line: an ARM7TDMI-S core at 60 MHz, 32 KB of flash, 8 KB of SRAM, one 8-channel 10-bit ADC and no DAC. There is no second bank, no spare sector for a loader, and no external memory interface. Dumping a protected LPC2131FBD64 heximal file is therefore an exercise in not losing any of it.

No Margin Anywhere

Requests phrased as dump protected LPC2131FBD64 heximal leave no room for a partial erase, since there is no spare sector.

Feature LPC2131FBD64 Larger sibling
Flash 32 KB up to 512 KB
SRAM 8 KB up to 32 KB
ADC 1 x 8 channels 2 x 8 channels
DAC none 10-bit
CAN none none

On a 512 KB device, a failed unlock attempt that erases one 4 KB sector leaves most of the program intact. On this device, the same attempt removes an eighth of the array, and because sector 0 contains the vector table it removes the entry point with it. The arithmetic changes the risk calculation before any tool is connected.

The 8 KB of SRAM is similarly tight. In-application programming requires the source data to sit in RAM, and an operation can move 256, 512, 1024 or 4096 bytes. A firmware update routine on this part has to work in small pieces. When we recover an image and see a buffer of exactly 256 bytes with a 0x100 alignment mask, that is usually the upgrade path rather than an application buffer.

The Protection Word And Its Address

Code Read Protection is a 32-bit value at 0x000001FC, placed in the space after the exception vectors that was reserved so an FIQ handler could live at the top of the vector region. The boot ROM reads it at every reset. 0x12345678 selects CRP1: JTAG off, ISP read and compare off, writes to sector 0 blocked, sector erase still allowed. 0x87654321 selects CRP2: most ISP commands gone, only full-chip erase left. 0x43218765 selects CRP3: ISP entry through P0.14 disabled when valid user code is present.

Early bootloader revisions implemented only the middle of those three. Reading the boot code version over the serial interface is the cheapest way to find out which scheme is present, and it is the first command we send. A protection change also needs a full power cycle to take effect, so a part programmed minutes ago may still be open at the bench.

Error Correction Changes The Read

The flash on this line carries Hamming error-correction capability, with single-bit correction on read. That is good for a product in the field and awkward for a physical extraction: the check bytes sit alongside the user data, and a capture that discards them can produce a file which looks complete but verifies wrong. We keep them with the data, note how they were handled, and read the array twice from different angles so that a marginal cell is not silently corrected into a plausible instruction word.

The vector checksum is the other detail that a rebuild must get right. The word at 0x14 is the two’s complement of the sum of the other seven vectors; the boot ROM will not transfer control to user code unless all eight add up to zero. Any image we hand back has that word recalculated.

What Is Not In The File

There is no CAN controller on this device and no DAC, so neither appears in the disassembly. The single ADC, two UARTs, two I2C buses, SPI and SSP, six PWM outputs and the vectored interrupt controller do. Runtime state in the 8 KB of SRAM is gone at power-down, and no flash read will bring it back. A customer asking for calibration values should be told that they may live in a flash sector used as data storage, which the sector map will show as programmed but not as code.

Practical Notes

Marking and date code first, then the bootloader revision, then the CRP word if it can be observed. We document which sectors were blank so that the delivered binary is not padded with invented 0xFF regions presented as firmware.

Our service scope lists what we accept for intake. The memory-type comparison explains why this array behaves differently from OTP and mask ROM; this STM32F407 case is a contrast with a much larger array. Within the family, the LPC2132FBD64 adds a DAC and the LPC2138FBD64 shows what happens at 512 KB, where the boot block starts eating usable space.