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

What is available on the nRF52840 for persistent storage (survives reboot / power cycle)?

I understand only the flash memory that stores the boot image is available.  We need ca 32 Kb of persistent storage.  How can that flash memory also be used for additional persistent storage?Is there software code to demonstrate read and writing to this persistent storage?

Parents
  • Hi,

    You can use the Flash Storage library to read, write, and erase data in persistent flash storage. If you want to see how this library can be used, you can take a look at the Flash Storage example.

    Best regards,

    Marte

  • Appreciate your help. I do have a few questions.  Look at this log where Nordic's nrfjprog command is used to program an application for an nRF52840:

    $ nrfjprog -f nrf52 --sectorerase --program hello-world.hex
    Parsing hex file.
    Erasing page at address 0x0.
    Erasing page at address 0x1000.
    Erasing page at address 0x2000.
    Erasing page at address 0x3000.
    Erasing page at address 0x4000.
    Erasing page at address 0x5000.
    Erasing page at address 0x6000.
    Erasing page at address 0x7000.
    Erasing page at address 0x8000.
    Erasing page at address 0x9000.
    Erasing page at address 0xA000.
    Erasing page at address 0xB000.
    Erasing page at address 0xC000.
    Applying system reset.
    Checking that the area to write is not protected.
    Programming device.
    nrfjprog -f nrf52 --reset
    Applying system reset.
    Run.
    $

    Please confirm nrfjprog programmed the flash up to address 0xD000 and no further.

    From this URL, it appears the flash on the nRF52840 is 523Kb, with a top address of 0x7FFFF, and that the application is programmed starting at 0x0000.  It also appears UICR.NRFFW[0] refers to the start address of the boot loader.  But I do not see UICR defined or referenced in the Flash Storage Example you suggested I review to see how to use the Flash Storage Library.

    Again, I appreciate your help here.  It is quite valuable.

  • Hi,

    When using --sectorerase only the targeted non-volative memory pages will be erased, and the hex-file is programmed to the target area, so from your log it should only have programmed up to address 0xD000 as you stated. --sectorerase does not erase UICR. If you want to look at the device memory layout of your programmed device you can use the Programmer app in nRF Connect for Desktop. If you select your device and press "Read", you will be able to see the memory layout.

    The nRF52840 contains 1 MB of flash that can be used for code and data storage. Please take a look at this page for information about the nRF52840s memory. There you will also see the memory layout and memory map.

    Best regards,

    Marte

  • One more question: I built the flash_fstorage example that you recommended, and extend it with a new command to print addresses.  Running it, I get:

    fstorage example:~$ addresses
    NRF_UICR_BASE: 10001000, nrf5_flash_end_addr_get(): 100000
    fstorage example:~$ flasharea print
    begin: 3E000, end: 3FFFF
    fstorage example:~$

    It turns out the 2 addresses shown with "flasharea print" are hard coded in main.c.  But the size of flash, as reported by nrf5_flash_end_addr_get(), is 1 Mb.  And that size is obtained by multiplying two apparent constants, code page size and code size, that are fields of a data structure, NRF_FICR_Type, whose base address appears to be 0x10000000.  How are these fields set up?  I have searched the Nordic SDK, but cannot seem to find where or how they are initialized?  Does this address 0x10000000 always have these values?

    Thanks again for your help here, Marte!

Reply
  • One more question: I built the flash_fstorage example that you recommended, and extend it with a new command to print addresses.  Running it, I get:

    fstorage example:~$ addresses
    NRF_UICR_BASE: 10001000, nrf5_flash_end_addr_get(): 100000
    fstorage example:~$ flasharea print
    begin: 3E000, end: 3FFFF
    fstorage example:~$

    It turns out the 2 addresses shown with "flasharea print" are hard coded in main.c.  But the size of flash, as reported by nrf5_flash_end_addr_get(), is 1 Mb.  And that size is obtained by multiplying two apparent constants, code page size and code size, that are fields of a data structure, NRF_FICR_Type, whose base address appears to be 0x10000000.  How are these fields set up?  I have searched the Nordic SDK, but cannot seem to find where or how they are initialized?  Does this address 0x10000000 always have these values?

    Thanks again for your help here, Marte!

Children
Related