Utilize device tree partition with MCU boot

I am working on custom hardware with an nRF52840. I have added the MCU boot in my earlier development as well but this issue I have never faced before.

Problem statement

I have defined a partition as mentioned below snippet where I have used the minimal MCU boot size configuration along with the MOVE WITH SCRATCH configuration. Along with 4 defined partitions of MCU boot boot, slot0, slot1, and scratc,h there is another partition named data_logger_storage which I have added to save my application data.

&flash0 {

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

		boot_partition: partition@0 {
			label = "mcuboot";
			reg = <0x00000000 0x00003E00>;
		};
		slot0_partition: partition@3E00 {
			label = "image-0";
			reg = <0x00003E00 0x0007B000>;
		};
		slot1_partition: partition@7EE00 {
			label = "image-1";
			reg = <0x0007EE00 0x0007B000>;
		};
		scratch_partition: partition@F9E00 {
			label = "image-scratch";
			reg = <0xF9E00 0x3F00>;
		};
		/*
		 * The flash starting at 0x000f8000 and ending at
		 * 0x000fffff is reserved for use by the application.
		 */

		/*
		 * Storage partition will be used by FCB/LittleFS/NVS
		 * if enabled.
		 */
		 data_logger_storage_partition: partition@FDD00 {
			label = "storage";
			reg = <0x000FDD00 0x00002000>;
		};		
	};
};

Here when I compile my code, I face an error 

error: 'PM_PM_PM_data_logger_storage_partition_ID_LABEL_OFFSET' was not declared in this scope

I have not added the pm.yml or pm_static.yml file in my application, because I have other running code with MCU boot and device tree partition that does not have the pm.yml.

So here are my query,
1. How can we use the device tree partition only when we enable the MCU boot? Because I do not have a scope to define pm.yml as the same code is designed in such a way that it can be used with any of nrf boards i.e the same code can be built for nrf52840 and nrf5340

I have attached the partitions.yml generated with this build, which certainly has different data from what I have defined in the device tree.

  • Also, your suggestion to use the board-specific pm_static.yml did not work for me. The generated partition.yml does not have my updated partition. It has the default partitions.

    I am using the custom board so I append my board name after pm_static_<board_name>.yml. But that did not work. 

    Instead of using a custom board, I have used the defined board like pm_static_nrf5284dk_nrf52840.yml which did not work as well.

    Is this feature supported by a specific nRF SDK version? Currently, I am running on 2.6.2.

  • Hi Ankit, 
    I don't think the Partition manager will look into the device tree partition location to inherit from there. 
    What you should do is to define your pm_static.yml based on build\partitions.yml file and modify to what you need. 

    For SDK v2.6.2 you can't do pm_static_<boardname>.yml but need to define the PM_STATIC_YML_FILE when you build. 
    You cant take a look at CMakeLists.txt file in \nrf\samples\matter\lock to see how it work. 

    Regarding your question about scratch area, as far as I know, we switch to swap move algorithm and don't use scratch move algorithm. 

    Do you have any reason that you prefer scratch move ? It make flash wear fast ter. 

  • Hi Hung,

    Sorry for my late reply and thank you for the clarification.

    So, I decided to go with the pm_static.yml file to manage my storage where I removed the scratch partition. So now I can manage my partition using the .yml file and it is working now.

    Thanks for the support.

Related