Checksum Description

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

cross mob
Anonymous
Not applicable

I'm working on creating a custom bootloader host program. I need to compute the checksums of the .cyacd file and to verify against the checksum calculated by the PSoC. I've seen some mixed descriptions and implementations in calculating this checksum and wonder if anyone could help.

To help guide the answers here is a list of what I'm confused about and what I understand.

   

1. The .cyacd is in ASCII and has to be parsed into hex values. I've done this in my code using help from btldrutils.

   

2. Format of the header in the .cyacd file is [4-byte silicon ID][1-byte Silicon Rev][1-byte checksum type]

   

Format of row in the .cyacd file is [1-byte array ID][2-byte row number][2-byte data length][64 data bytes][1 byte checksum]

   

3. The start of the program row is marked by a ':' and the end of the row is marked by '..'.

   

4. I'm using the basic summation (type 00 in header) from the data sheet this adds up every byte sent (besides the checksum) and takes the 2's complement of this value. Note- App note AN86526 attaches example code to run a bootloader host on a PSoC kit board and in the code the checksum for each row is calculated without taking the 2's complement.

   

 

   

My questions revolve around 4.

   

1. Is the header included in the checksum calculation?

   

2. Are the semi colons and periods part of this calculation?

   

3. Is the checksum calculated for each row or is it a running checksum for the entire file?

   

4. If its a running checksum do you take the 2's complement each row and then add it to the continuous checksum or do you take the 2's complement to verify that row and then add the number before you took the 2's complement to the continuous checksum?

   

5. Do you just add everything up and check the data after each row?

   

 

   

Any help or directions toward a file that would help me out would be great.

0 Likes
1 Solution
Anonymous
Not applicable

Hi Brendan,

   

The header and semicolon is not included as part of the checksum computation. The header is only used for validating the properties of the device (whether we are trying to bootload to the correct device, done using Silicon ID match) and is done using CyBtldr_ParseHeader.

   

Now, in the header itself - we specify the checksum type which indicates the type of checksum used in the packets sent between the bootloader and the bootloader host during the bootloading operation. If this byte is 0, the checksum is a basic summation. If it is 1, the checksum is CRC-16.

   

Please refer to the implementation of CyBtldr_ComputeChecksum in cybtldr_commad.c file. Simple SUM checksum is implemented in two's complement form: (you can find "return (1 + ~sum);").

   

Also, we validate if each row is correctly programmed. Hence we have a row checksum and check if the checksum received from bootloader matches the expected row checksum stored in cyacd file. If TRUE, then we conclude that the row is correctly programmed.

View solution in original post

0 Likes
15 Replies