Correct format of reg property in device tree for boot_partition

I'm adding DFU over Bluetooth support to an existing application based on nRF Connect v2.3.0 following these instructions.  What the instructions lack (and possibly is a given for Peripheral LBS, although I don't readily see it) is the device tree definition of `boot_partion` that is required.

I've added the following block to my custom boards DTS file:

&flash0 {
	partitions {
        compatible = "fixed-partitions";
        boot_partition: partition@0 {
            label = "mcuboot";
			reg = <0x000000000 0x00010000>;
        };
    };
};


But get a warning from the nRF Connect VSCode extension that my defintion of `reg` is ill-formed:

It is saying the form is `addr addr size` as opposed to `addr size`.  Building it anyway I get the following failure:

devicetree error: 'reg' property in <Node /soc/flash-controller@4001e000/flash@0/partitions/partition@0 in 'C:/ncs/v2.3.0/zephyr/misc/empty_file.c'> has length 8, which is not evenly divisible by 12 (= 4*(<#address-cells> (= 2) + <#size-cells> (= 1))). Note that #*-cells properties come either from the parent node or from the controller (in the case of 'interrupts').

Suspecting that the warning is correct I find it builds without issue if I format it `addr addr size`, however, it fails at the very end:

c:/ncs/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.exe: zephyr\zephyr_pre0.elf section `rodata' will not fit in region `FLASH'
c:/ncs/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.exe: region `FLASH' overflowed by 5436 bytes

This isn't a shock because I didn't know what values to choose for the `addr addr size`  format.

So - My question is 1) What is the correct format for defining the reg property for an image partition? and 2) What should the default value be for a nRF52840 based board?

Parents
  • So just another comment for others that might be seeing the same issue.

    The 'addr addr size' structure for the `reg` property suggested by the VSCode editor produced a warning by the compiler that #address-cells and #size-cells properties were missing and defaults were used.  If you define those, then the editor expects a 'addr size' stucture.  If you use 'addr size' w/o the #address-cells and #size-sells properties then you end up with the compile error I had above about it not being divisible by 12.

    In the end this was needed in my boards .dts even though I did use `CONFIG_PM_PARTITION_SIZE_MCUBOOT` in the childe image .conf:

    &flash0 {
    	partitions {
    		compatible = "fixed-partitions";
    		#address-cells = <1>;
    		#size-cells = <1>;
    
    		boot_partition: partition@0 {
    				label = "mcuboot";
    				reg = <0x000000000 0x00008000>;
    		};
    	};
    };

Reply
  • So just another comment for others that might be seeing the same issue.

    The 'addr addr size' structure for the `reg` property suggested by the VSCode editor produced a warning by the compiler that #address-cells and #size-cells properties were missing and defaults were used.  If you define those, then the editor expects a 'addr size' stucture.  If you use 'addr size' w/o the #address-cells and #size-sells properties then you end up with the compile error I had above about it not being divisible by 12.

    In the end this was needed in my boards .dts even though I did use `CONFIG_PM_PARTITION_SIZE_MCUBOOT` in the childe image .conf:

    &flash0 {
    	partitions {
    		compatible = "fixed-partitions";
    		#address-cells = <1>;
    		#size-cells = <1>;
    
    		boot_partition: partition@0 {
    				label = "mcuboot";
    				reg = <0x000000000 0x00008000>;
    		};
    	};
    };

Children
No Data
Related