Concurrent usage of NV and settings on the same partition

Hi,

Is it safe to use NVS and Settings on the same partition at the same time (the same application, BLE is running, NVS can be called concurrently to eg. pairing process)?

Assumptions:

  • Code that is using NVS performs nvs_init() on the settings_storage partition
  • Code that is using NVS is not exceeding  NVS_NAMECNT_ID  id

Dominik,

Parents
  • Hello Dominik,

    I'll take a look at this today/Monday

    Best regards,

    Simon

  • Some updates:

    Initializing and storing NV on the same partition, after settings have been loaded is causing sittuation where BLE/Settings is not storing new boundings in flash anymore. Also settings_save is not helping here.

    Let's change a question here to following one: is this usecase possible from architectural point of view or settings and NV access should use separate partitions.

  • I asked internally about this, if the bonding and custom data can use the same partition.

    It is possible to use the same NVS instance for custom data. I can refer you to zephyr/subsys/settings/include/settings/settings_nvs.h. The backend is using id starting from NVS_NAMECNT_ID (0x8000) till the maximum nvs' id value. All Id's below 0x8000 are available for custom usage currently.

    Best regards,

    Simon

  • Hi,

    Following settings_nvs.h hint:

    After reusing code from settings_backend_init() and settings_nvs_backend_init() I am still meeting the issue with BT settings. I can see that new data is being stored in flash (by dumping the chip) both for NVS and settings, but unfortunately bt_foreach_bond() does not find any boundings after reboot. Hovewer I can see that bt keys have found some keys in flash:

    On boot:

     Load settings
    [00:00:11.085,601] <dbg> bt_settings: bt_settings_decode_key: Decoded 10a51d0830f80 as 10:A5:1D:08:30:F8 (public)
    [00:00:11.112,213] <dbg> bt_gatt: ccc_set: Read CCC: handle 0x0004 value 0x0002
    [00:00:11.135,528] <dbg> bt_gatt: ccc_set: Read CCC: handle 0x0013 value 0x0001
    [00:00:11.158,874] <dbg> bt_gatt: ccc_set: Read CCC: handle 0x0024 value 0x0001
    [00:00:11.182,189] <dbg> bt_gatt: ccc_set: Read CCC: handle 0x0028 value 0x0001
    [00:00:11.205,535] <dbg> bt_gatt: ccc_set: Read CCC: handle 0x002c value 0x0001
    [00:00:11.228,881] <dbg> bt_gatt: ccc_load: Restoring CCC: handle 0x0004 value 0x0002
    [00:00:11.252,807] <dbg> bt_gatt: ccc_load: Restoring CCC: handle 0x0013 value 0x0001
    [00:00:11.276,733] <dbg> bt_gatt: ccc_load: Restoring CCC: handle 0x0024 value 0x0001
    [00:00:11.300,628] <dbg> bt_gatt: ccc_load: Restoring CCC: handle 0x0028 value 0x0001
    [00:00:11.324,523] <dbg> bt_gatt: ccc_load: Restoring CCC: handle 0x002c value 0x0001
    [00:00:11.348,541] <dbg> bt_gatt: ccc_set: Restored CCC for id:0 addr:10:A5:1D:08:30:F8 (public)
    [00:00:11.373,413] <dbg> settings: settings_call_set_handler: set-value OK. key: bt/ccc/10a51d0830f80
    [00:00:11.399,353] <dbg> bt_settings: bt_settings_decode_key: Decoded 10a51d0830f80 as 10:A5:1D:08:30:F8 (public)
    [00:00:11.425,903] <dbg> bt_gatt: find_sc_cfg: id: 0, addr: 10:A5:1D:08:30:F8 (public)
    [00:00:11.449,981] <dbg> bt_gatt: find_sc_cfg: id: 0, addr: 00:00:00:00:00:00 (public)
    [00:00:11.474,182] <dbg> bt_gatt: sc_set: Read SC: len 4
    [00:00:11.495,544] <dbg> bt_gatt: sc_set: Restored SC for 10:A5:1D:08:30:F8 (public)
    [00:00:11.519,317] <dbg> settings: settings_call_set_handler: set-value OK. key: bt/sc/10a51d0830f80
    [00:00:11.545,288] <dbg> bt_gatt: db_hash_set: Stored Hash:
                                      89 fc 9b 50 41 66 fc 4d  bb 6d 6c b2 3c 2c d7 e2 |...PAf.M .ml.<,..
    [00:00:11.576,690] <dbg> settings: settings_call_set_handler: set-value OK. key: bt/hash

    As a result of foreach command (I have added extra log there):

    [00:00:12.751,403] <dbg> bt_keys: bt_foreach_bond: bonded (nil) 0 id 0

            struct bt_keys *keys = &key_pool[i];
            BT_DBG("bonded %p %d id %d",keys->keys,i, keys->id);
    Can you please help me to identify why restored keys are not found by foreach command?

    Dominik,

  • Could you upload a minimal reproducible sample? Then I can continue to investigate this on my side

    Best regards,

    Simon

Reply Children
No Data
Related