Flash Checksum Calculation

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I am trying to verify the checksum of the programmed flash memory as part of a BIT test upon startup.  I am adding all the memory locations that are defined to be part of the flash memory.  The code is very straight forward:

unsigned long CalculateFlashCSUM()

{

unsigned long CheckSum=0;

    uint8 * FlashAddress;

    FlashAddress=CYDEV_FLASH_BASE;

   

    for(unsigned int i=0;i<=CYDEV_FLASH_SIZE;i++)

    {

        CheckSum += *(FlashAddress++);

    }

    return (CheckSum);

}

I was hoping that I could associate this with something in the hex program file.  This would make it easier to update the software because I could then just inspect the hex file to determine the expected CheckSum value, but the Checksum I am getting from above doesn't seem to match anything in the hex file.  Can anyone provide any insight?  Currently, CheckSum is calculated to be 0x0023D6E0 using the above algorithm and the bottom of the hex file looks like this:

:407FC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000081

:0200000490006A

:0400000000004005B7

:0200000490105A

:04000000BC90ACAF55

:0200000490303A

:020000006A6430

:0200000490402A

:4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C0

:400040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080

:400080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040

:4000C0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

:0200000490501A

:0C00000000012E12306900012E389ACD4C

:00000001FF

Thanks,

Rob

0 Likes
1 Solution
AnkitaS_51
Employee
Employee
100 likes received 50 likes received 25 likes received
0 Likes
2 Replies
AnkitaS_51
Employee
Employee
100 likes received 50 likes received 25 likes received
0 Likes
Anonymous
Not applicable

Thanks for the link to the other thread.  I believe that discussion is a bit different, but perhaps this discussion would be best continued there.