mcu-tools / mcuboot

Secure boot for 32-bit Microcontrollers!
Apache License 2.0
1.25k stars 648 forks source link

zephyr: Swap using scratch does not boot #1761

Closed de-nordic closed 11 months ago

de-nordic commented 11 months ago

Seems that building Zephyr version of MCUboot with CONFIG_BOOT_SWAP_USING_SCRATCH does not work. I have tried to build it for nrf52840dk_nrf52840 with overlay:

/* Replace storage_partition with scratch partition */
/delete-node/ &storage_partition;

&flash0 {

        partitions {
                scratch_partition: partition@f8000 {
                        label = "scratch";
                        reg = <0x000f8000 0x00008000>;
                };
        };
};

and uploaded binary does nothing. Added CONFIG_MCUBOOT_LOG_LEVEL_DBG_INF but MCUboot prints nothing, just looks like not doing anything. When engaged debugger then there is output visible on screen and it seems that MCUboot can not find bootable image, even though the same image used for testing it boots fine when using move algorithm.

I have found out that actually sole addition of the overlay breaks scratch, for example:

west build -d voot_move_no_dts -b nrf52840dk_nrf52840 bootloader/mcuboot/boot/zephyr/  -DCONFIG_MCUBOOT_LOG_LEVEL_DBG=y  -DCONFIG_BOOT_SWAP_USING_MOVE=y

will build MCUboot that is able to boot some image, and prints info to console while

west build -d voot_move -b nrf52840dk_nrf52840 bootloader/mcuboot/boot/zephyr/  -DCONFIG_MCUBOOT_LOG_LEVEL_DBG=y -DDTC_OVERLAY_FILE=$PWD/nrf52840dk_nrf52840_scratch.overlay -DCONFIG_BOOT_SWAP_USING_MOVE=y

where overlay is the one listed above, is broken.

This problem appears at list till 1.10.0 and is present at 61898dad92b8d9c29409a07e2f4dae9553145ccf

de-nordic commented 11 months ago

This may be problem with MCUboot using overlay already and the new overlay just discarding the original one.

de-nordic commented 11 months ago

Tested, not a problem