nRF5340 unable to enter MCUboot serial recovery mode via UART

I am trying to enter MCUboot serial recovery mode on an nRF5340 through a UART command.

I mainly followed the Nordic tutorial below:

https://academy.nordicsemi.com/courses/nrf-connect-sdk-intermediate/lessons/lesson-9-bootloaders-and-dfu-fota/topic/exercise-1-dfu-over-uart/

My goal is:

  • The application receives a specific UART command
  • The application sets bootloader mode
  • The device reboots
  • MCUboot enters serial recovery mode
  • Firmware update is performed through MCUmgr over UART

Below are my current configurations.

- prj.conf

CONFIG_FLASH=y 
CONFIG_FLASH_MAP=y 
CONFIG_NVS=y 
CONFIG_IMG_MANAGER=y 
CONFIG_STREAM_FLASH=y 
CONFIG_DFU_TARGET=y 
CONFIG_DFU_TARGET_MCUBOOT=y 

CONFIG_BOOTLOADER_MCUBOOT=y 

CONFIG_ZCBOR=y 
CONFIG_BASE64=y 
CONFIG_CRC=y 

CONFIG_MCUMGR=y 
CONFIG_MCUMGR_GRP_IMG=y 
CONFIG_MCUMGR_GRP_OS=y 
CONFIG_MCUMGR_GRP_STAT=y 
CONFIG_REBOOT=y 
CONFIG_RETENTION=y 
CONFIG_RETAINED_MEM=y 
CONFIG_RETENTION_BOOT_MODE=y

- sysbuild.conf

SB_CONFIG_BOOTLOADER_MCUBOOT=y

- sysbuild/mcuboot.conf

CONFIG_LOG=y

CONFIG_MCUBOOT_LOG_LEVEL_INF=y

CONFIG_SERIAL=n

CONFIG_CONSOLE=n

CONFIG_UART_CONSOLE=n

CONFIG_PRINTK=n

CONFIG_USE_SEGGER_RTT=n

CONFIG_MCUBOOT_SERIAL=y

CONFIG_MCUBOOT_INDICATION_LED=y

CONFIG_BOOT_SERIAL_UART=y
CONFIG_BOOT_SERIAL_BOOT_MODE=y

- sysbuild/mcuboot.overlay

/ { 
    chosen { 
        zephyr,uart-mcumgr = &uart0; 
    }; 
    
    aliases { 
        mcuboot-led0 = &led1; 
        mcuboot-button0 = &button0; 
    }; 
    
    leds { 
        compatible = "gpio-leds"; 
        led1: led_1 { 
            gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>; 
        }; 
    }; 
    
    buttons { 
        compatible = "gpio-keys"; 
        button0: button_0 { 
            gpios = <&gpio0 31 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; 
            label = "Power Switch"; 
        }; 
    }; //end buttons 
};

- app.overlay

/ { 
    chosen { 
        zephyr,console = &uart0; 
        zephyr,uart-mcumgr = &uart0; 
        zephyr,boot-mode = &boot_mode0; 
    }; 
};

- main.c

static void nrf53_reset_work_handler(struct k_work *work); 
K_WORK_DELAYABLE_DEFINE(nrf53_reset_work, nrf53_reset_work_handler);

static void nrf53_reset_work_handler(struct k_work *work) { 
    sys_reboot(SYS_REBOOT_WARM); 
} 

int main(void) { 
        ... 
        ret = bootmode_set(BOOT_MODE_TYPE_BOOTLOADER); 
        if (ret) { 
                printf("bootmode set failed: %d\r\n", ret); 
            } 
            
            if ((ret = bootmode_check(BOOT_MODE_TYPE_BOOTLOADER)) < 1) { 
                printf("bootmode check not set bootmode %d\r\n", ret); 
                break; 
            } 
            printf("bootmode start\r\n"); 
            k_work_reschedule(&nrf53_reset_work, K_NO_WAIT); 
    ... 
}

Current behavior

After rebooting, I connect using AuTerm over UART and open:

MCUmgr → Images → Go

When I press the Go button, the following data appears repeatedly on the UART terminal:

\06	AAsIAAABAAEBAKCYMQ==
\06	AAsAAAABAAEBAKCxzg==
\06	AAsIAAABAAEBAKCYMQ==
\06	AAsAAAABAAEBAKCxzg==

However, MCUmgr always times out.

Expected behavior

I expected MCUboot serial recovery mode to respond correctly and allow image upload through MCUmgr over UART.

Questions

  1. Is my boot mode configuration correct for entering MCUboot serial recovery mode?
  2. Do I need additional configurations related to:
    • CONFIG_MCUMGR_TRANSPORT_UART
    • CONFIG_UART_MCUMGR
    • zephyr,boot-mode
    • retained memory
    • UART ownership between app and MCUboot
  3. Is there something incorrect in my MCUboot UART configuration?
  4. The repeated Base64-like strings appear when pressing the MCUmgr button. Does this indicate that:
    • the PC is transmitting correctly,
    • but MCUboot is not responding?
  5. Are there additional required settings for nRF5340 specifically when using MCUboot serial recovery over UART?

Any advice would be appreciated.

Parents
  • Hello,

    There is a significant difference between "DFU over UART" and "Serial Recovery". Serial recovery is a single bank DFU, meaning it doesn't contain any images. That said, it does have the old application, until you try to upload a new one, but because of the nature of the single bank "Serial Recovery" bootloader, it is not set up to reply with a list of images, like it is in the "DFU over UART" bootloader. 

    You can, however, enable this. Please see:

    https://github.com/nrfconnect/sdk-mcuboot/blob/main/boot/zephyr/Kconfig.serial_recovery#L211

    If you enable this, then it should reply when you try to read the image list. (But you should consider whether you need this or not, in a serial recovery bootloader).

    You should also check that you are using the correct UART instance (The DK has two). 

    Best regards,

    Edvin

  • Thank you, Edvin.

    The issue was resolved by adding the UART pin configuration to sysbuild/mcuboot.overlay.

    MCUboot was using a different UART instance/pin configuration than the application, so mcumgr packets were being sent to the wrong UART.

    After explicitly configuring the UART pins and adding:

    &uart0 {
        status = "okay";
        current-speed = <115200>;
        pinctrl-0 = <&uart0_default>;
        pinctrl-1 = <&uart0_sleep>;
        pinctrl-names = "default", "sleep";
    };

    &pinctrl {

        uart0_default: uart0_default {
            group1 {
                psels = <NRF_PSEL(UART_TX, 1, 4)>; /* Change to your desired TX pin */
            };
            group2 {
                psels = <NRF_PSEL(UART_RX, 1, 5)>; /* Change to your desired RX pin */
                bias-pull-up;
            };
        };

        uart0_sleep: uart0_sleep {
            group1 {
                psels = <NRF_PSEL(UART_TX, 1, 4)>,
                             <NRF_PSEL(UART_RX, 1, 5)>;
                low-power-enable;
             };
         };
    };

    in the MCUboot overlay, serial recovery started working correctly and image upload succeeded.

    Thank you for the help.

Reply
  • Thank you, Edvin.

    The issue was resolved by adding the UART pin configuration to sysbuild/mcuboot.overlay.

    MCUboot was using a different UART instance/pin configuration than the application, so mcumgr packets were being sent to the wrong UART.

    After explicitly configuring the UART pins and adding:

    &uart0 {
        status = "okay";
        current-speed = <115200>;
        pinctrl-0 = <&uart0_default>;
        pinctrl-1 = <&uart0_sleep>;
        pinctrl-names = "default", "sleep";
    };

    &pinctrl {

        uart0_default: uart0_default {
            group1 {
                psels = <NRF_PSEL(UART_TX, 1, 4)>; /* Change to your desired TX pin */
            };
            group2 {
                psels = <NRF_PSEL(UART_RX, 1, 5)>; /* Change to your desired RX pin */
                bias-pull-up;
            };
        };

        uart0_sleep: uart0_sleep {
            group1 {
                psels = <NRF_PSEL(UART_TX, 1, 4)>,
                             <NRF_PSEL(UART_RX, 1, 5)>;
                low-power-enable;
             };
         };
    };

    in the MCUboot overlay, serial recovery started working correctly and image upload succeeded.

    Thank you for the help.

Children
No Data
Related