PSoC5LP: Is it possible to read code checksum during runtime?

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

cross mob
KyTr_1955226
Level 6
Level 6
250 sign-ins 10 likes given 50 solutions authored

Hi there,

I have a question regarding the code checksum on a PSoC5LP part (specifically CY8C5667AXI-LP040).

I have a request on a project to provide the checksum of code over a serial interface.  Is there a known good way during runtime to either read or calculate the checksum of the entire codespace of the PSoC?  Perhaps even an API function I'm not aware of?

Thanks for the help!

0 Likes
1 Solution

Hello KyTr.

If 5LP uses a bootloader, the bootloader validates the bootloadable via a checksum (CRC), AN73854 shows this in a flow chart.  If checksum's don't match, bootloader will not jump to bootloadable.  The checksum (or its 2's compliment) is stored in 5LP FLASH memory in the top row, see AN73854 section 6.4 Recovering from Failures.

The bootloader (see Bootloader Component datasheet) has an API for validating the checksum:
cystatus Bootloader_ValidateBootloadable (uint8 appId)
You might be able to clone this function (or call it from within bootloadable).

If target 5LP doesn't have a bootloader, clone the API or develop your own checksum calculator and compare against FLASH checksum.

From the API, it should be possible to figure out exactly where in FLASH the checksum is stored.

Hope this helps.

edit: bootloader has an API for getting the checksum from Metadata area of FLASH.
uint32 Bootloader_GetMetadata (uint8 field, uint8 appId)
So, you could experiment by adding a bootloader and display the checksum.  Then use Debugger to look at FLASH to find the matching checksum address.  You could try to interpret the 'memory map' from the build and find the address for the checksum.

Lots of good info in Bootloader Component datasheet.

edit: Lots of checksum utilities can be found in bootloader utility folder:
...\PSoC Creator\cybootloaderutils
cybtldr_command, cybtldr_api, cybtldr_parse, search for the word 'checksum'.

View solution in original post

0 Likes
8 Replies