Building MCUBoot with a DTS overlay file

Lawrence King



I am not sure if this issue should be asked here, or in the MCUBoot mailing list, but I will start by asking here.


I want to change the partitions in my nrf52840, this is easy when building a zephyr system, I simply put an overlay file with my new partition table in the project directory, cmake finds it and uses it, and all is good. I tried the same thing when building mcuboot, it doesn’t work, although it looks like it should work.


I downloaded the latest mcuboot code from JuulLabs ‘git clone’.  And after running the appropriate mcuboot setup scripts I built mcuboot for zephyr.

In the project directory mcuboot/boot/zephyr I ran ‘west build -b nrf52840_mdk’, the build completes west flash is successful and the bootloader is running on the board as expected. Now I want to change the partition table (and of course the keys). I created a file nrf52840_mdk.overlay in the mcuboot/boot/zephyr directory (I also tried putting the overlay in the boards subdirectory):


&flash0 {


         * For more information, see:



        partitions {

                compatible = "fixed-partitions";

                #address-cells = <1>;

                #size-cells = <1>;


                boot_partition: partition@0 {

                        label = "mcuboot";

                        reg = <0x000000000 0x0000C000>;


                slot0_partition: partition@c000 {

                        label = "image-0";

                        reg = <0x0000C000 0x000067000>;


                slot1_partition: partition@73000 {

                        label = "image-1";

                        reg = <0x00073000 0x000067000>;


                scratch_partition: partition@da000 {

                        label = "image-scratch";

                        reg = <0x000da000 0x0001c000>;


                blob_partition: partition@f7000 {

                        label = "image-blob";

                        reg = <0x000f7000 0x00001000>;




                 * The flash starting at 0x000f8000 and ending at (32kB)

                 * 0x000fffff is reserved for use by the application.



                /* Storage partition will be used by FCB/NFFS/NVS if enabled. */

                storage_partition: partition@f8000 {

                        label = "storage";

                        reg = <0x000f8000 0x00008000>;





As you can see this is almost exactly the same as the standard partitions except the scratch partition is 4k smaller, and I have added a 4k blob partition.

When I compile this and attempt to flash the code, the code goes into the wrong partition, because the dts.overlay file is ignored.


The CMakelists.txt file  looks reasonable, it should overlay the dts.overlay AND the nrf52840_mdk.overlay when building the dts file, but it doesn’t actually end up with two overlays.


I tried numerous combinations of adding an overlay or two on the west command line, but I couldn’t get it to work.

west build -b nrf52840_mdk -- -DDTC_OVERLAY_FILE=”whatever”


I eventually added the contents of the dts.overlay file to my nrf52840_mdk.overlay, and I commented out part of the CMakeLists.txt file to make it work, but I don’t think this is the right way to do it:


# Add a common dts overlay necessary to ensure mcuboot is linked into,

# and fits inside, the boot partition. (If the user specified a

# DTC_OVERLAY_FILE on the CMake command line, we need to append onto

# the list).





#    )





if (EXISTS ${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}.overlay)







What is the right way to get two overlays into the mcuboot build?



Lawrence King

Principal Developer

Connected Transport Market Unit



1  2 - linkedin  3 - instagram  4 - youtube  6 - facebook  7


CONFIDENTIAL: This e-mail and any attachments are confidential and intended solely for the use of the individual(s) to whom it is addressed. It can contain proprietary confidential information and be subject to legal privilege and/or subject to a non-disclosure Agreement. Unauthorized use, disclosure or copying is strictly prohibited. If you are not the/an addressee and are in possession of this e-mail, please delete the message and notify us immediately. Please consider the environment before printing this e-mail. Thank you.




Join to automatically receive all group messages.