Skip to content

Commit 15159dd

Browse files
nvlsianpucarlescufi
authored andcommitted
settings: always uses the storage partition for FCB
It was possible via Kconfig to assign any partition for FCB using its number. Partitions flash_area_id becomes non predefined (are auto-generated). So it is possible only to guess which number will be signed to certain area. Unfortunately it is not possible to transfer FLASH_AREA_XXX_ID label via Kconfig. Patch assigns settings to the storage partition and remove SETTINGS_FCB_FLASH_AREA property from settings Kconfig. fixes #13388 Signed-off-by: Andrzej Puzdrowski <[email protected]>
1 parent 5cf4995 commit 15159dd

File tree

11 files changed

+64
-52
lines changed

11 files changed

+64
-52
lines changed

subsys/settings/Kconfig

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,6 @@ config SETTINGS_FCB_MAGIC
6363
help
6464
Magic 32-bit word for to identify valid settings area
6565

66-
config SETTINGS_FCB_FLASH_AREA
67-
int "Flash area id used for settings"
68-
default $(dt_int_val,DT_FLASH_AREA_STORAGE_ID)
69-
depends on SETTINGS && SETTINGS_FCB
70-
help
71-
Id of the Flash area where FCB instance used for settings is
72-
expected to operate.
73-
7466
config SETTINGS_FS_DIR
7567
string "Serialization directory"
7668
default "/settings"

subsys/settings/src/settings_fcb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ int settings_fcb_src(struct settings_fcb *cf)
3838
cf->cf_fcb.f_scratch_cnt = 1;
3939

4040
while (1) {
41-
rc = fcb_init(CONFIG_SETTINGS_FCB_FLASH_AREA, &cf->cf_fcb);
41+
rc = fcb_init(DT_FLASH_AREA_STORAGE_ID, &cf->cf_fcb);
4242
if (rc) {
4343
return -EINVAL;
4444
}

subsys/settings/src/settings_init.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static void settings_init_fcb(void)
5959
int rc;
6060
const struct flash_area *fap;
6161

62-
rc = flash_area_get_sectors(CONFIG_SETTINGS_FCB_FLASH_AREA, &cnt,
62+
rc = flash_area_get_sectors(DT_FLASH_AREA_STORAGE_ID, &cnt,
6363
settings_fcb_area);
6464
if (rc != 0 && rc != -ENOMEM) {
6565
k_panic();
@@ -70,7 +70,7 @@ static void settings_init_fcb(void)
7070
rc = settings_fcb_src(&config_init_settings_fcb);
7171

7272
if (rc != 0) {
73-
rc = flash_area_open(CONFIG_SETTINGS_FCB_FLASH_AREA, &fap);
73+
rc = flash_area_open(DT_FLASH_AREA_STORAGE_ID, &fap);
7474

7575
if (rc == 0) {
7676
rc = flash_area_erase(fap, 0, fap->fa_size);

tests/subsys/settings/fcb/base64/Kconfig

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (c) 2019 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/delete-node/ &storage_partition;
8+
/delete-node/ &scratch_partition;
9+
10+
&flash0 {
11+
/*
12+
* For more information, see:
13+
* http://docs.zephyrproject.org/latest/guides/dts/index.html#flash-partitions
14+
*/
15+
partitions {
16+
compatible = "fixed-partitions";
17+
#address-cells = <1>;
18+
#size-cells = <1>;
19+
20+
storage_partition: partition@de000 {
21+
label = "storage";
22+
reg = <0x000de000 0x00010000>;
23+
};
24+
};
25+
};

tests/subsys/settings/fcb/base64/nrf52_pca10040.overlay

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
/delete-node/ &storage_partition;
8+
/delete-node/ &scratch_partition;
9+
710
&flash0 {
811
/*
912
* For more information, see:
@@ -14,20 +17,8 @@
1417
#address-cells = <1>;
1518
#size-cells = <1>;
1619

17-
boot_partition: partition@0 {
18-
label = "mcuboot";
19-
reg = <0x00000000 0xc000>;
20-
};
21-
slot0_partition: partition@c000 {
22-
label = "image-0";
23-
reg = <0x0000C000 0x32000>;
24-
};
25-
slot1_partition: partition@3e000 {
26-
label = "image-1";
27-
reg = <0x0003E000 0x32000>;
28-
};
29-
scratch_partition: partition@70000 {
30-
label = "image-scratch";
20+
storage_partition: partition@70000 {
21+
label = "storage";
3122
reg = <0x00070000 0x10000>;
3223
};
3324
};

tests/subsys/settings/fcb/raw/Kconfig

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (c) 2019 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/delete-node/ &storage_partition;
8+
/delete-node/ &scratch_partition;
9+
10+
&flash0 {
11+
/*
12+
* For more information, see:
13+
* http://docs.zephyrproject.org/latest/guides/dts/index.html#flash-partitions
14+
*/
15+
partitions {
16+
compatible = "fixed-partitions";
17+
#address-cells = <1>;
18+
#size-cells = <1>;
19+
20+
storage_partition: partition@de000 {
21+
label = "storage";
22+
reg = <0x000de000 0x00010000>;
23+
};
24+
};
25+
};

tests/subsys/settings/fcb/raw/nrf52_pca10040.overlay

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
/delete-node/ &storage_partition;
8+
/delete-node/ &scratch_partition;
9+
710
&flash0 {
811
/*
912
* For more information, see:
@@ -14,20 +17,8 @@
1417
#address-cells = <1>;
1518
#size-cells = <1>;
1619

17-
boot_partition: partition@0 {
18-
label = "mcuboot";
19-
reg = <0x00000000 0xc000>;
20-
};
21-
slot0_partition: partition@c000 {
22-
label = "image-0";
23-
reg = <0x0000C000 0x32000>;
24-
};
25-
slot1_partition: partition@3e000 {
26-
label = "image-1";
27-
reg = <0x0003E000 0x32000>;
28-
};
29-
scratch_partition: partition@70000 {
30-
label = "image-scratch";
20+
storage_partition: partition@70000 {
21+
label = "storage";
3122
reg = <0x00070000 0x10000>;
3223
};
3324
};

tests/subsys/settings/fcb/src/settings_test_fcb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ void config_wipe_fcb(struct flash_sector *fs, int cnt)
176176
int rc;
177177
int i;
178178

179-
rc = flash_area_open(CONFIG_SETTINGS_FCB_FLASH_AREA, &fap);
179+
rc = flash_area_open(DT_FLASH_AREA_STORAGE_ID, &fap);
180180

181181
for (i = 0; i < cnt; i++) {
182182
rc = flash_area_erase(fap, fs[i].fs_off, fs[i].fs_size);

0 commit comments

Comments
 (0)