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

keeping data in flash on fixed address

Hi,

with the pstorage library, is it possible to store data at a specific flash address? The background of the question is that I would like to store data in flash, and be able to access it again after a power cycle, e.g. when the batteries need to be replaced.

Also, I would like to keep the data even if a software update is done via the DFU boot loader.

How is that done?

Wim

Parents
  • Hi Wim

    This thread tells something about where data is actually stored in flash when using pstorage. Another option is to use pstorage in RAW mode where you write directly to addresses in the memory space.

    If you use bootloader, you need to configure the bootloader so it does not overwrite any application data stored in flash. The application data space is reserved with modifying the constant DFU_APP_DATA_RESERVED in dfu.types.h

  • Hello Stefan,

    apparently by default de DFU_APP_DATA_RESERVED is 0x0000 in the SDK, in version 7.2.0 at least, as I am using that one. Do I have to set this value to as much as memory I need in bytes? I did not fully understand why, in the thread you mentioned above, this value had to be set to 0x800 rather than 0x400. Was that because he was using the device manager? I do not use the device manager, and 1 page is enough, so for me setting DFU_APP_DATA_RESERVED to 0x400 would be fine, right?

    And about the actual data access: if I do a pstorage_block_identifier_get, do I get a pointer to the 'next available' data? In other words, if I only do this once in my application, and do this again, will I access the same physical flash space? And this it start reservation at the bottom of the reserved memory, so at 0x3C000-0x400 and then upwards, or downwards starting from 0x3BFFF?

Reply
  • Hello Stefan,

    apparently by default de DFU_APP_DATA_RESERVED is 0x0000 in the SDK, in version 7.2.0 at least, as I am using that one. Do I have to set this value to as much as memory I need in bytes? I did not fully understand why, in the thread you mentioned above, this value had to be set to 0x800 rather than 0x400. Was that because he was using the device manager? I do not use the device manager, and 1 page is enough, so for me setting DFU_APP_DATA_RESERVED to 0x400 would be fine, right?

    And about the actual data access: if I do a pstorage_block_identifier_get, do I get a pointer to the 'next available' data? In other words, if I only do this once in my application, and do this again, will I access the same physical flash space? And this it start reservation at the bottom of the reserved memory, so at 0x3C000-0x400 and then upwards, or downwards starting from 0x3BFFF?

Children
No Data
Related