1 Reply Latest reply on Sep 20, 2013 4:57 AM by resh

    Separate Flash area to store config data in Bootloadable project




      Here is an example project to store config data in flash that is separate from the application data.


      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 since bootloadable projects do not allow absolute address placement. So, you have to write to this flash location with hardcoded defines in the application project for these flash row numbers. 

      There are few points to consider:
      1.) Your bootloader project code region should not encroach in to the user area region. So, you have to freeze your bootloader project hex, get its code size, give some headroom of 1 flash row just in case, and then start the user flash area.

      2.) The other thing is that since you are doing a backdoor write to the user flash area which the linker has not allocated - so you protect the bootloader from being written accidentally ever by protecting its flash region (W setting). And also ensure that the application code is never updated by ensuring the flash write functions have a check on the flash row range such that it is always below the application start address.    






      An example is given below.    



      1) First build the bootloader project.Assume it takes 6414 bytes. 6414/256 = 26 rows.
           So 0x1A is the last bootloader row.    



      2) Give a margin of one row. So the configuration  data in flash can start from 0X1C.
          Give macros in bootloadable to write to specific rows 1C, 1D and 1E.    



      3) Place the bootloadable at 0x2000(row# 0x20) in flash using 'Manual application image placement'.    





      The flash content can be read back using programmer, after bootloading to verify.