I am trying to enter MCUboot serial recovery mode on an nRF5340 through a UART command.
I mainly followed the Nordic tutorial below:
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
- Is my boot mode configuration correct for entering MCUboot serial recovery mode?
- Do I need additional configurations related to:
CONFIG_MCUMGR_TRANSPORT_UARTCONFIG_UART_MCUMGRzephyr,boot-mode- retained memory
- UART ownership between app and MCUboot
- Is there something incorrect in my MCUboot UART configuration?
- 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?
- Are there additional required settings for nRF5340 specifically when using MCUboot serial recovery over UART?
Any advice would be appreciated.