This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF5340 FOTA upgrade over Bluetooth

I couldn't launch FOTA upgrade over Bluetooth for nRF5340 PDK. I followed this guide developer.nordicsemi.com/.../ug_nrf5340.html to fulfil FOTA upgrade for nRF5340 PDK. I used /home/roman/nordic/ncs/zephyr/samples/subsys/mgmt/mcumgr/smp_svr sample and modified it according to the guide (merely added CONFIG_MCUMGR_SMP_BT=y in prj.conf file). I built this sample and flashed it to nRF5340. A added a minor change to print new line and built it again. I uploaded a file /home/roman/SeggerProjects/smp_svr/build_nrf5340pdk_nrf5340_cpuapp/zephyr/app_update.bin to a mobile phone. After that, I launched an app nRF Connect for Mobile, connected to nRF5340 PDK (Zephyr). See screenshots.


I opened DFU, located uploaded app_update.bin and selected Test and Confirm option.

And after it, I only saw the next screen:

You can see a Log file from nRF Connect for Mobile:

nRF Connect, 2020-07-07
Zephyr (EB:F6:DA:7F:DA:51)
V	11:07:33.807	Connecting to EB:F6:DA:7F:DA:51...
D	11:07:33.807	gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferred PHY = LE 1M)
D	11:07:35.281	[Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
I	11:07:35.281	Connected to EB:F6:DA:7F:DA:51
D	11:07:35.285	[Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
D	11:07:35.307	wait(1600ms)
V	11:07:36.910	Discovering services...
D	11:07:36.910	gatt.discoverServices()
D	11:07:36.929	[Callback] Services discovered with status: 0
I	11:07:36.929	Services discovered
V	11:07:36.949	Generic Attribute (0x1801)
- Service Changed [I] (0x2A05)
   Client Characteristic Configuration (0x2902)
- Client Supported Features [R W] (0x2B29)
- Database Hash [R] (0x2B2A)
Generic Access (0x1800)
- Device Name [R] (0x2A00)
- Appearance [R] (0x2A01)
- Peripheral Preferred Connection Parameters [R] (0x2A04)
SMP Service (8d53dc1d-1db7-4cd3-868b-8a527460aa84)
- SMP Characteristic [N WNR] (da2e7828-fbce-4e01-ae9e-261174997c48)
   Client Characteristic Configuration (0x2902)
D	11:07:36.950	gatt.setCharacteristicNotification(00002a05-0000-1000-8000-00805f9b34fb, true)
I	11:07:40.131	Connection parameters updated (interval: 45.0ms, latency: 0, timeout: 420ms)
V	11:08:02.048	[McuMgr] Connecting...
D	11:08:02.051	[McuMgr] gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, LE 1M)
D	11:08:02.117	[McuMgr] [Callback] Connection state changed with status: 0 and new state: 2 (CONNECTED)
I	11:08:02.122	[McuMgr] Connected to EB:F6:DA:7F:DA:51
D	11:08:02.125	[McuMgr] wait(1600)
V	11:08:03.733	[McuMgr] Discovering services...
D	11:08:03.759	[McuMgr] gatt.discoverServices()
I	11:08:03.802	[McuMgr] Services discovered
V	11:08:03.819	[McuMgr] Primary service found
I	11:08:03.826	[McuMgr] Service Changed characteristic found on a bonded device
D	11:08:03.831	[McuMgr] gatt.setCharacteristicNotification(00002a05-0000-1000-8000-00805f9b34fb, true)
V	11:08:03.836	[McuMgr] Enabling indications for 00002a05-0000-1000-8000-00805f9b34fb
D	11:08:03.849	[McuMgr] gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x02-00)
I	11:08:03.936	[McuMgr] Data written to descr. 00002902-0000-1000-8000-00805f9b34fb, value: (0x) 02-00
I	11:08:03.961	[McuMgr] Service Changed notifications enabled
V	11:08:03.965	[McuMgr] Requesting new MTU...
D	11:08:03.968	[McuMgr] gatt.requestMtu(515)
I	11:08:04.027	[McuMgr] MTU changed to: 65
D	11:08:04.031	[McuMgr] gatt.setCharacteristicNotification(da2e7828-fbce-4e01-ae9e-261174997c48, true)
V	11:08:04.035	[McuMgr] Enabling notifications for da2e7828-fbce-4e01-ae9e-261174997c48
D	11:08:04.037	[McuMgr] gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x01-00)
I	11:08:04.657	Connection parameters updated (interval: 7.5ms, latency: 0, timeout: 5000ms)
I	11:08:04.667	[McuMgr] Connection parameters updated (interval: 7.5ms, latency: 0, timeout: 5000ms)
D	11:08:04.713	[Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_BONDING (11)
D	11:08:04.715	[McuMgr] [Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_BONDING (11)
D	11:08:05.189	[Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_BONDED (12)
I	11:08:05.190	Device bonded
D	11:08:05.206	[McuMgr] [Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_BONDED (12)
I	11:08:05.210	[McuMgr] Device bonded
I	11:08:05.557	Connection parameters updated (interval: 45.0ms, latency: 0, timeout: 420ms)
I	11:08:05.558	[McuMgr] Connection parameters updated (interval: 45.0ms, latency: 0, timeout: 420ms)


And a debug output from smp_svr sample to UART:

*** Booting Zephyr OS build v2.3.0-rc1-ncs1  ***
[00:00:00.006,011] <inf> smp_sample: os_mgmt_register_group()
[00:00:00.006,042] <inf> smp_sample: img_mgmt_register_group()
[00:00:00.006,042] <inf> smp_sample: stat_mgmt_register_group()
[00:00:00.006,042] <inf> smp_sample: start_smp_bluetooth()
[00:00:00.009,429] <inf> smp_bt_sample: smp_bt_register()
[00:00:00.009,460] <inf> smp_sample: build time: Jul  6 2020 23:40:42
[00:00:00.025,054] <inf> smp_bt_sample: Bluetooth initialized
[00:00:00.048,461] <inf> smp_bt_sample: Advertising successfully started
[00:00:12.934,600] <inf> smp_bt_sample: Connected

And nothing happened after it even I was waiting for a long time.

If I use another mobile app - nRF Toolbox, then I have a more meaningful warning to add Init file, which I don't have and about which there's nothing in the guide.

Can you point me what I should do to realise FOTA upgrade? Maybe I didn't find some appropriate guides, because the guide here developer.nordicsemi.com/.../ug_nrf5340.html is so short and general.

Parents
  • Update 10/2/2020: Added strikethrough to an incorrect statement I made

    The apps you are trying to use to perform DFU does not support the mcumgr SMP/Bluetooth protocol (read about it here and here), which is used to transfer the DFU image in the smp_svr sample (NCS). The SMP/Bluetooth Protocol consists of the service SMP service and the characteristic SMP Characteristic

    These apps are compatible with the Bootloader and the DFU Protocol in the nRF5 SDK. You can see that this DFU Protocol consists of a DFU BLE service with two characterstics; the DFU Control Point characteristic and the DFU Packet characteristic.

    I am not aware of any apps that support the SMP/Bluetooth protocol, but I'm sure there exists some. I will look around and get back to you. 

    If you have a device with Linux (Raspberry Pi), you can use the mcumgr tool with conntype=ble (mcumgr BLE is not supported on Windows).

    Best regards,

    Simon

  • Hii,

    I tried the same for nRF5340 DK (not pdk). I am unable to build the smp_svr application.

    my prj.conf file looks like this

    # 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

    # Enable flash operations.
    CONFIG_FLASH=y

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

    # Enable statistics and statistic names.
    CONFIG_STATS=y
    CONFIG_STATS_NAMES=y

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

    # Enable logging
    CONFIG_LOG=y

    CONFIG_MCUMGR_SMP_BT=y

Reply
  • Hii,

    I tried the same for nRF5340 DK (not pdk). I am unable to build the smp_svr application.

    my prj.conf file looks like this

    # 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

    # Enable flash operations.
    CONFIG_FLASH=y

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

    # Enable statistics and statistic names.
    CONFIG_STATS=y
    CONFIG_STATS_NAMES=y

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

    # Enable logging
    CONFIG_LOG=y

    CONFIG_MCUMGR_SMP_BT=y

Children
No Data
Related