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

Sharing persistent variable-data from application to bootloader

How do I share variable data from my nRF52 application to the bootloader code?
Check the update to this question after first comment by @HungBui

There is some short-data which needs to be shared from the application scope to bootloader across a reset. This data is variable (changes across each reset).

These are my constraints:

  1. Using SoftDevice 5.1 with SDK 14.2
  2. The data is variable across resets so UICR is not suitable for this purpose.
  • (would require ERASEUICR)
  1. The nRF52 application already uses FDS for persistent storage.
  • I could have used this persistent storage to share data with bootloader code but I can't get FDS to work in bootloader scope (nrf_dfu_flash already has a fstorage instance that conflicts with my FDS attempt there).

I guess, the requirement is to be able to reserve a flash page at a well-known-memory-address to which the application can write safely and the bootloader code can simply read it off with C pointers.


Updated question after Hung Bui's comment:
I am trying to use fstorage while FDS is initialized (and therefore nrf_fstorage_sd is being used).

Infocenter fstorage notes suggest that I can use two instances of fstorage initialized on different pages as long as I don't do multi-threaded accesses.

While, this seems feasible in theory, when I try to code a second fstorage instance besides m_fs of FDS, its init (nrf_fstorage_sd.c:init()) does not seem to work. There are a bunch of other globals (like m_flags, m_flash_info, m_fifo) that don't seem to work correctly with this approach.

The init for example, fails to setup p_flash_info in my nrf_fstorage_t instance.

Am I missing something here?

Parents
  • @Nik: The documentation you pointed to is for SDK v11 are you sure it matches with your current SDK ? If you use SDK v14.2 please follow the documentation here.

    I assume you are planning to use fstorage inside bootloader ?

    In the bootloader we used fstorage to store the bootloader setting in nrf_dfu_flash.c. You can follow what we do there to create yours.

    Have you tried to use fstorage in a normal application ?

Reply
  • @Nik: The documentation you pointed to is for SDK v11 are you sure it matches with your current SDK ? If you use SDK v14.2 please follow the documentation here.

    I assume you are planning to use fstorage inside bootloader ?

    In the bootloader we used fstorage to store the bootloader setting in nrf_dfu_flash.c. You can follow what we do there to create yours.

    Have you tried to use fstorage in a normal application ?

Children
No Data
Related