The LPC1342/43 bootloader code is a great feature, allowing for firmware upgrades over USB with no additional hardware (given USB socket is there). Simply pull PIO0_1 low, reset the chip and it enumerates as a mass storage USB device. Copy over the firmware binary and you're done. Cool, isn't it? At least in theory, as my first attempt to flash the MCU using my Linux box simply failed - the firmware got corrupted.

The source of the problem is a simplified FAT16 implementation in the bootloader itself - it expects the file to occupy successive fielsystem clusters. That's how Windows and Mac FAT16 implementations work, but unfortunately Linux FAT16 behaves slightly different (it's still a perfectly valid behavior, though). Googling around I've found a good explanation of the problem.

Obviously, opening the existing firmware.bin file and writing the new content over it should work, as it doesn't change the file's cluster allocation. However, it doesn't work like that even when cp is used to overwrite the file (as opposed to removing the file and copying a brand new one). This is because cp always opens the target file with O_WRONLY | O_TRUNC | O_LARGEFILE flags - and O_TRUNC effectively makes the file recreated from scratch.

The problem was recognized by NXP, and described in AN10986 application note (see chapter 4.4), I highly recommend reading it!

This one is my personal favorite - the tool simply overwrites the file, as described above, also updating the firmware checksum for your convenience. To use this method download the lpc-flash.tar.bz2 file, unpack and compile with usual ./configure && make install.
Invocation is as simple as: