How to configure Settings API to work on a specific partition defined in the pm_static.yaml file

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:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
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
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

This is how I am trying to initialize it. I know it's incomplete but am having trouble getting to the next steps.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#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);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

The log entries when running are:

Fullscreen
1
2
3
<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)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I saw these threads on the topic, 

  • With Sysbuild:

    It works:

    What is sysbuild vs build system defaults? I notice the build configuration looks different:

    vs with build system defaults:

    Why with sysbuild is it picking the external flash? Is it utilizing a .conf or .overlay not being included using build system defaults? If so, which one? Actually, I copied the .conf/.overlay in the boards file into another project and see the same result.

    How would I get the board to:

    1. Use littlefs vs NVS for everything (settings)?
    2. Use SPI vs QSPI

    And where is the use of partition manager described along with settings like:

    Fullscreen
    1
    2
    3
    4
    CONFIG_PM_PARTITION_SIZE_SETTINGS_STORAGE=0x200000
    CONFIG_PM_PARTITION_REGION_SETTINGS_STORAGE_EXTERNAL=y
    CONFIG_PM_PARTITION_REGION_LITTLEFS_EXTERNAL=y
    CONFIG_PM_PARTITION_SIZE_LITTLEFS=0x200000
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    If I'm putting using   CONFIG_PM_PARTITION_SIZE_SETTINGS_STORAGE=0x200000 and CONFIG_PM_PARTITION_SIZE_LITTLEFS=0x200000, doesn't that mean I'm setting the partition size? Why would I use those settings over the pm_static.yml?

    And why do you put SB_CONFIG_BOOTLOADER_MCUBOOT=y in sysbuild.conf? The Nordic video on Adding DFU shows using CONFIG_BOOTLOADER_MCUBOOT=Y in the prj.conf as does DevAcademy.
  • v2.6.1 is optional to use sysbuild, so you also can use CONFIG_BOOTLOADER_MCUBOOT=Y in the prj.conf. 

    lcj said:

    How would I get the board to:

    1. Use littlefs vs NVS for everything (settings)?

    You can refer to samples/subsys/settings and tests/subsys/settings/file  in the Zephyr tree. 

    lcj said:
    Use SPI vs QSPI

    You can compare the differences by referring to the files under the boards folder: 

1 2 3 4