1
0
mirror of https://github.com/CovidBraceletPrj/CovidBracelet.git synced 2024-11-12 22:48:52 +01:00

Init ens_fs in storage.c

This commit is contained in:
H1ghBre4k3r 2021-04-12 19:31:15 +02:00 committed by Patrick Rathje
parent 725259cfce
commit 30dc3c31eb
2 changed files with 14 additions and 0 deletions

View File

@ -1,6 +1,7 @@
#include <device.h>
#include <drivers/flash.h>
#include <fs/nvs.h>
#include <logging/log.h>
#include <power/reboot.h>
#include <storage/flash_map.h>
#include <string.h>
@ -18,6 +19,8 @@
static struct nvs_fs info_fs;
static ens_fs_t ens_fs;
// Information about currently stored contacts
static stored_contacts_information_t contact_information = {.oldest_contact = 0, .count = 0};
@ -73,6 +76,7 @@ int init_contact_storage(void) {
if (rc) {
// Error during retrieval of page information
printk("Cannot retrieve page information (err %d)\n", rc);
return rc;
}
info_fs.sector_size = info.size;
@ -81,15 +85,24 @@ int init_contact_storage(void) {
rc = nvs_init(&info_fs, DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL);
if (rc) {
// Error during nvs_init
printk("Cannot init NVS (err %d)\n", rc);
return rc;
}
// Load the current storage information
rc = load_storage_information();
if (rc) {
printk("Cannot load storage information (err %d)\n", rc);
return rc;
}
printk("Currently %d contacts stored!\n", contact_information.count);
printk("Space available: %d\n", FLASH_AREA_SIZE(storage));
rc = ens_fs_init(&ens_fs, FLASH_AREA_ID(ens_storage), 32);
if(rc) {
printk("Cannot init ens_fs (err %d)\n", rc);
}
return rc;
}

View File

@ -23,6 +23,7 @@ CONFIG_NVS=y
CONFIG_NVS_LOG_LEVEL_DBG=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y
# CONFIG_DISK_ACCESS=y
CONFIG_MAIN_STACK_SIZE=2048