SDK : NCS v2.8.0
SoC : nRF52840
HW : custom board
Hello,
I was trying to use settings subsystem, and I managed to make setting_write() and settings_read() work. Now, I am trying to clear a settings with following code, but have gotten errors:
void settings_clear() {
const struct flash_area *fa;
int err;
err = flash_area_open(DT_NODELABEL(settings_partition), &fa);
if (err) {
printk("Failed to open settings storage: %d\n", err);
return;
}
err = flash_area_erase(fa, 0, fa->fa_size);
if (err) {
printk("Failed to erase settings storage: %d\n", err);
} else {
printk("Settings storage erased!\n");
}
flash_area_close(fa);
}
When I tried this code, I got following errors:
D:/ncs/xcam5/build/xcam5/zephyr/include/generated/zephyr/devicetree_generated.h:10178:43: error: 'DT_N_S_soc_S_flash_controller_4001e000_S_flash_0_S_partitions_S_partition_f8000' undeclared (first use in this function); did you mean 'DT_N_S_soc_S_flash_controller_4001e000_S_flash_0_S_partitions_S_partition_f8000_ORD'?
10178 | #define DT_N_NODELABEL_settings_partition DT_N_S_soc_S_flash_controller_4001e000_S_flash_0_S_partitions_S_partition_f8000
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
D:/ncs/xcam5/build/xcam5/zephyr/include/generated/zephyr/devicetree_generated.h:10178:43: note: in definition of macro 'DT_N_NODELABEL_settings_partition'
10178 | #define DT_N_NODELABEL_settings_partition DT_N_S_soc_S_flash_controller_4001e000_S_flash_0_S_partitions_S_partition_f8000
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/DevTools/nRF/ncs/v2.8.0/zephyr/include/zephyr/devicetree.h:200:29: note: in expansion of macro 'DT_CAT'
200 | #define DT_NODELABEL(label) DT_CAT(DT_N_NODELABEL_, label)
| ^~~~~~
D:/ncs/xcam5/src/main.c:168:31: note: in expansion of macro 'DT_NODELABEL'
168 | err = flash_area_open(DT_NODELABEL(settings_partition), &fa);
| ^~~~~~~~~~~~
10178 | #define DT_N_NODELABEL_settings_partition DT_N_S_soc_S_flash_controller_4001e000_S_flash_0_S_partitions_S_partition_f8000
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
D:/ncs/xcam5/build/xcam5/zephyr/include/generated/zephyr/devicetree_generated.h:10178:43: note: in definition of macro 'DT_N_NODELABEL_settings_partition'
10178 | #define DT_N_NODELABEL_settings_partition DT_N_S_soc_S_flash_controller_4001e000_S_flash_0_S_partitions_S_partition_f8000
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/DevTools/nRF/ncs/v2.8.0/zephyr/include/zephyr/devicetree.h:200:29: note: in expansion of macro 'DT_CAT'
200 | #define DT_NODELABEL(label) DT_CAT(DT_N_NODELABEL_, label)
| ^~~~~~
D:/ncs/xcam5/src/main.c:168:31: note: in expansion of macro 'DT_NODELABEL'
168 | err = flash_area_open(DT_NODELABEL(settings_partition), &fa);
| ^~~~~~~~~~~~
My board.dts file:
&flash0 {
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
boot_partition: partition@0 {
label = "mcuboot";
reg = <0x00000000 DT_SIZE_K(48)>;
};
slot0_partition: partition@c000 {
label = "image-0";
reg = <0x0000c000 DT_SIZE_K(472)>;
};
slot1_partition: partition@82000 {
label = "image-1";
reg = <0x00082000 DT_SIZE_K(472)>;
};
settings_partition: partition@f8000 {
label = "settings";
reg = <0x000F8000 DT_SIZE_K(16)>;
};
storage_partition: partition@fc000 {
label = "storage";
reg = <0x000FC000 DT_SIZE_K(16)>;
};
};
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
boot_partition: partition@0 {
label = "mcuboot";
reg = <0x00000000 DT_SIZE_K(48)>;
};
slot0_partition: partition@c000 {
label = "image-0";
reg = <0x0000c000 DT_SIZE_K(472)>;
};
slot1_partition: partition@82000 {
label = "image-1";
reg = <0x00082000 DT_SIZE_K(472)>;
};
settings_partition: partition@f8000 {
label = "settings";
reg = <0x000F8000 DT_SIZE_K(16)>;
};
storage_partition: partition@fc000 {
label = "storage";
reg = <0x000FC000 DT_SIZE_K(16)>;
};
};
my proj.conf file has:
CONFIG_SETTINGS=y
CONFIG_SETTINGS_NVS=y
CONFIG_NVS=y
CONFIG_FLASH_MAP=y
CONFIG_SETTINGS_NVS=y
CONFIG_NVS=y
CONFIG_FLASH_MAP=y
Question:
How can I get the correct "settings_partition" ID, which is to be used in flash_area_open() function?
Thanks,
Robin