Skip to content

Commit 7976d2b

Browse files
MaureenHelmnashif
authored andcommitted
samples: nvs: Use flash erase block size from dts
The nvs sample assumed a 1 KB flash erase block size, which caused the sample to fail on frdm_k64f because its erase block size is 4 KB. Get the erase block size from dts instead. Signed-off-by: Maureen Helm <[email protected]>
1 parent f3be631 commit 7976d2b

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

dts/arm/nordic/nrf51822.dtsi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
compatible = "soc-nv-flash";
2828
label = "NRF_FLASH";
2929
reg = <0x00000000 DT_FLASH_SIZE>;
30+
erase-block-size = <1024>;
3031
write-block-size = <4>;
3132
};
3233
};

samples/subsys/nvs/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#include <string.h>
4646
#include <nvs/nvs.h>
4747

48-
#define NVS_SECTOR_SIZE 1024 /* Multiple of FLASH_PAGE_SIZE */
48+
#define NVS_SECTOR_SIZE FLASH_ERASE_BLOCK_SIZE /* Multiple of FLASH_PAGE_SIZE */
4949
#define NVS_SECTOR_COUNT 3 /* At least 2 sectors */
5050
#define NVS_STORAGE_OFFSET FLASH_AREA_STORAGE_OFFSET /* Start address of the
5151
* filesystem in flash

0 commit comments

Comments
 (0)