MCUBOOT + settings storage + user storage

I want to reserve some flash area to store application specific configuration data.  This data will not change for the life of the product.  I originally had an area set aside in the dts file, like so.

&flash0 {
	partitions {
		compatible = "fixed-partitions";
		#address-cells = <1>;
		#size-cells = <1>;

		boot_partition: partition@0 {
			label = "mcuboot";
			reg = <0x0 0x10000>;
		};
		slot0_partition: partition@10000 {
			label = "image-0";
			reg = <0x10000 0xE5000>;
		};
	
		app_partition: partition@F5000 {
            label = "app-data";
            reg = <0x000F5000 0x00003000>;
        };

		storage_partition: partition@f8000 {
			label = "storage";
			reg = <0xf8000 0x8000>;
		};
	};
};

That caused a problem when I added MCUBOOT as the bootloader, because MCUBOOT would erase the "app-partition" section.

When the project has a child image, as it does when MCUBOOT is enabled, the flash partitions in the DTS will be ignored.  The partitions from the Partition Manager will be used instead.

I added this to overlay-dfu_support.conf to preserve the settings storage partition:

CONFIG_PM_PARTITION_SIZE_SETTINGS_STORAGE=0x8000
CONFIG_SETTINGS_NVS_SECTOR_COUNT=8
That fixed the settings storage, but still erased the app-data partition, so I changed to this:
CONFIG_PM_PARTITION_SIZE_SETTINGS_STORAGE=0xB000
CONFIG_SETTINGS_NVS_SECTOR_COUNT=11
Now, the problem is that there is no partition for app-data, just settings storage, so after a while the settings erase the app-data.
How do I add a partition for application specific data using partition manager?
Mary
  • I added this to 

    <sdk>/bootloader/mcuboot/boot/zephyr/pm.yml

    # Added user storage 
    user:
      address: 0xf5000
      end_address: 0xF8000
      placement:
        before:	[settings_storage]
      region: flash_primary
      size: 0x3000

    This works, so far, but I'd rather not modify the SDK.  Is there a way to add a partition at the application level?

    Mary

  • Hi Mary,

    I will have to get back to you on this.

    Regards,

    Elfving

  • Hello again,

    In NCS when you enabled bootloader the partition manager is enabled, and it will override whatever is defined in DTS and specify it's own flash partition layout. You can do some tweaking in the options but in our applications we always define a static partition configuration (pm_static.yml). This way we don't depend on the algorithm to chose the layout for us (plus I have a guarantee the layout won't change between builds). Take a look here for partition layout for partition manager.


    You can check build-folder/partitions.yml to see how it was sorted out in the end.

    The easiest way to add a static pm file would be to simply take the partitions.yml in the build folder and copy it, rename it, and place it as a pm_static.yml in the project folder. See if that helps.

    Regards,

    Elfving

Related