CRC Checksum Generation with MCUXpresso IDE

Showing results for 
Search instead for 
Did you mean: 

CRC Checksum Generation with MCUXpresso IDE

No ratings

CRC Checksum Generation with MCUXpresso IDE

Some customers want to generate CRC checksum during compile project, while the GUN tool chain in MCUXpresso IDE doesn’t include CRC checksum calculation function, so we need  the help of CRC checksum tools. In this article, use SRecord.

About detail theoretical knowledge of SRecord, please refer to

In this thread, mainly describe the steps about how to generate CRC checksum with MCUXpresso IDE post-build, through a hands on.



LPC54S018 chip

MCUXpresso IDE

SRecord tool




Generate and place CRC checksum to 0x10000170 of LPC54s018 after compile project.

In image header for LPC540xx devices, the offset 0x10 is crc_value, in LPC54s018 , the address is 0x10000170. so we need save CRC checksum value in  this  place.




  • Import SDK demo “led_blinky” into MCUXpresso IDE (Just use this demo to demonstrate).


  • Enable Compute CRC, because there is one bit in Image header for LPC540xx,Just add “ADD_CRC” or “ADD_CRC =1”, build project.




Can check from S19 file:

When choose no CRC computation (no defined “ ADD_CRC “ symbol), the data in address 0x0164 bit0 is 1,



When choose compute CRC, the data in address 0x0164 bit0 is 0,




After download, srec_cat.exe is the main program we used.

  • Place srec_cat.exe utility in a common directory (to reuse it even if you change the project or even the MCUXpresso IDE version). Be sure you add that “common directory” in the PATH environment variable, then be sure the eclipse was restarted to “see” the PATH content.


  • Create command file crc_add.txt, and place it under" Debug" folder of project.

(About detail commands, please refer to SRecord Reference Manual.)

# srec_cat command file to add the CRC and produce application file to be flashed
# Usage: srec_cat @filename

#first: create CRC checksum

lpcxpresso54s018m_led_blinky.srec            # input file

-fill 0xFF 0x10000180 0x10010000             # fill code area with 0xff

-crop 0x10000180 0x10010000                  # just keep code area for CRC   

                        calculation below (CRC will be at 0x1FFFE..0x1FFFF)

-CRC16_Big_Endian 0x10000170 -CCITT         # calculate big endian CCITT  

                                            CRC16 at given address.

-crop 0x10000170 0x10000172                 # keep the CRC itself

#second: add application file

lpcxpresso54s018m_led_blinky.srec           # input file

-fill 0xFF 0x10000180 0x10010000            # fill code area with 0xff

-crop 0x10000000 0x10000170 0x10000172 0x10010000  #keep all except CRC

#finally, produce the output file

-Output                                     # produce output



  • Add post-build command to create srecord file with CRC checksum.

arm-none-eabi-objcopy -v -O srec "${BuildArtifactFileName}" "${BuildArtifactFileBaseName}.srec" & srec_cat.exe @CRC_add.txt



7Build project, the .srec with CRC checksum file will under Debug folder:





Pay attention:

For the format of image header of LPC540xx devices, we need enable compute CRC and put the CRC value in the specific address. while for other chips, maybe do not need enable, and also can place it in your own address.







Labels (2)
Version history
Revision #:
4 of 4
Last update:
‎12-11-2020 03:14 AM
Updated by: