Repurposing flash partition for non-volatile storage on Thingy91

I am using the Thingy91 and want a larger flash partition to use for non-volatile storage ("storage" is only 0x6000 in size). I am building for nonsecure ("west build -b thingy91_nrf9160_ns") and am not performing firmware upgrades, so it is my understanding that I could use "image-1" or "image-1-nonsecure" for my storage purposes.

I have been looking at these lines in nrf/boards/arm/thingy91_nrf9160/thingy91_nrf9160_common.dts for reference:

&flash0 {
	/*
	 * For more information, see:
	 * http://docs.zephyrproject.org/devices/dts/flash_partitions.html
	 */
	partitions {
		compatible = "fixed-partitions";
		#address-cells = <1>;
		#size-cells = <1>;

		boot_partition: partition@0 {
			label = "mcuboot";
			reg = <0x00000000 0x10000>;
		};
		slot0_partition: partition@10000 {
			label = "image-0";
		};
		slot0_ns_partition: partition@40000 {
			label = "image-0-nonsecure";
		};
		slot1_partition: partition@80000 {
			label = "image-1";
		};
		slot1_ns_partition: partition@b0000 {
			label = "image-1-nonsecure";
		};
		scratch_partition: partition@f0000 {
			label = "image-scratch";
			reg = <0x000f0000 0xa000>;
		};
		storage_partition: partition@fa000 {
			label = "storage";
			reg = <0x000fa000 0x00006000>;
		};
	};
};

Is my proposed use of  "image-1" or "image-1-nonsecure" correct and safe? 

If so, I would then do something like this in my application:

//Do necessary #include's
#define STORAGE_NODE_LABEL image_1
static struct nvs_fs fs;

void main(void)
{
fs.flash_device = FLASH_AREA_DEVICE(STORAGE_NODE_LABEL);
fs.offset = FLASH_AREA_OFFSET(image_1);
//Define sector size and count, then mount and use NVS here...
}

Or should I reduce the sizes of "image-0" and "image-1" in the .dts file and increase the size of "storage" instead?

Parents
  • I just did a quick test using "image_1" as I described above and it worked! I checked the offset and it is using the mcuboot_secondary region specified in thingy91_pm_static.yml (0x75000).

    However, I cannot specify a sector size over 61,440 bytes (=4096*15) because the maximum uint16_t and size_t value is 65535. Is there any way to specify a larger sector size or work around this?

    I have tried changing nvs_fs.sector_size from uint16_t to uint32_t in nvs.h, but then I get errors in soc_flash_nrf.c because of size_t's max value as seen below.

Reply
  • I just did a quick test using "image_1" as I described above and it worked! I checked the offset and it is using the mcuboot_secondary region specified in thingy91_pm_static.yml (0x75000).

    However, I cannot specify a sector size over 61,440 bytes (=4096*15) because the maximum uint16_t and size_t value is 65535. Is there any way to specify a larger sector size or work around this?

    I have tried changing nvs_fs.sector_size from uint16_t to uint32_t in nvs.h, but then I get errors in soc_flash_nrf.c because of size_t's max value as seen below.

Children
Related