This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Using NVS with Bluetooth Enabled

SDK: NCS 1.8.0

Based on: Peripheral LBS example

Central: Mobile (iPhone)

Peripheral: nRF52832

Hi,

I am attempting to integrate NVS within my custom application based on the example mentioned above and it seems as the data is not being written correctly in flash. I followed the example found within the ncs SDK, on how to initialize NVS.

When data is written to flash using "nvs_write", there is no error returned and the correct number of bytes is returned but when attempting to read back the data at a later time, "nvs_read" returns an error code of "-2 ENOENT". 

After stepping through the code it seems as "nvs_init()" is called twice, once by "bt_enable()" and again within my custom initialization of nvs. I have attached a screenshot of the UART output and what's interesting is that both instances of nvs return the same "alloc wra" and "data wra" values. Is this expected?

Here is my custom initialization of NVS below:

Are there additional settings that need to be modified when using Bluetooth with NVS for user data?

Any advice would be appreciated!

Thank you,

Tom

Parents
  • Hi Tom, 

    I haven't managed to reproduce the same error that you got. But I did see an issue that when using NVS with Bluetooth, sometimes the data is not stored even after nvs_write() was successful. The solution was to define my own "userstorage" partition so that it's not related to the bluetooth storage at the default "storage" partition. (check my nrf52dk_nrf52832.overlay file)


    I attached my example here, could you please test.  

    There is a discussion here that might be related to your issue. 

    peripheral_lbs_nvs.zip

Reply
  • Hi Tom, 

    I haven't managed to reproduce the same error that you got. But I did see an issue that when using NVS with Bluetooth, sometimes the data is not stored even after nvs_write() was successful. The solution was to define my own "userstorage" partition so that it's not related to the bluetooth storage at the default "storage" partition. (check my nrf52dk_nrf52832.overlay file)


    I attached my example here, could you please test.  

    There is a discussion here that might be related to your issue. 

    peripheral_lbs_nvs.zip

Children
No Data
Related