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 Reply Children
  • Thanks for your answer! Can you advise me which examples of realization FOTA nRF5340 upgrade I should examine to comprehend this process and repeat it? Do you have examples of FOTA upgrade over Bluetooth only for nRF5 SDK and not for nRF Connect SDK? I tried to repeat completely this example from your guide developer.nordicsemi.com/.../ug_nrf5340.html. And it's written developer.nordicsemi.com/.../README.html that "This sample application supports the following mcumgr transports by default: Shell, Bluetooth, UDP". I thought that Bluetooth is included. Maybe I didn't understand you properly. But can you give me a link with an example of FOTA upgrade for nRF5340 and/or guidelines on how to implement it? It would help me a lot.

  • Probably, I didn't copy completely a debug output from smp_svr sample to UART. I tried again and I saw that I didn't include a mcuboot bootloader log. So, the whole log is:

    *** Booting Zephyr OS build v2.3.0-rc1-ncs1  ***
    [00:00:00.003,112] <inf> mcuboot: Starting bootloader
    [00:00:00.009,338] <inf> mcuboot: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    [00:00:00.019,500] <inf> mcuboot: Boot source: none
    [00:00:00.025,024] <inf> mcuboot: Swap type: none
    [00:00:00.194,885] <inf> mcuboot: Bootloader chainload address offset: 0x10000
    [00:00:00.202,728] <inf> mcuboot: Jumping to the first image slot
    *** Booting Zephyr OS build v2.3.0-rc1-ncs1  ***
    [00:00:00.006,042] <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_bt_sample: Roman Alexeev 1 bluetooth.c
    [00:00:00.009,490] <inf> smp_sample: build time: Jul 10 2020 10:25:54
    [00:00:00.009,490] <inf> smp_sample: Roman Alexeev 1 main.c
    [00:00:00.025,146] <inf> smp_bt_sample: Bluetooth initialized
    [00:00:00.061,889] <inf> smp_bt_sample: Advertising successfully started
    [00:09:12.476,562] <inf> smp_bt_sample: Connected

    Tell me, please, does FOTA upgrade works for nRF5340 PDK or not? And are there a working example and a guide of how to implement it?

  • How would you like to perform the DFU on the nRF5340? From a computer? From a mobile phone? From another microcontroller?

    If you want to update it from a computer, BLE is only supported on MacOS and Linux at the moment, but the serial protocol is supported on all OS's to my understanding. Please tell me if I should explain one of these approaches in more detail.

    If you want to update it from a mobile phone or another device, I can help you with that as well. But I'm not aware of any out-of-the-box solutions for this. But you could implement it by writing the software yourself since the protocols are described here: SMP/Bluetooth or SMP/Console. However, there may be some out-of-the-box solutions out there, please tell me if I should look into this.

    Best regards,

    Simon

  • Simon, thank you for the answer.

    How would you like to perform the DFU on the nRF5340? From a computer? From a mobile phone? From another microcontroller?

    I am interested in FOTA (OTA DFU) upgrade using a mobile phone. I used nRF Connect for Mobile and I also tried to use nRF Toolbox on an Android mobile phone.

    In the case of nRF52840 DK I was successful to launch an example from developer.nordicsemi.com/.../README.html using a guide developer.nordicsemi.com/.../ug_nrf52.html. And I upgraded the firmware of nRF52840 using nRF Connect for Mobile over Bluetooth. But when I did about the same steps with nRF5340 DK, then it didn't work. So, I would like to clarify the differences in FOTA upgrade between these two boards, using smp_svr example or any other examples of FOTA over Bluetooth.

    In general, my goal is to launch a firmware, which realizes Over-the-Air Device Firmware Update on nRF5340 PDK, and upgrade it using a mobile phone (Android for now) over Bluetooth to new firmware. Unfortunately, I haven't found any working guides and examples of OTA DFU for nRF5340 yet.

  • I am not aware of any such solutions when using NCS (the nRF5340 only supports NCS, not the nRF5 SDK), but I would be surprised if it wasn't/or is being worked on.

    But I will investigate/ask internally and get back to you.

    Best regards,

    Simon

Related