NVS & MX25R64

HI

I am using nRF54L15 PDK with NCS 3.0.0.
In my code, I am using NVS to store data on the MX25R64 flash on the PDK. The initialization code is as follows:

struct flash_pages_info info;
data_fs.flash_device = FIXED_PARTITION_DEVICE(sensor_ptr_storage);
if (!device_is_ready(data_fs.flash_device)) {
    printk("Flash device %s is not ready\n", data_fs.flash_device->name);
    return 0;
}
data_fs.offset = FIXED_PARTITION_OFFSET(sensor_ptr_storage);

int rc = flash_get_page_info_by_offs(data_fs.flash_device, data_fs.offset, &info);
if (rc) {
    printk("Unable to get page info, rc=%d\n", rc);
    return 0;
}

data_fs.sector_size = info.size;
data_fs.sector_count = FLASH_AREA_SIZE(sensor_ptr_storage) / info.size;
printk("data_fs.sector_size %d,data_fs.sector_count %d\n",info.size,data_fs.sector_count);

if(nvs_mount(&data_fs)) {
    printk("Flash Init failed\n");
    return 0;
}

rc = nvs_read(&data_fs, NVS_PTR_ID, (uint8_t *)&entry_desc, sizeof(struct fcb_entry));
if(rc != sizeof(struct fcb_entry)) {
    printk("nvs read failed,err=%d\n",rc);
} else {
    printk("nvs read successfully,sector: 0x%x,\n",entry_desc.fe_sector->fs_off);
}

The sensor_ptr_storage partition is configured as follows:

At runtime, nvs_mount initialization reports an error "Invalid sector size". Debugging shows that data_fs.sector_size is 0, while info.size is 65536.

  1. Does flash_get_page_info_by_offs read the information per page? The info.size should be 4096, why is it 65536 (64K)?

  2. I see that sector_size is of type uint16_t, while info.size is of type size_t, their sizes are different. Is the value 65536 read from info.size incorrect?

    thanks!

Parents Reply Children
Related