Explanations about flash_fstorage example.

Hello

I have some questions about flash_fstorage example.

NRF_FSTORAGE_DEF(nrf_fstorage_t fstorage) =
{
    .evt_handler = fstorage_evt_handler,
    .start_addr = 0x3e000,
    .end_addr   = 0x3ffff,
};

After reading the macro, it seems that fstorage will be located in .fs_data flash zone.

start_addr is set to 0x3e000. Where does this address come from? Is it an absolute value in device's flash? Is it relative to .fs_data start address?

Thanks

Julien

  • Hi,

    These are the example values that need to be set manually depending on a specific need. You can read more in flash storage example documentation.

    Best regards,
    Dejan

  • Hi Dejan.

    Documentation answers none of my questions.

    How can I know that 0x3e000 belongs to fs_data ? ( If what I understood is right )

    Julien

  • The diagram on this page infocenter.nordicsemi.com/.../lib_fstorage.html

    show that FDS area is located after application code.

    Please, for my comprehension, could you answer the following questions : 

    - is fstorage data located in .fs_data flash zone?

    - If my app code is growing (new version), fstorage might be overwritten. Right ?

    - In the example, there's a function called uint32_t nrf5_flash_end_addr_get(). This function is " Helper function to obtain the

    last address on the last page of the on-chip flash that can be used to write user data.". The usage is clear to me but

    what's the way to get the first address on the first page available to write data?.

    Thanks

    Julien

  • Hi Julien,

    julienD said:
    is fstorage data located in .fs_data flash zone?

    No. It is not a part of fstorage.

    julienD said:
    If my app code is growing (new version), fstorage might be overwritten. Right ?

    If you want to have an option of new application  version you should have a bootloader which is located on top of the flash. If you have MBR and Softdevice, then these two would go to the bottom of the flash. There is a free space between bootloader and softdevice controller which is used to put application with its data. If you have FDS, it would be located just below the bootloader.
    If your application is too big it will have a potential to exceed its limits and could overwrite either the application data or bootloader. You could also potentially run out of the flash space.

    julienD said:

    In the example, there's a function called uint32_t nrf5_flash_end_addr_get(). This function is " Helper function to obtain the

    last address on the last page of the on-chip flash that can be used to write user data.". The usage is clear to me but

    what's the way to get the first address on the first page available to write data?

    Function nrf5_flash_end_addr_get() gets the last available address for writing to the flash. This address is the bottom address of the bootloader. This value can also be obtained by looking at the address (base address plus offset) of the register UICR.NRFFW[0] . You can read more about UICR registers in the product documentation. For the value of flash starting address, it is up to the user to ensure that different instances operate on non-overlapping flash memory regions. From the hex file of your application you can determine (with drag&drop to the nRF for Desktop Programmer application) the value for  the starting address of your application.

    In the documentation, you can read more about flash storage and bootloader memory layout.

    Best regards,
    Dejan

  • OK, thanks for your answer.

    Best regards

    Julien

Related