Bootloader does not appear to be honoring checksum exclude section
In the PSoC Creator workspace I have two projects. 1. The bootloader 2. The Application. The bootloader has the ‘Bootloader’ component on the schematic and the Application has the Bootloadable component. The Bootloadable component declares a Checksum exclude section size of 2048 bytes. This 2048 is intended to cover the 512 bytes of EEPROM data and the 64 bytes of Bootloadable Meta Data. EEPROM Component has 512 bytes reserved but seems to want 1024 bytes. So, I played safe and reserved more than required. I have a custom linker script that locates the EEPROM starting at address 0x3F800 (i.e. 2048 bytes from the top of flash).
The Bootloader is implemented over UART.
To facilitate debugging and to simplify the problem. I have initialized the EEPROM contents to zeros. The EEPROM calls have been replaced e.g. EEPROM_Write replaced by MyEEPROM_Write. MyEEPROM_Write does nothing i.e. it’s empty. The MyEEPROM_Read calls have been modified to return sensible default values rather than values from the EEPROM.
When I compile the code and download it to the device, I read it back using the Cypress Programmer tool. If I read and analyze the hex file uploaded from the device, I see that the exclude size is correctly stored in the meta data. I also see that the checksum (0xDE) is stored correctly.
When I download the project firmware, the application fails to execute. If I try to use a host app to download the cyad file, then it downloads but fails on an invalid checksum. It consistently fails every time I try to download.
I added debug code to the bootloader to interrogate the checksums. The meta data checksum is as expected (0xDE). The calculated checksum is different (0xAF).
Using the hex file read from the Cypress Programmer, if I calculate the checksum from the start of the application to the very end of flash memory then I get 0xAF. i.e. this is the same value that the firmware is calculating in Bootloader_ValidateBootloadable. To eliminate coincidence, I modified the firmware to force different checksums. It seems that the calculated checksum always calculates from the start of the application to the top of flash and does not honor the exclude section. In every case, if I calculate the checksum from the start of the application to the beginning of the exclude section, my checksum matches the value stored by the Bootloader Meta Data.
I modified the Bootloader_ValidateBootloadable source code to subtract 2048 bytes from the ‘end’ and now the bootload validation passes.
The meta data contains a length value of 0x3E700 which maybe in error since the bootloadable app starts at 0x6400 and the 0x3E700 would take it past the EEPROM section to the top flash address.
Is this a bug in the library or am I missing a step? How do I fix this? Modifying the generated source code to subtract the 2040 bytes is not a good solution.
PSoC Creator 4.2
Bootloader/Bootloadable Component 1.60
EEPROM Component 2.20