Need some help with CONFIG_UART_CONSOLE_MCUMGR

I'm doing a project for adding a Bluetooth capability to an embedded Linux device. The Linux master talks to the nRF52840-based Bluetooth module via a dedicated serial (UART) link. I've got a console feature on the BT module such that the Linux master can send commands and receive responses in plain old ASCII.

I'm at the point of trying to implement DFU, which in the Zephyr world means SMP and MCUMGR. Ultimately, I'm going to want SMP running in the application so that a file can be sent to the BT module (a Central) to perform BT DFU with a Peripheral device. For now, I'm starting with the SMP in MCUboot as described in the blog devzone.nordicsemi.com/.../device-firmware-update-dfu-with-mcuboot-bootloader. In this case, the serial port is the USB CDC ACM feature.

In my development and test activities, I'm using a nRF52840 DK.

I followed the instructions from "Add DFU support to your application" (devzone.nordicsemi.com/.../ncs-dfu). With the log messages coming through RTT, it works.

I had elsewhere seen mention of CONFIG_UART_CONSOLE_MCUMGR, and the guide article states, "Another option is to use the configs from smp_svr/overlay-serial-console.config to enable the UART console with mcumgr pass through". Well, the smp_svr example does indeed have an overlay_serial_console.conf file, although there's nothing in the instructions to explain how to use it or test the result. So I merge the contents of overlay_serial_console.conf into the prj.conf from the instructions. Here's the diff between the config files:
$ diff prj_serial_dfu.conf prj.conf
21a22
> CONFIG_UART_CONSOLE_MCUMGR=y
23a25,26
> CONFIG_CONSOLE_SUBSYS=y
> CONFIG_CONSOLE_GETLINE=y
26,28c29,31
< CONFIG_UART_CONSOLE=n
< CONFIG_RTT_CONSOLE=y
< CONFIG_USE_SEGGER_RTT=y
---
> CONFIG_UART_CONSOLE=y
> #CONFIG_RTT_CONSOLE=y
> #CONFIG_USE_SEGGER_RTT=y

And here's overlay_serial_console.conf:
# Enable USB subsystem
CONFIG_USB_DEVICE_STACK=y
CONFIG_SERIAL=y
CONFIG_UART_LINE_CTRL=y
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n
CONFIG_CONSOLE=y
# USB backend is serial device
CONFIG_MCUMGR_TRANSPORT_UART=y
CONFIG_BASE64=y
CONFIG_CRC=y

I can build and flash it, and the console part works, but mcumgr can't talk to it. I have to shut off the terminal for console I/O because the system won't share the COM port (and mcumgr complains "Error: Access is denied". After I kill the terminal and try again, mcumgr waits several seconds and then complains "Error: NMP timeout". I conclude that the SMP server isn't really listening through the console port, and there's something more to using CONFIG_UART_CONSOLE_MCUMGR.

Related