Mcumgr to transfer file from host to nrf52840 device over uart

"I'm working with nRF Connect SDK v2.2.0 for nrf52840 and I'm trying to implement file transfer functionality using mcumgr over UART in Application. I've successfully configured and verified firmware upgrade using mcumgr in mcuboot , but now I need to transfer ordinary files, not firmware files in Application. Can you provide a step-by-step guide on how to set up and use mcumgr for transferring regular files over UART in nRF Connect SDK v2.2.0? 
And suggest any other method apart from using mcumgr to tranfer file from hos to nrf52840 over uart?
Here is my config

CONFIG_STDOUT_CONSOLE=y
CONFIG_USB_DEVICE_STACK=y

CONFIG_HEAP_MEM_POOL_SIZE=4096
CONFIG_MAIN_STACK_SIZE=24576
CONFIG_LOG=y 
CONFIG_USB_DRIVER_LOG_LEVEL_ERR=y
CONFIG_USB_DEVICE_LOG_LEVEL_ERR=y
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_LINE_CTRL=y
CONFIG_SPI=y
CONFIG_CBPRINTF_FP_SUPPORT=y


CONFIG_ENTROPY_GENERATOR=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_GPIO=y
CONFIG_PRINTK=y

CONFIG_RTT_CONSOLE=y
CONFIG_USE_SEGGER_RTT=y

CONFIG_NEWLIB_LIBC=y
CONFIG_PTHREAD_IPC=y
CONFIG_POSIX_API=y
CONFIG_MAX_PTHREAD_COUNT=20

CONFIG_TIMESLICING=y
CONFIG_TIMESLICE_SIZE=2


CONFIG_UART_CONSOLE=n 
#CONFIG_APP_WIPE_STORAGE=y

CONFIG_FILE_SYSTEM=y
CONFIG_FILE_SYSTEM_LITTLEFS=y

CONFIG_FLASH=y
CONFIG_FLASH_MAP=y
CONFIG_FLASH_PAGE_LAYOUT=y

CONFIG_NEWLIB_LIBC_NANO=n 

CONFIG_STDOUT_CONSOLE=y

CONFIG_NORDIC_QSPI_NOR=y

CONFIG_NCS_SAMPLES_DEFAULTS=y
CONFIG_BT=n # BT disabling completely
CONFIG_BT_PERIPHERAL=n # BT disabling completely

CONFIG_MCUMGR=y
CONFIG_MCUMGR_CMD_FS_MGMT=y
# CONFIG_MCUMGR_GRP_FS=Y

CONFIG_BASE64=y
CONFIG_FLASH=y
# CONFIG_IMG_MANAGER=y

CONFIG_NET_BUF=y
CONFIG_ZCBOR=y
CONFIG_FLASH_MAP=y
CONFIG_STREAM_FLASH=y
#CONFIG_MCUMGR_GRP_FS_FILE_ACCESS_HOOK=y
#MGMT_DEF_EVT_OP_ALL
# 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

# Allow for large Bluetooth data packets.
#CONFIG_BT_L2CAP_TX_MTU=252
#CONFIG_BT_BUF_ACL_RX_SIZE=256

# Allow for large Bluetooth data packets.
 # BT disabling completely
#CONFIG_BT_L2CAP_TX_MTU=498
#CONFIG_BT_BUF_ACL_RX_SIZE=502
#CONFIG_BT_BUF_ACL_TX_SIZE=502
#CONFIG_BT_CTLR_DATA_LENGTH_MAX=251

# Enable the Bluetooth (unauthenticated) and shell mcumgr transports.
CONFIG_MCUMGR_SMP_BT=n  # BT disabling completely
CONFIG_MCUMGR_SMP_BT_AUTHEN=n
CONFIG_MCUMGR_SMP_BT_CONN_PARAM_CONTROL=n  # BT disabling completely
CONFIG_MCUMGR_SMP_REASSEMBLY_BT=n # BT disabling completely
CONFIG_MCUMGR_BUF_SIZE=2475
#CONFIG_OS_MGMT_MCUMGR_PARAMS=y


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

# Enable file system commands
#CONFIG_MCUMGR_CMD_FS_MGMT=y


# Required by the `taskstat` command.
CONFIG_THREAD_MONITOR=y

# Enable logging
CONFIG_MCUBOOT_UTIL_LOG_LEVEL_WRN=y

CONFIG_MCUMGR_SMP_SHELL=y

CONFIG_LOG_MODE_IMMEDIATE=y
#SMP for UART
CONFIG_MCUMGR_SMP_UART=y


#To increase the UART/USB transfer speed for DFU Upload FW
CONFIG_CONSOLE_INPUT_MAX_LINE_LEN=1240
CONFIG_UART_MCUMGR_RX_BUF_SIZE=1240
Parents Reply Children
  • Hi Amanda,

    Thank you for your reply!

    I could be able to run the smp server, that you cited and able to transfer small files.
    My use case is to transfer 300kB of file to Filesystem, but It did not succeed. Even I tried low sized file, 108kB of file size, but it also failed with timeout.



    Here 

    mu.txt file size is 1kB

    mu108_kb.txt file size is108kB

    C:\Users\MK\Downloads\serial_upgrade>mcumgr --conntype serial --connstring "COM10,baud=115200" fs upload mu.txt /lfs1/mu.txt
    12
    Done

    C:\Users\MK\Downloads\serial_upgrade>mcumgr --conntype serial --connstring "COM10,baud=115200" fs upload mu108_kb.txt /lfs1/mu108_kb.txt
    Error: NMP timeout

    Any suggestion?

    Thanks,

    MK V

  • ++++
    In this exercise, i tried to determine the least number of characters in the file that I can transfer.

    Here the number of characters included in the file is 35, also same it showed it written 35 bytes in the console. 

    C:\Users\MK\Downloads\serial_upgrade>mcumgr --conntype serial --connstring "COM10,baud=115200" fs upload mu108_kb.txt /lfs1/mu108_kb.txt
    35
    Done

    Here after added extra one character to the mu108_kb.txt for successive cases.

    C:\Users\MK\Downloads\serial_upgrade>mcumgr --conntype serial --connstring "COM10,baud=115200" fs upload mu108_kb.txt /lfs1/mu108_kb.txt
    36
    Done

    C:\Users\MK\Downloads\serial_upgrade>mcumgr --conntype serial --connstring "COM10,baud=115200" fs upload mu108_kb.txt /lfs1/mu108_kb.txt
    37
    Done

    C:\Users\MK\Downloads\serial_upgrade>mcumgr --conntype serial --connstring "COM10,baud=115200" fs upload mu108_kb.txt /lfs1/mu108_kb.txt
    38
    Done

    C:\Users\MK\Downloads\serial_upgrade>mcumgr --conntype serial --connstring "COM10,baud=115200" fs upload mu108_kb.txt /lfs1/mu108_kb.txt
    Error: NMP timeout

    Maximum character I could transfer using mcumgr over UART is 38 bytes. 

    Could you elaborate me on this transfer limitation and What is the possibilities to transfers 500kB of file over uart using mcumgr on application?


    Thanks,

    MK V

Related