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?

  • So I have DFU working now (sorta - succeeds 1 of 3 tries) - But I think my issues now are probably just related to general Bluetooth and device stability.

    In the end my app was at the extreme limit of the image size with mcuboot. I found another ticket where someone ran into a similar problem and turning off some of my other kconfig properties to get my build smaller ended up succeeding and booting.  It seems that if you're close enough to the max image size the dynamic partitioning will let you down.

  •   Hi. It's not true that device tree is not used with MCUboot. When MCUBoot is configured then the DTS file bootloader/mcuboot/boot/zephyr/app.overlay is used:

    / {
            chosen {
                    zephyr,code-partition = &boot_partition;
            };
    };
    

    Therefore board file needs to contain partitions. Why is it this way? Why can't we have single place for partitions definition?

Related