cancel
Showing results for 
Search instead for 
Did you mean: 

checksum CODE and IELFTOOL

gfoujanet
Associate II
Posted on April 23, 2013 at 15:33

Hello everybody,

I would like to know if you have already use IELFTOOL to calculate the checksum of your code and to store it in the FLASH. Like explain by IAR and theirs technicals notes, ->I have created a section like this in the ICF file:

1.
define block CHECKSUM_TEST { readonly section .checksum };
2.
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
3.
place in ROM_region { ro, first block CHECKSUM_TEST };

and I add

1.
--keep=__checksum --place_holder __checksum,2,.checksum,4

line to arguments of IAR ELF linker. If I see the MAP file, I can see the section created and keep:

1.
''P1'': 0x5b70
2.
CHECKSUM_TEST 0x08000124 0x2 <
Block
>
3.
.checksum const 0x08000124 0x2 Place holder __checksum
4.
...

Now, I would like to calculate the checksum with IELFTOOL. So I tried to use the tool like this:

1.
ielftool --checksum=__checksum:2,crc16;0xSTART_RANGE-0xEND_RANGE

This method works if I choose a START_RANGE just after the .checksum (ok it's normal) and If I chhose the END_RANGE in the code, not after the code. Else ielftool write an error :

1.
ielftool error: The checksum range contains uninitialized data

Do you know How to Find the last byte of code? And do you think that my method is ok or not? Thank a lot. #ielftool-checksum-stm32
1 REPLY 1
Posted on April 23, 2013 at 16:04

And do you think that my method is ok or not?

 

I'd probably lean toward building a custom tool to pad the ROM image to the desired size, with the pad character of my choosing.

You could perhaps automate with off-the-shelf tools using an AWK script to process the .MAP file and extract the values you need.

The .ICF might permit you place specific symbols, add fill, and the other tools might be able to process that. Reading the documentation for the tools may be enlightening in this regard.

Placing the CRC in the front, or middle of the ROM also seems fraught with issues, better to place it at the end, either physically at the end of the ROM, or beyond all the code and statics. But whatever, it should cover all your programmed data to confirm the validity.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..