Skip to main content
lowpowermcu
Associate III
August 6, 2011
Question

checcksum calculation using IAR v6 and stm32

  • August 6, 2011
  • 6 replies
  • 2306 views
Posted on August 06, 2011 at 13:31

Dear STM32 users,

I want to add a checksum to my application in such way I can every let's say 100 seconds check the flash integrity using CRC.

I have found that IAR simplifies this task and can add at the final adress (or other specified locations) the CRC of the application.

I refer to the techical note 11927 Checksum calculation with IELFTOOL after linking with ILINK

http://supp.iar.com/Support/?note=11927&from=search+result

and the provided examples:

http://supp.iar.com/FilesPublic/SUPPORT/003588/Check_Sum_511.zip

I am following the steps in this tech note and I stuck here:

Add usage of the symbol __checksum in your application

In fact I don't understand what does mean ''add usage of the symbol......''

When I declare it as following:

unsigned short __checksum;

I got thsi error message:

Error[Li006]: duplicate definitions for ''__checksum''; in ''C:\.....\checksum\Obj\main.o'', and ''Place holder __checksum''

When I declare it as following as done in the example provided by IAR:

extern unsigned short __checksum;

I got this error message:

ielftool error: The string '__checksum' was not found in the string table

Is there someone who can help me on this? and thank you in advance.

PS: I am using the IAR v6

MCU Lüfter
    This topic has been closed for replies.

    6 replies

    Fristedt.Jan
    Associate III
    August 8, 2011
    Posted on August 08, 2011 at 10:26

    I have no experience with the IAR tools but if your output files are Intel hex it's easy to patch them with the CRC manually.

    I think you should use a 32 bit checksum instead of a 16 bit which is really a bit short for the memory size of the STM32.

    There is a CRC unit in the STM32 that you can use. It's described in RM0008 section 3.

    lowpowermcu
    Associate III
    August 9, 2011
    Posted on August 09, 2011 at 16:28

    Hi jan,

    I will use crc 32-bit embedded in STM32 but now I am stuck how to generate the CRC using IAR v6.

    Any help is welcome.

    MCU Lüfter

    tbenson
    Associate
    August 9, 2011
    Posted on August 09, 2011 at 18:47

    Here are the settings I used in IAR to get the checksum to match the STM32-generated one (note that your addresses will be different depending on your application):

    0690X00000604tuQAA.png

    Also see http://supp.iar.com/Support/?Note=11927

    lowpowermcu
    Associate III
    August 9, 2011
    Posted on August 09, 2011 at 21:39

    Hi benson,

    In ''http://supp.iar.com/Support/?Note=11927'' I don't understand what does mean ''add usage of the symbol......''

    When I declare it as following:

    unsigned short __checksum;

    I got thsi error message:

    Error[Li006]: duplicate definitions for ''__checksum''; in ''C:\.....\checksum\Obj\main.o'', and ''Place holder __checksum''

    When I declare it as following as done in the example provided by IAR:

    extern unsigned short __checksum;

    I got this error message:

    ielftool error: The string '__checksum' was not found in the string table

    How did you get off of it?

    Thank you

    MCU Lüfter

    tbenson
    Associate
    August 9, 2011
    Posted on August 09, 2011 at 22:54

    Make sure you add the __checksum symbol to the Input dialog as shown below:

    0690X00000604vzQAA.png

    I'm heading out for vacation now, so good luck :)

    lowpowermcu
    Associate III
    August 10, 2011
    Posted on August 11, 2011 at 00:23

    Hi benson,

    I am really thankfull for your help.

    Thanks again benson.

    MCU Lüfter