AnsweredAssumed Answered

LPC Image Checksums

Question asked by LPCware Support on Mar 31, 2016

Note: If using LPCXpresso IDE v7.9.0 or later, then it is now possible to automatically generate the checksum word as part of the project build.

 

For more details, please see the FAQ :

 


 

NXP LPC parts use a word in the vector table of the processor to store a checksum that is examined by the bootloader to identify a valid image. For ARM7/ARM9 based parts this checksum word is stored at offset 0x14, for Cortex-M based parts it is stored at offset 0x1C

 

Note: This checksum is calculated from the contents of the vector table, not the whole image. For more details please see the user manual for the MCU that you are using.

 

When downloading code via the debugger, this checksum word will be filled in automatically as the image is downloaded.

 

When creating a binary file, you will need to ensure that you run the supplied checksum utility to post-process the binary yourself. If you modify the supplied post-build step to create your binary (as per the FAQ Post-processing your linked application , then this will normally be done automatically by the post-build step:

checksum -p ${TargetChip} -d ${BuildArtifactFileBaseName}.bin;  

But if you need to create a hex file for use by FlashMagic care needs to be taken that you do not run the checksum utility on the hex file itself. The checksum utility only works on binary files, not hex files. Therefore, the checksum utility will corrupt your hex file if you use the hex file as input.

 

Note that FlashMagic will automatically set the checksum word for you when you use it to program a hex file to an LPC device. But if you wish to set the checksum yourself, then the recommend way of creating such a hex file is as follows:

  • convert to binary
  • run the checksum utility
  • convert the binary in hex, using arm-none-eabi-objcopy -I binary -O ihex myfile.bin myfile.hex

Generating other types of checksum

 

There are many other different types of checksums that users may want to perform on an image. A great tool for manipulating image files and generating a variety of checksums is the Open Source SRecord Tool.

Outcomes