CRC Checksum Generation with MCUXpresso IDE

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CRC Checksum Generation with MCUXpresso IDE

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

https://mcuoneclipse.com/2015/04/26/crc-checksum-generation-with-srecord-tools-for-gnu-and-eclipse/

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

 

Environment:

LPC54S018 chip

MCUXpresso IDE

SRecord tool

(http://srecord.sourceforge.net/)

 

Purpose:

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.

Alice_Yang_0-1604999377811.png

 

Steps:

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

 

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

 

Alice_Yang_3-1604999377880.png

 

Can check from S19 file:

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

Alice_Yang_4-1604999377881.png

 

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

    

Alice_Yang_5-1604999377883.png

 

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.
Alice_Yang_6-1604999377927.png
 

22222.jpg

  • 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

lpcxpresso54s018m_led_blinky_crc.srec

 

  • 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

Alice_Yang_7-1604999377956.png

 

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

Alice_Yang_8-1604999377966.png
 
 

 

134.jpg

 

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.

 

Reference:

https://mcuoneclipse.com/2015/04/26/crc-checksum-generation-with-srecord-tools-for-gnu-and-eclipse/

 

 

 

 

Labels (2)
Attachments
No ratings
Version history
Last update:
‎12-11-2020 03:14 AM
Updated by: