I'm improving the default bootloader to calculate the entire application CRC instead of the 8bit checksum.
I was successful in inserting the CRC into the cyacd file and implementing it in the bootloader.
My problem is that when I insert it into the hex file it is not enough and I get the following error when trying to program the hex file with the PSoC programmer "FAILED! Hex File parsing failure. Checksum of Main Flash does not match Hex Checksum record" I'm assuming that aside from the row checksums there is also a checksum of the entire file.
How is this checksum calculated and where is it stored?
Can you please let us know how you are adding the checksum? Are you manually editing the hexfile to add the checksum?
The checksum of the entire hexfile is stored to ensure that the hexfile is not modified after the build process and that the correct data is programmed into the device. The checksum is stored at 0x90300000. You can refer to page 78 of the PSoC 5LP Device Programming Specifications document for further information regarding the checksum.
I calculated and added the checksum but now I'm getting another error from the PSoC programmer
"Hex File parsing failure. Meta Data is corrupted"
I verified that I calculate the checksum correctly using the original file, but still getting an error when I do it with my modified file.
I just found this post, and according to it, I'm out of luck. there is an additional proprietary checksum that prevents doing what I'm trying to do.
Is there any way to get around this?
I'm assuming you were successful using a CRC for the serial programming in the bootloader process. Due to high speed (2MHz) serial digital signaling it is very good to have a more robust end-to-end verification like a multi-byte CRC you are using. Serial data transfer can be notorious for bit errors. It has been this way since the old days (4-20mA loops, RS-232, RS485, etc).
In the case of the one byte checksum for the .hex file: There is probably no need to change it. As you can see the PSoC Programmer is assuming a specific checksum algorithm. Creating or copying .hex files is very robust nowadays. The .hex checksum is a small, simple and reliable measure to ensure file integrity in the case of a rare copying issue or more importantly in case human-alterations of the file contents.
The .hex checksum is more of a legacy feature back when files were stored on floppy disks which have the possibility of data corruption.
I place my CRC within the flash to be verified by the code on every boot of the MCU, This is because the built-in 8bit checksum in the metadata is not robust enough. The cyacd is used for updates and the hex for production so therefore I need to place the CRC in the hex too. I'm not using the checksum of the hex file, it is just preventing me from programing the file since I did not update it after adding my CRC.
I think I understand now.
Here's an idea: Place the CRC in the EEPROM. The EEPROM data is usually not included in the .hex file. You can perform the boot CRC validation and compare it to the CRC value.