samples: nvs: fix flash device access
Get the correct flash device from the storage partition node. The current code is relying on the invalid assumption that the chosen zephyr,flash-controller node is the device which contains the storage partition. Reported-by: Dominik Ermel <dominik.ermel@nordicsemi.no> Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
parent
e30cfa42d4
commit
673b4b4394
1 changed files with 4 additions and 1 deletions
|
@ -48,6 +48,9 @@
|
|||
|
||||
static struct nvs_fs fs;
|
||||
|
||||
#define STORAGE_NODE DT_NODE_BY_FIXED_PARTITION_LABEL(storage)
|
||||
#define FLASH_NODE DT_MTD_FROM_FIXED_PARTITION(STORAGE_NODE)
|
||||
|
||||
/* 1000 msec = 1 sec */
|
||||
#define SLEEP_TIME 100
|
||||
/* maximum reboot counts, make high enough to trigger sector change (buffer */
|
||||
|
@ -75,7 +78,7 @@ void main(void)
|
|||
* 3 sectors
|
||||
* starting at FLASH_AREA_OFFSET(storage)
|
||||
*/
|
||||
flash_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_flash_controller));
|
||||
flash_dev = DEVICE_DT_GET(FLASH_NODE);
|
||||
if (!device_is_ready(flash_dev)) {
|
||||
printk("Flash device %s is not ready\n", flash_dev->name);
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue