Report
2 years, 7 months ago.

Read/Write settings from/to the file system/flash in nrf52_dk?

What would be the best way to read and write to the flash in the nrf52_dk? I would like to be able to store some configuration values once the device is configured with some pre-defined settings and read those settings back when the device resets or is powered on?

Thanks, Yogesh

Question relating to:

The nRF52 Development Kit is a single-board development kit for Bluetooth Smart, ANT and 2.4GHz proprietary applications using the nRF52 Series SoC. This kit supports both development for nRF52832 SoCs.
Comment on this question

2 Answers

3 months, 1 week ago.

If you initialize BLE using mbed code like this

BLE &ble = BLE::Instance(); ble.onEventsToProcess(scheduleBleEventsProcessing); ble.init(bleInitComplete);

I'm calling fds_init() inside of bleInitComplete() however nRF52 hangs within few ms after fds_init. I susepect this has something to do with memory regions. I have in my linker script following:

/* Linker script to configure memory regions. */

/* Default to no softdevice */

  1. if !defined(MBED_APP_START)
  2. define MBED_APP_START 0x0
  3. endif
  1. if !defined(MBED_APP_SIZE)
  2. define MBED_APP_SIZE 0x80000
  3. endif

/* If softdevice is present, set aside space for it */

  1. if !defined(MBED_RAM_START)
  2. if defined(SOFTDEVICE_PRESENT)
  3. define MBED_RAM_START 0x200031D0
  4. define MBED_RAM_SIZE 0xCE30
  5. else
  6. define MBED_RAM_START 0x20000000
  7. define MBED_RAM_SIZE 0x10000
  8. endif
  9. endif
  1. define MBED_RAM0_START MBED_RAM_START
  2. define MBED_RAM0_SIZE 0xE0
  3. define MBED_RAM1_START (MBED_RAM_START + MBED_RAM0_SIZE)
  4. define MBED_RAM1_SIZE (MBED_RAM_SIZE - MBED_RAM0_SIZE)

MEMORY { FLASH (rx) : ORIGIN = MBED_APP_START, LENGTH = MBED_APP_SIZE RAM_NVIC (rwx) : ORIGIN = MBED_RAM0_START, LENGTH = MBED_RAM0_SIZE RAM (rwx) : ORIGIN = MBED_RAM1_START, LENGTH = MBED_RAM1_SIZE }

Any suggestion how to setup better ? Thanks Peter

2 years, 7 months ago.

Hi. My recommendation is to use flash data storage http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v11.0.0%2Flib_fds.html&cp=4_0_3_3_30

FDS is already in usage by peer manager (nordic's code cover such modules like: security_manger...). initialization : https://github.com/ARMmbed/mbed-os/blob/master/targets/TARGET_NORDIC/TARGET_NRF5/sdk/ble/peer_manager/peer_data_storage.c#L339

Thanks Andrzej for taking the time to respond. FDS is exactly what I was looking for I think, and works for my requirements. I have some follow up questions.

1) I see you mention that the FDS is being used by the peer manager, does that mean I shouldn't be initializing the FDS module in my application, since it has already been initialized?

2) Also the FS_REGISTER_CFG requires the number of page size and priority, not sure what valid values to set. I would probably store as much as maximum of 50 bytes worth of data. Also what would be an ideal priority for an application that is just using for storing and updating configuration values?

3) Also I am guessing erasing and writing would cause flash wear and in turn effects the overall endurance of the flash, does this API handle leveling the wear of the flash? I was wondering how best to ensure that data writes and erases so wear is minimal on the flash.

Thanks, Yogesh

posted by Yogesh k 19 Dec 2016

4) I forgot to add another question. Since I am using mbed api's for my development, I was wondering if there is something similar to LocalFileSystem API that I can use to write and read from a file, instead of directly using the FDS Api's?

posted by Yogesh k 19 Dec 2016

1) if you initialize BLE - do not initialize FDS second time 2) if you using fds - it use 3 pages by default definition - for app purpose low priority is sufficient (default 0xFF) 3) 4) no

posted by Andrzej Puzdrowski 21 Dec 2016

Hey Andrzej,

Thanks a lot for helping me out with the FDS API's. I am facing this issue with the linker on the online compiler using the FDS Api's. Do you have any suggestions how to resolve this error or should I be trying to compile this offline using MBED CLI and reference the right libraries containing the FDS related api's? Here is the link to the issue I had posted.

https://developer.mbed.org/questions/76765/Linker-error-when-using-the-Nordics-Flas/

Thanks, Yogesh

posted by Yogesh k 27 Jan 2017

You need to log in to post a question