Skip to content

Commit 3821731

Browse files
kkasperczyk-nopull[bot]
authored andcommitted
[nrfconnect] Extended DFU documentation about using mcumgr tool. (#7251)
Examples documentation about performing Device Firmware Upgrade over BLE describes only case using Nordic mobile app. It would be beneficial to have also documentation that shows how to perform firmware upgrade from PC command line tool. * Moved DFU description from examples to separate guide readme. * Extended documentation by case using mcumgr command line tool to perform DFU. * Removed unnecessary part of the code allowing to advertise over BLE with non conn type that was added in very early verison of BLE Manager implementation.
1 parent 8c83726 commit 3821731

File tree

6 files changed

+133
-41
lines changed

6 files changed

+133
-41
lines changed

config/nrfconnect/app/overlay-dfu_support.conf

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ CONFIG_MCUMGR_CMD_IMG_MGMT=y
3333
CONFIG_MCUMGR_CMD_OS_MGMT=y
3434
CONFIG_MCUMGR_SMP_BT=y
3535
CONFIG_MCUMGR_SMP_BT_AUTHEN=n
36+
CONFIG_MCUMGR_BUF_COUNT=6
3637

3738
# Increase BT MTU and RX buffer for big size DFU messages
3839
CONFIG_BT_L2CAP_TX_MTU=252

config/nrfconnect/app/sample-defaults.conf

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ CONFIG_BT_DEVICE_NAME_MAX=15
5252
CONFIG_BT_MAX_CONN=1
5353
CONFIG_BT_PHY_UPDATE=n
5454
CONFIG_BT_CTLR_PHY_2M=n
55+
CONFIG_SDC_MAX_CONN_EVENT_LEN_DEFAULT=3000
5556

5657
# Enable NFC support
5758
CONFIG_CHIP_NFC_COMMISSIONING=y
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Performing Device Firmware Upgrade in the nRF Connect SDK examples
2+
3+
The following examples for the development kits from Nordic Semiconductor
4+
support over-the-air Device Firmware Upgrade:
5+
6+
- [CHIP nRF Connect Lock Example Application](../../examples/lock-app/nrfconnect/README.md)
7+
- [CHIP nRF Connect Lighting Example Application](../../examples/lighting-app/nrfconnect/README.md)
8+
9+
Currently, the Bluetooth LE is the only available transport for performing the
10+
DFU operation and it uses
11+
[Simple Management Protocol](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/guides/device_mgmt/index.html#device-mgmt).
12+
The upgrade can be done either using a smartphone application or a PC command
13+
line tool.
14+
15+
## Device Firmware Upgrade using smartphone
16+
17+
To upgrade your device firmware over Bluetooth LE using smartphone, complete the
18+
following steps:
19+
20+
1. Install one of the following applications on your smartphone:
21+
22+
- [nRF Connect for Mobile](https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Connect-for-mobile)
23+
- [nRF Toolbox](https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Toolbox)
24+
25+
2. Push **Button 1** on the device to enable the software update functionality.
26+
3. Push **Button 4** on the device to start the Bluetooth LE advertising.
27+
4. Follow the instructions about downloading the new image to a device on the
28+
[FOTA upgrades](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_nrf52.html#fota-upgrades)
29+
page in the nRF Connect documentation.
30+
31+
## Device Firmware Upgrade using PC command line tool
32+
33+
To upgrade your device firmware over Bluetooth LE, you can use the PC command
34+
line tool provided by the [mcumgr](https://github.com/zephyrproject-rtos/mcumgr)
35+
project.
36+
37+
> **_WARNING:_** mcumgr tool using Bluetooth LE is available only for Linux and
38+
> macOS systems. On Windows, there is no support for Device Firmware Upgrade
39+
> over Bluetooth LE yet.
40+
41+
Complete the following steps to perform DFU using mcumgr:
42+
43+
1. Install the tool by following the
44+
[mcumgr command line tool installation instructions](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/guides/device_mgmt/index.html#command-line-tool).
45+
2. Push **Button 1** on the device to enable software update functionality.
46+
3. Push **Button 4** on the device to start the Bluetooth LE advertising.
47+
48+
> **_NOTE:_** In all of the commands listed in the following steps, replace
49+
> `ble-hci-number` with the Bluetooth hci integer value (for example, `0`) and
50+
> `ble-device-name` with the CHIP device name advertised over Bluetooth LE (for
51+
> example, `ChipLock`).
52+
53+
4. Upload the firmware image to the device by running the following command in
54+
your example directory:
55+
56+
$ sudo mcumgr --conntype ble --hci ble-hci-number --connstring peer_name='ble-device-name' image upload build/zephyr/app_update.bin
57+
58+
The operation can take few minutes. Wait until the progress bar reaches
59+
100%.
60+
61+
5. Obtain the list of images present in the device memory by running following
62+
command:
63+
64+
$ sudo mcumgr --conntype ble --hci ble-hci-number --connstring peer_name='ble-device-name' image list
65+
66+
The displayed output contains the old image in slot 0 that is currently
67+
active and the new image in slot 1, which is not active yet (flags field
68+
empty):
69+
70+
Images:
71+
image=0 slot=0
72+
version: 0.0.0
73+
bootable: true
74+
flags: active confirmed
75+
hash: 7bb0e909a846e833465cbb44c581cf045413a5446c6953a30a3dcc2c3ad51764
76+
image=0 slot=1
77+
version: 0.0.0
78+
bootable: true
79+
flags:
80+
hash: cbd58fc3821e749d3abfb00b3069f98c078824735f1b2a333e8a1579971e7de1
81+
Split status: N/A (0)
82+
83+
6. Swap the firmware images by calling the following method with `image-hash`
84+
replaced by the image present in the slot 1 hash (for example,
85+
`cbd58fc3821e749d3abfb00b3069f98c078824735f1b2a333e8a1579971e7de1`):
86+
87+
$ sudo mcumgr --conntype ble --hci ble-hci-number --connstring peer_name='ble-device-name' image test image-hash
88+
89+
You can observe that the `flags:` field in the image for slot 1 changes
90+
value to `pending`:
91+
92+
Images:
93+
image=0 slot=0
94+
version: 0.0.0
95+
bootable: true
96+
flags: active confirmed
97+
hash: 7bb0e909a846e833465cbb44c581cf045413a5446c6953a30a3dcc2c3ad51764
98+
image=0 slot=1
99+
version: 0.0.0
100+
bootable: true
101+
flags: pending
102+
hash: cbd58fc3821e749d3abfb00b3069f98c078824735f1b2a333e8a1579971e7de1
103+
Split status: N/A (0)
104+
105+
7. Reset the device with the following command to let the bootloader swap
106+
images:
107+
108+
$ sudo mcumgr --conntype ble --hci ble-hci-number --connstring peer_name='ble-device-name' reset
109+
110+
The device is reset and the following notifications appear in its console:
111+
112+
*** Booting Zephyr OS build zephyr-v2.5.0-1101-ga9d3aef65424 ***
113+
I: Starting bootloader
114+
I: Primary image: magic=good, swap_type=0x2, copy_done=0x1, image_ok=0x1
115+
I: Secondary image: magic=good, swap_type=0x2, copy_done=0x3, image_ok=0x3
116+
I: Boot source: none
117+
I: Swap type: test
118+
119+
Swapping operation can take some time, and after it completes, the new
120+
firmware is booted.
121+
122+
Visit the
123+
[mcumgr image management](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/guides/device_mgmt/indexhtml#image-management)
124+
section to get familiar with all image management commands supported by the
125+
tool.

examples/lighting-app/nrfconnect/README.md

+3-17
Original file line numberDiff line numberDiff line change
@@ -462,20 +462,6 @@ CHIP-enabled Thread network.
462462

463463
### Testing Device Firmware Upgrade
464464

465-
> **_NOTE:_** Currently performing DFU over BLE is supported only using
466-
> smartphone with dedicated Nordic application installed.
467-
468-
To upgrade your device firmware over Bluetooth LE using smartphone, complete the
469-
following tasks:
470-
471-
1. Install on your smartphone
472-
[nRF Connect for Mobile](https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Connect-for-mobile)
473-
or
474-
[nRF Toolbox](https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Toolbox)
475-
application.
476-
2. Push **Button 4** on the device to start Bluetooth LE advertising.
477-
3. Push **Button 1** on the device to enable software update functionality.
478-
4. Follow the instructions in the section about downloading the new image to a
479-
device on the
480-
[FOTA upgrades](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_nrf52.html#fota-upgrades)
481-
page in the nRF Connect documentation.
465+
Read the
466+
[DFU tutorial](../../../docs/guides/nrfconnect_examples_software_update.md) to
467+
see how to upgrade your device firmware.

examples/lock-app/nrfconnect/README.md

+3-17
Original file line numberDiff line numberDiff line change
@@ -454,20 +454,6 @@ CHIP-enabled Thread network.
454454

455455
### Testing Device Firmware Upgrade
456456

457-
> **_NOTE:_** Currently performing DFU over BLE is supported only using
458-
> smartphone with dedicated Nordic application installed.
459-
460-
To upgrade your device firmware over Bluetooth LE using smartphone, complete the
461-
following tasks:
462-
463-
1. Install on your smartphone
464-
[nRF Connect for Mobile](https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Connect-for-mobile)
465-
or
466-
[nRF Toolbox](https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Toolbox)
467-
application.
468-
2. Push **Button 4** on the device to start Bluetooth LE advertising.
469-
3. Push **Button 1** on the device to enable software update functionality.
470-
4. Follow the instructions in the section about downloading the new image to a
471-
device on the
472-
[FOTA upgrades](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_nrf52.html#fota-upgrades)
473-
page in the nRF Connect documentation.
457+
Read the
458+
[DFU tutorial](../../../docs/guides/nrfconnect_examples_software_update.md) to
459+
see how to upgrade your device firmware.

src/platform/Zephyr/BLEManagerImpl.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,6 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void)
249249
VerifyOrExit(err == CHIP_NO_ERROR, err = MapErrorZephyr(err));
250250

251251
err = bt_le_adv_start(&advParams, ad, ARRAY_SIZE(ad), nullptr, 0u);
252-
if (err == -ENOMEM)
253-
{
254-
// No free connection objects for connectable advertiser. Advertise as non-connectable instead.
255-
advParams.options &= ~BT_LE_ADV_OPT_CONNECTABLE;
256-
err = bt_le_adv_start(&advParams, ad, ARRAY_SIZE(ad), nullptr, 0u);
257-
}
258-
259252
VerifyOrExit(err == CHIP_NO_ERROR, err = MapErrorZephyr(err));
260253

261254
// Transition to the Advertising state...

0 commit comments

Comments
 (0)