Using Variables Stored in Flash in PSoC® 3 and PSoC 5 Bootloadable Projects - KBA82443 | Cypress Semiconductor
Support & Community
Using Variables Stored in Flash in PSoC® 3 and PSoC 5 Bootloadable Projects - KBA82443
When I change the value of variables stored in flash in a bootloadable project, the PSoC® gets stuck in the bootloader code on subsequent power-up or RESET. What is the reason for this?
By default, variables declared in a PSoC Creator™ project are stored in SRAM. However,few variables whose values need to be saved even if the supply to PSoC is removed are stored in flash. Any read or write operations in flash are done only row-wise.
PSoC Creator provides a number of APIs to alter a particular section of flash memory when the code is running. Refer to Help > Documentation > System Reference > System Reference Guide for a definition of these APIs.
When these APIs are used in a bootloadable project, there is a potential problem. Every time PSoC 3, PSoC 5, or PSoC 5LPboots up, the bootloader code checks the checksum of the whole bootloadable code and if the checksum does not match the already storedvalue corresponding to the original bootloadable project, it does not load the modified bootloadable project.
When these APIs are used to change the value of flash variables that are part of bootloadable code, the checksum fails the next time PSoC 3, PSoC 5, or PSoC 5LP gets through a RESET. This is because the bootloadable project’s checksum value,which is stored in the metadata section of the Bootloadable session, will not be modified when the flash content of the bootloadable project is modified.
To work around this, you can use the new feature available in PSoC Creator 2.1. In the bootloader project, double-click on the bootloader component configuration window and select the check box called ‘Fast Application Verification’.When this parameter is enabled, then bootloader calculates flash checksum only once when the new bootloadable code (application code) is downloaded. Then, one nonvolatile flag is set to indicate that the checksum matches and the bootloader does not compute the checksum on furtherResets. This gives the application code the freedom to change the values of its flash variables.