Codespace Checksum

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

cross mob
Anonymous
Not applicable

Hi all,

   

I want to generate a checksum of my codespace. Is there an API I can call?

   

Thanks,

   

Rick

0 Likes
9 Replies
Anonymous
Not applicable

BTW, this is for psoc 4 with 16 KB of memory.

0 Likes
Anonymous
Not applicable

I'm assuming you mean a checksum of the binary op codes, If so, then one method that would be pretty easy, is to write a script to create a checksum based on the .hex file output of the compiler. If you are wanting to use it in code however, then you might have to write a checksum yourself that reads the flash and computes the checksum.

0 Likes
Anonymous
Not applicable

Hi e.pratt,

   

I wrote code to calculate the checksum from 0x0000 to 0x3FFF, for 16 KB memory, but it doesn't match up to the checksum in PSoc Programmer software. What method does the PSoC Programmer use?

   

Thanks,

   

Rick

0 Likes
Anonymous
Not applicable

Hello dv89, I'm not sure what the PSoC Programmer does. I imagine it does a checksum on the entire flash hex file on the PC, and then loads that into the checksum location when it programs the flash.

   

According to this forum post, the checksum is in an Application Note 2026; After googling for the AN2026 document, all I found was the ISSP document here.

   

It seems to mention reading the entire flash hex file, and then computing the checksum before writing it to the chip when programming.

   

I would guess it is using a simple accumulation checksum. Add all bytes together, then keep only the lowest number of bytes that fit the size of checksum you are wanting to keep. Now, this value we will call the SUM. Using some math, we calculate what number when added to the SUM will give us all zeroes. CHECKSUM + SUM = 0. Solve for the CHECKSUM, and that will be the value that the programmer calculates to put into the flash storage (I believe).

   

Here is another document containing useful information about the programmer: http://www.cypress.com/file/44411/download

0 Likes
Anonymous
Not applicable

So i have this code in my project:

   

uint8 * MyPointer = (uint8*) 0x0000;   // Initialize to point to address 0x0000

   

for(i=0x0000; i < 0x3FFF; i++)

   

      CheckSum+= *(MyPointer++);

   

 

   

Why when i read the contents of the flash memory the checksum does not match to that of the PSoC programmer? The code above is to add up all the bytes in my 16 KB of flash memory but it returns invalid data at certain parts of the memory. For exampe if i read address 0x0005, the data at that location is 0x11 but when the pointer returns the value of that address it gives me a 0x93. What is going on here? Am i pointing to somewhere else?

   

Thanks,

   

Rick

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Probably because address 0x0005 is ram and not code.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

So what would be the correct way to calculate the flash checksum?

   

Rick

   

0 Likes
Anonymous
Not applicable

This NXP page might have useful information on it, otherwise searching for ARM Cortex M0 related checksum calculations for HEX/binary images would be useful.

   

https://community.nxp.com/thread/389046

0 Likes
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hi ,

Please have a look at this.

http://www.cypress.com/documentation/application-notes/an89056-psoc-4-iec-60730-class-b-and-iec-6150...

This contains  describes the PSoC® 4 IEC 60730 Class B and IEC 61508 safety integrity level (SIL) Safety Software Library and includes example projects with self-check routines to help ensure reliable and safe operation. 

Best Regards,
VSRS

0 Likes