IELFTOOL Checksum - When using NXP LPC devices

Technical Note 52619

Arkitekturer:

ARM

Komponent:

general

Uppdaterad:

2015-11-06 13:47

Introduction

This Technical Note discusses the "special" vector table checksum that is required by some NXP LPC devices.

Note for NXP LPC devices

NXP LPC devices need a special checksum to be placed at a specific address (in the vector table). IAR Embedded Workbench for ARM will automatically calculate this checksum and place it. It is very important that a custom CRC checksum must not be calculated over this special checksum in the vector table.

Problem 1 - ielftool error

When you build you get the error
ielftool error: Checksums have dependencies

The error is issued since both the vector table checksum and the application checksum are calculated by the same ielftool command.

Solution 1 - exclude the vector table

The solution is to exclude the vector table from the calculation of the application checksum, which can be done by setting the start address to the first address that follows the vector table.

Change option "Linker > Checksum > Start address" from 0x0 to 0x40.

(Check the .map file to find the end address of section .intvec)

Problem 2 - checksum have to include the vector table

The checksum of your application have to include the vector table too, but "Solution 1" excludes the vector table.

Solution 2 - use post-build command line

If you use a post-build command line, the two checksums will be calculated by separate ielftool commands, i.e. avoiding the dependency that caused the ielftool error, and the start address 0x0 can be used.

  1. Deselect option "Linker > Checksum > Fill unused code memory".
  2. Add option "Linker > Extra Options > Use command line options"
    --place_holder __checksum,2,.checksum,1
    --define_symbol __checksum_begin=0x0
    --define_symbol __checksum_end=0xfffb
  3. Set option "Build Actions > Post-build command line"
    ielftool
    --fill 0xFF;0x0-0xfffb
    --checksum __checksum:2,crc16,0x0;0x0-0xfffb
    --verbose "$TARGET_PATH$" "$TARGET_PATH$"

Problem 3 - binary file does not include checksum

The option "Output Converter > Output > Generate additional output > Output format: binary" is set, but the checksum of the application is not included in the generated binary file.

The reason is that the binary file is generated after linking but before the post-build action, i.e. before the checksum is calculated by the post-build action!

Solution 3 - use post-build .bat file

The solution is to let the post-build command line invoke a .bat file that first calculates the checksum and then generates additional output.

See example project IAR Embedded Workbench for ARM - Example (LPC device).zip.

Note:

This example project is based on an example called 'Example (1 range, 3 diff. locations)', configuration 'PlaceEndOfROM'. The target is changed to LPC1768 in order to provoke the ielftool error, but the address range over which the checksum is calculated is still the same as in the original example project.

Description:

  1. Set option "Build Actions > Post-build command line"
    $PROJ_DIR$\post-build.bat "$TARGET_BPATH$"
  2. Create file post-build.bat in the project folder, with the following content:
    set OUT=%1.out
    set HEX=%1.hex
    set BIN=%1.bin

    :: calculate application checksum
    ielftool --fill 0xFF;0x0-0xfffb --checksum __checksum:2,crc16,0x0;0x0-0xfffb --verbose %OUT% %OUT%

    :: generate additional output: hex
    ielftool.exe --ihex --verbose %OUT% %HEX%

    :: generate additional output: binary
    ielftool.exe --bin --verbose %OUT% %BIN%

 

All product names are trademarks or registered trademarks of their respective owners.

Det här innehållet finns tyvärr inte på svenska.

Vår webbplats finns främst på vårt koncernspråk engelska, förutom det innehåll för investerare som vi är lagstadgade att kommunicera på svenska. Vi rekommenderar att du besöker vår globala webbplats på engelska för att få en bättre upplevelse.

Vi stöder inte längre Internet Explorer. För att få bästa möjliga upplevelse av iar.com rekommenderar vi att du uppgraderar till en modern webbläsare som Chrome eller Edge.