This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

how to preserve app data??

Hi nordics!

I want to using app_data for preserving data.

For that.

First, I change the value DFU_APP_DATA_RESERVED to "0x0400"

Second, I change the memory start address and size of the application.

image description

Finally, I uploaded the bootloader to the device, and I uploaded the application by using DFU of nRFToolbox application.

But after I store the data(32byte) to the p_storage reign and uploaded the application by using DFU again, I can not find the app_data.

Is there any way or example for using app data??

Thanks.

  • Hi

    I think that examining the pstorage_platform.h file will tell you where the application data is stored in flash. Generally, the rules are like this:

    • When there is no bootloader present on the device, the application data is stored at the top of the flash. The 256kB flash has range of 0x00000000 - 0x00040000 in the memory map. The last page (addresses 0x3FC00 - 0x3FFFF) is the pstorage swap page, and application data is on two pages below that in the memory map (addresses 0x3F400 - 0x3FBFF), if there are two pages reserved for the application data, see the pstorage_platform.h defines, i.e. the PSTORAGE_MAX_APPLICATIONS constant. In the case where there is no bootloader and value of PSTORAGE_MAX_APPLICATIONS is 2, then the application data is stored at location 0x3F400 and you can read out the memory content of the two pages from the command prompt with:

        nrfjprog --memrd 0x0003F400 --n 2048
      
    • If the device manager is used and is initialized, it will use one flash page. If you initialize the the device manager before calling pstorage_register for your application data, device manager will use the first page (starting with address 0x3F400) and the application data will be stored in the second page (starting with address 0x3F800).

    • When there is a bootloader present, it is located on the top of flash and the application data is below the bootloader in the memory map, as shown here. For the bootloader in SDK 7.1.0, it's start address is 0x3C000, but to check the location, you can read out the bootloader start address from UICR by with:

        nrfjprog --memrd 0x10001014 --n 4
      

    If the start address of the bootloader is 0x3C000, then the swap page start address is at 0x3C000-0x400=0x3BC00 and the two pages of application data is located from 0x3BC00-0x800=0x3B400 to 0x3BC00, so you can read out the memory contents of the two application data pages with:

    nrfjprog --memrd 0x0003B400 --n 2048
    

    In your specific case where you apparently have only one page reserved for application data and have the bootloader present, then your application data can be read out with:

    nrfjprog --memrd 0x0003F800 --n 1024
    

    So in order not to override the application data when you upload the applicaton via the bootloader, I think you need to put

    #define DFU_APP_DATA_RESERVED           0x0800
    

    in dfu_types.h file in order not to override your application data

Related