Lines Matching full:the
6 Bluetooth Mesh supports the distribution of firmware images across a mesh network. The Bluetooth
7 mesh DFU subsystem implements the Bluetooth Mesh Device Firmware Update Model specification version
11 restrictions on the size, format or usage of the images. The primary design goal of the subsystem is
12 to provide the qualifiable parts of the Bluetooth Mesh DFU specification, and leave the usage,
13 firmware validation and deployment to the application.
15 The DFU specification is implemented in the Zephyr Bluetooth Mesh DFU subsystem as three separate
31 The Bluetooth Mesh DFU subsystem defines three different roles the mesh nodes have to assume in the
35 Target node is the receiver and user of the transferred firmware images. All its functionality is
36 implemented by the :ref:`bluetooth_mesh_dfu_srv` model. A transfer may be targeting any number of
40 The Distributor role serves two purposes in the DFU process. First, it's acting as the Target
41 node in the Upload Firmware procedure, then it distributes the uploaded image to other Target
42 nodes as the Distributor. The Distributor does not select the parameters of the transfer, but
43 relies on an Initiator to give it a list of Target nodes and transfer parameters. The Distributor
45 :ref:`bluetooth_mesh_dfu_cli`. The :ref:`bluetooth_mesh_dfd_srv` is responsible for communicating
46 with the Initiator, and the :ref:`bluetooth_mesh_dfu_cli` is responsible for distributing the
47 image to the Target nodes.
50 The Initiator role is typically implemented by the same device that implements the Bluetooth Mesh
52 <bluetooth_mesh_models_cfg_cli>` roles. The Initiator needs a full overview of the potential
53 Target nodes and their firmware, and will control (and initiate) all firmware updates. The
54 Initiator role is not implemented in the Zephyr Bluetooth Mesh DFU subsystem.
58 :alt: Graphic overview of the DFU roles mesh nodes can have during the process of image
61 DFU roles and the associated Bluetooth Mesh models
63 Bluetooth Mesh applications may combine the DFU roles in any way they'd like, and even take on
64 multiple instances of the same role by instantiating the models on separate elements. For instance,
65 the Distributor and Initiator role can be combined by instantiating the
66 :ref:`bluetooth_mesh_dfu_cli` on the Initiator node and calling its API directly.
68 It's also possible to combine the Initiator and Distributor devices into a single device, and
69 replace the Firmware Distribution Server model with a proprietary mechanism that will access the
79 The Bluetooth Mesh DFU process is designed to act in three stages:
82 First, the image is uploaded to a Distributor in a mesh network by an external entity, such as a
83 phone or gateway (the Initiator). During the Upload stage, the Initiator transfers the firmware
84 image and all its metadata to the Distributor node inside the mesh network. The Distributor
85 stores the firmware image and its metadata persistently, and awaits further instructions from the
86 Initiator. The time required to complete the upload process depends on the size of the image.
87 After the upload completes, the Initiator can disconnect from the network during the much more
88 time-consuming Distribution stage. Once the firmware has been uploaded to the Distributor, the
89 Initiator may trigger the Distribution stage at any time.
92 Before starting the Distribution stage, the Initiator may optionally check if Target nodes can
93 accept the new firmware. Nodes that do not respond, or respond that they can't receive the new
94 firmware, are excluded from the firmware distribution process.
97 Before the firmware image can be distributed, the Initiator transfers the list of Target nodes
98 and their designated firmware image index to the Distributor. Next, it tells the Distributor to
99 start the firmware distributon process, which runs in the background while the Initiator and the
100 mesh network perform other duties. Once the firmware image has been transferred to the Target
101 nodes, the Distributor may ask them to apply the firmware image immediately and report back with
111 Firmware images are represented as a BLOB (the firmware itself) with the following additional
115 The firmware ID is used to identify a firmware image. The Initiator node may ask the Target nodes
116 for a list of its current firmware IDs to determine whether a newer version of the firmware is
117 available. The format of the firmware ID is vendor specific, but generally, it should include
118 enough information for an Initiator node with knowledge of the format to determine the type of
119 image as well as its version. The firmware ID is optional, and its max length is determined by
123 The firmware metadata is used by the Target node to determine whether it should accept an
124 incoming firmware update, and what the effect of the update would be. The metadata format is
125 vendor specific, and should contain all information the Target node needs to verify the image, as
126 well as any preparation the Target node has to make before the image is applied. Typical metadata
127 information can be image signatures, changes to the node's Composition Data and the format of the
128 BLOB. The Target node may perform a metadata check before accepting incoming transfers to
129 determine whether the transfer should be started. The firmware metadata can be discarded by the
130 Target node after the metadata check, as other nodes will never request the metadata from the
131 Target node. The firmware metadata is optional, and its maximum length is determined by
134 The Bluetooth Mesh DFU subsystem in Zephyr provides its own metadata format
136 an end product. The support for it is enabled using the
137 :kconfig:option:`CONFIG_BT_MESH_DFU_METADATA` option. The format of the metadata is presented in
138 the table below.
159 | | | in the New firmware core type field. |
161 | New number of elements | 2 B | Number of elements on the node |
164 | | | in the New firmware core type field. |
175 The AES-CMAC algorithm serves as a hashing function with a fixed key and is not used for
176 encryption in Bluetooth Mesh DFU metadata. The resulting hash is not secure since the key is
180 The firmware URI gives the Initiator information about where firmware updates for the image can
181 be found. The URI points to an online resource the Initiator can interact with to get new
182 versions of the firmware. This allows Initiators to perform updates for any node in the mesh
183 network by interacting with the web server pointed to in the URI. The URI must point to a
184 resource using the ``http`` or ``https`` schemes, and the targeted web server must behave
185 according to the Firmware Check Over HTTPS procedure defined by the specification. The firmware
191 The out-of-band distribution mechanism is not supported.
198 A new image may have the Composition Data Page 0 different from the one allocated on a Target node.
199 This may have an effect on the provisioning data of the node and how the Distributor finalizes the
200 DFU. Depending on the availability of the Remote Provisioning Server model on the old and new image,
201 the device may either boot up unprovisioned after applying the new firmware or require to be
202 re-provisioned. The complete list of available options is defined in :c:enum:`bt_mesh_dfu_effect`:
205 The device stays provisioned after the new firmware is programmed. This effect is chosen if the
206 composition data of the new firmware doesn't change.
208 This effect is chosen when the composition data changes and the device doesn't support the remote
209 provisioning. The new composition data takes place only after re-provisioning.
211 This effect is chosen when the composition data changes and the device supports the remote
212 provisioning. In this case, the device stays provisioned and the new composition data takes place
213 after re-provisioning using the Remote Provisioning models.
215 This effect is chosen if the composition data in the new firmware changes, the device doesn't
216 support the remote provisioning, and the new composition data takes effect after applying the
219 When the Target node receives the Firmware Update Firmware Metadata Check message, the Firmware
220 Update Server model calls the :c:member:`bt_mesh_dfu_srv_cb.check` callback, the application can
221 then process the metadata and provide the effect value. If the effect is
222 :c:enumerator:`BT_MESH_DFU_EFFECT_COMP_CHANGE`, the application must call functions
224 prepare the Composition Data Page and Models Metadata Page contents before applying the new
232 The DFU protocol is implemented as a set of procedures that must be performed in a certain order.
234 The Initiator controls the Upload stage of the DFU protocol, and all Distributor side handling of
235 the upload subprocedures is implemented in the :ref:`bluetooth_mesh_dfd_srv`.
237 The Distribution stage is controlled by the Distributor, as implemented by the
238 :ref:`bluetooth_mesh_dfu_cli`. The Target node implements all handling of these procedures in the
239 :ref:`bluetooth_mesh_dfu_srv`, and notifies the application through a set of callbacks.
245 DFU stages and procedures as seen from the Distributor
247 Uploading the firmware
250 The Upload Firmware procedure uses the :ref:`bluetooth_mesh_blob` to transfer the firmware image
251 from the Initiator to the Distributor. The Upload Firmware procedure works in two steps:
253 1. The Initiator generates a BLOB ID, and sends it to the Distributor's Firmware Distribution Server
254 along with the firmware information and other input parameters of the BLOB transfer. The Firmware
255 Distribution Server stores the information, and prepares its BLOB Transfer Server for the
256 incoming transfer before it responds with a status message to the Initiator.
257 #. The Initiator's BLOB Transfer Client model transfers the firmware image to the Distributor's BLOB
258 Transfer Server, which stores the image in a predetermined flash partition.
260 When the BLOB transfer finishes, the firmware image is ready for distribution. The Initiator may
261 upload several firmware images to the Distributor, and ask it to distribute them in any order or at
262 any time. Additional procedures are available for querying and deleting firmware images from the
265 The following Distributor's capabilities related to firmware images can be configured using the
268 * :kconfig:option:`CONFIG_BT_MESH_DFU_SLOT_CNT`: Amount of image slots available on the device.
272 Populating the Distributor's receivers list
275 Before the Distributor can start distributing the firmware image, it needs a list of Target nodes to
276 send the image to. The Initiator gets the full list of Target nodes either by querying the potential
277 targets directly, or through some external authority. The Initiator uses this information to
278 populate the Distributor's receivers list with the address and relevant firmware image index of each
279 Target node. The Initiator may send one or more Firmware Distribution Receivers Add messages to
280 build the Distributor's receivers list, and a Firmware Distribution Receivers Delete All message to
283 The maximum number of receivers that can be added to the Distributor is configured through the
286 Initiating the distribution
289 Once the Distributor has stored a firmware image and received a list of Target nodes, the Initiator
290 may initiate the distribution procedure. The BLOB transfer parameters for the distribution are
291 passed to the Distributor along with an update policy. The update policy decides whether the
292 Distributor should request that the firmware is applied on the Target nodes or not. The Distributor
293 stores the transfer parameters and starts distributing the firmware image to its list of Target
299 The Distributor's Firmware Update Client model uses its BLOB Transfer Client model's broadcast
300 subsystem to communicate with all Target nodes. The firmware distribution is performed with the
303 1. The Distributor's Firmware Update Client model generates a BLOB ID and sends it to each Target
304 node's Firmware Update Server model, along with the other BLOB transfer parameters, the Target
305 node firmware image index and the firmware image metadata. Each Target node performs a metadata
306 check and prepares their BLOB Transfer Server model for the transfer, before sending a status
307 response to the Firmware Update Client, indicating if the firmware update will have any effect on
308 the Bluetooth Mesh state of the node.
309 #. The Distributor's BLOB Transfer Client model transfers the firmware image to all Target nodes.
310 #. Once the BLOB transfer has been received, the Target nodes' applications verify that the firmware
311 is valid by performing checks such as signature verification or image checksums against the image
313 #. The Distributor's Firmware Update Client model queries all Target nodes to ensure that they've
314 all verified the firmware image.
316 If the distribution procedure completed with at least one Target node reporting that the image has
317 been received and verified, the distribution procedure is considered successful.
320 The firmware distribution procedure only fails if *all* Target nodes are lost. It is up to the
321 Initiator to request a list of failed Target nodes from the Distributor and initiate additional
322 attempts to update the lost Target nodes after the current attempt is finished.
324 Suspending the distribution
327 The Initiator can also request the Distributor to suspend the firmware distribution. In this case,
328 the Distributor will stop sending any messages to Target nodes. When the firmware distribution is
329 resumed, the Distributor will continue sending the firmware from the last successfully transferred
332 Applying the firmware image
335 If the Initiator requested it, the Distributor can initiate the Apply Firmware on Target Node
336 procedure on all Target nodes that successfully received and verified the firmware image. The Apply
338 performed before a new transfer is initiated. The Apply Firmware on Target Node procedure consists
339 of the following steps:
341 1. The Distributor's Firmware Update Client model instructs all Target nodes that have verified the
342 firmware image to apply it. The Target nodes' Firmware Update Server models respond with a status
344 #. The Target node's application performs any preparations needed before applying the transfer, such
345 as storing a snapshot of the Composition Data or clearing its configuration.
346 #. The Target node's application swaps the current firmware with the new image and updates its
347 firmware image list with the new firmware ID.
348 #. The Distributor's Firmware Update Client model requests the full list of firmware images from
349 each Target node, and scans through the list to make sure that the new firmware ID has replaced
350 the old.
353 During the metadata check in the distribution procedure, the Target node may have reported that
354 it will become unprovisioned after the firmware image is applied. In this case, the Distributor's
355 Firmware Update Client model will send a request for the full firmware image list, and expect no
358 Cancelling the distribution
361 The firmware distribution can be cancelled at any time by the Initiator. In this case, the
362 Distributor starts the cancelling procedure by sending a cancelling message to all Target nodes. The
363 Distributor waits for the response from all Target nodes. Once all Target nodes have replied, or the
364 request has timed out, the distribution procedure is cancelled. After this the distribution
365 procedure can be started again from the ``Firmware distribution`` section.
371 This section lists the types common to the Device Firmware Update mesh models.