Firmware Update Demonstration Using the DFU Python Script#
This section assumes you have installed the Bluetooth Mesh – NCP Empty v1.1 demo binary to one of the devices, the Bluetooth Mesh – SoC DFU Distributor example application to another, and the Bluetooth Mesh – SoC Light example application to the other(s). You should also have generated a firmware update image for the light example. Copy the firmware update image application.gbl
to the root of the script’s directory, run the script in the interactive mode, and then follow the steps below to perform a firmware update.
Note: the DFU Python script sends the GBL file directly to the mesh network.
Getting Started with the DFU Python Script and Bluetooth Mesh Device Firmware Update Example Walkthrough describe the setup of the examples and the preparation of the firmware update image.
The examples display firmware update status on the device’s LCD and output detailed information of the firmware update process to VCOM UART. To see the logs, open a serial terminal on the serial port assigned for the device with the following serial settings: baud rate 115200, data bits 8, stop bits 1 and parity None.
Perform a factory reset on the provisioner.
>>>reset --type factory Factory reset completed
Provision all devices.
Issue the
prov
command with the--scan
option. The parameter.3
stands for 300 milliseconds.>>>prov --scan .3 Scanning for unprovisioned nodes... Unprovisioned beacon: uuid=994c62c4bf480f51bb3995094a266ec2, bearer=PB-GATT, address=68:0a:e2:dd:29:4a, ad-dress_type=Public, rssi=-33 Unprovisioned beacon: uuid=5100db6c367ef95aaec40a95fee47966, bearer=PB-GATT, address=d0:cf:5e:68:aa:29, ad-dress_type=Public, rssi=-28 Unprovisioned beacon: uuid=36494ea9987db45588b29a7b900a9da2, bearer=PB-GATT, address=84:71:27:6e:f2:cd, ad-dress_type=Public, rssi=-1 ... ... +----------+------------------------------------+-----------+---------------------+----------------+ | Idx | UUID | Bearer | Address | Address Type | +----------+------------------------------------+-----------+---------------------+----------------+ | 0 | 36494ea9987db45588b29a7b900a9da2 | PB-GATT | 84:71:27:6e:f2:cd | Public | +----------+------------------------------------+-----------+---------------------+----------------+ | 1 | 36494ea9987db45588b29a7b900a9da2 | PB-ADV | 84:71:27:6e:f2:cd | Public | +----------+------------------------------------+-----------+---------------------+----------------+ | 2 | 5100db6c367ef95aaec40a95fee47966 | PB-GATT | d0:cf:5e:68:aa:29 | Public | +----------+------------------------------------+-----------+---------------------+----------------+ | 3 | 5100db6c367ef95aaec40a95fee47966 | PB-ADV | d0:cf:5e:68:aa:29 | Public | +----------+------------------------------------+-----------+---------------------+----------------+ | 4 | 994c62c4bf480f51bb3995094a266ec2 | PB-GATT | 68:0a:e2:dd:29:4a | Public | +----------+------------------------------------+-----------+---------------------+----------------+ | 5 | 994c62c4bf480f51bb3995094a266ec2 | PB-ADV | 68:0a:e2:dd:29:4a | Public | +----------+------------------------------------+-----------+---------------------+----------------+ Select devices to provision Comma/Space separated list of indexes, BT addresses or UUIDs
When it prompts to select devices to provision, select the PB-ADV bearer of devices. In the example, the index 3 is the Distributor device and the indices 1 and 5 are the Light devices.
Devices:3,1,5 The device with 5100db6c367ef95aaec40a95fee47966 UUID is provisioned. The device with 36494ea9987db45588b29a7b900a9da2 UUID is provisioned. The device with 994c62c4bf480f51bb3995094a266ec2 UUID is provisioned.
Rename nodes for easy identification.
Issue the
node list
command to show the nodes in the mesh network.>>>node list +------------+-----------------+--------------------------------------+-------------+--------------+ | Idx | Name | UUID | Address | Elements | +------------+-----------------+--------------------------------------+-------------+--------------+ | 0 | Node_2005 | 5100db6c367ef95aaec40a95fee47966 | 0x2005 | 1 | +------------+-----------------+--------------------------------------+-------------+--------------+ | 1 | Node_2006 | 36494ea9987db45588b29a7b900a9da2 | 0x2006 | 3 | +------------+-----------------+--------------------------------------+-------------+--------------+ | 2 | Node_2009 | 994c62c4bf480f51bb3995094a266ec2 | 0x2009 | 3 | +------------+-----------------+--------------------------------------+-------------+--------------+ | 3 | Provisioner | 764b0e71f3fc5c5ab856d6e1a90b4e32 | 0x2001 | 4 | +------------+-----------------+--------------------------------------+-------------+--------------+
Issue the node rename command to rename nodes.
>>>node rename Node_2005 Distributor_2005 >>>node rename Node_2006 Light_2006 >>>node rename Node_2009 Light_2009 >>>node list +-----------+---------------------+-------------------------------------+------------+-------------+ | Idx | Name | UUID | Address | Elements | +-----------+---------------------+-------------------------------------+------------+-------------+ | 0 | Distributor_2005 | 5100db6c367ef95aaec40a95fee47966 | 0x2005 | 1 | +-----------+---------------------+-------------------------------------+------------+-------------+ | 1 | Light_2006 | 36494ea9987db45588b29a7b900a9da2 | 0x2006 | 3 | +-----------+---------------------+-------------------------------------+------------+-------------+ | 2 | Light_2009 | 994c62c4bf480f51bb3995094a266ec2 | 0x2009 | 3 | +-----------+---------------------+-------------------------------------+------------+-------------+ | 3 | Provisioner | 764b0e71f3fc5c5ab856d6e1a90b4e32 | 0x2001 | 4 | +-----------+---------------------+-------------------------------------+------------+-------------+
Configure nodes with built-in profiles.
Issue the
group add
command to create a new group, specify a group address, specify a configuration profile to apply, and specify what node(s) to be added to the group.Add the Distributor node to the group named GrpDist1:
>>>group add --appkey-idx 0 --group-addr 0xC000 --sub-addrs Dist*[0] --profile distributor --name GrpDist1 App group GrpDist1 adds appkey binding to BLOB Transfer Client model on 0x2005 element address. App group GrpDist1 adds appkey binding to Firmware Update Client model on 0x2005 element address. App group GrpDist1 adds appkey binding to Firmware Distribution Server model on 0x2005 element address. App group GrpDist1 adds appkey binding to Firmware Update Server model on 0x2005 element address. App group GrpDist1 adds appkey binding to BLOB Transfer Server model on 0x2005 element address. App group GrpDist1 adds subscription to Firmware Update Server model on 0x2005 element address. App group GrpDist1 adds subscription to BLOB Transfer Server model on 0x2005 element address.
Add the Light node(s) to the group named GrpLight1:
>>>group add --appkey-idx 0 --group-addr 0xC001 --sub-addrs Light*[0] --profile target_node --name GrpLight1 App group GrpLight1 adds appkey binding to Firmware Update Server model on 0x2009 element address. App group GrpLight1 adds appkey binding to BLOB Transfer Server model on 0x2009 element address. App group GrpLight1 adds appkey binding to Firmware Update Server model on 0x2006 element address. App group GrpLight1 adds appkey binding to BLOB Transfer Server model on 0x2006 element address. App group GrpLight1 adds subscription to Firmware Update Server model on 0x2009 element address. App group GrpLight1 adds subscription to BLOB Transfer Server model on 0x2009 element address. App group GrpLight1 adds subscription to Firmware Update Server model on 0x2006 element address. App group GrpLight1 adds subscription to BLOB Transfer Server model on 0x2006 element address.
Show the group information:
>>>group list +-------------------+-----------------------+---------------------------+--------------------------+ | Idx | Name | Group Address | Appkey Index | +-------------------+-----------------------+---------------------------+--------------------------+ | 0 | GrpDist1 | 0xC000 | 0 | +-------------------+-----------------------+---------------------------+--------------------------+ | 1 | GrpLight1 | 0xC001 | 0 | +-------------------+-----------------------+---------------------------+--------------------------+
Upload a firmware image to the Distributor.
Issue the
dist upload
command to uploadapplication.gbl
to the Distributor.>>>dist upload --distributor Distributor_2005 --fwid 0x02FF:s:light --metadata s:test --timeout-base 1 applica-tion.gbl FW data (427260 bytes) is loaded from application.gbl. Upload progress: 0.00% ... ... ... Upload progress: 100.00% Firmware with 0x02FF:light FWID is uploaded to Distributor (0x2005).
Show the firmware list from the Distributor.
>>>dist info --fw-list --distributor Distributor_2005 +---------------------------------------------+----------------------------------------------------+ | Index | FWID | +---------------------------------------------+----------------------------------------------------+ | 0 | 0x02FF:light | +---------------------------------------------+----------------------------------------------------+
Distribute the firmware image to Light node(s).
Issue the
dist start
command to instruct the Distributor to start firmware image distribution.>>>dist start --distributor Distributor_2005 --fw-list-idx 0 --group GrpLight1 Distribution phase is changed to transfer active. Distribution transfer progress: 0% ... ... Distribution transfer progress: 100% Distribution phase is changed to applying update. Distribution phase is changed to completed. The FW distribution of 0 FW list index is completed on the Distributor (0x2005). +-----------------+----------------+----------------------+--------------------+-------------------+ | Address | FW Idx | Phase | BLOB status | DFU status | +-----------------+----------------+----------------------+--------------------+-------------------+ | 0x2006 | 0 | apply success | success | success | +-----------------+----------------+----------------------+--------------------+-------------------+ | 0x2009 | 0 | apply success | success | success | +-----------------+----------------+----------------------+--------------------+-------------------+