I'm trying to get the settings api working with multiple partitions using little FS. Some of the implementation is specific to Nordic and was hoping to get an example of how to do it with the pm_static.yaml. The fs subsystem is working, but I'm not sure how to configure the settings_storage partition to be used for settings.
I have this in my pm_static.yaml:
littlefs_storage: address: 0x0 region: external_flash size: 0x200000 lvgl_raw_partition: address: 0x200000 region: external_flash size: 0x200000 settings_storage: address: 0x400000 size: 0x100000 region: external_flash
This is how I am trying to initialize it. I know it's incomplete but am having trouble getting to the next steps.
#define STORAGE_PARTITION storage_partition #define STORAGE_PARTITION_ID FIXED_PARTITION_ID(STORAGE_PARTITION) /* struct settings_handler my_conf = { .name = "foo", .h_set = foo_settings_set }; */ static int setting_manager_load_cb(const char *name, size_t len, settings_read_cb read_cb, void *cb_arg) { LOG_DBG("Loading setting %s", name); } SETTINGS_STATIC_HANDLER_DEFINE(settings_app_handler, SETTINGS_PATH, NULL, setting_manager_load_cb, NULL, NULL); void setting_manager_init() { LOG_DBG("Initializing setting manager"); int rc; rc = settings_subsys_init(); if (rc) { LOG_ERR("settings subsys initialization: fail (err %d)", rc); return; } LOG_DBG("Settings subsystem initialized, loading..."); //settings_register(&my_conf); settings_load(); LOG_DBG("Settings loaded"); //foo_val++; //settings_save_one("foo/bar", &foo_val, sizeof(foo_val)); //printk("foo: %d\n", foo_val); }
The log entries when running are:
<dbg> setting_manager: setting_manager_init: Initializing setting manager <dbg> setting_manager: setting_manager_init: Settings subsystem initialized, loading... <err> fs: file open error (-2)
I saw these threads on the topic,