MCUboot won't boot into serial recovery mode by using retained memory

Hello!

I have an application using MCUboot and a single application slot. I want to use the Retention System to signal to MCUboot wether to boot normally or into serial recovery mode. I can write into the retained memory portion by using bootmode_set(BOOT_MODE_TYPE_NORMAL) or bootmode_set(BOOT_MODE_TYPE_BOOTLOADER). Within the application, this does write in the specified byte and keeps the value (0 or 1) over a sys_reboot().

However, regardless of the value in that memory, the bootloader never enters serial recovery mode but rather always boots normally.

As I am using a nRF52832 DK, I created an overlay for the retention boot mode:

/ {
    sram@2000FFFF {
            compatible = "zephyr,memory-region", "mmio-sram";
            reg = <0x2000FFFF 0x1>;
            zephyr,memory-region = "RetainedMem";
            status = "okay";

            retainedmem {
                    compatible = "zephyr,retained-ram";
                    status = "okay";
                    #address-cells = <1>;
                    #size-cells = <1>;

                    retention0: retention@0 {
                            compatible = "zephyr,retention";
                            status = "okay";
                            reg = <0x0 0x1>;
                    };
            };
    };

    chosen {
            zephyr,boot-mode = &retention0;
    };
};

/* Reduce SRAM0 usage by 1 byte to account for non-init area */
&sram0 {
    reg = <0x20000000 0xFFFF>;
};

The MCUboot config in .\child_image\mcuboot includes

CONFIG_SINGLE_APPLICATION_SLOT=y

# Enable Serial Recovery Mode to allow for DFU over UART
CONFIG_MCUBOOT_SERIAL=y
CONFIG_UART_CONSOLE=n
CONFIG_MCUBOOT_INDICATION_LED=y

# allow rebooting directly into the serial recovery mode
CONFIG_BOOT_SERIAL_BOOT_MODE=y

# To detect if the bootloader is running
CONFIG_BOOT_MGMT_ECHO=y 
# Will erase slot 0 if signature validation fails
CONFIG_BOOT_VALIDATE_SLOT0=y 
# Will stay in bootloader if no application is found (e.g. erased after image verification)
CONFIG_BOOT_SERIAL_NO_APPLICATION=y

# Use Retention system
CONFIG_RETAINED_MEM=y
CONFIG_RETENTION=y
CONFIG_RETENTION_BOOT_MODE=y

while the applications prj.conf includes

CONFIG_BOOTLOADER_MCUBOOT=y

CONFIG_RETAINED_MEM=y
CONFIG_RETENTION=y
CONFIG_RETAINED_MEM_ZEPHYR_RAM=y
CONFIG_RETENTION_BOOT_MODE=y

CONFIG_REBOOT=y

Now I found out, that while compiling, I get warnings in the MCUboot portion of the compile:

warning: BOOT_SERIAL_BOOT_MODE (defined at
C:/ncs/v2.6.1/bootloader/mcuboot/boot/zephyr\Kconfig.serial_recovery:166) was assigned the value 'y'
but got the value 'n'. Check these unsatisfied dependencies: RETENTION_BOOT_MODE (=n). See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_BOOT_SERIAL_BOOT_MODE and/or look up
BOOT_SERIAL_BOOT_MODE in the menuconfig/guiconfig interface. The Application Development Primer,
Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be
helpful too.

warning: RETENTION (defined at subsys/retention/Kconfig:4) was assigned the value 'y' but got the
value 'n'. Check these unsatisfied dependencies: DT_HAS_ZEPHYR_RETENTION_ENABLED (=n). See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_RETENTION and/or look up RETENTION in the
menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration Values,
and Kconfig - Tips and Best Practices sections of the manual might be helpful too.

warning: RETENTION_BOOT_MODE (defined at subsys/retention/Kconfig:46) was assigned the value 'y' but
got the value 'n'. Check these unsatisfied dependencies: RETENTION (=n). See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_RETENTION_BOOT_MODE and/or look up
RETENTION_BOOT_MODE in the menuconfig/guiconfig interface. The Application Development Primer,
Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be
helpful too.

These warnings ONLY appear in the MCUboot compile portion, NOT in the application compile portion.

Then, when I look at the build/zephyr/.config and build/mcuboot/zephyr/.config files, I can see that the application config includes the specified configurations, but the mcuboot config is missing all "RETAINED_MEM.." and "RETENTION..." configurations. I believe that this might cause the error, that mcuboot is not booting into the serial recovery mode.

Can you help me out here in any way? Did I miss something?

Thanks for your help!

Related