Separate Flash Area for Storing Configuration Data in a Bootloadable Project - KBA89254 | Cypress Semiconductor
Support & Community
Separate Flash Area for Storing Configuration Data in a Bootloadable Project - KBA89254
If you need to provide an area in flash for configuration data, but you do not want changes to this area of flash to require recalculating the application checksum of the bootloadable project, how can you reserve a section of flash that does not get included in the application checksum calculation?
You have to use the Manual application image placement option in the bootloadable component, and give an address that starts at "End Address of Bootloader project + Required User code area in flash" rounded off to the nearest 256 byte address. With this method, you can use the flash region between the bootloader project and the application project for storing the user data.
This user array in flash cannot be assigned an absolute address because bootloadable projects do not allow absolute address placement. You have to write to this flash location with hardcoded defines in the application project for these flash row numbers.
There are a few points to consider:
- Your bootloader project code region should not encroach on the user area region. You have to freeze your bootloader project hex, get its code size, give a headroom of one flash row just in case, and then start the user flash area.
- Because you are doing a backdoor write to the user flash area (which the linker has not allocated), you must protect the bootloader from being written on accidentally by protecting its flash region (W setting). You also must ensure that the application code is never updated by ensuring that the flash write functions have a check on the flash row range in the code such that the highest flash row is always below the application start address.
An example is given below.
- First build the bootloader project. Assume it takes 6414 bytes; 6414/256 = 26 rows. So 0x1A is the last bootloader row.
- Skip one row. Now the configuration data in flash can start from 0X1C. Use macros in the bootloadable project for flash rows 1C, 1D, and 1E. Write to these specific rows using the flash write API CyWriteRowData( arrayId, rowAddress, &Data) in the bootloadable project.
- Place the bootloadable project at 0x2000(row# 0x20) in flash using Manual application image placement.
The flash content can be read back using PSoC® Programmer™, after bootloading to verify the configuration data.