One of my dev boards is an LPC2378-STK. It’s a fun board but, the JTAG programming interface for it is dreadfully slow. I messed around a bit and learned that programming the flash memory with the iap interface was the way to go. It was taking around 18 secs to write a sector with the isp interface, while almost instant when using iap. In order to make use of the iap programming interface a secondary bootloader needs to be present in flash.
SD Secondary Bootloader
There’s a number of choices for implementing a secondary bootloader on the LPC2378-STK, ethernet, usb, and SD/MMC are available. I chose the SD/MMC route. The board also includes an LCD, and joystick. I made use of these and added functionality to select from a list, the program that I want to load into flash. The list is displayed on the boards LCD and represents the programs stored on the SD card.
USB Mass Storage
To populate the SD card with the programs, I set up the USB to act as a mass storage device. The board shows up automatically under Linux and Windows. I used the LPC_USB project to get started and coupled the result with Chans FAT for file system functions. I found good examples for the SD/MMC interface from Martin Thomas. For some reason I was using Windows at the time… anyway, the JTAG I was using didn’t like the board getting reset. I solved the problem with a bat file and a gdb script that assist with transferring the image to the SD card and resetting the JTAG. They are included in the source package. If your host is Linux, I’ll assume you can write your own script. Note, everything works *much* better on Linux, even inside a VM.
Linking
The object code must be linked with respect to its location in flash. Additionally the exception vectors need to be loaded into high memory in the startup script. The ReadMe file in the source package includes a linker script for use with the GNU toolchain and startup assembly for building a project that can be launched with the bootloader.
http://engine12.com/files/lpc2378-stk/USB_Bootloader.zip
http://gandalf.arubi.uni-kl.de/avr_projects/arm_projects/
http://elm-chan.org/fsw/ff/00index_e.html
http://sourceforge.net/projects/lpcusb/