Without understanding why, it failes at the assert here:
int init_fs() {
if (fs_is_initialized) return 0; // already initialized
ss_list_init(&fs_cache);
uint8_t *data = NULL;
size_t len = 0;
fs.flash_device = NVS_PARTITION_DEVICE;
fs.sector_size = 0x1000; // where to read this? :DT_PROP(NVS_PARTITION, erase_block_size); //<0x1000>
fs.sector_count = FLASH_AREA_SIZE(nvs_storage) / fs.sector_size;
fs.offset = NVS_PARTITION_OFFSET;
int rc = nvs_mount(&fs);
if (rc) {
LOG_ERR("failed to mount nvs\n");
return -1;
}
rc = nvs_read(&fs, DIR_ID, NULL, 0);
len = rc;
/*************************
* Read DIR_ENTRY from NVS
* This is used to construct a linked list that
* serves as a cache and lookup table for the filesystem
*/
if (!data && rc) {
data = SS_ALLOC_N(len * sizeof(uint8_t));
rc = nvs_read(&fs, DIR_ID, data, len);
__ASSERT_NO_MSG(rc == len);
}
ss_list_init(&fs_cache);
generate_dir_table_from_blob(&fs_cache, data, len);
if (ss_list_empty(&fs_cache)) goto out;
fs_is_initialized++;
out:
free(data);
return ss_list_empty(&fs_cache);
}
So something “wrong” with the NVS storage?