2 Replies Latest reply on Jan 4, 2018 6:43 AM by robert.giumarra_2378941

    Flash Checksum Calculation

    robert.giumarra_2378941

      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