NVS write fails error -22 when building with sysbuild

nRF54L15 - ncs 3.02 - toolchain 3.02

I changed my build settings from no sysbuild to sysbuild in order to use serial recovery and/or FOTA. I thought everything was OK until I tried saving settings to NVS where I now get error -22

(Before asking why I'm using NVS not ZMS I was advised to as ZMS is still buggy and it gives problems)

Do I need to manually change partitioning to make this work?

Here is the NVS write code:


	struct nvs_fs fs;
	struct flash_pages_info info;

	fs.flash_device = NVS_PARTITION_DEVICE;

	if (!device_is_ready(fs.flash_device)) {
		printk("Flash device %s is not ready\n", fs.flash_device->name);
		return 1;
	}

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

	fs.sector_size = info.size;
	fs.sector_count = 3U;
	rc = nvs_mount(&fs);
	if (rc) {
		printk("Flash Init failed, rc=%d\n", rc);
		return rc;
	}

	rc = nvs_write(&fs, NVS_SETTINGS_ADDR, &mybuff, sizeof(mybuf));

	return rc;

Parents
  • Hi Nick

    I can confirm I've recreated this on the DFUTest sample you uploaded now. The error seems to come from the nvs_prev_ate() in nvs.c. The settings use one sector, the app can't use three sectors of the storage_partition when using settungs, If you want/need to use the settings here, max sector_count can only be 2U with the following:

       fs.sector_size = info.size;

       fs.sector_count = 2U;

    If you change this, the error will be resolved. Moving over to sysbuild and adding the BT DIS settings is what toppled the application here. You can get a better overview of your systems storage and partitions in the memory report which is part of the nRF Connect extension in VS Code.

    Best regards,

    Simon

  • Claude beat you to it I'm afraid. I have ditched using NV entirely as I found out I can just use Zephyr's settings subsystem for persistent storage. All my settings data is stored in a single structure, so settings_save_one() and settings_load_one() work for me.

Reply Children
No Data
Related