Storing to flash storage

Hi, 

We're working on the nrf52833 chipset and were wondering how to add more data to the flash storage. I've traced the calls of load_settings() in the main and where fcb_init() is called in bt_enable() but it seems to just know where flash data is. There's no struct or file that actually has data that I can manipulate / add to. Ideally, we would like to be able to see where the bluetooth configuration data is in the flash. Any pointers to the right direction or advice would be appreciated.

Thanks,

Spencer

Parents Reply
  • Hi Spencer

    SpencerEtn said:
    I thought I posted an update but I guess it didn't post. I figured out the error with the undefined references were because the nvs.h file was not linked to any nvs.c file in the zephyr library.

    This seems wierd.

    Are you able to build and run the NVS sample I linked to earlier?
    Cause if you are Zephyr should be able to handle the NVS functionality.

    I am able to build this sample, without modifying any libraries.

    Regards,
    Sigurd Hellesvik

Children
  • Hi Sigurd,

    Sorry for the late response; I was out of office, but I was able to build and use the NVS sample you linked after linking the nvs files to my project. Going forward with nvs and flash, my colleagues have some additional queries related to them.

    We are able to read and write bytes using the nvs functions, but we have noticed that after bluetooth provisioning the same area we are writing to with the nvs functions are being overwritten by the configuration data. If we direct the nvs writes to a particular location where the ble stack is not writing to, will this be fine? (creating a new flash area in linker script). 

    We had compiled a couple questions regarding the flash storage and nvs functionality. If this is too long for this thread or would be better suited in a new thread please feel free to let me know!

         1. How do we control the address to be written and what is the recommended location to be used for nvs functions?

    We see the storage variable being used in the flash_area_offset() function so we are thinking we need to add variable in the linker script similarly to that, but we are not too sure.

         2. After provisioning and sending control commands such as like the on/off generic light, etc. we have observed that data is continuously being written to flash one after another. We are wondering if it is really necessary to write this sort of information to flash?

    We observed in the gatt.c; an example function is db_hash_store() that will write to the flash memory. 

         3. Similarly related to the second question, the RPL (replay messages) related information is being written to memory. Can we allocate some max memory for replay messages and what is the default value for size of these messages?

    We found that in settings.c the bt_mesh_rpl_pending_store() function was writing RPL stuff but we didn't necessarily want to store so much information in the flash related to replay messages.

    Best Regards,

    Spencer

  • Hi Spencer,

    NVS and Bluetooth Low Energy (LE) Settings will use the same Storage area when handled by the device tree.

    The other alternative to managing flash is using the Partition Manager.

    For discussion on how to use NVS and  Bluetooth LE Settings at the same time, along with a solution, see This post.

    Does the post I linked have the solution you needed?

    I will answer question 2 and 3 in another answer shortly.

    Regards,
    Sigurd Hellesvik

Related