DFU over UART

Hi,

I'm using nrf connect SDK 2.3.0  with custom board, Now, I would like to be able to upgrade the firmware of the board in future, The DFU procedure should be performed over UART.

Hardware setup :- UART pins(rx) of a board (with nrf52833 soc) is connected to laptop via UART TTL converter(COM7 port)

I was able locate this document online, make the necessary modifications, and installed the mcumgr module using the go module.

However, commands are not working, if i give this command "mcumgr --conntype serial --connstring "COM7,baud=115200" echo hello"  it's returning with "NMP TIMEOUT"

And this is my prj.confg file

#
# Copyright (c) 2018 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

# Enable the UART driver
CONFIG_UART_ASYNC_API=y
CONFIG_NRFX_UARTE0=y
CONFIG_SERIAL=y

CONFIG_GPIO=y

CONFIG_I2C=y
CONFIG_I2C_NRFX=y
CONFIG_CBPRINTF_FP_SUPPORT=y

CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_NVS=y
CONFIG_LOG_MODE_IMMEDIATE=n
CONFIG_NVS_LOG_LEVEL_DBG=n
CONFIG_REBOOT=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y

# CONFIG_TIMER=y
# CONFIG_TIMER_1=y
# CONFIG_SYSTEM_WORKQUEUE=y


# Make sure printk is printing to the UART console
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=n

CONFIG_HEAP_MEM_POOL_SIZE=2048

CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_APPEARANCE=833
CONFIG_BT_MAX_CONN=1
CONFIG_BT_MAX_PAIRED=1

# Enable the NUS service
CONFIG_BT_NUS=y

# Enable bonding
CONFIG_BT_SETTINGS=y
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_NVS=y
CONFIG_SETTINGS=y

# Enable DK LED and Buttons library
CONFIG_DK_LIBRARY=y

# This example requires more workqueue stack
# CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

# Config logger
CONFIG_LOG=n
CONFIG_USE_SEGGER_RTT=n
CONFIG_LOG_BACKEND_RTT=n
CONFIG_LOG_BACKEND_UART=n
CONFIG_LOG_PRINTK=n

CONFIG_NEWLIB_LIBC=y
CONFIG_NFCT_PINS_AS_GPIOS=y

CONFIG_ASSERT=n
CONFIG_BT_CTLR_PHY_CODED=y

# thej
CONFIG_BT_LL_SOFTDEVICE=y
CONFIG_BT_LL_SW_SPLIT=n
CONFIG_BT_CTLR_ADVANCED_FEATURES=y
CONFIG_BT_CTLR_CONN_RSSI=y
# CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL=y
# here
CONFIG_BT_CTLR_TX_PWR_ANTENNA=10
CONFIG_BT_USER_PHY_UPDATE=y

CONFIG_PM=y
CONFIG_NEWLIB_LIBC_MIN_REQUIRED_HEAP_SIZE=2048

CONFIG_MPSL_FEM=y
CONFIG_MPSL_FEM_NRF21540_GPIO=y
CONFIG_MPSL_FEM_PIN_FORWARDER=y

CONFIG_MPSL_FEM_NRF21540_TX_GAIN_DB_POUTA=10

# Enable mcumgr.
CONFIG_MCUMGR=y

# Enable most core commands.
CONFIG_MCUMGR_CMD_IMG_MGMT=y
CONFIG_MCUMGR_CMD_OS_MGMT=y

# Ensure an MCUboot-compatible binary is generated.
CONFIG_BOOTLOADER_MCUBOOT=y

# Enable the serial mcumgr transport.
CONFIG_MCUMGR_SMP_UART=y

# Disable UART Console and enable the RTT console
CONFIG_UART_CONSOLE=n
CONFIG_RTT_CONSOLE=y
CONFIG_USE_SEGGER_RTT=y

# Some command handlers require a large stack.
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096

Parents Reply Children
  • Hi, 

    I tried the your sample with "Hello world" application, I'm not able add "CONFIG_MCUMGR_TRANSPORT_UART=y and

    CONFIG_MCUMGR_GRP_IMG=y" in prj.config instead I added "CONFIG_MCUMGR_SMP_UART=y" and build it.
    However, the command "mcumgr --conntype serial --connstring "COM7" echo hello"   is not retuning "hello" and not getting timeout as error aswell, it just gives empty line like this
    "PS C:\hello_world> mcumgr --conntype serial --connstring "COM7" echo hello

    PS C:\hello_world> mcumgr --conntype serial --connstring "COM7" echo hello

    PS C:\hello_world>"

    I read somewhere like mcumgr uses uart0 for the image transfer, if that the case also custom board pins are as per the device tree file.
    prj.config file for your ref
    # nothing here
    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_MCUMGR=y
    # CONFIG_MCUMGR_TRANSPORT_UART=y
    # CONFIG_MCUMGR_GRP_IMG=y
    CONFIG_MCUMGR_SMP_UART=y
    
    # CONFIG_MCUMGR_TRANSPORT_UART dependencies
    CONFIG_BASE64=y
    
    # CONFIG_MCUMGR_GRP_IMG dependencies
    CONFIG_FLASH=y
    CONFIG_IMG_MANAGER=y
    
    # CONFIG_IMG_MANAGER dependencies
    CONFIG_STREAM_FLASH=y
    
    # CONFIG_MCUMGR dependencies
    CONFIG_NET_BUF=y
    CONFIG_ZCBOR=y
    
    # Required for CONFIG_IMG_MANAGER
    CONFIG_FLASH_MAP=y

    Where might it be going wrong?

  • Theja said:
    I tried the your sample with "Hello world" application, I'm not able add "CONFIG_MCUMGR_TRANSPORT_UART=y and

    Which sample? I sent 3 samples.

    Theja said:
    However, the command "mcumgr --conntype serial --connstring "COM7" echo hello"   is not retuning "hello" and not getting timeout as error aswell, it just gives empty line like this

    Echo is part of the OS Management group, so you must enable  CONFIG_MCUMGR_GRP_OS.

  • Thank you for your support, it's working after adding
    "CONFIG_MCUMGR_CMD_IMG_MGMT=y and CONFIG_MCUMGR_CMD_OS_MGMT=y"

    I also wanted to send a hex file rather than a bin file, but I tried using "zephyr.hex" and it didn't work. Could you please advise me?

  • Theja said:
    I also wanted to send a hex file rather than a bin file, but I tried using "zephyr.hex" and it didn't work. Could you please advise me?

    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/services/device_mgmt/mcumgr.html:

    "mcumgr does not understand .hex files, when uploading a new image always use the .bin file."

Related