Lpcsprg LPC21xx serial programmer

This small tool implements the serial programming protocol for NXP (ex-Philips) LPC21xx-type CPUs.


NXP (ex-Philips) LPC21xx are cheap SOCs with 32kB of RAM, a decent amount of flash ROM, nice peripherals and an ARM 7 core. Plus, they don't require any proprietary tools to develop. You can use the GNU tool chain for cross-compiling, and program them using JTAG or the serial protocol.

The serial protocol is a little bit involved as it uses UU encoding for transferring data, so I've written lpcsprg (LPC Serial Programmer), an Ocaml program to do just that.

(The protocol is documented in the LPC datasheet.)

Licence and downloading

Lpcsprg is copyright Antoine Berke DURAK and is released under the GNU General Public License version 3. You can get the source at http://github.com/berke/lpcsprg/tree/master or clone the repository with git clone git://github.com/berke/lpcsprg.git .


To use Lpcsprg, you specify the serial port with the -device option, the baud rate with -baud and the CPU clock with -clock (in MHz). After that, you specify a sequence of commands.

Getting device information

The -info option causes Lpcsprg to retrieve the device code and the bootloader information.

Dumping memory

Device memory (including RAM) can be dumped with the -dump file jstart length command, where start is the start address and length is the length.


The command -erase begin end erases the flash sectors begin to end inclusive.


The option -program file.hex takes an input file in Intel HEX format and programs the device accordingly. It will automatically erase sectors. With the -cache file option, it will save the programmed sectors in file and avoir reprogramming them if they haven't changed (of course aligning your objects at sector boundaries will help.)