Creating files for the bootloaders

Per default the LPCXpresso project wizard only generates the .axf executable that is needed to debug the program.
If you want to program the LPCXpresso device in a different way, using the USB bootloader or the ISP protocol, you need different type of files.

Creating a .bin file for the USB bootloader

After building the program, we need to convert the .axf formatted file that the LPCXPresso tools created into a binary format that is compatible with the flash loaders and as a next step we need to store the checksum that is used by the boot process to detect a valid flash image.

First open the project properties of your project (right click on the project and select Properties).
Then select the C/C++ Build - Settings view and select the "Build Steps" tab in the right pane. This will give you a windows that looks like this:

Commands on this line are all separated by ssemicolons, note the hash (#) sign after the arm-none-eabi-size command and remove this. This enables the two commands after the arm-non-eabi-size command:

  • arm-none-eabi-objcopy -O binary
    takes the .axf file and creates a binary file (looks like a raw memory dump)
  • checksum -p ${TargetChip}
    creates, and writes into the file, the checksum that is needed by the boot process.

If you now build your project, the .bin file will be created as part of the process.
Note that the .bin file is only created when the build process has to perform some build steps.

On building you will see something like this:

Performing post-build steps
arm-none-eabi-size lpc17_pureasm.axf;  arm-none-eabi-objcopy -O binary lpc17_pureasm.axf lpc17_pureasm.bin ; checksum -p LPC1769 -d lpc17_pureasm.bin;
   text       data        bss        dec        hex    filename
    256          0          0        256        100    lpc17_pureasm.axf
Created checksum 0x74fcf7ef in lpc17_pureasm.bin at offset 0x1c


The bottom line shows that the checksum was being written, the two line above that are the output of the size command, showing the size of the created program.

This file can now be used as a .bin file for the USB bootloader.

Creating a .hex file for FlashMagic or lpc21isp

An ISP program like FlashMagic or lpc21isp requires an intel hex file format. FlashMagic calculates the checksum neeed but I am not sure about lpc21isp. The procedure described here will create a .hex file that also contains the checksum created in the previous step.

Just add the following command to the post build steps from the section above:

arm-none-eabi-objcopy -I binary -O ihex ${BuildArtifactFileBaseName}.bin ${BuildArtifactFileBaseName}.hex;

This takes the previously created .bin file (with checksum) as input and create a .hex file.
If you need a Motorola S-record format, use -O srec and use .srec as file extension.

Links to tools

  • FlashMagic
    A nice flashy utility with a lot of options
  • lpc21isp
    Is an open source ISP programming tool, delivered as source code, you need a C compiler for your windows, linux, OS-X environment in order to be able to compile this.