Topics

DFU over UART #nrf52832


gurpreet+zephy@...
 

Hi,

I'm trying to build an app that can be upgraded over UART. I see the smp_svr sample has an example of doing this over BT, and I could get that to work.
I've tweaked the prj.conf to add the line 
CONFIG_MCUMGR_SMP_UART=y

I've also disabled CONFIG_MCUMGR_SMP_BT just to prevent things from getting confusing. 

My nrf52 has an mcuboot which was obtained from https://github.com/runtimeco/mcuboot
I then sign and build my modified smp_svr image and then flash it to the device. 

I see the following on console
***** Booting Zephyr OS zephyr-v1.13.0-6-g497974b8b *****
Zephyr Shell, Zephyr version: 1.13.0
Type 'help' for a list of available commands
shell> Bluetooth initialized
Advertising failed to start (rc -5)

the console, however is read only - I cant access the shell. This is all on the nRF52 dev board.
I'm using Ubuntu 18.04 as my host environment. 

My questions:
1. Is there some step I'm missing to allow device upgrades over UART? 
2. Do I need to do anything in particular for 2-way access to the shell

For reference, my prj.conf is:
# Enable mcumgr.
CONFIG_MCUMGR=y
 
# Some command handlers require a large stack.
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
 
# Ensure an MCUboot-compatible binary is generated.
CONFIG_BOOTLOADER_MCUBOOT=y
 
# Allow for large Bluetooth data packets.
CONFIG_BT_L2CAP_TX_MTU=260
CONFIG_BT_RX_BUF_LEN=260
 
# Enable the Bluetooth and shell mcumgr transports.
#CONFIG_MCUMGR_SMP_BT=y
CONFIG_MCUMGR_SMP_SHELL=y
CONFIG_MCUMGR_SMP_UART=y
 
# Bluetooth support requires a net_buf user_data size >= 7.
CONFIG_NET_BUF_USER_DATA_SIZE=7
 
# Enable flash operations.
CONFIG_FLASH=y
 
# Enable the NFFS file system.
CONFIG_FILE_SYSTEM=y
CONFIG_FILE_SYSTEM_NFFS=y
 
# Required by the `taskstat` command.
CONFIG_THREAD_MONITOR=y
 
# Enable statistics and statistic names.
CONFIG_STATS=y
CONFIG_STATS_NAMES=y
 
# Enable all core commands.
CONFIG_MCUMGR_CMD_FS_MGMT=y
CONFIG_MCUMGR_CMD_IMG_MGMT=y
CONFIG_MCUMGR_CMD_OS_MGMT=y
CONFIG_MCUMGR_CMD_STAT_MGMT=y
 
### nRF5 specific settings
 
# Specify the location of the NFFS file system.
CONFIG_FS_NFFS_FLASH_DEV_NAME="NRF_FLASH_DRV_NAME"
Thanks in advance..
Gurpreet 


Carles Cufi
 

Hi there,

 

I believe that if you enable DFU over serial then the shell is not available, because the protocol takes over.

I’ve added Andrzej on copy.

 

Carles

 

From: users@... <users@...> On Behalf Of gurpreet+zephy@...
Sent: 05 November 2018 18:47
To: users@...
Subject: [Zephyr-users] DFU over UART #nrf52832

 

Hi,

I'm trying to build an app that can be upgraded over UART. I see the smp_svr sample has an example of doing this over BT, and I could get that to work.
I've tweaked the prj.conf to add the line 
CONFIG_MCUMGR_SMP_UART=y

I've also disabled CONFIG_MCUMGR_SMP_BT just to prevent things from getting confusing. 

My nrf52 has an mcuboot which was obtained from https://github.com/runtimeco/mcuboot
I then sign and build my modified smp_svr image and then flash it to the device. 

I see the following on console

***** Booting Zephyr OS zephyr-v1.13.0-6-g497974b8b *****

Zephyr Shell, Zephyr version: 1.13.0

Type 'help' for a list of available commands

shell> Bluetooth initialized

Advertising failed to start (rc -5)


the console, however is read only - I cant access the shell. This is all on the nRF52 dev board.
I'm using Ubuntu 18.04 as my host environment. 

My questions:
1. Is there some step I'm missing to allow device upgrades over UART? 
2. Do I need to do anything in particular for 2-way access to the shell

For reference, my prj.conf is:

# Enable mcumgr.

CONFIG_MCUMGR=y

 

# Some command handlers require a large stack.

CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

 

# Ensure an MCUboot-compatible binary is generated.

CONFIG_BOOTLOADER_MCUBOOT=y

 

# Allow for large Bluetooth data packets.

CONFIG_BT_L2CAP_TX_MTU=260

CONFIG_BT_RX_BUF_LEN=260

 

# Enable the Bluetooth and shell mcumgr transports.

#CONFIG_MCUMGR_SMP_BT=y

CONFIG_MCUMGR_SMP_SHELL=y

CONFIG_MCUMGR_SMP_UART=y

 

# Bluetooth support requires a net_buf user_data size >= 7.

CONFIG_NET_BUF_USER_DATA_SIZE=7

 

# Enable flash operations.

CONFIG_FLASH=y

 

# Enable the NFFS file system.

CONFIG_FILE_SYSTEM=y

CONFIG_FILE_SYSTEM_NFFS=y

 

# Required by the `taskstat` command.

CONFIG_THREAD_MONITOR=y

 

# Enable statistics and statistic names.

CONFIG_STATS=y

CONFIG_STATS_NAMES=y

 

# Enable all core commands.

CONFIG_MCUMGR_CMD_FS_MGMT=y

CONFIG_MCUMGR_CMD_IMG_MGMT=y

CONFIG_MCUMGR_CMD_OS_MGMT=y

CONFIG_MCUMGR_CMD_STAT_MGMT=y

 

### nRF5 specific settings

 

# Specify the location of the NFFS file system.

CONFIG_FS_NFFS_FLASH_DEV_NAME="NRF_FLASH_DRV_NAME"

Thanks in advance..
Gurpreet 


Puzdrowski, Andrzej <Andrzej.Puzdrowski@...>
 

I believe that uart and BT channel are available out of the box for this sample. Uart is shared between SMP protocol and the Shell thank to CONFIG_MCUMGR_SMP_SHELL=y.

If you switch of this option the you need to enable SMP serial on its own (so CONFIG_MCUMGR_SMP_UART=y) and disable uart as shell channel.

 

From: Cufi, Carles
Sent: Tuesday, November 06, 2018 12:07 PM
To: gurpreet+zephy@...; users@...; Puzdrowski, Andrzej <Andrzej.Puzdrowski@...>
Subject: RE: [Zephyr-users] DFU over UART #nrf52832

 

Hi there,

 

I believe that if you enable DFU over serial then the shell is not available, because the protocol takes over.

I’ve added Andrzej on copy.

 

Carles

 

From: users@... <users@...> On Behalf Of gurpreet+zephy@...
Sent: 05 November 2018 18:47
To: users@...
Subject: [Zephyr-users] DFU over UART #nrf52832

 

Hi,

I'm trying to build an app that can be upgraded over UART. I see the smp_svr sample has an example of doing this over BT, and I could get that to work.
I've tweaked the prj.conf to add the line 
CONFIG_MCUMGR_SMP_UART=y

I've also disabled CONFIG_MCUMGR_SMP_BT just to prevent things from getting confusing. 

My nrf52 has an mcuboot which was obtained from https://github.com/runtimeco/mcuboot
I then sign and build my modified smp_svr image and then flash it to the device. 

I see the following on console

***** Booting Zephyr OS zephyr-v1.13.0-6-g497974b8b *****

Zephyr Shell, Zephyr version: 1.13.0

Type 'help' for a list of available commands

shell> Bluetooth initialized

Advertising failed to start (rc -5)


the console, however is read only - I cant access the shell. This is all on the nRF52 dev board.
I'm using Ubuntu 18.04 as my host environment. 

My questions:
1. Is there some step I'm missing to allow device upgrades over UART? 
2. Do I need to do anything in particular for 2-way access to the shell

For reference, my prj.conf is:

# Enable mcumgr.

CONFIG_MCUMGR=y

 

# Some command handlers require a large stack.

CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

 

# Ensure an MCUboot-compatible binary is generated.

CONFIG_BOOTLOADER_MCUBOOT=y

 

# Allow for large Bluetooth data packets.

CONFIG_BT_L2CAP_TX_MTU=260

CONFIG_BT_RX_BUF_LEN=260

 

# Enable the Bluetooth and shell mcumgr transports.

#CONFIG_MCUMGR_SMP_BT=y

CONFIG_MCUMGR_SMP_SHELL=y

CONFIG_MCUMGR_SMP_UART=y

 

# Bluetooth support requires a net_buf user_data size >= 7.

CONFIG_NET_BUF_USER_DATA_SIZE=7

 

# Enable flash operations.

CONFIG_FLASH=y

 

# Enable the NFFS file system.

CONFIG_FILE_SYSTEM=y

CONFIG_FILE_SYSTEM_NFFS=y

 

# Required by the `taskstat` command.

CONFIG_THREAD_MONITOR=y

 

# Enable statistics and statistic names.

CONFIG_STATS=y

CONFIG_STATS_NAMES=y

 

# Enable all core commands.

CONFIG_MCUMGR_CMD_FS_MGMT=y

CONFIG_MCUMGR_CMD_IMG_MGMT=y

CONFIG_MCUMGR_CMD_OS_MGMT=y

CONFIG_MCUMGR_CMD_STAT_MGMT=y

 

### nRF5 specific settings

 

# Specify the location of the NFFS file system.

CONFIG_FS_NFFS_FLASH_DEV_NAME="NRF_FLASH_DRV_NAME"

Thanks in advance..
Gurpreet 


Puzdrowski, Andrzej <Andrzej.Puzdrowski@...>
 

Bellow the minimal config I used. As you can see I disabled channel sharing between shell and SMP. Shell is switched to RTT.

 

CONFIG_SOC_SERIES_NRF52X=y

CONFIG_SOC_NRF52840_QIAA=y

CONFIG_ARM_MPU=y

CONFIG_ARM=y

CONFIG_THREAD_MONITOR=y

CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

CONFIG_CONSOLE=y

CONFIG_RTT_CONSOLE=y

CONFIG_SERIAL=y

CONFIG_UART_NRFX=y

CONFIG_UART_0_NRF_UART=y

CONFIG_ENTROPY_NRF5_THR_THRESHOLD=4

CONFIG_ENTROPY_NRF5_ISR_THRESHOLD=12

CONFIG_ENTROPY_NRF5_THR_BUF_LEN=4

CONFIG_ENTROPY_NRF5_ISR_BUF_LEN=12

CONFIG_STATS=y

CONFIG_STATS_NAMES=y

CONFIG_BOOTLOADER_MCUBOOT=y

CONFIG_BT_RX_BUF_LEN=260

CONFIG_BT_L2CAP_TX_MTU=260

CONFIG_BT_CTLR=y

CONFIG_FILE_SYSTEM=y

CONFIG_FILE_SYSTEM_NFFS=y

CONFIG_FS_NFFS_FLASH_DEV_NAME="NRF_FLASH_DRV_NAME"

CONFIG_MCUMGR_SMP_BT=y

CONFIG_MCUMGR_SMP_UART=y

CONFIG_NET_BUF_USER_DATA_SIZE=7

CONFIG_CONSOLE_SHELL=y

CONFIG_MCUMGR_CMD_FS_MGMT=y

CONFIG_MCUMGR_CMD_IMG_MGMT=y

CONFIG_MCUMGR_CMD_OS_MGMT=y

CONFIG_MCUMGR_CMD_STAT_MGMT=y

 

From: Puzdrowski, Andrzej
Sent: Tuesday, November 06, 2018 12:32 PM
To: Cufi, Carles <Carles.Cufi@...>; gurpreet+zephy@...; users@...
Subject: RE: [Zephyr-users] DFU over UART #nrf52832

 

I believe that uart and BT channel are available out of the box for this sample. Uart is shared between SMP protocol and the Shell thank to CONFIG_MCUMGR_SMP_SHELL=y.

If you switch of this option the you need to enable SMP serial on its own (so CONFIG_MCUMGR_SMP_UART=y) and disable uart as shell channel.

 

From: Cufi, Carles
Sent: Tuesday, November 06, 2018 12:07 PM
To: gurpreet+zephy@...; users@...; Puzdrowski, Andrzej <Andrzej.Puzdrowski@...>
Subject: RE: [Zephyr-users] DFU over UART #nrf52832

 

Hi there,

 

I believe that if you enable DFU over serial then the shell is not available, because the protocol takes over.

I’ve added Andrzej on copy.

 

Carles

 

From: users@... <users@...> On Behalf Of gurpreet+zephy@...
Sent: 05 November 2018 18:47
To: users@...
Subject: [Zephyr-users] DFU over UART #nrf52832

 

Hi,

I'm trying to build an app that can be upgraded over UART. I see the smp_svr sample has an example of doing this over BT, and I could get that to work.
I've tweaked the prj.conf to add the line 
CONFIG_MCUMGR_SMP_UART=y

I've also disabled CONFIG_MCUMGR_SMP_BT just to prevent things from getting confusing. 

My nrf52 has an mcuboot which was obtained from https://github.com/runtimeco/mcuboot
I then sign and build my modified smp_svr image and then flash it to the device. 

I see the following on console

***** Booting Zephyr OS zephyr-v1.13.0-6-g497974b8b *****

Zephyr Shell, Zephyr version: 1.13.0

Type 'help' for a list of available commands

shell> Bluetooth initialized

Advertising failed to start (rc -5)


the console, however is read only - I cant access the shell. This is all on the nRF52 dev board.
I'm using Ubuntu 18.04 as my host environment. 

My questions:
1. Is there some step I'm missing to allow device upgrades over UART? 
2. Do I need to do anything in particular for 2-way access to the shell

For reference, my prj.conf is:

# Enable mcumgr.

CONFIG_MCUMGR=y

 

# Some command handlers require a large stack.

CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

 

# Ensure an MCUboot-compatible binary is generated.

CONFIG_BOOTLOADER_MCUBOOT=y

 

# Allow for large Bluetooth data packets.

CONFIG_BT_L2CAP_TX_MTU=260

CONFIG_BT_RX_BUF_LEN=260

 

# Enable the Bluetooth and shell mcumgr transports.

#CONFIG_MCUMGR_SMP_BT=y

CONFIG_MCUMGR_SMP_SHELL=y

CONFIG_MCUMGR_SMP_UART=y

 

# Bluetooth support requires a net_buf user_data size >= 7.

CONFIG_NET_BUF_USER_DATA_SIZE=7

 

# Enable flash operations.

CONFIG_FLASH=y

 

# Enable the NFFS file system.

CONFIG_FILE_SYSTEM=y

CONFIG_FILE_SYSTEM_NFFS=y

 

# Required by the `taskstat` command.

CONFIG_THREAD_MONITOR=y

 

# Enable statistics and statistic names.

CONFIG_STATS=y

CONFIG_STATS_NAMES=y

 

# Enable all core commands.

CONFIG_MCUMGR_CMD_FS_MGMT=y

CONFIG_MCUMGR_CMD_IMG_MGMT=y

CONFIG_MCUMGR_CMD_OS_MGMT=y

CONFIG_MCUMGR_CMD_STAT_MGMT=y

 

### nRF5 specific settings

 

# Specify the location of the NFFS file system.

CONFIG_FS_NFFS_FLASH_DEV_NAME="NRF_FLASH_DRV_NAME"

Thanks in advance..
Gurpreet 


gurpreet+zephy@...
 

Thanks Andrzej and Carles. 
I tried these steps but had some compiler errors with 
CONFIG_SOC_NRF52840_QIAA=y
enabled.
warning: the value '' is invalid for UART_0_NRF_TX_PIN (defined at /home/gps/src/zephyr/boards/arm/nrf52_pca10040/Kconfig.defconfig:14, drivers/serial/Kconfig.nrfx:62), which has type int -- assignment ignored
 
warning: the value '' is invalid for UART_0_NRF_RX_PIN (defined at /home/gps/src/zephyr/boards/arm/nrf52_pca10040/Kconfig.defconfig:17, drivers/serial/Kconfig.nrfx:69), which has type int -- assignment ignored
 
Error: Aborting due to non-whitelisted Kconfig warning 'warning: the value '' is invalid for
UART_0_NRF_TX_PIN (defined at /home/gps/src/zephyr/boards/arm/nrf52_pca10040/Kconfig.defconfig:14,
drivers/serial/Kconfig.nrfx:62), which has type int -- assignment ignored'. Note: If this warning
Once I disabled this, the code successfully compiled. I then proceeded to add a serial interface to mcumgr as follows:
>mcumgr conn show
Connection profiles: 
  myserial-nrf: type=serial, connstring='dev=/dev/ttyACM0,baud=115200'

But when i try to run it, there is a timeout. 
>mcumgr -c "myserial-nrf" image list
Error: NMP timeout
 
Note, the same command works with BLE. 

>mcumgr --conntype ble --connstring 'peer_name=Zephyr' image list 
Images:
 slot=0
    version: 1.2.0
    bootable: true
    flags: active confirmed
    hash: 5d0888224321f9734009ab06a0b11c76e5f0303baaad421534f99de590ec0123
Split status: N/A (0)

Any thoughts on what I may be doing wrong here? 

Thanks in advance,
Gurpreet 


gurpreet+zephy@...
 

I've made some progress.
Once I get the device in serial mode I am able to start the mcumgr upload, but it constantly times out.

The RTT output from the dev board:
***** Booting Zephyr OS zephyr-v1.13.0-49-g121f323de *****
[MCUBOOT] [INF] main: Enter the serial recovery mode
[MCUBOOT] [INF] boot_serial_output: TX


And the mcumgr logs with debug ON:

zephyr (dfu_expt) 15:22:55>mcumgr -ldebug -t 60 --conntype=serial --connstring='dev=/dev/ttyACM0,baud=115200' image upload signed-hello1.bin
DEBU[2018-11-12 15:23:01.044] Using connection profile: name=unnamed type=serial connstring=dev=/dev/ttyACM0,baud=115200 
DEBU[2018-11-12 15:23:01.044] {add-oic-listener} [transceiver.go:64] token=[] 
DEBU[2018-11-12 15:23:01.044] {add-oic-listener} [transceiver.go:64] token=[] 
 0 / 47864 [---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------]   0.00%DEBU[2018-11-12 15:23:01.044] {add-nmp-listener} [serial_sesn.go:217] seq=66 
DEBU[2018-11-12 15:23:01.045] Encoded &{NmpBase:{hdr:{Op:2 Flags:0 Len:0 Group:1 Seq:66 Id:5}}} to:
00000000  a0                                                |.| 
DEBU[2018-11-12 15:23:01.045] Encoded:
00000000  02 00 00 01 00 01 42 05  a0                       |......B..| 
DEBU[2018-11-12 15:23:01.045] Tx NMP request: 00000000  02 00 00 01 00 01 42 05  a0                       |......B..| 
DEBU[2018-11-12 15:23:01.045] Base64 encoding request:
00000000  02 00 00 01 00 01 42 05  a0                       |......B..| 
DEBU[2018-11-12 15:23:01.045] Tx serial
00000000  06 09                                             |..| 
DEBU[2018-11-12 15:23:01.045] Tx serial
00000000  41 41 73 43 41 41 41 42  41 41 46 43 42 61 44 4d  |AAsCAAABAAFCBaDM|
00000010  6f 51 3d 3d                                       |oQ==| 
DEBU[2018-11-12 15:23:01.045] Tx serial
00000000  0a                                                |.| 
DEBU[2018-11-12 15:23:01.053] Rx serial:
00000000  06 09 41 42 41 44 41 41  41 47 41 41 46 34 65 44  |..ABADAAAGAAF4eD| 
 0 B / 46.74 KiB [----------------]   0.00%
DEBU[2018-11-12 15:23:28.019] Rx serial:                                   
 0 B / 46.74 KiB [----------------]   0.00%

This shows that the initial frame seems to be sent (as per https://github.com/apache/mynewt-mcumgr/blob/master/transport/smp-console.md#overview), but mcumgr fails to send the remaining bytes. 

Is there something I'm missing? 

-Gurpreet 


gurpreet+zephy@...
 

I tried this with v1.2.0 of mcuboot, as well as the latest master code.