IELFTOOL Checksum - Over several ranges

Technical Note 53274

Architectures:

ARM, RH850, RX, SH, STM8

Component:

general

Updated:

3/21/2019 1:54 PM

Introduction

The checksum calculation can be made over several ranges. If several ranges are used, then please note:

  • The GUI accepts only one range, so you need to turn off the checksum options, and instead...
    • ...enter some command line options in Project > Options... > Linker > "Extra options".
    • ...enter some command line options to "build actions" > "post build command line"
  • Be careful to calculate (in the application) the ranges with the lowest address range first and so on.
  • The calculation (in the application) will not be able to use checksum symbols (defined by the GUI), so you need to make some effort to use correct ranges in the application.

Two ranges - two checksum values

See example project: Two ranges two checksums 650.zip.

The 1st range is 0x1006000 to 0x102FFFB and the 2nd range 0x1030000 to 0x103EFFB.

Three changes are required:

  1. The changes for IAR ILINK linker are made at "Project > Options... > Linker > Extra options".
    Add the following:
    --place_holder __checksum1,2,.checksum1,1
    --place_holder __checksum2,2,.checksum2,1
    --define_symbol __checksum_begin1=0x1006000
    --define_symbol __checksum_end1=0x102FFFB
    --define_symbol __checksum_begin2=0x1030000
    --define_symbol __checksum_end2=0x103EFFB
  2. Use a post-build command line to perform the checksum calculation, by setting "Project > Options... > Build Actions > Post-build command line"
    ielftool --fill 0xFF;0x1006000-0x102FFFB --fill 0xFF;0x1030000-0x103EFFB
    --checksum __checksum1:2,crc16,0x0;0x1006000-0x102FFFB
    --checksum __checksum2:2,crc16,0x0;0x1030000-0x103EFFB
    --verbose "$TARGET_PATH$" "$TARGET_PATH$"
  3. In the .icf file, define memory ranges and where to place the checksums:
    define symbol __ICFEDIT_region_ROM_start__ = 0x1006000;
    define symbol __ICFEDIT_region_ROM_end__ = 0x102FFFF;

    define symbol __ICFEDIT_region_PFM_start__ = 0x1030000;
    define symbol __ICFEDIT_region_PFM_end__ = 0x103EFFF;

    define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__
    to __ICFEDIT_region_ROM_end__];

    define region PFM_region = mem:[from __ICFEDIT_region_PFM_start__
    to __ICFEDIT_region_PFM_end__];

    place at end of ROM_region { readonly section .checksum1 };
    place at end of PFM_region { readonly section .checksum2 };

Two ranges - one checksum value

See example project: Two ranges one checksum 650.zip.

The 1st range is 0x1006000 to 0x102FFFB and the 2nd range is 0x1030000 to 0x103EFFF.

Three changes are required:

  1. The changes for IAR ILINK linker are made at "Project > Options... > Linker > Extra options".
    Add the following:
    --place_holder __checksum,2,.checksum,1
    --define_symbol __checksum_begin1=0x1006000
    --define_symbol __checksum_end1=0x102FFFB
    --define_symbol __checksum_begin2=0x1030000
    --define_symbol __checksum_end2=0x103EFFF
  2. Use a post-build command line to perform the checksum calculation, by setting "Project > Options... > Build Actions > Post-build command line"
    ielftool --fill 0xFF;0x1006000-0x102FFFB --fill 0xFF;0x1030000-0x103EFFF
    --checksum __checksum:2,crc16,0x0;0x1006000-0x102FFFB;0x1030000-0x103EFFF
    --verbose "$TARGET_PATH$" "$TARGET_PATH$"
  3. In the .icf file, define memory ranges and where to place the checksum:
    define symbol __ICFEDIT_region_ROM_start__ = 0x1006000;
    define symbol __ICFEDIT_region_ROM_end__ = 0x102FFFF;

    define symbol __ICFEDIT_region_PFM_start__ = 0x1030000;
    define symbol __ICFEDIT_region_PFM_end__ = 0x103EFFF;

    define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__
    to __ICFEDIT_region_ROM_end__];

    define region PFM_region = mem:[from __ICFEDIT_region_PFM_start__
    to __ICFEDIT_region_PFM_end__];

    place at end of ROM_region { readonly section .checksum };

 

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

We do no longer support Internet Explorer. To get the best experience of iar.com, we recommend upgrading to a modern browser such as Chrome or Edge.