Download as pdf or txt
Download as pdf or txt
You are on page 1of 66

1

3 ZigBee Document 095264r23


4

5 ZigBee Over-the-Air Upgrading Cluster


6 Revision 23
7 Version 1.1
8

10 March 12, 2014


11

12

13 Sponsored by:
14 ZigBee Alliance

15 Accepted for release by:


16 This document has not yet been accepted for release by the ZigBee Alliance Board of
17 Directors.

18 Abstract:
19 This is an implementation specification requirements document that describes the ZigBee
20 Over The Air (OTA) image (FW) Upgrade. The document is to provide a standard for Over
21 The Air message format for upgrading image along with necessary commands and
22 parameters to ensure interoperability of Over The Air upgrading. Certain security aspects will
23 also be enforced or recommended to protect the network from any vulnerability that may be
24 exposed from the Over The Air upgrading.

25 Keywords:
26 ZigBee, Over The Air (OTA), Upgrade Server, Upgrade Client, digital signature, certificate
27
28
29
30
31 Copyright © ZigBee Alliance, Inc. (2003, 2004). All rights Reserved. This information within this
32 document is the property of the ZigBee Alliance and its use and disclosure are restricted.
33
34 Elements of ZigBee Alliance specifications may be subject to third party intellectual property rights,
35 including without limitation, patent, copyright or trademark rights (such a third party may or may not

Copyright ã 1996-2016 by the ZigBee Alliance.


2400 Camino Ramon, Suite 375, San Ramon, CA 94583, USA
http://www.zigbee.org
All rights reserved.

Permission is granted to members of the ZigBee Alliance to reproduce this document for their own use or the use of
other ZigBee Alliance members only, provided this notice is included. All other rights reserved. Duplication for sale,
or for commercial or for-profit use is strictly prohibited without the prior written consent of the ZigBee Alliance.
ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

36 be a member of ZigBee). ZigBee is not responsible and shall not be held responsible in any manner for
37 identifying or failing to identify any or all such third party intellectual property rights.
38
39 This document and the information contained herein are provided on an “AS IS” basis and ZigBee
40 DISCLAIMS ALL WARRANTIES EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
41 (A) ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT
42 INFRINGE ANY RIGHTS OF THIRD PARTIES (INCLUDING WITHOUT LIMITATION ANY
43 INTELLECTUAL PROPERTY RIGHTS INCLUDING PATENT, COPYRIGHT OR TRADEMARK
44 RIGHTS) OR (B) ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
45 PARTICULAR PURPOSE, TITLE OR NON-INFRINGEMENT. IN NO EVENT WILL ZIGBEE BE
46 LIABLE FOR ANY LOSS OF PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA,
47 INTERRUPTION OF BUSINESS, OR FOR ANY OTHER DIRECT, INDIRECT, SPECIAL OR
48 EXEMPLARY, INCIDENTIAL, PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND,
49 IN CONTRACT OR IN TORT, IN CONNECTION WITH THIS DOCUMENT OR THE
50 INFORMATION CONTAINED HEREIN, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
51 LOSS OR DAMAGE. All Company, brand and product names may be trademarks that are the sole
52 property of their respective owners.
53
54 The above notice and this paragraph must be included on all copies of this document that are made.
55
56 ZigBee Alliance, Inc.
57 2400 Camino Ramon, Suite 375
58 San Ramon, CA 94583, USA
59

Page ii Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

60 Contact information

61 Much of the information in this document is preliminary and subject to change. Members of the ZigBee
62 Working Group are encouraged to review and provide inputs for this proposal. For document status
63 updates, please contact:
64 Rob Alexander
65 Ember Corporation
66 25 Thomson Place
67 Boston, MA 02210
68 Email: rob.alexander@ember.com
69 Phone: +1.617.951.1244
70
71
72 You can also submit comments using the ZigBee Alliance reflector. Its web site address is:
73 www.zigbee.org
74 The information on this page should be removed when this document is accepted.

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page iii
ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

75 Participants

76 The following is a list of those who were members of the ZigBee Alliance Firmware OTA Task Group
77 leadership when this document was released:
78 Jack McPeck: Chair
79 Skip Ashton: Vice-Chair
80 Wally Barnum: Co-Vice-Chair
81 Michael Cowan: Technical Editor
82
83 The following members made specific contributions to this document:
84 Jack McPeck
85 Skip Ashton
86 Don Sturek
87 Dan Lohman
88 Wally Barnum
89 Areeya Vimayangkoon
90 Rob Alexander
91 Colby Gore
92 Don Sturek
93 John Mani
94 Jens Klostergaard Lyngsoe
95 Jeff Blevins
96 David Smith
97
98
99
100
101
102

Page iv Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

103 Table of Contents

104 1 Introduction............................................................................................................................................... 1
105 1.1 Purpose ............................................................................................................................................ 1
106 1.2 Scope................................................................................................................................................ 1

107 2 References................................................................................................................................................. 2
108 2.1 ZigBee Alliance Documents ............................................................................................................ 2

109 3 Definitions ................................................................................................................................................ 3


110 3.1 Term Definitions .............................................................................................................................. 3
111 3.2 Conformance levels ......................................................................................................................... 3

112 4 Acronyms and abbreviations .................................................................................................................... 4

113 5 General description ................................................................................................................................... 5


114 5.1 Introduction...................................................................................................................................... 5
115 5.2 Cluster list ........................................................................................................................................ 5

116 6 OTA Upgrade Cluster ............................................................................................................................... 7


117 6.1 Overview.......................................................................................................................................... 7
118 6.2 Security ............................................................................................................................................ 7
119 6.2.1 Terminology ........................................................................................................................ 7
120 6.2.2 Image Verification .............................................................................................................. 8
121 6.2.3 Image Transport .................................................................................................................. 8
122 6.2.4 Image Signature .................................................................................................................. 9
123 6.3 OTA File Format ............................................................................................................................. 9
124 6.3.1 General Structure ................................................................................................................ 9
125 6.3.2 OTA Header Format ........................................................................................................... 9
126 6.3.3 Sub-element Format .......................................................................................................... 14
127 6.3.4 Tag Identifiers ................................................................................................................... 15
128 6.3.5 ECDSA Signature Sub-element ........................................................................................ 15
129 6.3.6 ECDSA Signing Certificate Sub-element ......................................................................... 16
130 6.3.7 OTA File Naming ............................................................................................................. 16
131 6.3.8 Signatures .......................................................................................................................... 16
132 6.4 Discovery of the Upgrade Server .................................................................................................. 19
133 6.5 Server and Client ........................................................................................................................... 19
134 6.5.1 Sleepy Devices .................................................................................................................. 20
135 6.6 Dependencies ................................................................................................................................. 20
136 6.7 OTA Cluster Attributes.................................................................................................................. 21
137 6.7.1 UpgradeServerID Attribute .............................................................................................. 22
138 6.7.2 FileOffset Attribute ........................................................................................................... 22
139 6.7.3 CurrentFileVersion Attribute ............................................................................................ 22
140 6.7.4 CurrentZigBeeStackVersion Attribute .............................................................................. 22
141 6.7.5 DownloadedFileVersion Attribute .................................................................................... 23
142 6.7.6 DownloadedZigBeeStackVersion Attribute ...................................................................... 23
143 6.7.7 ImageUpgradeStatus Attribute ......................................................................................... 23
144 6.7.8 Manufacturer ID ............................................................................................................... 24
145 6.7.9 Image Type ID ................................................................................................................... 24
146 6.7.10 BlockRequestDelay ........................................................................................................... 24
147 6.8 OTA Cluster Parameters ................................................................................................................ 24
148 6.8.1 QueryJitter Parameter ....................................................................................................... 25
149 6.8.2 DataSize Parameter ........................................................................................................... 25
150 6.8.3 OTAImageData Parameter ................................................................................................ 25
151 6.8.4 CurrentTime and UpgradeTime/RequestTime Parameters ............................................... 25
152 6.9 OTA Upgrade Diagram ................................................................................................................. 27
153 6.10 Command Frames .......................................................................................................................... 27
154 6.10.1 OTA Cluster Command Identifiers ................................................................................... 28
Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page v
ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

155 6.10.2 OTA Cluster Status Codes ................................................................................................ 29


156 6.10.3 Image Notify Command .................................................................................................... 30
157 6.10.4 Query Next Image Request Command ............................................................................. 33
158 6.10.5 Query Next Image Response Command ........................................................................... 34
159 6.10.6 Image Block Request Command....................................................................................... 36
160 6.10.7 Image Page Request Command ........................................................................................ 38
161 6.10.8 Image Block Response Command .................................................................................... 42
162 6.10.9 Upgrade End Request Command ...................................................................................... 45
163 6.10.10 Upgrade End Response Command ................................................................................... 47
164 6.10.11 Query Specific File Request Command ............................................................................ 48
165 6.10.12 Query Specific File Response Command ......................................................................... 50
166 6.11 Multiple Files Required for a Bootload ........................................................................................ 51
167 6.11.1 Single OTA File with multiple sub-elements ................................................................... 51
168 6.11.2 Separate OTA files upgraded independently .................................................................... 52
169 6.11.3 Multiple OTA files dependent on each other .................................................................... 52
170 6.12 OTA Upgrade Cluster Management .............................................................................................. 52
171 6.12.1 Query Upgrade Status ....................................................................................................... 53
172 6.12.2 Query Downloaded ZigBee Stack and File versions ........................................................ 53
173 6.12.3 Rate Limiting .................................................................................................................... 53
174 6.12.4 Current Time, Request Time, and Minimum Block Request Delay ................................. 54
175 6.13 OTA Upgrade Process ................................................................................................................... 54
176 6.14 Application Profile Specific Decisions .......................................................................................... 55
177 6.14.1 SE Profile: OTA Upgrade from SE 1.x to SE 2.0 ............................................................. 55
178 6.15 OTA Upgrade Recovery ................................................................................................................ 56

179

Page vi Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

180 List of Figures

181 Figure 1 - Typical Usage of OTA Upgrade Cluster ......................................................................................... 6


182 Figure 2 - OTA Upgrade Message Diagram .................................................................................................. 27
183 Figure 3 - Rate Limiting Exchange ................................................................................................................ 54
184

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page vii
ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

185 List of Tables

186 Table 1-2 - Document revision history ........................................................................................................... ix


187 Table 5-1 - Clusters specified in this document............................................................................................... 5
188 Table 6-1 - Sample OTA File .......................................................................................................................... 9
189 Table 6-2 - OTA Header Fields ....................................................................................................................... 9
190 Table 6-3 - OTA Header Field Control Bitmask ........................................................................................... 11
191 Table 6-4 - Image Type Values ..................................................................................................................... 11
192 Table 6-5 - Recommended File Version Definition ...................................................................................... 12
193 Table 6-6 - ZigBee Stack Version Values ..................................................................................................... 13
194 Table 6-7 - Security Credential Version ........................................................................................................ 13
195 Table 6-8 - Hardware Version Format ........................................................................................................... 14
196 Table 6-9 - Sub-element format ..................................................................................................................... 14
197 Table 6-10 - Tag Identifiers ........................................................................................................................... 15
198 Table 6-11 - ECDSA Signature ..................................................................................................................... 15
199 Table 6-12 - ECDSA Signing Certificate Sub-element ................................................................................. 16
200 Table 6-13 - Attributes of OTA Upgrade Cluster .......................................................................................... 21
201 Table 6-14 - Image Upgrade Status Attribute Values .................................................................................... 23
202 Table 6-15 - Parameters of OTA Upgrade Cluster ........................................................................................ 24
203 Table 6-16 - Meaning of CurrentTime and UpgradeTime Parameters .......................................................... 26
204 Table 6-17 - OTA Upgrade cluster command frames ................................................................................... 28
205 Table 6-18 - Status Code defined and used by OTA Upgrade Cluster .......................................................... 29
206 Table 6-19 - Format of Image Notify Command Payload ............................................................................. 30
207 Table 6-20 - Image Notify Command Payload Type..................................................................................... 30
208 Table 6-21 - Format of Query Next Image Request Command Payload ....................................................... 33
209 Table 6-22 - Query Next Image Request Field Control Bitmask .................................................................. 33
210 Table 6-23 - Format of Query Next Image Response Command Payload .................................................... 34
211 Table 6-24 - Format of Image Block Request Command Payload ................................................................ 36
212 Table 6-25 - Image Block Request Field Control Bitmask............................................................................ 36
213 Table 6-26 - Image Page Request Command Payload................................................................................... 38
214 Table 6-27 - – Image Page Request Field Control Bitmask .......................................................................... 39
215 Table 6-28 - Image Block Response Command Payload with SUCCESS status .......................................... 42
216 Table 6-29 - Image Block Response Command Payload with WAIT_FOR_DATA status .......................... 42
217 Table 6-30 - Image Block Response Command Payload with ABORT status.............................................. 42
218 Table 6-31 - Format of Upgrade End Request Command Payload ............................................................... 45
219 Table 6-32 - Format of Upgrade End Response Command Payload ............................................................. 47
220 Table 6-33 - Format of Query Specific File Request Command Payload ..................................................... 48
221 Table 6-34 - Format of Query Specific File Response Command Payload ................................................... 50
222

Page viii Copyright ã 2016, The ZigBee Alliance. All rights reserved.
ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

223 Change history

224 Error! Reference source not found. shows the change history for this specification.
225 Table 1-1 - Document revision history

Revision Version Description

00 0.1 Initial draft incorporating ideas from Ember (Areeya


Vimayangkoon and Rob Alexander)

01 0.1 Incorporated comments from Colby Gore, Don Sturek,


Daniel Lohman, John Mani, Wally Barnum, Jens
Klostergaard Lyngsoe, Benno Ritter, Jeff Blevins, Rob
Alexander and Areeya Vimayangkoon
Incorporated comments from 095373r03ZB OTA Upgrades
02 0.1
TRD LB comments and more individual comments from
HA work group, Daniel Lohman, Rob Alexander and
Areeya Vimayangkoon
03 0.1 Incorporated comments from Rob Alexander, Dan Lohman,
and Wally Barnum.

04 0.1 Incorporated comments from Dan Lohman, Michael


Cowan, Wally Barnum and Rob Alexander (as of
11/18/09): usage of disable default response, image notify
command modification, new QuerySpecificFile request and
response commands, change data type for UTC time and
signature

05 0.1 Accepted changes from revision 03 and 04

06 0.1 Incorporated comments from Dan Lohman, Rob Alexandra


regarding: byte ordering of OTA header data, clarify
QueryNextImageResponse payload, adding bit control for
hw version in OTA header, use octet instead of octet string
data type for image data and add block size to
imageBlockResponse command. Add assigned cluster id
for OTA cluster of 0x0018

07 0.1 Incorporated comments from SE 1.1 test event. There are


several important changes made to the specification from
testing results and several discussions during the test event.
Changes have impacted almost all cluster commands as
well as OTA header. There will also be a new OTA cluster
specific status; replacing the use of ZCL status. Specific
description of possible error cases for each command along
with recommended or mandated actions that need to be
taken.

12 0.7 Incorporated comments from 0.7 letter ballot.

13 0.7 Incorporated comments from re-ballot.

14 0.9 Addition of sections describing ECDSA signature


verification and calculation.

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page ix


ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

15 0.9 Added descriptions of Manufacturer ID and image type ID

16 0.9 Updated for CCBs 1314 and 1315.

17 1.0 Release

18 1.0 Updated Revision number to 18 and updated table of


contents.

19 1.1 Zigbee Smart Energy 1.1.1 Release


Updates for CCBs 1474, 1478, 1446, 1453
Added Rate Limiting feature for Home Automation Profile
version 1.2 (not yet released).

20-21 1.1 Pdf version for HA1.2 0.7 Ballot

22-23 1.1 Merging in lost changes from 0422-05

226
227

Page x Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

228 1 Introduction

229 1 .1 P u rp o s e
230 The objective of this document is to provide detailed technical requirements for Over The Air image
231 upgrade. This document captures the TRD resolution analysis and presents a clear methodology for
232 implementation of the OTA Upgrade cluster using the existing ZigBee stack(s), ZigBee Cluster Library
233 and this OTA cluster specification.
234 The main goal of Over The Air Upgrade cluster is to provide an interoperable mean for devices from
235 different manufacturers to upgrade each other’s image. Additionally, the OTA Upgrade cluster defines
236 a mechanism by which security credentials, logs and configuration file types are accessible by offering
237 a solution that utilizes a set of optional and mandatory commands.

238 1 .2 Scope
239 The document will only describe features that require implementation in order to be ZigBee OTA
240 upgrade (cluster) certified. Other optional features including using multicast for sending upgrade
241 messages and (upgrade) cloning will not be discussed in this document.
242 Currently, only Application Bootloader support is required in order to support ZigBee OTA Upgrade
243 cluster. MAC Bootloader upgrading is not supported at the moment.

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page 1


ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

244 2 References

245 2 .1 Z ig B e e A llia n c e D o c u m e n ts
246 [R1] 084912r05ZB_ZARC_Interest-OTA_Upgrades_MRD.doc
247 [R2] 085028r01ZB_ZARC_Interest-OTA_Upgrades_TRD.doc
248 [R3] 075123r02ZB_AFG-ZigBee_Cluster_Library_Specification.pdf
249 [R4] 075356r16ZB_AMI_PTG-AMI_Profile_Specification.pdf
250 [R5] 053474r18ZB_TSC-ZigBee-Specification.pdf

Page 2 Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

251 3 Definitions

252 3 .1 T e rm D e fin itio n s


253 Application Bootloading Bootloading method where the device has memory for receiving
254 and storing a new image while it is running its current stack and
255 application. The new image is fully received before it is applied.
256 OTA Upgrade Server The ZigBee device class that sends the commands and image to a
257 client device as part of OTA upgrade process. How the server
258 retrieves the upgrade image is outside the scope of this document.
259 OTA Upgrade Client The ZigBee device that is the target for receiving and upgrading its
260 (running) image.
261 Vendor A company or an entity that provides the software. Used in the
262 specification when referring to ZigBee stack provider.
263 Manufacturer A company or a group of companies that produce the device
264 including both the software and the hardware. A device’s
265 manufacturer may refer to several entities; each contributing parts
266 to make up the device.

267 3 .2 C o n fo r m a n c e le v e ls
268 3.2.1 expected: A key word used to describe the behavior of the hardware or software in the design
269 models assumed by this Draft. Other hardware and software design models may also be implemented.
270 3.2.2 may: A key word that indicates flexibility of choice with no implied preference.
271 3.2.3 shall: A key word indicating a mandatory requirement. Designers are required to implement all
272 such mandatory requirements.
273 3.2.4 should: A key word indicating flexibility of choice with a strongly preferred alternative.
274 Equivalent to the phrase is recommended.

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page 3


ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

275 4 Acronyms and abbreviations


276 AES Advanced Encryption Standard
277 AMI Advanced Metering Infrastructure or Advanced Metering Initiative
278 ESP Energy Service Portal
279 EUI64 Extended Universal Identifier-64
280 HA Home Automation (Application Profile)
281 HAN Home Area Network
282 IHD In-Home Display
283 MRD Market Requirements Document
284 NAN Neighborhood Area Network
285 OTA Over the Air
286 PAN Personal Area Network
287 ZED ZigBee End Device (equivalent to IEEE’s RFD – Reduced Functionality Device)
288 ZR ZigBee Router (equivalent to IEEE’s FFD – Full Functionality Device)
289 SE Smart Energy (Application Profile)
290 TC Trust Center
291 TRD Technical Requirements Document
292 ZCL ZigBee Cluster Library
293 ZDO ZigBee Device Object
294 ZDP ZigBee Device Profile
295

Page 4 Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

296 5 General description

297 5 .1 In tro d u c tio n


298 The existing OTA upgrade methods available are platform specific, not OTA interoperable and do not
299 provide a common framework for upgrading networks that support a mix of devices from multiple
300 platforms and ZigBee Stack vendors.
301 The intent of this document is to provide an interoperable OTA upgrade of new image for devices
302 deployed in the field. As long as the device supports the OTA Upgrade cluster and it is certified by an
303 approved test house, its image shall be upgradeable by another device from the same or different
304 manufacturer that also implemented and certified the OTA Upgrade cluster.
305 OTA Upgrade cluster will also require that in order to support OTA upgrade, the device will need to
306 have an application bootloader installed as well as sufficient memory (external or internal) to store the
307 newly loaded image. An application bootloader uses the running ZigBee stack and application to
308 retrieve and store a new image. Depending upon the manufacturer, the image may consist of a
309 bootloader image, a ZigBee stack image or only a patch to the application image. Whatever comprises
310 the OTA upgrade image being sent to the node does not concern the ZigBee OTA cluster and it is
311 outside the scope of this document.
312 To use an application bootloader, the device is required to have sufficient memory (internal or external)
313 to store the newly downloaded OTA upgrade image. By doing so, the current running image is not
314 overwritten until the new image has been successfully downloaded. It also allows the possibility of a
315 node saving an image in its memory and forwarding that image to another node. Application
316 bootloading provides flexibility of when the device decides to download new OTA upgrade image as
317 well as when the device decides to switch to running the new image.
318 Since the bootloading is done at the application level, it automatically makes use of various features
319 already offered by the ZigBee Network Layer and Application Sub Layer (APS) including the ability to
320 bootload a device that is multiple hops away, message retries to increase reliability, and security. It
321 also allows the network to continue to operate normally while the bootload is in progress. In addition,
322 it supports bootloading of sleeping (RxOnWhenIdle=FALSE) devices.
323 The application bootload messages are built upon typical ZigBee messages, with additional ZigBee
324 Cluster Library (ZCL) header and payload and ZigBee OTA cluster specific payload.

325 5 .2 C lu s te r lis t
326 The clusters defined in this document are listed in Error! Reference source not found. 2.
327 Table 5-1 - Clusters specified in this document

Cluster Name Cluster ID Description

OTA Upgrade 0x0019 Parameters and commands for upgrading image on devices Over The
Air.

328
329

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page 5


ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

Upgrade Client Upgrade Server

C S

C = Client S = Server

330 Figure 1 - Typical Usage of OTA Upgrade Cluster


331 Upgrade Client is a device to be upgraded with new image. Upgrade server is a device that has the new
332 image to send to the client. This document shall specify how the client discovers the server, the over
333 the air message format between the client and server, and the means for the server to signal the client to
334 switch to running the new image.
335 It is possible that the upgrade server may have several OTA upgrade images from different
336 manufacturers. How the upgrade server receives these OTA upgrade images and how it stores and
337 manages them are outside the scope of this document.
338 In addition to the typical use case of transferring new firmware images to client devices, OTA Upgrade
339 cluster may also be used to transfer device specific file types such as log, configuration or security
340 credentials (needed for upgrading from SE 1.0 or SE 1.1 to SE 2.0). The cluster provides flexibility in
341 OTA header and a set of optional commands that make transferring of such file types possible. It is up
342 to each application profile and manufacturer to decide whether to implement and mandate such
343 features.

Page 6 Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

344 6 OTA Upgrade Cluster

345 6 .1 O v e rv ie w
346 The cluster provides a standard way to upgrade devices in the network via OTA messages. Thus the
347 upgrade process may be performed between two devices from different manufacturers. Devices are
348 required to have application bootloader and additional memory space in order to successfully
349 implement the cluster.
350
351 It is the responsibility of the server to indicate to the clients when the update images are available. The
352 client may be upgraded, downgraded or reinstalled. The upgrade server must know which client
353 devices to upgrade and to what file version. The upgrade server may be notified of such information
354 via the backend system. For ZR clients, the server may send a message to notify the device when an
355 updated image is available. It is assumed that ZED clients will not be awake to receive an unsolicited
356 notification of an available image. All clients (ZR and ZED) shall query (poll) the server periodically
357 to determine whether the server has an image update for them1.
358
359 The cluster is implemented in such a way that the client service works on both ZED and ZR devices.
360 Being able to handle polling is mandatory for all server devices while being able to send a notify is
361 optional. Hence, all client devices must be able to use a ‘poll’ mechanism to send query message to the
362 server in order to see if the server has any new file for it. The polling mechanism also puts fewer
363 resources on the upgrade server. It is ideal to have the server maintain as little state as possible since
364 this will scale when there are hundreds of clients in the network. The upgrade server is not required to
365 keep track of what pieces of an image that a particular client has received; instead the client shall do
366 that. Lastly poll makes more sense for devices that may need to perform special setup to get ready to
367 receive an image, such as unlocking flash or allocating space for the new image.
368

369 6 .2 S e c u rity
370 Security for the OTA Upgrade cluster encompasses these areas: image verification, image transport,
371 and image encryption. The OTA Upgrade cluster is intended to be used with all ZigBee application
372 profiles. Security mechanism of each application profile dictates the security level of over-the-air
373 image upgrading. For example application profile with strict security policies (such as Smart Energy)
374 may support image signature as well as encryption in both network and APS layers; while Home
375 Automation application profile may only support network encryption . Each application profile must
376 decide the list of required security policies for their use of the OTA Upgrade cluster.

377 6.2.1 Terminology


378 There are many aspects to security. These can be broken down into the following areas:
379 confidentiality, integrity, authentication, availability, and non-repudiation. Authorization and auditing
380 can also be considered as part of security.
381 Confidentiality – This is the requirement that no third party can read data that is not intended for that
382 party. This is discussed below in Image Encryption.
383 Integrity – This is the property of security where the recipient can verify that data was not modified
384 between the time it was initially distributed by the sender and when it was received by the intended
385 recipient. Modifications to the data by third parties can be detected. This is discussed in Image
386 Verification below.
387 Authentication – This is the property where the identity of the sender of data can be verified by the
388 intended recipient. This is discussed in Image Verification below.

1
CCB 1373 – Image notify is optional

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page 7


ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

389 Availability – This refers to the property that resources are available when they are required and
390 cannot be unfairly consumed by an attacker. The OTA Upgrade cluster does not address this; as such it
391 will not be discussed any further.
392 Non-repudiation – This refers to the property where a sender/receiver cannot deny that a security
393 exchange took place. The OTA Upgrade cluster does not address this; as such it will not be discussed
394 any further.

395 6.2.2 Image Verification

396 6.2.2.1 Asymmetric Verification of Authenticity and Integrity


397 It is strongly encouraged that there is a means to verify the authenticity and integrity of the bootload
398 image. This is most often accomplished through asymmetric encryption technologies (i.e.
399 public/private keys) where only one device is able to create a digital signature but many devices are
400 able to verify it. Bootload images may be signed by the private key of the manufacturer with that
401 signature appended to the image that is transported to the device. Once the complete image has been
402 received the signature is verified using the public key of the signer.
403 Devices may be pre-installed with the certificate (public key) of the device that created the signature, or
404 they may receive the certificate over-the-air. How the signer's security data is obtained is considered
405 outside the scope of the OTA Upgrade cluster and is manufacturer specific. When signer certificates
406 are sent over-the-air and not pre-installed, it is recommended that the transportation of the certificate be
407 done using encryption from a trusted source to reduce the chance an attacker may inject their own
408 signer certificate into the device.
409 Images with verification mechanisms built in may be transported over insecure communication
410 mechanisms while still maintaining their authenticity and integrity. In fact it is likely that the
411 originator of the upgrade image (the manufacturer) will not be directly connected to any ZigBee
412 networks and therefore distribute the upgrade image across other mediums (such as the internet) before
413 arriving on the ZigBee network. In that case it is crucial that the Image Verification be independent of
414 the communication medium. Any attempts to tamper with the signature or the data itself must be
415 detected and will cause the upgrade image to be rejected by the target device. An attacker that crafts its
416 own signed image and tries to have it accepted will be rejected since that image will not be signed by
417 the manufacturer's signing authority.
418 It is up to each profile to determine the minimum requirements for image verification. For Smart
419 Energy profile there is already a minimum set of security requirements included in NEMA SG-AMI 1-
420 2009. The OTA Upgrade cluster will communicate the methods in use for basic image verification.
421 Individual manufacturers are free to augment this and provide their own extensions. Those extensions
422 are outside the scope of the OTA Upgrade cluster.
423 Without asymmetric encryption technology, a device is limited in its ability to authenticate images.
424 Images may be encrypted with symmetric keys such that only those devices that need to decrypt the
425 image have access to the key. However the security of this system is dependent on the security of all
426 devices that have access to the symmetric key.

427 6.2.2.2 Verification of Integrity by Hash Value


428 For profiles that do not employ the asymmetric verification method, the authenticity of the OTA image
429 cannot be verified. However it is possible to verify the integrity of the OTA image by using the hash
430 value method in section 6.3.10. There will be no signer certificate nor no signature involved.
431

432 6.2.3 Image Transport


433 When there is a means to verify the authenticity of the bootload images, transport of the images in a
434 secure fashion provides little additional security to the integrity and authenticity. What secure
435 transportation provides is a means to communicate the policies about when a device should perform
436 upgrade or what version it should upgrade to.

Page 8 Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

437 A secured ZigBee network uses network security for all messages, but that does not provide point-to-
438 point security. APS security should be used to assure that messages are sent from only the trusted
439 source (the upgrade server). This will be utilized to provide implicit and explicit authorization by the
440 upgrade server about when devices will initiate bootload events.
441 Distribution of upgrade image via broadcast or multicast messages is not recommended because its lack
442 of point-to-point security. Reception of upgrade images via broadcast or multicast should not be
443 inferred as authorization by the upgrade server to initiate the upgrade. In this case, the act of receiving
444 the image and upgrading it should be split up into separate events. The latter communications should
445 be done via unicast to verify that the upgrade server has authorized a device to upgrade to a previously
446 received image. Application profiles must determine what level of authorization is required by the
447 upgrade server.

448 6.2.4 Image Signature


449 For certain application profiles, the OTA Upgrade cluster provides mechanisms to sign the OTA file to
450 protect the authenticity and integrity of the image. The application profiles, must determine if this is
451 required.

452 6.2.5 Image Integrity Code


453 For certain application profiles, the OTA Upgrade cluster provides hash mechanisms to provide
454 protection against unintended data corruption. The application profiles, must determine if this is
455 required.
456

457 6 .3 O T A F ile F o rm a t

458 6.3.1 General Structure


459 The OTA file format is composed of a header followed by a number of sub-elements. The header
460 describes general information about the file such as version, the manufacturer that created it, and the
461 device it is intended for. Sub-elements in the file may contain upgrade data for the embedded device,
462 certificates, configuration data, log messages, or other manufacturer specific pieces. Below is an
463 example file.
464 Table 6-1 - Sample OTA File

Octets Variable Variable Variable Variable

Data OTA Header Upgrade Image Signer Certificate Signature

465
466 The OTA header will not describe details of the particular sub-elements. Each sub-element is self-
467 describing. With exception of a few sub-elements, the interpretation of the data contained is up to the
468 manufacturer of the device.

469 6.3.2 OTA Header Format


470 Table 6-2 - OTA Header Fields

Octets Data Types Field Names Mandatory/Optional

4 Unsigned OTA upgrade file identifier M


32-bit integer

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page 9


ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

2 Unsigned OTA Header version M


16-bit integer

2 Unsigned OTA Header length M


16-bit integer

2 Unsigned OTA Header Field control M


16-bit integer

2 Unsigned Manufacturer code M


16-bit integer

2 Unsigned Image type M


16-bit integer

4 Unsigned File version M


32-bit integer

2 Unsigned ZigBee Stack version M


16-bit integer

32 Character string OTA Header string M

4 Unsigned Total Image size M


32-bit integer
(including header)

0/1 Unsigned Security credential version O


8-bit integer

0/8 IEEE Address Upgrade file destination O

0/2 Unsigned Minimum hardware version O


16-bit integer

0/2 Unsigned Maximum hardware version O


16-bit integer

471 The first entry of the table above (OTA upgrade file identifier) represents the first field in the OTA
472 header, and the last entry represents the last field. The endianness used in each data field shall be little
473 endian in order to be compliant with general ZigBee messages.
474 Please refer to section 2.5.2 in [R3] for more description on data types.

475 6.3.2.1 OTA Upgrade File Identifier


476 The value is a unique 4-byte value that is included at the beginning of all ZigBee OTA upgrade image
477 files in order to quickly identify and distinguish the file as being a ZigBee OTA cluster upgrade file,
478 without having to examine the whole file content. This helps distinguishing the file from other file
479 types on disk. The value is defined to be “0x0BEEF11E”.

480 6.3.2.2 OTA Header Version


481 The value enumerates the version of the header and provides compatibility information. The value is
482 composed of a major and minor version number (one byte each). The high byte (or the most significant
483 byte) represents the major version and the low byte (or the least significant byte) represents the minor
484 version number. A change to the minor version means the OTA upgrade file format is still backward
485 compatible, while a change to the major version suggests incompatibility.

Page 10 Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

486 The current OTA header version shall be 0x0100 with major version of “01” and minor version of
487 “00”.

488 6.3.2.3 OTA Header Length


489 This value indicates full length of the OTA header in bytes, including the OTA upgrade file identifier,
490 OTA header length itself to any optional fields. The value insulates existing software against new
491 fields that may be added to the header. If new header fields added are not compatible with current
492 running software, the implementations should process all fields they understand and then skip over any
493 remaining bytes in the header to process the image or signing certificate. The value of the header
494 length depends on the value of the OTA header field control, which dictates which optional OTA
495 header fields are included.

496 6.3.2.4 OTA Header Field Control


497 The bit mask indicates whether additional information such as Image Signature or Signing Certificate
498 are included as part of the OTA Upgrade Image.
499 Table 6-3 - OTA Header Field Control Bitmask

Bits Name

0 Security Credential Version Present

1 Device Specific File

2 Hardware Versions Present

3 - 15 Reserved

500 Security credential version present bit indicates whether security credential version field is present or
501 not in the OTA header.
502 Device specific file bit in the field control indicates that this particular OTA upgrade file is specific to a
503 single device.
504 Hardware version present bit indicates whether minimum and maximum hardware version fields are
505 present in the OTA header or not.

506 6.3.2.5 Manufacturer Code


507 This is the ZigBee assigned identifier for each member company. When used during the OTA upgrade
508 process, manufacturer code value of 0xffff has a special meaning of a wild card. The value has a
509 ‘match all’ effect. OTA server may send a command with wild card value for manufacturer code to
510 match all client devices from all manufacturers.

511 6.3.2.6 Image Type


512 The manufacturer should assign an appropriate and unique image type value to each of its devices in
513 order to distinguish the products. This is a manufacturer specific value. However, the OTA Upgrade
514 cluster has reserved the last 64 values of image type value to indicate specific file types such as security
515 credential, log, and configuration. When a client wants to request one of these specific file types, it
516 shall use one of the reserved image type values instead of its own (manufacturer specific) value when
517 requesting the image via Query Next Image Request command.
518 Table 6-4 - Image Type Values

File Type Values File Type Description

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page 11


ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

0x0000 – 0xffbf Manufacturer Specific


0xffc0 Client2 Security credentials
0xffc1 Client3 Configuration
0xffc2 Server4 Log
0xffc3 – 0xfffe Reserved (unassigned)
0xffff Reserved: wild card
519 Image type value of 0xffff has a special meaning of a wild card. The value has a ‘match all’ effect.
520 For example, the OTA server may send Image Notify command with image type value of 0xffff to
521 indicate to a group of client devices that it has all types of images for the clients. Additionally, the
522 OTA server may send Upgrade End Response command with image type value of 0xffff to indicate a
523 group of clients, with disregard to their image types, to upgrade.

524 6.3.2.7 File Version


525 For firmware image, the file version represents the release and build number of the image’s application
526 and stack. The application release and build numbers are manufacturer specific, however, each
527 manufacturer should obtain stack release and build numbers from their stack vendor. OTA Upgrade
528 cluster makes the recommendation below regarding how the file version should be defined, in an
529 attempt to make it easy for humans and upgrade servers to determine which versions are newer than
530 others. The upgrade server should use this version value to compare with the one received from the
531 client.
532 The server may implement more sophisticated policies to determine whether to upgrade the client
533 based on the file version. A higher file version number indicates a newer file.
534 Table 6-5 - Recommended File Version Definition
Application Release Application Build Stack Release Stack Build
1 byte 1 byte 1 byte 1 byte
8-bit integer 8-bit integer 8-bit integer 8-bit integer
535
536 For example,
537 File version A: 0x10053519 represents application release 1.0 build 05 with stack release 3.5 b19.
538 File version B: 0x10103519 represents application release 1.0 build 10 with stack release 3.5 b19.
539 File version C: 0x10103701 represents application release 1.0 build 10 with stack release 3.7 b01.
540 File version B is newer than File version A because its application version is higher while File version
541 C is newer than File version B because its stack version is higher.
542 The file version value may be defined differently for different image types. For example, version
543 scheme for security credential data may be different than that of log or configuration file or a normal
544 firmware upgrade image version5. The specific implementation of a versioning scheme is manufacturer
545 specific.
546 Note that a binary-coded decimal convention (BCD) concept is used here for version number. This is
547 to allow easy conversion to decimal digits for printing or display, and allows faster decimal
548 calculations.

2
CCB 1478
3
CCB 1478
4
CCB 1478
5
CCB 1474

Page 12 Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

549 6.3.2.8 ZigBee Stack Version


550 This information indicates the ZigBee stack version that is used by the application. This provides the
551 upgrade server an ability to coordinate the distribution of images to devices when the upgrades will
552 cause a major jump that usually breaks the over-the-air compatibility, for example, from ZigBee Pro to
553 upcoming ZigBee IP. The values below represent currently available ZigBee stack versions
554 Table 6-6 - ZigBee Stack Version Values

ZigBee Stack Version Stack Name


Values

0x0000 ZigBee 2006

0x0001 ZigBee 2007

0x0002 ZigBee Pro

0x0003 ZigBee IP

0x0004 – 0xffff Reserved

555 6.3.2.9 OTA Header String


556 This is a manu facturer specific string that may be used to store other necessary information as seen
557 fit by each manufacturer. The idea is to have a human readable string that can prove helpful during
558 development cycle. The string is defined to occupy 32 bytes of space in the OTA header.

559 6.3.2.10 Total Image Size


560 The value represents the total image size in bytes. This is the total of data in bytes that shall be
561 transferred over-the-air from the server to the client. In most cases, the total image size of an OTA
562 upgrade image file is the sum of the OTA header and the actual file data (along with its tag) lengths. If
563 the image is a signed image and contains a certificate of the signer, then the Total image size shall also
564 include the signer certificate and the signature (along with their tags) in bytes.
565 This value is crucial in the OTA upgrade process. It allows the client to determine how many image
566 request commands to send to the server to complete the upgrade process.

567 6.3.2.11 Security Credential Version


568 This information indicates security credential version type, such as SE1.0 or SE2.0 that the client is
569 required to have, before it shall install the image. One use case for this is so that after the client has
570 downloaded a new image from the server, it should check if the value of security credential version
571 allows for running the image. If the client’s existing security credential version does not match or is
572 outdated from what specified in the OTA header, it should obtain new security credentials before
573 upgrading to running the new image.
574 Table 6-7 - Security Credential Version

Security Credential Security Credential Version Types


Version Values

0x00 SE 1.0

0x01 SE 1.1

0x02 SE 2.0

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page 13


ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

0x03 – 0xff Reserved

575 6.3.2.12 Upgrade File Destination


576 If Device Specific File bit is set, it indicates that this OTA file contains security credential/certificate
577 data or other type of information that is specific to a particular device. Hence, the upgrade file
578 destination field (in OTA header) should also be set to indicate the IEEE address of the client device
579 that this file is meant for.

580 6.3.2.13 Minimum Hardware Version


581 The value represents the earliest hardware platform version this image should be used on. This field is
582 defined as follows:
583 Table 6-8 - Hardware Version Format
Version Revision
1 byte 1 byte
8-bit integer 8-bit integer
584 The high byte represents the version and the low byte represents the revision.

585 6.3.2.14 Maximum Hardware Version


586 The value represents the latest hardware platform this image should be used on. The field is defined
587 the same as the Minimum Hardware Version (above).
588 The hardware version of the device should not be earlier than the minimum (hardware) version and
589 should not be later than the maximum (hardware) version in order to run the OTA upgrade file.

590 6.3.3 Sub-element Format


591 Sub-elements in the file are composed of an identifier followed by a length field, followed by the data.
592 The identifier provides for forward and backward compatibility as new sub-elements are introduced.
593 Existing devices that do not understand newer sub-elements may ignore the data.
594 Table 6-9 - Sub-element format

Octets 2-bytes 4-bytes Variable

Data Tag ID Length Field Data

595
596 Sub-elements provide a mechanism to denote separate sections of data utilized by the device for the
597 upgrade. For example, a device that has multiple processors each with their own firmware image could
598 use a separate sub-element for each one. The details of how this is handled would be up to the
599 manufacturer of the device.
600 A few sub-elements are not manufacturer specific and defined by the OTA cluster itself. See section
601 6.3.4 below.

602 6.3.3.1 Tag ID


603 The tag identifier denotes the type and format of the data contained within the sub-element. The
604 identifier is one of the values from Table 12 below.

Page 14 Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

605 6.3.3.2 Length Field


606 This value dictates the length of the rest of the data within the sub-element in bytes. It does not include
607 the size of the Tag ID or the Length Fields.

608 6.3.3.3 Data


609 The length of the data in the sub-element must be equal to the value of the Length Field in bytes. The
610 type and format of the data contained in the sub-element is specific to the Tag.

611 6.3.4 Tag Identifiers


612 Sub-elements are generally specific to the manufacturer and the implementation. However this
613 specification has defined a number of common identifiers that may be used across multiple
614 manufacturers.
615 Table 6-10 - Tag Identifiers

Tag Identifiers Description

0x0000 Upgrade Image

0x0001 ECDSA Signature

0x0002 ECDSA Signing Certificate

0x0003 Image Integrity Code

0x0004 – 0xefff Reserved

0xf000 – 0xffff Manufacturer Specific Use

616 Manufacturers may define tag identifiers for their own use and dictate the format and behavior of
617 devices that receive images with that data.

618 6.3.5 ECDSA Signature Sub-element


619 The ECDSA Signature sub-element contains a signature for the entire file as means of insuring that the
620 data was not modified at any point during its transmission from the signing device.
621 If an image contains an ECDSA Signature Sub-element it shall be the last sub-element in the file.
622 Table 6-11 - ECDSA Signature

Octets 2-bytes 4-bytes 8-bytes 42-bytes

Data Tag ID: 0x0001 Length Field: Signer IEEE Signature Data
0x00000032 Address

623 6.3.5.1 Signer IEEE Address


624 This field shall contain the IEEE address of the device that created the signature, in little endian format.

625 6.3.5.2 Signature Data


626 This field shall contain the ECDSA signature data, and is generated as described in the section ECDSA
627 Signature Calculation.

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page 15


ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

628 6.3.6 ECDSA Signing Certificate Sub-element


629 This sub-element is used to include information about the authority that generated the signature for the
630 OTA file.
631 Table 6-12 - ECDSA Signing Certificate Sub-element

Octets 2-bytes 4-bytes 48-bytes

Data Tag ID: 0x0002 Length Field: ECDSA


0x00000030 Certificate

632 6.3.6.1 ECDSA Certificate


633 This shall contain the data for the ECDSA certificate of the device. The certificate shall be formatted
634 as described in the Smart Energy specification [R4].

635 6.3.7 Image Integrity Code Sub-element


636 This sub-element includes a hash value used to verify the integrity of the OTA file.
637 Table 6-13 – Hash Value Sub-element

Octets 2-bytes 4-bytes 16-bytes

Data Tag ID: 0x0003 Length Field: Hash Value


0x00000010

638 6.3.7.1 Hash Value


639 This hash value used to verify the integrity of the OTA file and the detail to generate the hash is listed
640 in section 6.3.10.
641

642 6.3.8 OTA File Naming


643 OTA Upgrade cluster provides recommendation below regarding OTA Upgrade image file naming
644 convention and extension. This is an effort to assist the upgrade server in sorting different image files
645 received from different manufacturers.
646 The OTA Upgrade image file name should contain the following information at the beginning of the
647 name with each field separated by a dash (“-“): manufacturer code, image type and file version. The
648 value of each field stated should be in hexadecimal number and in capital letter. Each manufacturer
649 may append more information to the name as seen fit to make the name more specific. The OTA
650 Upgrade file extension should be “.zigbee”.
651 An example of OTA Upgrade image file name and extension is “1001-00AB-10053519-
652 upgradeMe.zigbee”.

653 6.3.9 Signatures


654 It is up to the application profile to determine whether or not a signature is necessary for over the air
655 upgrade files. If a profile has mandated the use of signatures then a device adhering to that profile shall
656 only accept images that have a signature sub-element. If such a device receives an OTA file that does
657 not contain a signature sub-element then the device will discard the image and proceed with any further
658 processing required by the specific application profile. The device must verify the signature as
659 described in the following sections prior to acting on any data inside the file.

Page 16 Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

660 If a profile does not require the use of signatures then devices may still choose to use images with
661 signatures. However it is highly recommended that such a device only accept images either with
662 signatures or without, but not accept both. A device greatly reduces its security if it will accept signed
663 or unsigned upgrade files.

664 6.3.9.1 ECDSA Signature Calculation


665 It is expected that in most all cases the signer device is not a real ZigBee device and is not part of any
666 ZigBee network. Therefore the signer’s IEEE is not a real ZigBee device address, but the address of a
667 virtual device that exists only to sign upgrade images for a manufacturer and or a set of products. Its
668 address should be separate from the block of device addresses produced by a manufacturer as certified
669 ZigBee devices.
670 The signature calculation shall be performed as follows:
671 1. A valid OTA image shall have previously been created including all the necessary header
672 fields, tags, and their data, in the image.
673 2. An ECDSA signer certificate tag sub-element shall be constructed with the certificate of the
674 signing device, and appended to the image.
675 3. An ECDSA signature tag sub-element shall be constructed including only the tag ID, the
676 length of the tag (50 bytes), and the signer’s IEEE address. No actual signature data shall be
677 included yet. The tag shall be appended to the image.
678 4. The OTA image header shall be updated with a new total image size, including the signature
679 certificate tag sub-element that was added, and the full size of the ECDSA signature tag sub-
680 element (56 bytes).
681 5. A message digest shall be calculated over the entire image.
682 a. The message digest shall be computed by using the Matyas-Meyer-Oseas
683 cryptographic hash specified in section B.6 of [R5]. This uses the extended AES-
684 MMO hash proposed as a change to an earlier version of [R5].
685 6. The CA public key of the device that issued the signer’s certificate shall be obtained.
686 7. The signer device’s public key shall be obtained by extracting it from the signer certificate.
687 8. The ECDSA algorithm shall be used to calculate the signature using the message digest, the
688 CA’s public key, and the signer device’s public key.
689 9. The r and s components of the signature shall both be appended to the image. The r
690 component shall be appended first, and then the s component.
691

692 6.3.9.2 ECDSA Signature Verification


693 The signature of a completely downloaded OTA file shall be verified as follows.
694 1. The ZigBee device shall first determine if the signer of the image is an authorized signer.
695 a. It does this by extracting the signer IEEE from ECDSA signature tag sub-element.
696 i. If an ECDSA signature tag sub-element is not found in the image then the
697 image shall be discarded as invalid and no further processing shall be done.
698 b. The device shall compare the extracted signer IEEE with the list of local, known,
699 authorized signers and determines if there is a match.
700 c. If no match is found then the image shall be discarded as invalid and no further
701 processing shall be done.
702 2. The device shall then obtain the certificate associated with the signer IEEE.
703 a. The device shall extract the signer certificate data from the ECDSA signing
704 certificate sub-element.
705 i. If there is no ECDSA signing certificate tag sub-element then it shall discard
706 the image as invalid and no further processing shall be done.
707 b. The device shall verify that the signer IEEE address within the ECDSA signature tag
708 sub-element matches the subject field of the ECDSA signing certificate sub-element.
709 i. Note: The subject field IEEE is in big-endian format and the signer IEEE is
710 in little endian format.

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page 17


ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

711 c. If the addresses do not match then the image shall be discarded as invalid and no
712 further processing shall be done.
713 3. The device shall then obtain the CA public key associated with the signer.
714 a. The device shall obtain the IEEE of the CA public key from the issuer field within
715 the ECDSA certificate data of the ECDSA signing certificate sub-element.
716 b. If the IEEE of the CA does not match its list of known CAs, or the public key for that
717 CA could not be locally obtained, then the image shall be discarded as invalid and no
718 further processing shall be done.
719 4. The device shall then calculate the message digest of the image.
720 a. The digest shall be calculated using the Matyas-Meyer-Oseas cryptographic hash
721 function over the entire image except for the signature data of the ECDSA signature
722 sub-element.
723 i. Note: The calculation shall include the signature tag ID of the ECDSA
724 signature sub-element, the length field of the ECDSA signature sub-elment,
725 and the signer IEEE field of the ECDSA signature sub-element.
726 5. The signer’s public key shall be obtained by extracting it from the signer certificate.
727 6. The device shall then pass the calculated digest value, signer certificate, and CA public key to
728 the ECDSA verification algorithm.
729 7. If the ECDSA algorithm returns success, then the image shall be considered valid.
730 8. If the ECDSA algorithm returns any other result, then the image shall be discarded as invalid
731 and no further processing shall be done.

732 6.3.10 Image Integrity Code


733 It is up to the application profile to determine whether or not an image integrity code is necessary for
734 over the air upgrade files. Profiles that already use digital signatures shall NOT use this Image Integrity
735 Hash Code sub-element in conjunction to the ECDSA signature. If a profile has mandated the use of
736 hash values then a device adhering to that profile shall only accept images that have a valid hash sub-
737 element. If such a device receives an OTA file that does not contain a hash sub-element then the device
738 will discard the image and proceed with any further processing required by the specific application
739 profile. The device must verify the hash as described in the following sections prior to acting on any
740 data inside the file.
741 The hash value provides protection against unintended data corruption. An OTA image which is hosted
742 at a back-end image repository might be stored and forwarded at several intermediate locations before
743 it reaches the OTA server, where it is typically stored on a local file system. There is a potential for this
744 file being corrupted either during transfer or as a result of file system errors. The hash value provides
745 an interoperable way for OTA servers to detect corrupt images before advertising such files to OTA
746 clients. Otherwise corrupt images might only be detected by OTA clients after complete download
747 over-the-air. Since this condition cannot be detected by the OTA server, it would offer the same
748 (corrupt) file over and over again.
749 If the application profile does not mandate the use of this hash value, it is strongly recommended that
750 image integrity is ascertained using another approach, for example a hash value (SHA-256 or
751 comparable) that is maintained out-of-band and provided by the device vendor together with the OTA
752 image.

753 6.3.10.1 Hash Value Calculation


754 The hash value calculation shall be performed as follows:

755 1. A valid OTA image shall have previously been created including all the necessary header
756 fields, tags, and their data, in the image.
757 2. An AES-MMO hash value tag sub-element header shall be constructed including only the tag
758 ID and the length of the sub-element data (16 bytes). No actual data shall be included yet. The
759 tag header shall be appended to the image.
760 3. The OTA image header shall be updated with a new total image size, including the hash tag
761 sub-element header that was added, and the full size of the hash tag sub-element (6 + 16 = 22
762 bytes).

Page 18 Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

763 4. The hash value shall be calculated using the Matyas-Meyer-Oseas cryptographic hash
764 specified in section B.6 of [R5]. The hash is calculated starting with the OTA image header
765 and spanning just before the hash sub-element header, i.e. the calculation takes in to account
766 the first byte of the image header up to the last byte of the sub-element preceding the hash
767 sub-element.
768 5. The computed hash value shall be appended to the image.

769 6.3.10.2 Hash Value Verification


770 The hash value of a complete OTA file shall be verified as follows.
771 1. The device shall calculate the hash value of the image using the Matyas-Meyer-Oseas
772 cryptographic hash function. The hash is calculated starting with the OTA image header and
773 spanning just before the hash sub-element header, i.e. the calculation takes in to account the
774 first byte of the image header up to the last byte of the sub-element preceding the hash sub-
775 element.
776 2. The device shall then compare the calculated hash value with the data stored in the hash
777 tag sub-element data. If both octet strings are equal, the image shall be considered intact,
778 otherwise the image shall be considered corrupt.
779 3. If the image is regarded corrupt, it shall be discarded as invalid and no further
780 processing shall be done.
781

782 6 .4 D is c o v e r y o f th e U p g ra d e S e rv e r
783 Before becoming part of the network, a device may be preprogrammed with the IEEE address of the
784 authorized upgrade server. In this case, once the device is part of the network, it shall discover the
785 network address of the upgrade server via ZDO network address discovery command.
786
787 If the device is not preprogrammed with the upgrade server’s IEEE address, the device shall discover
788 the upgrade server before it participates in any upgrade process. The device shall send Match
789 Descriptor Request (ZDO command) to discover an upgrade server by specifying a single OTA cluster
790 ID in the input Cluster attribute. If the receiving node is an upgrade server, it shall reply with Match
791 Descriptor Response, with the (active) endpoint that the OTA cluster is implemented on, hence,
792 identifying itself as acting as server in OTA Upgrade cluster. Since Match descriptor request may be
793 sent as unicast or broadcast, the client may get multiple responses if there are more than one server in
794 the network. The client shall use the first response received6.. Each application profile should specify
795 the frequency of OTA server discovery done by the client. After discovering the OTA server’s short
796 ID via the ZDO Match descriptor request the client shall discover the IEEE address of the upgrade
797 server via ZDO IEEE address discovery command and store the value in UpgradeServerID attribute.
798
799 A node shall have an application link key with the Upgrade server; it shall request one prior to any
800 OTA operations.
801 1. If the upgrade server is the trust center, it should use its trust center link key.
802 2. If the upgrade server is not the trust center, the device shall perform partner link key request,
803 in case of SE profile or use the global link key in case of other profiles.
804

805 6 .5 S e rv e r a n d C lie n t
806 The server must be able to store one or more OTA upgrade image(s). The server may notify devices in
807 the network when it receives new OTA upgrade image by sending an Image Notify Command. The
808 Image Notify Command will be received reliably only on ZR devices since ZED devices may have
809 their radio off at the time. The Image Notify Command may be sent as unicast or broadcast. If sent as
810 broadcast, the message also has a jitter mechanism built in to avoid the server being overwhelmed by
811 the requests from the clients. If sent as unicast, the client shall ignore the jitter value.

6
CCB 1314.

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page 19


ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

812 The client device will send Query Next Image Request Command if the information in the Image
813 Notify Command is of interest and after applying the jitter value. All devices shall send in a Query
814 Next Image Request Command periodically regardless of whether an Image Notify was sent by the
815 OTA server. 7
816 When the device has received a response to its query indicating a new OTA upgrade image is available,
817 the client device shall request blocks of the OTA upgrade image. The process continues until the client
818 receives all image data. At that point, the client shall verify the integrity of the whole image received
819 and send Upgrade End Request Command along with the upgrade status. The server shall notify the
820 client of when to upgrade to new image in the Upgrade End Response.
821 It is the responsibility of the server to ensure that all clients in the network are upgraded. The server
822 may be told which client to upgrade or it may keep a database of all clients in the network and track
823 which client has not yet been upgraded.

824 6.5.1 Sleepy Devices


825 The upgrade server has no reliable way to immediately notify the sleepy devices of the availability of
826 new OTA Upgrade image, hence, the devices shall query the server periodically to learn if there are
827 new images available. The query for new upgrade image may be done as a separate event or it may be
828 done in addition to normal scheduled communication between the device and the server. The frequency
829 as to how often the sleepy devices query the server shall be specified by each application profile.
830 Moreover, it is important to realize that the frequency that the sleepy device checks for new image
831 (sending Query Next Image command) determines how often the particular node could be
832 upgraded. This rate will also drive how fast code updates may be pushed out to each network. For the
833 SE 1.x to SE 2.0 transition, if sleepy devices only check in once a month for the new image then it will
834 likely to take over a month to complete the transition. If the application profile fails to set any
835 requirement on the sleepy device checking for new images then it is unlikely that the OTA upgrade
836 feature will work reliably for those devices.
837 It is a recommendation that sleepy devices shall make their best effort to poll more rapidly during the
838 OTA Upgrade Image download process in order to ensure that the download completes in a timely
839 manner. However, it is acknowledged that some sleepy devices may not be able to do so due to
840 limitation on their batteries or due to other reasons such as battery-less/Green Power devices. Hence,
841 such devices may take much longer to complete the download process.

842 6 .6 D e p e n d e n c ie s
843 Each device that wishes to implement the OTA Upgrade cluster shall have the following:
844 - ZigBee Device Object (ZDO) match descriptor request and response commands. The
845 command is used to discover upgrade server.
846 - ZigBee Cluster Library (ZCL) global commands and basic cluster attributes.
847 - Application Bootloader: To actually upgrade existing image with newly installed one on the
848 additional memory space. The implementation of the Bootloader along with its specification,
849 for example, where it lives and its size are outside the scope of this document.
850 - Additional Memory Space shall be large enough to hold the whole OTA Upgrade Image: It is
851 important to be able to store the new image until the device receives a signal from the server
852 to switch to running the image. This is because it may be necessary for all devices in the
853 network to switch their images at once if the new image is not OTA compatible with the old
854 one.
855 In addition, if the client device is composed of multiple processors; each requires separate
856 image, then the additional memory space shall be large enough to hold all the images for all
857 the processors that make up the device. In case of server devices, its additional memory space
858 will depend on how many images the devices are planning to hold.

7
CCB 1315

Page 20 Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

859 The specification of the additional memory space and its connection to the processor is outside
860 the scope of this document.

861 6 .7 O T A C lu s te r A ttrib u te s
862 Below are attributes defined for OTA Upgrade cluster. Currently, all attributes are client side attributes
863 (only stored on the client). There is no server side attribute at the moment. All attributes with the
864 exception of UpgradeServerID should be initialized to their default values before being used.
865 Table 6-14 - Attributes of OTA Upgrade Cluster

Attribute Ma Stored
Identifier nda On
tory
Acc
Name Type Range Default /
ess
Opt
ion
al

IEEE
0x0000 UpgradeServerID - Read 0xffffffffffffffff M Client
Address

Unsigne 0x0000
d 0000 –
0x0001 FileOffset Read 0xffffffff O Client
32-bit 0xfffffff
integer f

Unsigne 0x0000
d 0000 –
0x0002 CurrentFileVersion Read 0xffffffff O Client
32-bit 0xfffffff
integer f

Unsigne
CurrentZigBeeStack d 0x0000
0x0003 Read 0xffff O Client
Version 16-bit – 0xffff
integer

Unsigne 0x0000
DownloadedFileVers d 0000 –
0x0004 Read 0xffffffff O Client
ion 32-bit 0xfffffff
integer f

Unsigne
DownloadedZigBeeS d 0x0000
0x0005 Read 0xffff O Client
tackVersion 16-bit – 0xffff
integer

8-bit
0x00 –
0x0006 ImageUpgradeStatus enumer Read 0x00 M Client
0xff
ation

Unsigne
0x0000-
0x0007 Manufacturer ID d 16-bit Read - O Client
0xffff
integer

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page 21


ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

Attribute Ma Stored
Identifier nda On
tory
Acc
Name Type Range Default /
ess
Opt
ion
al

Unsigne
0x0000-
0x0008 Image Type ID d 16-bit Read - O Client
0xffff
integer

Unsigne
MinimumBlockReque 0x0000-
0x0009 d 16-bit Read - O Client
stDelay 0x0258
integer

Unsigne 0x0000
d 0000 –
0x000A Image Stamp Read O Client
32-bit 0xfffffff
integer f

866 6.7.1 UpgradeServerID Attribute


867 The attribute is used to store the IEEE address of the upgrade server resulted from the discovery of the
868 upgrade server’s identity. If the value is set to a non-zero value and corresponds to an IEEE address of
869 a device that is no longer accessible, a device may choose to discover a new Upgrade Server depending
870 on its own security policies.
871 The attribute is mandatory because it serves as a placeholder in a case where the client is programmed,
872 during manufacturing time, its upgrade server ID. In addition, the attribute is used to identify the
873 current upgrade server the client is using in a case where there are multiple upgrade servers in the
874 network. The attribute is also helpful in a case when a client has temporarily lost connection to the
875 network (for example, via a reset or a rejoin), it shall try to rediscover the upgrade server via network
876 address discovery using the IEEE address stored in the attribute.
877 By default the value is 0xffffffffffffffff, which is an invalid IEEE address (according to [R3]). The
878 attribute is a client-side attribute and stored on the client. Please refer to section 6.4 for description on
879 OTA server discovery.

880 6.7.2 FileOffset Attribute


881 The parameter indicates the current location in the OTA upgrade image. It is essentially the (start of
882 the) address of the image data that is being transferred from the OTA server to the client. The attribute
883 is optional on the client and is made available in a case where the server wants to track the upgrade
884 process of a particular client.

885 6.7.3 CurrentFileVersion Attribute


886 The file version of the running firmware image on the device. The information is available for the
887 server to query via ZCL read attribute command. The attribute is optional on the client.

888 6.7.4 CurrentZigBeeStackVersion Attribute


889 The ZigBee stack version of the running image on the device. The information is available for the
890 server to query via ZCL read attribute command. The attribute is optional on the client.

Page 22 Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

891 6.7.5 DownloadedFileVersion Attribute


892 The file version of the downloaded image on additional memory space on the device. The information
893 is available for the server to query via ZCL read attribute command. The information is useful for the
894 OTA upgrade management, so the server shall ensure that each client has downloaded the correct file
895 version before initiate the upgrade. The attribute is optional on the client.

896 6.7.6 DownloadedZigBeeStackVersion Attribute


897 The ZigBee stack version of the downloaded image on additional memory space on the device. The
898 information is available for the server to query via ZCL read attribute command. The information is
899 useful for the OTA upgrade management, so the server shall ensure that each client has downloaded the
900 correct ZigBee stack version before initiate the upgrade. The attribute is optional on the client.

901 6.7.7 ImageUpgradeStatus Attribute


902 The upgrade status of the client device. The status indicates where the client device is at in terms of the
903 download and upgrade process. The status helps to indicate whether the client has completed the
904 download process and whether it is ready to upgrade to the new image. The status may be queried by
905 the server via ZCL read attribute command. Hence, the server may not be able to reliably query the
906 status of ZED client since the device may have its radio off. The attribute is optional on the client.
907 Table 6-15 - Image Upgrade Status Attribute Values

Image Upgrade Status


Description
Values

0x00 Normal

0x01 Download in progress

0x02 Download complete

0x03 Waiting to upgrade

0x04 Count down

0x05 Wait for more

0x06 – 0xff Reserved

908 Normal status typically means the device has not participated in any download process. Additionally,
909 the client shall set its upgrade status back to Normal if the previous upgrade process was not successful.
910 Download in progress status is used from when the client device receives SUCCESS status in the
911 Query Next Image Response command from the server prior to when the device receives all the image
912 data it needs.
913 Download complete status indicates the client has received all data blocks required and it has already
914 verified the OTA Upgrade Image signature (if applied) and has already written the image onto its
915 additional memory space. The status will be modified as soon as the client receives Upgrade End
916 Response command from the server.
917 Wait to upgrade status indicates that the client is told by the server to wait until another (upgrade)
918 command is sent from the server to indicate the client to upgrade its image.
919 Count down status indicates that the server has notified the client to count down to when it shall
920 upgrade its image.

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page 23


ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

921 Wait for more (upgrade) image indicates that the client is still waiting to receive more OTA upgrade
922 image files from the server. This is true for a client device that is composed of multiple processors and
923 each processor requires different image. The client shall be in this state until it has received all
924 necessary OTA upgrade images, then it shall transition to Download complete state.

925 6.7.8 Manufacturer ID


926 This attribute shall reflect the ZigBee assigned value for the manufacturer of the device. See also
927 section 6.3.2.5.

928 6.7.9 Image Type ID


929 This attribute shall indicate the image type identifier of the file that the client is currently downloading,
930 or a file that has been completely downloaded but not upgraded to yet. The value of this attribute shall
931 be 0xFFFF when the client is not downloading a file or is not waiting to apply an upgrade.

932 6.7.10 BlockRequestDelay


933 This attribute acts as a rate limiting feature for the server to slow down the client download and prevent
934 saturating the network with block requests. The attribute lives on the client but can be changed during
935 a download if rate limiting is supported by both devices.
936 This attribute shall reflect the minimum delay between Image Block Request commands generated by
937 the client in milliseconds. The value of this attribute shall be updated when the rate is changed by the
938 server, but should reflect the client default when an upgrade is not in progress or a server does not
939 support this feature.
940 The value is in milliseconds and defaults to 0 (no delay).

941 6.7.11 Image Stamp Attribute


942 This attribute acts as a second verification to identify the image in the case that sometimes developers
943 of the application have forgotten to increase the firmware version attribute. It is a 32 bits value and has
944 a valid range from 0x00000000 to 0xFFFFFFFF. This attribute value must be consistent during the
945 lifetime of the same image and also must be unique for each different build of the image. This attribute
946 value should not be hardcoded or generated by any manual process. This attribute value should be
947 generated by performing a hash or checksum on the entire image. There are two possible methods to
948 generate this checksum. It can be generated dynamically during runtime of the application or it can be
949 generated during compile time of the application.

950 6 .8 O T A C lu s te r P a r a m e te r s
951 Below are defined parameters for OTA Upgrade cluster server. These values are considered as
952 parameters and not attributes because their values tend to change often and are not static. Moreover,
953 some of the parameters may have multiple values on the upgrade server at one instance. For example,
954 for DataSize parameter, the value may be different for each OTA upgrade process. These parameters
955 are included in commands sent from server to client. The parameters cannot be read or written via
956 ZCL global commands.
957 Table 6-16 - Parameters of OTA Upgrade Cluster

Mandatory
Name Type Range Default
/ Optional

Unsigned
QueryJitter 8-bit 0x01 – 0x64 0x32 M
integer

Page 24 Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

Mandatory
Name Type Range Default
/ Optional

Unsigned
DataSize 8-bit 0x00 – 0xff 0xff M
integer

OTAImageData Octet Varied all 0xff’s M

Unsigned
0x00000000
CurrentTime 32-bit 0xffffffff M
– 0xffffffff
integer

Unsigned
0x00000000
UpgradeTime or RequestTime 32-bit 0xffffffff M
– 0xffffffff
integer

958 6.8.1 QueryJitter Parameter


959 The parameter is part of Image Notify Command sent by the upgrade server. The parameter indicates
960 whether the client receiving Image Notify Command should send in Query Next Image Request
961 command or not.
962 The server chooses the parameter value between 1 and 100 (inclusively) and includes it in the Image
963 Notify Command. On receipt of the command, the client will examine other information (the
964 manufacturer code and image type) to determine if they match its own values. If they do not, it shall
965 discard the command and no further processing shall continue. If they do match then it will determine
966 whether or not it should query the upgrade server. It does this by randomly choosing a number
967 between 1 and 100 and comparing it to the value of the QueryJitter parameter received. If it is less than
968 or equal to the QueryJitter value from the server, it shall continue with the query process. If not, then it
969 shall discard the command and no further processing shall continue.
970
971 By using the QueryJitter parameter, it prevents a single notification of a new OTA upgrade image from
972 flooding the upgrade server with requests from clients.

973 6.8.2 DataSize Parameter


974 A value that indicates the length of the OTA image data included in the (Image Block Response)
975 command payload sent from the server to client.

976 6.8.3 OTAImageData Parameter


977 This is a part of OTA upgrade image being sent over the air. The length of the data is dictated by the
978 data size parameter. The server does not need to understand the meaning of the data, only the client
979 does. The data may also be compressed or encrypted to increase efficiency or security.
980 The parameter is in octet data type and is used with the file offset value (defined in section 6.7.2) to
981 indicate the location of the data and the data size value to indicate the length of the data.

982 6.8.4 CurrentTime and UpgradeTime/RequestTime Parameters


983 If CurrentTime and UpgradeTime are used in the command (ex. Upgrade End Response), the server
984 uses the parameters to notify the client when to upgrade to the new image. If CurrentTime and
985 RequestTime are used in the command (ex. Image Block Response), the server is notifying the client
986 when to request for more upgrade data. The CurrentTime indicates the current time of the OTA server.
987 The UpgradeTime indicates the time that the client shall upgrade to running new image. The
988 RequestTime indicates when the client shall request for more data.

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page 25


ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

989 The value of the parameters and their interpretation may be different depending on whether the devices
990 support ZCL Time cluster or not. If ZCL Time cluster is supported, the values of both parameters may
991 indicate the UTC Time values that represent the Universal Time Coordinated (UTC) time. If the
992 device does not support ZCL Time cluster, then it shall compute the offset time value from the
993 difference between the two time parameters. The resulted offset time is in seconds. A device that does
994 support the time cluster may use offset time instead of UTC Time when it sends messages that
995 reference the time according to Table 6-17.
996 The table below shows how to interpret the time parameter values depending on whether Time cluster
997 is supported on the device. The intention here is to be able to support a mixed network of nodes that
998 may not all support Time cluster.
999 Table 6-17 - Meaning of CurrentTime and UpgradeTime Parameters

UpgradeTime or
CurrentTime
Value RequestTime Description
Value

Device shall use UpgradeTime or RequestTime as an offset


0x00000000 Any
time from now.

Server supports Time cluster; client shall use


0x00000001 – UpgradeTime/RequestTime value as UTCTime if it also
Any
0xffffffffe supports Time cluster or it shall compute the offset time if it
does not.

The client should wait for a (upgrade) command from the


Any 0xffffffff server. Note that value of 0xffffffff should not be used for
RequestTime.

1000 Using value of all 0xFF’s for UpgradeTime to indicate a wait (for Upgrade End Response command
1001 from the server) on ZED client devices is not recommended since upgrade server should not be
1002 assumed to know the wake up cycle of the end device, hence, it is not guaranteed that the end device
1003 will receive the upgrade command. If the wait value (0xffffffff) is used on ZED client, the client
1004 should keep querying the server at a reasonable rate (not faster than once every 60 minutes) to see if it
1005 is time to upgrade.
1006 Using value of all 0xFF’s for RequestTime to indicate an indefinite wait time is not recommended. If
1007 the server does not know when it will have the image data ready, it shall use a reasonable wait time and
1008 when the client resend the image request, the server shall keep telling it to wait. There is no limit to
1009 how many times the server should the client to wait for the upgrade image. Using value of 0xffffffff
1010 shall cause the client to wait indefinitely and server may not have a way to tell the client to stop waiting
1011 especially for ZED client.

Page 26 Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

1012 6 .9 O T A U p g ra d e D ia g ra m

Upgrade Server Upgrade Client

Image Notify (optional)

Query Next Image Request

Query Next Image Response

(New Image Available)

Image Block/Page Request

(Block/Page 0)

Image Block Response

(Block 0)

...

Image Block/Page Request

(Block/Page n)

Image Block Response

(Block n)

Upgrade End Request

(Retrieval Complete)

Upgrade End Response

(Upgrade when: Now)

1013
1014 Figure 2 - OTA Upgrade Message Diagram
1015 Please refer to section 6.10 for the command description used in the diagram above.

1016 6 .1 0 C o m m a n d F r a m e s
1017 OTA upgrade messages do not differ from typical ZigBee APS messages so the upgrade process should
1018 not interrupt the general network operation. All OTA Upgrade cluster commands shall be sent with
1019 APS retry option, hence, require APS acknowledgement; unless stated otherwise.

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page 27


ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

1020 OTA Upgrade cluster commands, the frame control value shall follow the description below:
1021 • Frame type is 0x01: commands are cluster specific (not a global command).
1022 • Manufacturer specific is 0x00: commands are not manufacturer specific.
1023 • Direction: shall be either 0x00 (client->server) or 0x01 (server->client) depending on the
1024 commands.
1025 • Disable default response is 0x00 for all OTA request commands sent from client to server:
1026 default response command shall be sent when the server receives OTA Upgrade cluster
1027 request commands that it does not support or in case an error case happens. A detailed
1028 explanation of each error case along with its recommended action is described for each OTA
1029 cluster command.
1030 • Disable default response is 0x01 for all OTA response commands (sent from server to client)
1031 and for broadcast/multicast Image Notify command: default response command is not sent
1032 when the client receives a valid OTA Upgrade cluster response commands or when it receives
1033 broadcast or multicast Image Notify command. However, if a client receives invalid OTA
1034 Upgrade cluster response command, a default response shall be sent. A detailed explanation of
1035 each error case along with its recommended action is described for each OTA cluster
1036 command.

1037 6.10.1 OTA Cluster Command Identifiers


1038 Value for command identifier should be one of the values in table 8 below.
1039 Table 6-18 - OTA Upgrade cluster command frames



Command Direction Disable Default
Mandator
Identifier Description Response
y
Field
/Optional
Value

Set if sent as
Server -> Client(s) broadcast or
0x00 Image Notify O
(0x01) multicast; Not Set
if sent as unicast

Client -> Server Not Set


0x01 Query Next Image Request M
(0x00)

Page 28 Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster



Command Direction Disable Default
Mandator
Identifier Description Response
y
Field
/Optional
Value

Server -> Client Set


0x02 Query Next Image Response M
(0x01)

Client -> Server Not Set


0x03 Image Block Request M
(0x00)

Client -> Server Not Set


0x04 Image Page Request O
(0x00)

Server -> Client Set


0x05 Image Block Response M
(0x01)

Client -> Server Not Set


0x06 Upgrade End Request M
(0x00)

Server -> Client Set


0x07 Upgrade End Response M
(0x01)

Client -> Server Not Set


0x08 Query Specific File Request O
(0x00)

Server -> Client Set


0x09 Query Specific File Response O
(0x01)

1040 6.10.2 OTA Cluster Status Codes


1041 OTA Upgrade cluster uses ZCL defined status codes during the upgrade process. These status codes
1042 are included as values in status field in payload of OTA Upgrade cluster’s response commands and in
1043 default response command. Some of the status codes are new and are still in the CCB process (CC-
1044 1176) in order to be included in the ZCL specification. The status codes should be included in the r04
1045 of the ZCL specification.
1046 Table 6-19 - Status Code defined and used by OTA Upgrade Cluster

ZCL Status Code Value Description

SUCCESS 0x00 Success Operation

ABORT 0x95 Failed case when a client or a


server decides to abort the
upgrade process.

NOT_AUTHORIZED 0x7E Server is not authorized to


upgrade the client

INVALID_IMAGE 0x96 Invalid OTA upgrade image


(ex. failed signature validation
or signer information check or

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page 29


ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

CRC check)

WAIT_FOR_DATA 0x97 Server does not have data


block available yet

NO_IMAGE_AVAILABLE 0x98 No OTA upgrade image


available for a particular client

MALFORMED_COMMAND 0x80 The command received is


badly formatted. It usually
means the command is missing
certain fields or values
included in the fields are
invalid ex. invalid jitter value,
invalid payload type value,
invalid time value, invalid data
size value, invalid image type
value, invalid manufacturer
code value and invalid file
offset value

UNSUP_CLUSTER_COMMAND 0x81 Such command is not


supported on the device

REQUIRE_MORE_IMAGE 0x99 The client still requires more


OTA upgrade image files in
order to successfully upgrade

1047

1048 6.10.3 Image Notify Command


1049 The purpose of sending Image Notify command is so the server has a way to notify client devices of
1050 when the OTA upgrade images are available for them. It eliminates the need for ZR client devices
1051 having to check with the server periodically of when the new images are available. However, all client
1052 devices still need to send in Query Next Image Request command in order to officially start the OTA
1053 upgrade process.

1054 6.10.3.1 Payload Format


1055 Table 6-20 - Format of Image Notify Command Payload

Octets 1 1 0/2 0/2 0/4

Data 8-bit Unsigned Unsigned 16- Unsigned Unsigned


Type Enumeration 8-bit bit 16-bit 32-bit

Field Payload Query Manufacturer Image (new)


Name type jitter code type File
version

1056 6.10.3.2 Payload Field Definitions

1057 6.10.3.2.1 Image Notify Command Payload Type


1058 Table 6-21 - Image Notify Command Payload Type

Page 30 Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster


Payload Type Values Description

0x00 Query jitter

0x01 Query jitter and manufacturer code

0x02 Query jitter, manufacturer code, and image type

0x03 Query jitter, manufacturer code, image type, and new file version

0x04 – 0xff Reserved

1059 6.10.3.2.2 Query Jitter


1060 See section 6.8.1 for detailed description.

1061 6.10.3.2.3 Manufacturer Code


1062 Manufacturer code when included in the command should contain the specific value that indicates
1063 certain manufacturer. If the server intends for the command to be applied to all manufacturers then the
1064 value should be omitted. See [R3] section 2.3.1.2 for detailed description.

1065 6.10.3.2.4 Image Type


1066 Image type when included in the command should contain the specific value that indicates certain file
1067 type. If the server intends for the command to be applied to all image type values then the wild card
1068 value (0xffff) should be used. See section 6.3.2.6 for detailed description.

1069 6.10.3.2.5 (new) File Version


1070 The value shall be the OTA upgrade file version that the server tries to upgrade client devices in the
1071 network to. If the server intends for the command to be applied to all file version values then the wild
1072 card value (0xffffffff) should be used. See section 6.3.2.7 for detailed description.

1073 6.10.3.3 When Generated


1074 For ZR client devices, the upgrade server may send out a unicast, broadcast, or multicast indicating it
1075 has the next upgrade image, via an Image Notify command. Since the command may not have APS
1076 security (if it is broadcast or multicast), it is considered purely informational and not authoritative.
1077 Even in the case of a unicast, ZR shall continue to perform the query process described in later section.
1078 When the command is sent with payload type value of zero, it generally means the server wishes to
1079 notify all clients disregard of their manufacturers, image types or file versions. Query jitter is needed
1080 to protect the server from being flooded with clients’ queries for next image.
1081 The server may choose to send the Image Notify command to a more specific group of client devices
1082 by choosing higher payload type value. Only devices with matching information as the ones included
1083 in the Image Notify command will send back queries for next image.

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page 31


ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

1084 However, payload type value of 0x03 has a slightly different effect. If the client device has all the
1085 information matching those included in the command including the new file version, the device shall
1086 then ignore the command. This indicates that the device has already gone through the upgrade process.
1087 This is to prevent the device from downloading the same image version multiple times. This is only
1088 true if the command is sent as broadcast/multicast8.
1089 Query jitter value indicates how the server wants to space out the responses from the client; generally
1090 as a result of sending the command as broadcast or multicast. The client will only respond back if it
1091 randomly picks a value that is equal or smaller than the query jitter value. When sending Image Notify
1092 command as broadcast or multicast, the Disable Default Response bit in ZCL header must be set (to
1093 0x01) to avoid the client from sending any default response back to the upgrade server. This agrees
1094 with section 2.4.12 in [R3].
1095 If the command is sent as unicast, the payload type value may be zero and the Query jitter value may
1096 be the maximum value of 100 to signal the client to send in Query Next Image Request. The server
1097 may choose to use other payload type values besides zero when sending as unicast. However, since the
1098 server already knows the specific client (address) it wants to upgrade so other information is generally
1099 irrelevant.
1100 The upgrade server may choose to send Image Notify command to avoid having ZR clients sending in
1101 Query Next Image Request to it periodically.

1102 6.10.3.4 Effect on Receipt


1103 On receipt of a unicast Image Notify command, the device shall always send a Query Next Image
1104 request back to the upgrade server. This provides a way for the server to force reinstallation of image
1105 on the device.
1106
1107 On receipt of a broadcast or multicast Image Notify command, the device shall keep examining each
1108 field included in the payload with its own value. For each field, if the value matches its own, it shall
1109 proceed to examine the next field. If values in all three fields (naming manufacturer code, image type
1110 and new file version) match its own values, then it shall discard the command. The new file version in
1111 the payload shall match either the device’s current running file version or the downloaded file version
1112 (on the additional memory space).
1113
1114 If manufacturer code or the image type values in the payload does not match the device’s own value, it
1115 shall discard the command. For payload type value of 0x01, if manufacturer code matches the device’s
1116 own value, the device shall proceed. For payload type value of 0x02, if both manufacturer code and
1117 image type match the device’s own values, the device shall proceed. For payload type value of 0x03, if
1118 both manufacturer code and image type match the device’s own values but the new file version is not a
1119 match, the device shall proceed. In this case, the (new) file version may be lower or higher than the
1120 device’s file version to indicate a downgrade or an upgrade of the firmware respectively.
1121
1122 To proceed, the device shall randomly choose a number between 1 and 100 and compare it to the value
1123 of the QueryJitter value in the received message. If the generated value is less than or equal to the
1124 received value for QueryJitter, it shall query the upgrade server. If not, then it shall discard the
1125 message and no further processing shall continue.
1126
1127 By using the QueryJitter field, a server may limit the number of devices that will query it for a new
1128 OTA upgrade image, preventing a single notification of a new software image from flooding the
1129 upgrade server with requests.
1130
1131 In application profiles that mandate APS encryption for OTA upgrade cluster messages, OTA messages
1132 sent as broadcast or multicast should be dropped by the receivers.

8
CCB1470

Page 32 Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

1133 6.10.3.5 Handling Error Cases


1134 The section describes all possible error cases that the client may detect upon reception invalid Image
1135 Notify command from the server, along with the action that shall be taken.
1136
1137 For invalid broadcast or multicast Image Notify command, for example, out-of-range query jitter value
1138 is used, or the reserved payload type value is used, or the command is badly formatted, the client shall
1139 ignore such command and no processing shall be done. In addition, the broadcast/multicast command
1140 shall have disable default response bit in the ZCL frame control set to 0x01.
1141
1142 The cases below describe how to handle invalid Image Notify command that is sent as unicast. Such
1143 command shall not have default response bit set.

1144 6.10.3.5.1 Malformed Command


1145 Scenarios for this error case include unicast Image Notify command with payload type of non-zero
1146 value, unicast Image Notify command with query jitter value that is not 100, broadcast Image Notify
1147 command with out of range query jitter value. In such scenario, the client should ignore the invalid
1148 message and shall send default response command with MALFORMED_COMMAND status to the
1149 server.
1150

1151 6.10.4 Query Next Image Request Command

1152 6.10.4.1 Payload Format


1153 Table 6-22 - Format of Query Next Image Request Command Payload

Octets 1 2 2 4 0/2

Data Type Unsigned Unsigned 16- Unsigned Unsigned Unsigned


8-bit bit 16-bit 32-bit 16-bit

Field Name Field Manufacturer Image (Current) Hardware


control code type File version
version

1154 6.10.4.2 Payload Field Definitions

1155 6.10.4.2.1 Query Next Image Request Command Field Control


1156 The field control indicates whether additional information such as device’s current running hardware
1157 version is included as part of the Query Next Image Request command.
1158 Table 6-23 - Query Next Image Request Field Control Bitmask

Bits Name

0 Hardware Version Present

1-7 Reserved

1159 6.10.4.2.2 Manufacturer Code


1160 The value shall be the device’s assigned manufacturer code. Wild card value shall not be used in this
1161 case. See [R3] section 2.3.1.2 for detailed description.

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page 33


ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

1162 6.10.4.2.3 Image Type


1163 The value shall be between 0x0000 - 0xffbf (manufacturer specific value range). See section 6.3.2.6
1164 for detailed description. For other image type values, Query Specific File Request command should be
1165 used.

1166 6.10.4.2.4 (current) File Version


1167 The file version included in the payload represents the device’s current running image version. Wild
1168 card value shall not be used in this case. See section 6.3.2.7 for more detailed description.

1169 6.10.4.2.5 (optional) Hardware Version


1170 The hardware version if included in the payload represents the device’s current running hardware
1171 version. Wild card value shall not be used in this case. See section 6.3.2.13 for hardware version
1172 format description.

1173 6.10.4.3 When Generated


1174 Client devices shall send a Query Next Image Request command to the server to see if there is new
1175 OTA upgrade image available. ZR devices may send the command after receiving Image Notify
1176 command. ZED device shall periodically wake up and send the command to the upgrade server. Client
1177 devices query what the next image is, based on their own information.

1178 6.10.4.4 Effect on Receipt


1179 The server takes the client’s information in the command and determines whether it has a suitable
1180 image for the particular client. The decision should be based on specific policy that is specific to the
1181 upgrade server and outside the scope of this document.. However, a recommended default policy is for
1182 the server to send back a response that indicates the availability of an image that matches the
1183 manufacturer code, image type, and the highest available file version of that image on the
1184 server. However, the server may choose to upgrade, downgrade, or reinstall clients’ image, as its
1185 policy dictates. If client’s hardware version is included in the command, the server shall examine the
1186 value against the minimum and maximum hardware versions included in the OTA file header.
1187
1188 How the server retrieves and stores the clients’ file is also outside the scope of this document. The
1189 server may have a backend communication to retrieve the images or it may have database software to
1190 manage file storage.

1191 6.10.4.5 Handling Error Cases


1192 All error cases resulting from receiving Query Next Image Request command are handled by the
1193 corresponding Query Next Image Response command with the exception of the malformed request
1194 command described below that is handled by default response command. Please refer to section
1195 6.10.5.2 for more information regarding how the Query Next Image response command is generated.

1196 6.10.4.5.1 Malformed Command


1197 Upon reception a badly formatted Query Next Image Request command, for example, the command is
1198 missing one of the payload fields; the server shall send default response command with
1199 MALFORMED_COMMAND status to the client and it shall not process the command further.

1200 6.10.5 Query Next Image Response Command

1201 6.10.5.1 Payload Format


1202 Table 6-24 - Format of Query Next Image Response Command Payload

Page 34 Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

Octets 1 0/2 0/2 0/4 0/4

Data Type Unsigned Unsigned 16- Unsigned Unsigned Unsigned


8-bit bit 16-bit 32-bit 32-bit

Field Status Manufacturer Image File Image size


Name code type version

1203 6.10.5.2 Payload Field Definitions

1204 6.10.5.2.1 Query Next Image Response Status


1205 Only if the status is SUCCESS that other fields are included. For other (error) status values, only status
1206 field shall be present. See section 6.10.2 for a complete list and description of OTA Cluster status
1207 codes.

1208 6.10.5.2.2 Manufacturer Code


1209 The value shall be the one received by the server in the Query Next Image Request command. See
1210 [R3] section 2.3.1.2 for detailed description.

1211 6.10.5.2.3 Image Type


1212 The value shall be the one received by the server in the Query Next Image Request command. See
1213 section 6.3.2.6 for detailed description.

1214 6.10.5.2.4 File Version


1215 The file version indicates the image version that the client is required to install. The version value may
1216 be lower than the current image version on the client if the server decides to perform a downgrade. The
1217 version value may be the same as the client’s current version if the server decides to perform a reinstall.
1218 However, in general, the version value should be higher than the current image version on the client to
1219 indicate an upgrade. See section 6.3.2.7 for more description.

1220 6.10.5.2.5 Image Size


1221 The value represents the total size of the image (in bytes) including header and all sub-elements. See
1222 section 6.3.2.10 for more description.

1223 6.10.5.3 When Generated


1224 The upgrade server sends a Query Next Image Response with one of the following status: SUCCESS,
1225 NO_IMAGE_AVAILABLE or NOT_AUTHORIZED. When a SUCCESS status is sent, it is
1226 considered to be the explicit authorization to a device by the upgrade server that the device may
1227 upgrade to a specific software image.
1228
1229 A status of NO_IMAGE_AVAILABLE indicates that the server is authorized to upgrade the client but
1230 it currently does not have the (new) OTA upgrade image available for the client. For all clients (both
1231 ZR and ZED)9, they shall continue sending Query Next Image Requests to the server periodically until
1232 an image becomes available.
1233
1234 A status of NOT_AUTHORIZED indicates the server is not authorized to upgrade the client. In this
1235 case, the client may perform discovery again to find another upgrade server. The client may implement

9
CCB 1373 – Image notify is optional

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page 35


ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

1236 an intelligence to avoid querying the same unauthorized server.

1237 6.10.5.4 Effect on Receipt


1238 A status of SUCCESS in the Query Next Image response indicates to the client that the server has a
1239 new OTA upgrade image. The client shall begin requesting blocks of the image using the Image Block
1240 Request command. A ZED client may choose to change its wake cycle to retrieve the image more
1241 quickly.

1242 6.10.5.5 Handling Error Cases


1243 The Query Next Image Response command shall have the disable default response bit set. Hence, if
1244 the command is received successfully, no default response command shall be generated. However, the
1245 default response shall be generated to indicate the error cases below.

1246 6.10.5.5.1 Malformed Command


1247 Upon reception a badly formatted Query Next Image Response command, for example, the command
1248 is missing one of the payload field, other payload fields are included when the status field is not
1249 SUCCESS, the image type value included in the command does not match that of the device or the
1250 manufacturer code included in the command does not match that of the device; the client should ignore
1251 the message and shall send default response command with MALFORMED_COMMAND status to the
1252 server.

1253 6.10.6 Image Block Request Command

1254 6.10.6.1 Payload Format


1255 Table 6-25 - Format of Image Block Request Command Payload

Octets 1 2 2 4 4 1 0/8 0/2

Data Unsigne Unsigne Unsigne Unsigne Unsigne Unsigne IEEE Unsigne


Type d 8-bit d 16-bit d 16-bit d 32-bit d 32-bit d 8-bit Address d 16-bit

Field Field Manufa Image File File Maximu Request BlockRe


Name control cturer type version offset m data node questDel
code size address ay

1256 6.10.6.2 Payload Field Definitions

1257 6.10.6.2.1 Image Block Request Command Field Control


1258 Field control value is used to indicate additional optional fields that may be included in the payload of
1259 Image Block Request command. Currently, the device is only required to support field control value of
1260 0x00; support for other field control value is optional.
1261 Field control value 0x00 (bit 0 not set) indicates that the client is requesting a generic OTA upgrade
1262 file; hence, there is no need to include additional fields. The value of Image Type included in this case
1263 shall be manufacturer specific.
1264 Field control value of 0x01 (bit 0 set) means that the client’s IEEE address is included in the payload.
1265 This indicates that the client is requesting a device specific file such as security credential, log or
1266 configuration; hence, the need to include the device’s IEEE address in the image request command.
1267 The value of Image type included in this case shall be one of the reserved values that are assigned to
1268 each specific file type.
1269 Table 6-26 - Image Block Request Field Control Bitmask

Page 36 Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

Bits Name

0 Request node’s IEEE address Present

1 BlockRequestDelay present

2-7 Reserved

1270 6.10.6.2.2 Manufacturer Code


1271 The value shall be that of the client device assigned to each manufacturer by ZigBee. See [R3] section
1272 2.3.1.2 for detailed description.

1273 6.10.6.2.3 Image Type


1274 The value shall be between 0x0000 - 0xffbf (manufacturer specific value range). See section 6.3.2.6
1275 for detailed description.

1276 6.10.6.2.4 File Version


1277 The file version included in the payload represents the OTA upgrade image file version that is being
1278 requested. See section 6.3.2.7 for more detailed description.

1279 6.10.6.2.5 File Offset


1280 The value indicates number of bytes of data offset from the beginning of the file. It essentially points
1281 to the location in the OTA upgrade image file that the client is requesting the data from. The value
1282 reflects the amount of (OTA upgrade image file) data (in bytes) that the client has received so far.
1283 See section 6.7.2 for more description.

1284 6.10.6.2.6 Maximum Data Size


1285 The value indicates the largest possible length of data (in bytes) that the client can receive at once. The
1286 server shall respect the value and not send the data that is larger than the maximum data size. The
1287 server may send the data that is smaller than the maximum data size value, for example, to account for
1288 source routing payload overhead if the client is multiple hops away. By having the client send both file
1289 offset and maximum data size in every command, it eliminates the burden on the server for having to
1290 remember the information for each client.

1291 6.10.6.2.7 (optional) Request Node Address


1292 This is the IEEE address of the client device sending the Image Block Request command.

1293 6.10.6.2.8 (optional) Block Request Delay


1294 This is the current value of the BlockRequestDelay attribute of the device that is making the request as
1295 set by the server. If the device supports the attribute then it SHALL include this field in the request.
1296 The value is in milliseconds.
1297 This attribute does not necessarily reflect the actual delay applied by the client between Image Block
1298 Requests, only the value set by the server on the client.
1299

1300 6.10.6.3 When Generated


1301 The client device requests the image data at its leisure by sending Image Block Request command to

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page 37


ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

1302 the upgrade server. The client knows the total number of request commands it needs to send from the
1303 image size value received in Query Next Image Response command.
1304
1305 The client repeats Image Block Requests until it has successfully obtained all data. Manufacturer code,
1306 image type and file version are included in all further queries regarding that image. The information
1307 eliminates the need for the server to remember which OTA Upgrade Image is being used for each
1308 download process.
1309
1310 If the client supports the BlockRequestDelay attribute it shall include the value of the attribute as the
1311 BlockRequestDelay field of the Image Block Request message. The client shall ensure that it delays at
1312 least BlockRequestDelay milliseconds after the previous Image Block Request was sent before sending
1313 the next Image Block Request message. A client may delay its next Image Block Requests longer than
1314 its BlockRequestDelay attribute.
1315

1316 6.10.6.4 Effect on Receipt


1317 The server uses the manufacturer code, image type, and file version to uniquely identify the OTA
1318 upgrade image request by the client. It uses the file offset to determine the location of the requested
1319 data within the OTA upgrade image. If the server supports rate-limited transfers it SHALL check the
1320 Minimum Block Request Delay field and compare it to the desired rate for the client.

1321 6.10.6.5 Handling Error Cases


1322 In most cases, the server sends Image Block Response command in response to the client’s Image
1323 Block Request command. However, with the exception of a few error cases described below that the
1324 server shall send default response command as a response.

1325 6.10.6.5.1 Malformed Command


1326 Upon reception a badly formatted Image Block Request command, for example, the command is
1327 missing one of the payload field or the file offset value requested by the client is invalid, for example,
1328 the value is larger than the total image size; the server should ignore the message and it shall send
1329 default response command with MALFORMED_COMMAND status to the client.

1330 6.10.6.5.2 No Image Available


1331 If either manufacturer code or image type or file version information in the request command is invalid
1332 or the OTA upgrade file for the client for some reason has disappeared which result in the server no
1333 longer able to retrieve the file, it shall send default response command with
1334 NO_IMAGE_AVAILABLE status to the client. After three attempts, if the client keeps getting the
1335 default response with the same status, it should go back to sending Query Next Image Request
1336 periodically or waiting for next Image Notify command.

1337 6.10.6.5.3 Command Not Supported


1338 If the client sends image request command with field control value of 0x01 that indicates device
1339 specific file request and if the server does not support such request, it shall send default response with
1340 UNSUP_CLUSTER_COMMAND status. Upon reception of such response, the client should
1341 terminate the attempt to request the device specific file and it may try to query different server.

1342 6.10.7 Image Page Request Command

1343 6.10.7.1 Payload Format


1344 Table 6-27 - Image Page Request Command Payload

Page 38 Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

Octets 1 2 2 4 4 1 2 2 0/8

Data Unsigned Unsigned 16- Unsigned Unsigned Unsigned Unsigned Unsigned Unsigned IEEE
Type 8-bit bit 16-bit 32-bit 32-bit 8-bit 16-bit 16-bit Address

Field Field Manufacturer Image File File Maximum Page size Response Request
Name control code type version offset data size Spacing node
address

1345 6.10.7.2 Payload Field Definitions

1346 6.10.7.2.1 Image Page Request Command Field Control


1347 Field control value is used to indicate additional optional fields that may be included in the payload of
1348 Image Page Request command. Currently, the device is only required to support field control value of
1349 0x00; support for other field control value is optional.
1350 Field control value 0x00 indicates that the client is requesting a generic OTA upgrade file; hence, there
1351 is no need to include additional fields. The value of Image Type included in this case shall be
1352 manufacturer specific.
1353 Field control value of 0x01 means that the client’s IEEE address is included in the payload. This
1354 indicates that the client is requesting a device specific file such as security credential, log or
1355 configuration; hence, the need to include the device’s IEEE address in the image request command.
1356 The value of Image type included in this case shall be one of the reserved values that are assigned to
1357 each specific file type.
1358 Table 6-28 - – Image Page Request Field Control Bitmask

Bits Name

0 Request node’s IEEE address Present

1-7 Reserved

1359 6.10.7.2.2 Manufacturer Code


1360 The value shall be that of the client device assigned to each manufacturer by ZigBee. See [R3] section
1361 2.3.1.2 for detailed description.

1362 6.10.7.2.3 Image Type


1363 The value shall be between 0x0000 - 0xffbf (manufacturer specific value range). See section 6.3.2.6
1364 for detailed description.

1365 6.10.7.2.4 File Version


1366 The file version included in the payload represents the OTA upgrade image file version that is being
1367 requested. See section 6.3.2.7 for more detailed description.

1368 6.10.7.2.5 File Offset


1369 The value indicates number of bytes of data offset from the beginning of the file. It essentially points
1370 to the location in the OTA upgrade image file that the client is requesting the data from. The value
1371 reflects the amount of (OTA upgrade image file) data (in bytes) that the client has received so far.
1372 See section 6.7.2 for more description.

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page 39


ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

1373 6.10.7.2.6 Maximum Data Size


1374 The value indicates the largest possible length of data (in bytes) that the client can receive at once. The
1375 server shall respect the value and not send the data that is larger than the maximum data size. The
1376 server may send the data that is smaller than the maximum data size value, for example, to account for
1377 source routing payload overhead if the client is multiple hops away. By having the client send both file
1378 offset and maximum data size in every command, it eliminates the burden on the server for having to
1379 remember the information for each client.

1380 6.10.7.2.7 Page Size


1381 The value indicates the number of bytes to be sent by the server before the client sends another Image
1382 Page Request command. In general, page size value shall be larger than the maximum data size value.

1383 6.10.7.2.8 Response Spacing


1384 The value indicates how fast the server shall send the data (via Image Block Response command) to the
1385 client. The value is determined by the client. The server shall wait at the minimum the (response)
1386 spacing value before sending more data to the client. The value is in milliseconds

1387 6.10.7.2.9 (optional) Request Node Address


1388 This is the IEEE address of the client device sending the Image Block Request command.

1389 6.10.7.3 When Generated


1390 The support for the command is optional. The client device may choose to request OTA upgrade data
1391 in one page size at a time from upgrade server. Using Image Page Request reduces the numbers of
1392 requests sent from the client to the upgrade server, compared to using Image Block Request command.
1393 In order to conserve battery life a device may use the Image Page Request command. Using the Image
1394 Page Request command eliminates the need for the client device to send Image Block Request
1395 command for every data block it needs; possibly saving the transmission of hundreds or thousands of
1396 messages depending on the image size.
1397 The client keeps track of how much data it has received by keeping a cumulative count of each data
1398 size it has received in each Image Block Response. Once the count has reach the value of the page size
1399 requested, it shall repeat Image Page Requests until it has successfully obtained all pages. Note that the
1400 client may choose to switch between using Image Block Request and Image Page Request during the
1401 upgrade process. For example, if the client does not receive all data requested in one Image Page
1402 Request, the client may choose to request the missing block of data using Image Block Request
1403 command, instead of requesting the whole page again.
1404
1405 Since a single Image Page Request may result in multiple Image Block Response commands sent from
1406 the server, the client, especially ZED client, should make its best effort to ensure that all responses are
1407 received. A ZED client may select a small value for the response spacing and stay awake to receive all
1408 data blocks. Or it may choose a larger value and sleeps between receiving each data block.
1409 Manufacturer code, image type and file version are included in all further queries regarding that image.
1410 The information eliminates the need for the server to remember which OTA Upgrade Image is being
1411 used for each download process.

Page 40 Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

1412 6.10.7.4 Effect on Receipt


1413 The server uses the file offset value to determine the location of the requested data within the OTA
1414 upgrade image. The server may respond to a single Image Page Request command with possibly
1415 multiple Image Block Response commands; depending on the value of page size. Each Image Block
1416 Response command sent as a result of Image Page Request command shall have increasing ZCL
1417 sequence number. Note that the sequence number may not be sequential (for example, if the server is
1418 also upgrading another client simultaneously); additionally ZCL sequence numbers are only 8-bit and
1419 may wrap.
1420 In response to the Image Page Request, the server shall send Image Block Response commands with no
1421 APS retry to disable APS acknowledgement. The intention is to minimize the number of packets sent
1422 by the client in order to optimize the energy saving. APS acknowledgement is still used for Image
1423 Block Response sent in response to Image Block Request command.
1424
1425 Image Block Response message (in response to Image Page Request) only relies on network level retry.
1426 This may not be as reliable over multiple hops communication, however, the benefit of using Image
1427 Page Request is to save energy on the ZED client and using APS ack with the packet undermines that
1428 effort. ZED client needs to make the decision which request it uses. Image Page Request may speed
1429 up the upgrade process; the client transmits fewer packets, hence, less energy use but it may be less
1430 reliable. On the other hand, Image block request may slow down the upgrade process; the client is
1431 required to transmit more packets but it is also more predictable and reliable; it also allows the upgrade
1432 process to proceed at the client's pace.

1433 6.10.7.5 Handling Error Cases


1434 In most cases, the server sends Image Block Response command in response to the client’s Image Page
1435 Request command. However, with the exception of a few error cases described below that the server
1436 shall send default response command as a response.

1437 6.10.7.5.1 Malformed Command


1438 Upon reception a badly formatted Image Page Request command, for example, the command is
1439 missing one of the payload fields or the file offset value requested by the client is invalid. The server
1440 should ignore the message and it shall send default response command with
1441 MALFORMED_COMMAND status to the client.

1442 6.10.7.5.2 No Image Available


1443 If either manufacturer code or image type or file version information in the request command is invalid
1444 or the OTA upgrade file for the client for some reason has disappeared which result in the server no
1445 longer able to retrieve the file, it shall send default response command with
1446 NO_IMAGE_AVAILABLE status to the client. After three attempts, if the client keeps getting the
1447 default response with the same status, it should go back to sending Query Next Image Request
1448 periodically or waiting for next Image Notify command.

1449 6.10.7.5.3 Command Not Supported


1450 If the client sends Image Page Request command with field control value of 0x00 to request OTA
1451 upgrade image and the server does not support Image Page Request command, it shall send default
1452 response with UNSUP_CLUSTER_COMMAND status. Upon reception of such response, the client
1453 shall switch to using Image Block Request command instead to request OTA image data.
1454 If the client sends image request command with field control value of 0x01 that indicates device
1455 specific file request and if the server does not support such request, it shall send default response with
1456 UNSUP_CLUSTER_COMMAND status. Upon reception of such response, the client should
1457 terminate the attempt to request the device specific file and it may try to query different server.

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page 41


ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

1458 6.10.8 Image Block Response Command

1459 6.10.8.1 Payload Format


1460 Table 6-29 - Image Block Response Command Payload with SUCCESS status

Octets 1 2 2 4 4 1 Variable

Data Unsigned Unsigned 16- Unsigned Unsigned Unsigned Unsigned Octet


Type 8-bit bit 16-bit 32-bit 32-bit 8-bit

Field Success Manufacturer Image File File Data size Image


Name status code type version offset data

1461
1462 Table 6-30 - Image Block Response Command Payload with WAIT_FOR_DATA status

Octets 1 4 4 2

Data Type Unsigned 8- Unsigned 32- Unsigned 32- Unsigned 16-bit


bit bit bit

Field Name Wait for Current time Request time BlockRequestDelay


data Status

1463
1464 Table 6-31 - Image Block Response Command Payload with ABORT status

Octets 1

Data Type Unsigned 8-bit

Field Name Abort Status

1465 6.10.8.2 Payload Field Definitions

1466 6.10.8.2.1 Image Block Response Status


1467 The status in the Image Block Response command may be SUCCESS, ABORT or
1468 WAIT_FOR_DATA. If the status is ABORT then only the status field shall be included in the
1469 message, all other fields shall be omitted.
1470 See section 6.10.2 for a complete list and description of OTA Cluster status codes.

1471 6.10.8.2.2 Manufacturer Code


1472 The value shall be the same as the one included in Image Block/Page Request command. See [R3]
1473 section 2.3.1.2 for detailed description.

1474 6.10.8.2.3 Image Type


1475 The value shall be the same as the one included in Image Block/Page Request command. See section
1476 6.3.2.6 for detailed description.

Page 42 Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

1477 6.10.8.2.4 File Version


1478 The file version indicates the image version that the client is required to install. The version value may
1479 be lower than the current image version on the client if the server decides to perform a downgrade. The
1480 version value may be the same as the client’s current version if the server decides to perform a reinstall.
1481 However, in general, the version value should be higher than the current image version on the client to
1482 indicate an upgrade. See section 6.3.2.7 for more description.

1483 6.10.8.2.5 File Offset


1484 The value represents the location of the data requested by the client. For most cases, the file offset
1485 value included in the (Image Block) response should be the same as the value requested by the client.
1486 For (unsolicited) Image Block responses generated as a result of Image Page Request, the file offset
1487 value shall be incremented to indicate the next data location.

1488 6.10.8.2.6 Data Size


1489 The value indicates the length of the image data (in bytes) that is being included in the command. The
1490 value may be equal or smaller than the maximum data size value requested by the client. See section
1491 6.8.2 for more description.

1492 6.10.8.2.7 Image Data


1493 The actual OTA upgrade image data with the length equals to data size value. See section 6.8.3 for
1494 more description.

1495 6.10.8.2.8 Current Time and Request Time


1496 If status is WAIT_FOR_DATA, the payload then includes the server’s current time and the request
1497 time that the client shall retry the request command. The client shall wait at least the request time value
1498 before trying again. In case of sleepy device, it may choose to wait longer than the specified time in
1499 order to not disrupt its sleeping cycle. If the current time value is zero that means the server does not
1500 support UTC time and the client shall treat the request time value as offset time. If neither time value
1501 is zero, and the client supports UTC time, it shall treat the request time value as UTC time. If the client
1502 does not support UTC time, it shall calculate the offset time from the difference between the two time
1503 values. The offset indicates the minimum amount of time to wait in seconds. The UTC time indicates
1504 the actual time moment that needs to pass before the client should try again.
1505 See section 6.8.4 for more description.

1506 6.10.8.2.9 Block Request Delay


1507 This value is only included if the status is WAIT_FOR_DATA and the server supports rate limiting.
1508 This is the minimum delay that the server wants the client to wait between subsequent block requests.
1509 The client shall update its BlockRequestDelay attribute to this value. The BlockRequestDelay value
1510 SHALL be observed in all future Image Block Request messages for the duration of the firmware
1511 image download, or until updated by the server.
1512 If the server does not support rate limiting or does not wish to slow the client’s download, the field
1513 shall be set to 0.
1514 See 6.7.10 for more description of the valid ranges and use of this attribute.
1515 See section 6.12.3 for more description on how the rate limiting feature works.
1516

1517 6.10.8.3 When Generated


1518 Upon receipt of an Image Block Request command the server shall generate an Image Block Response.
1519 If the server is able to retrieve the data for the client and does not wish to change the image download

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page 43


ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

1520 rate, it will respond with a status of SUCCESS and it will include all the fields in the payload. The use
1521 of file offset allows the server to send packets with variable data size during the upgrade process. This
1522 allows the server to support a case when the network topology of a client may change during the
1523 upgrade process, for example, mobile client may move around during the upgrade process. If the client
1524 has moved a few hops away, the data size shall be smaller. Moreover, using file offset eliminates the
1525 need for data padding since each Image Block Response command may contain different data size. A
1526 simple server implementation may choose to only support largest possible data size for the worst-case
1527 scenario in order to avoid supporting sending packets with variable data size.
1528
1529 The server shall respect the maximum data size value requested by the client and shall not send the data
1530 with length greater than that value. The server may send the data with length smaller than the value
1531 depending on the network topology of the client. For example, the client may be able to receive 100
1532 bytes of data at once so it sends the request with 100 as maximum data size. But after considering all
1533 the security headers (perhaps from both APS and network levels) and source routing overhead (for
1534 example, the client is five hops away), the largest possible data size that the server can send to the
1535 client shall be smaller than 100 bytes.
1536
1537 If the server simply wants to cancel the download process, it shall respond with ABORT status. An
1538 example is while upgrading the client the server may receive newer image for that client. It may then
1539 choose to abort the current process so that the client may reinitiate a new upgrade process for the newer
1540 image.
1541
1542 If the server does not have the image block available for the client yet or it wants to slow down (pause
1543 or rate-limit) the download process, it shall send the response back with status WAIT_FOR_DATA and
1544 with RequestTime value that the client shall wait before resending the request. This is a one-time
1545 (temporary) delay of the download for the client.
1546
1547 If the Image Block Request message contains the BlockRequestDelay field and the server wishes to
1548 slow the client’s rate of sending Image Block requests, then the server shall send an Image Block
1549 Response with status WAIT_FOR_DATA. In this case the RequestTime and CurrentTime in the
1550 message shall be set so that their delta is zero, and the BlockRequestDelay field shall be set to the
1551 minimum delay that server wants the client to add between all subsequent Image Block Requests.
1552

1553 6.10.8.4 Effect on Receipt


1554 When the client receives the Image Block Response it shall examine the status field. If the value is
1555 SUCCESS it shall write the image data to its additional memory space. The client then shall continue
1556 to send Image Block Request commands with incrementing block numbers to request the remaining
1557 blocks of the OTA upgrade image. If the client has received the final block of the image, it shall
1558 generate an Upgrade End request command. In case of the client using Image Page Request, after
1559 receiving an Image Block Response, the client shall wait for response spacing time before expecting
1560 another Image Block Response from the server. A ZED client may go to sleep in between receiving
1561 Image Block Responses in order to save the energy.
1562 If the client receives a response with ABORT status, it shall abort the upgrade process. It may retry the
1563 entire upgrade operation at a later point in time.
1564 Upon receipt of WAIT_FOR_DATA status, the client shall wait at a minimum for the specified
1565 RequestTime and try to retrieve the image data again by resending Image Block Request or Image Page
1566 Request command with the same file offset value. If the CurrentTime and RequestTime are the same
1567 value and the client supports the BlockRequestDelay attribute, then it shall examine if the message
1568 contains the Block Request Delay field in the Image Block Response. If the field is present and has a
1569 value is different than its current attribute value, it shall update its local attribute. Prior to sending its
1570 next Image Block Request message it shall add a minimum delay equal to the new value of its Block
1571 Request Delay attribute.
1572 If the delta between the CurrentTime and RequestTime is zero and the BlockRequestDelay field is not
1573 present or is zero, the client may immediately send an Image Block Request command.

Page 44 Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

1574

1575 6.10.8.5 Handling Error Cases


1576 If Image Block Response command is received successfully by the client, no default response will be
1577 generated if the disable default response bit is set in the ZCL header. However, a few error cases
1578 described below may cause the client to send default response to the server with an error code.

1579 6.10.8.5.1 Malformed Command


1580 Upon reception a badly formatted Image Block Response command, for example, the command is
1581 missing one of the payload field, the payload fields do not correspond to the status field, the request
1582 time value returned by the server is invalid, for example, the value is less than the client’s current time
1583 or the value is less than the server’s own current time, the data size value returned by the server is
1584 invalid, for example, the value is greater than the maximum data size specified by the client, or the
1585 value does not match the number of bytes of data actually included in the payload, or the value, when
1586 combined with file offset, is greater than the total image size or the file offset value returned by the
1587 server is invalid. The client should ignore the command and shall send default response command with
1588 MALFORMED_COMMAND status to the server.
1589

1590 6.10.9 Upgrade End Request Command

1591 6.10.9.1 Payload Format


1592 Table 6-32 - Format of Upgrade End Request Command Payload

Octets 1 2 2 4

Data Type Unsigned Unsigned 16- Unsigned Unsigned


8-bit bit 16-bit 32-bit

Field Name Status Manufacturer Image type File


code version

1593 6.10.9.2 Payload Field Definitions

1594 6.10.9.2.1 Upgrade End Request Command Status


1595 The status value of the Upgrade End Request command shall be SUCCESS, INVALID_IMAGE,
1596 REQUIRE_MORE_IMAGE, or ABORT. See section 6.10.2 for more description.

1597 6.10.9.2.2 Manufacturer Code


1598 The value shall be that of the client device assigned to each manufacturer by ZigBee. See [R3] section
1599 2.3.1.2 for detailed description.

1600 6.10.9.2.3 Image Type


1601 The value shall be between 0x0000 - 0xffbf (manufacturer specific value range). See section 6.3.2.6
1602 for detailed description.

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page 45


ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

1603 6.10.9.2.4 File Version


1604 The file version included in the payload represents the newly downloaded OTA upgrade image file
1605 version. See section 6.3.2.7 for more detailed description.

1606 6.10.9.3 When Generated


1607 Upon reception all the image data, the client should verify the image to ensure its integrity and validity.
1608 If the device requires signed images it shall examine the image and verify the signature as described in
1609 section 6.3.9.2. Clients may perform additional manufacturer specific integrity checks to validate the
1610 image, for example, CRC check on the actual file data.
1611
1612 If the image fails any integrity checks, the client shall send an Upgrade End Request command to the
1613 upgrade server with a status of INVALID_IMAGE. In this case, the client may reinitiate the upgrade
1614 process in order to obtain a valid OTA upgrade image. The client shall not upgrade to the bad image
1615 and shall discard the downloaded image data.
1616
1617 If the image passes all integrity checks and the client does not require additional OTA upgrade image
1618 file, it shall send back an Upgrade End Request with a status of SUCCESS. However, if the client
1619 requires multiple OTA upgrade image files before performing an upgrade, it shall send an Upgrade End
1620 Request command with status REQUIRE_MORE_IMAGE. This shall indicate to the server that it
1621 cannot yet upgrade the image it received.
1622
1623 If the client decides to cancel the download process for any other reasons, it has the option of sending
1624 Upgrade End Request with status of ABORT at anytime during the download process. The client shall
1625 then try to reinitiate the download process again at a later time.
1626
1627 When a client finishes downloading a device specific file, it shall send Upgrade End Request command
1628 with status of SUCCESS to the server to indicate the end of the upgrade process.

1629 6.10.9.4 Effect on Receipt


1630 For manufacturer specific image type file download, upon receipt of a SUCCESS Upgrade End
1631 Request command the upgrade server shall reply with the Upgrade End Response indicating when the
1632 client shall upgrade to the newly retrieved image. For other status value received such as
1633 INVALID_IMAGE, REQUIRE_MORE_IMAGE, or ABORT, the upgrade server shall not send
1634 Upgrade End Response command but it shall send default response command with status of success
1635 and it shall wait for the client to reinitiate the upgrade process.
1636 The server may utilize the Upgrade End Request command as a means to know when devices are done
1637 downloading a particular image. This helps the server manage the images and remove those that are no
1638 longer needed. However, the upgrade server should not rely on receiving the command and may
1639 impose upper limits on how long it will store a particular OTA upgrade image. The specific
1640 implementation of this is outside the scope of this document.

1641 6.10.9.5 Handling Error Cases


1642 Upgrade End Request command does not have disable default response bit set. Hence, in a case where
1643 the Upgrade End Request command has been received and the server does not send Upgrade End
1644 Response command in response, a default response command shall be sent with SUCCESS status. If
1645 the Upgrade End Request command has not been received, default response command with error status
1646 shall be sent as described below.

1647 6.10.9.5.1 Malformed Command


1648 Upon reception a badly formatted Upgrade End Request command, for example, the command is
1649 missing one of the payload fields. The server shall send default response command with
1650 MALFORMED_COMMAND status to the client.

Page 46 Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

1651 6.10.10 Upgrade End Response Command

1652 6.10.10.1 Payload Format


1653 Table 6-33 - Format of Upgrade End Response Command Payload

Octets 2 2 4 4 4

Data Unsigned 16- Unsigned Unsigned Unsigned Unsigned


Type bit 16-bit 32-bit 32-bit 32-bit

Field Manufacturer Image File Current Upgrade


Name code type version time time

1654 6.10.10.2 Payload Field Definitions


1655 The ability to send the command with wild card values for manufacturer code, image type and file
1656 version is useful in this case because it eliminates the need for the server having to send the command
1657 multiple times for each manufacturer as well as having to keep track of all devices’ manufacturers in
1658 the network.

1659 6.10.10.2.1 Manufacturer Code


1660 Manufacturer code may be sent using wildcard value of 0xfffff in order to apply the command to all
1661 devices disregard of their manufacturers. See [R3] section 2.3.1.2 for detailed description.

1662 6.10.10.2.2 Image Type


1663 Image type may be sent using wildcard value of 0xfffff in order to apply the command to all devices
1664 disregard of their manufacturers. See section 6.3.2.6 for detailed description.

1665 6.10.10.2.3 File Version


1666 The file version included in the payload represents the newly downloaded OTA upgrade image file
1667 version. The value shall match that included in the request. Alternatively, file version may be sent
1668 using wildcard value of 0xfffffffff in order to apply the command to all devices disregard of their
1669 manufacturers. See section 6.3.2.7 for more detailed description.

1670 6.10.10.2.4 Current Time and Upgrade Time


1671 Current time and Upgrade time values are used by the client device to determine when to upgrade its
1672 running firmware image(s) with the newly downloaded one(s). See section 6.8.4 for more description.

1673 6.10.10.3 When Generated


1674 When an upgrade server receives an Upgrade End Request command with a status of
1675 INVALID_IMAGE, REQUIRE_MORE_IMAGE, or ABORT, no additional processing shall be done
1676 in its part. If the upgrade server receives an Upgrade End Request command with a status of
1677 SUCCESS, it shall generate an Upgrade End Response with the manufacturer code and image type
1678 received in the Upgrade End Request along with the times indicating when the device should upgrade
1679 to the new image.
1680
1681 The server may send an unsolicited Upgrade End Response command to the client. This may be used
1682 for example if the server wants to synchronize the upgrade on multiple clients simultaneously. For
1683 client devices, the upgrade server may unicast or broadcast Upgrade End Response command
1684 indicating a single client device or multiple client devices shall switch to using their new images. The
1685 command may not be reliably received by sleepy devices if it is sent unsolicited.

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page 47


ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

1686
1687 For device specific file download, the client should not always expect the server to respond back with
1688 Upgrade End Response command. For example, in a case of a client has just finished retrieving a log
1689 file from the server, the server may not need to send Upgrade End Response command. However, if
1690 the client has just retrieved a security credential or a configuration file, the server may send Upgrade
1691 End Response command to notify the client of when to apply the file. The decision of whether
1692 Upgrade End Response command should be sent for device specific file download is manufacturer
1693 specific.

1694 6.10.10.4 Effect on Receipt.


1695 The client shall examine the manufacturer code, image type and file version to verify that they match
1696 its own. If the received values do not match its own values or they are not wild card values, then it
1697 shall discard the command and no further processing shall continue. If all values match, the client shall
1698 examine the time values to determine the upgrade time. For more information on determining the time,
1699 please refer to section 6.8.4.
1700

1701 6.10.10.5 Handling Error Cases


1702 If Upgrade End Response command is received successfully by the client or if it is sent as broadcast or
1703 multicast, no default response will be generated. However, a few error cases described below may
1704 cause the client to send default response to the server.

1705 6.10.10.5.1 Malformed Command


1706 Upon reception a badly formatted Upgrade End Response command, for example, the command is
1707 missing one of the payload field or the request time value returned by the server is invalid, for example,
1708 the value is less than the client’s current time or the value is less than the server’s own current time.
1709 The client should ignore the command and shall send default response command with
1710 MALFORMED_COMMAND status to the server.
1711

1712 6.10.11 Query Specific File Request Command

1713 6.10.11.1 Payload Format


1714 Table 6-34 - Format of Query Specific File Request Command Payload

Octets 8 2 2 4 2

Data IEEE Unsigned 16- Unsigned Unsigned Unsigned


Type Address bit 16-bit 32-bit 16-bit

Field Request Manufacturer Image type File version (Current)


Name node code ZigBee
address stack
version

1715 6.10.11.2 Payload Field Definitions

1716 6.10.11.2.1 Request Node Address


1717 This is the IEEE address of the client device sending the request command. This indicates that the
1718 client is requesting a device specific file such as security credential, log or configuration; hence, the
1719 need to include the device’s IEEE address in the image request command.

Page 48 Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

1720 6.10.11.2.2 Manufacturer Code


1721 The value shall be that of the client device assigned to each manufacturer by ZigBee. See [R3] section
1722 2.3.1.2 for detailed description.

1723 6.10.11.2.3 Image Type


1724 The value of image type included in this case shall be one of the reserved values that are assigned to
1725 each specific file type. The value should be between 0xffc0 – 0xfffe, however, only 0xffc0 – 0xffc2 is
1726 being used currently. See section 6.3.2.6 for detailed description.

1727 6.10.11.2.4 File Version


1728 The value indicates the version of the device specific file being requested. See section 6.3.2.7 for more
1729 detailed description.

1730 6.10.11.2.5 (current) ZigBee Stack Version


1731 The value may represent the current running ZigBee stack version on the device or the ZigBee stack
1732 version of the OTA upgrade image being stored in additional memory space. The decision of which
1733 value to include depends on which device specific file being requested. For example, if the client is
1734 requesting a new security credential file in order to be able to run the newly downloaded image (ex. SE
1735 2.0), then it should include the ZigBee stack version value of the new image.

1736 6.10.11.3 When Generated


1737 Client devices shall send a Query Specific File Request command to the server to request for a file that
1738 is specific and unique to it. Such file could contain non-firmware data such as security credential
1739 (needed for upgrading from Smart Energy 1.1 to Smart Energy 2.0), configuration or log. When the
1740 device decides to send the Query Specific File Request command is manufacturer specific. However,
1741 one example is during upgrading from SE 1.1 to 2.0 where the client may have already obtained new
1742 SE 2.0 image and now needs new SE 2.0 security credential data.
1743
1744 The fields included in the payload helps the upgrade server in obtaining or creating the right file for the
1745 client.

1746 6.10.11.4 Effect on Receipt


1747 The server takes the client’s information in the command and either obtain the file via the backend
1748 system or create the file itself. Details of how the file is being obtained or created is manufacturer
1749 specific and outside the scope of this document. The device specific file shall follow OTA upgrade file
1750 format (section 6.3) and shall have Device Specific File bit set in OTA header field control. Moreover,
1751 the value of the Upgrade File Destination field in the OTA header shall match the Request node
1752 address value in the command’s field.
1753

1754 6.10.11.5 Handling Error Cases


1755 In most cases all error cases resulted from receiving Query Specific File Request command are handled
1756 by the corresponding Query Specific File Response command with the exception of a few error cases
1757 described below that are handled by default response command.

1758 6.10.11.5.1 Malformed Command


1759 Upon reception a badly formatted Query Specific File Request command, for example, the command is
1760 missing one of the payload fields; the server shall send default response command with
1761 MALFORMED_COMMAND status to the client and it shall not process the command further.

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page 49


ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

1762 6.10.11.5.2 Command Not Supported


1763 Certain server may not support transferring of device specific file and the implement of Query Specific
1764 File Request command; in this case the server shall send default response with
1765 UNSUP_CLUSTER_COMMAND status.
1766

1767 6.10.12 Query Specific File Response Command

1768 6.10.12.1 Payload Format


1769 Table 6-35 - Format of Query Specific File Response Command Payload

Octets 1 0/2 0/2 0/4 0/4

Data Unsigned Unsigned 16- Unsigned Unsigned Unsigned


Type 8-bit bit 16-bit 32-bit 32-bit

Field Status Manufacturer Image type File Image size


Name code version

1770 6.10.12.2 Payload Field Definitions

1771 6.10.12.2.1 Query Specific File Response Status


1772 Only if the status is SUCCESS that other fields are included. For other (error) status values, only status
1773 field shall be present.

1774 6.10.12.2.2 Manufacturer Code


1775 The value shall be the one received by the server in the Query Specific File Request command. See
1776 [R3] section 2.3.1.2 for detailed description.

1777 6.10.12.2.3 Image Type


1778 The value shall be the one received by the server in the Query Specific File Request command. See
1779 section 6.3.2.6 for detailed description.

1780 6.10.12.2.4 File Version


1781 The file version indicates the image version that the client is required to download. The value shall be
1782 the same as the one included in the request. See section 6.3.2.7 for more description.

1783 6.10.12.2.5 Image Size


1784 The value represents the total size of the image (in bytes) including all sub-elements. See section
1785 6.3.2.10 for more description.

1786 6.10.12.3 When Generated


1787 The server sends Query Specific File Response after receiving Query Specific File Request from a
1788 client. The server shall determine whether it first supports the Query Specific File Request command.
1789 Then it shall determine whether it has the specific file being requested by the client using all the
1790 information included in the request. The upgrade server sends a Query Specific File Response with
1791 one of the following status: SUCCESS, NO_IMAGE_AVAILABLE or NOT_AUTHORIZED.
1792

Page 50 Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

1793 A status of NO_IMAGE_AVAILABLE indicates that the server currently does not have the device
1794 specific file available for the client. A status of NOT_AUTHORIZED indicates the server is not
1795 authorized to send the file to the client.

1796 6.10.12.4 Effect on Receipt


1797 A status of SUCCESS in the Query Specific File response indicates to the client that the server has a
1798 specific file for it. The client shall begin requesting file data using the Image Block Request or Image
1799 Page Request command with a field control value set to 0x01 and include its IEEE address. A ZED
1800 client may choose to change its wake cycle to retrieve the file more quickly.
1801 If the client receives the response with status of NOT_AUTHORIZED, it may perform discovery again
1802 to find another upgrade server. The client may implement an intelligence to avoid querying the same
1803 unauthorized server.

1804 6.10.12.5 Handling Error Cases


1805 Query Specific File Response command shall have disable default response bit set. Hence, if the
1806 command is received successfully, no default response command shall be generated. However, the
1807 default response shall be generated to indicate the error cases below.

1808 6.10.12.5.1 Malformed Command


1809 Upon reception a badly formatted Query Specific File Response command, for example, the command
1810 is missing one of the payload field, other payload fields are included when the status field is not
1811 SUCCESS, the manufacturer code included in the command does not match that of the device or the
1812 image type value included in the command does not match that of the device; the client should ignore
1813 the message and shall send default response command with MALFORMED_COMMAND status to the
1814 server.

10
1815 6 .1 1 M u ltip le F ile s R e q u ire d fo r a B o o tlo a d
1816 Zigbee devices may require multiple boatload files in order to be upgraded correctly. These files often
1817 correspond to multiple embedded chips contained within the physical device that have separate
1818 firmware images to run them.
1819
1820 A device has a number of options for managing these files depending on its own internal configuration
1821 or dependencies. This section describes the three main options:
1822

1823 6.11.1 Single OTA File with multiple sub-elements


1824 One of the simplest mechanisms to support multiple firmware images is to bundle all the images into a
1825 single OTA file. Within the OTA file each firmware image could be noted with a different sub-element
1826 tag indicating the module it is designated for. The advantage of this system is that it allows for a single
1827 OTA client to request a single OTA file from the server that contains all the upgrade data it needs.
1828 Management of the multiple firmware images is handled internally by the device.
1829
1830 Typically a manufacturer would put all of the firmware images used by the device into the image and
1831 upgrade all modules at the same time. In that case the device manufacturer would need a download
1832 storage space (e.g. an external EEPROM) big enough to hold an OTA image that contained all the
1833 firmware images for all the modules.
1834
1835 The OTA client reports only the overall upgrade status regardless of how many internal modules are
1836 being manipulated. The OTA client’s attributes reflect only the single OTA Image Type ID,
1837 CurrentFileVersion, DownloadedVersion, and ImageUpgradeStatus attributes.
10
CCB 1479

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page 51


ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

1838 6.11.2 Separate OTA files upgraded independently


1839 Another method that can be used is to have each upgradeable module within the physical device
1840 request bootload images from the OTA server separately. In this case a module would report the same
1841 manufacturer ID but a different image type ID. The modules would operate on separate endpoints to
1842 properly report the attributes about the current state of that module’s upgrade cycle
1843 (ImageUpgradeStatus) as well as the version number it is running (CurrentFileVersion) and
1844 downloading (DownloadedFileVersion). As each module completed a download they would separately
1845 request permission to finish the upgrade via the Upgrade End Request command.
1846 During the manufacturer specific part of the upgrade, it is possible that the OTA client endpoint
1847 undergoing the upgrade, or even the entire Zigbee NWK layer, may not be accessible over-the-air.
1848 Once the upgrade is complete the endpoint’s client attributes reflecting the new version would be
1849 updated.
1850 Manufacturer’s are free to choose different versioning schemes for each image type used by the
1851 physical device and decide when to release updates for each module. However in general it is assumed
1852 that each module can be upgraded independently of the others. Each OTA file would need to be given
1853 to the OTA server and managed separately.
1854 Though each module operates independently it is certainly possible that specific, shared resources may
1855 preclude multiple simultaneous downloads or upgrades. For example, if the device has a single
1856 EEPROM that can store only one download image at a time, then only one OTA client may be
1857 downloading or updating. Other OTA clients on other endpoints corresponding to other modules
1858 would have to wait until the required resources are free for it to use.
1859

1860 6.11.3 Multiple OTA files dependent on each other


1861 The last method a device might use to handle upgrading separate modules in the physical device is to
1862 use multiple OTA files that have a dependency on each other. In this case the OTA client would
1863 sequentially download and apply each OTA file before going to the next one.
1864 This method might be used in the case where a single OTA file containing all the OTA images is not
1865 possible because the device does not contain a storage space big enough to hold all the module
1866 firmware images. Additionally each module cannot operate independently due to an internal device
1867 restriction.
1868 The details of the dependencies within the OTA files are specific to the manufacturer of the device.
1869 For example if the device required the OTA file for Image Type 7 before it received the OTA file for
1870 Image Type 3, the device must manage this.
1871 After each OTA file has been downloaded and processed the OTA client shall send an Upgrade End
1872 Request command with a status of REQUIRE_MORE_IMAGE. It shall then download and process
1873 the next file. In this case the act of “processing” is manufacturer specific; it may or may not involve
1874 upgrading the internal component.During each OTA file download the OTA client shall update its
1875 attributes to reflect the module that is being upgraded. For example the Image Type ID,
1876 CurrentFileVersion, DownloadedFileVersion shall bet set to the values of the internal module that the
1877 OTA client is processing an upgrade image for.
1878 Upon completion of the download for all modules the OTA client shall send an Upgrade End Request
1879 command with a status of SUCCESS. The OTA server has the ability to delay or abort the final
1880 upgrade via the normal mechanisms.

1881 6 .1 2 O T A U p g ra d e C lu s te r M a n a g e m e n t
1882 This section provides ways for the upgrade server to monitor and manage the network-wide OTA
1883 upgrade process. It is important to realize that the server cannot reliably query the upgrade status of the
1884 sleepy devices.

Page 52 Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

1885 6.12.1 Query Upgrade Status


1886 Server may send ZCL read attribute command for Image Upgrade Status attribute on the client devices.
1887 The attribute indicates the progress of the client’s file download as well as its upgrade progress. The
1888 server may want to make sure that all clients have completely downloaded their new images prior to
1889 issuing the Upgrade End Response command.
1890 A client shall only download a single file at a time. It shall not download a second file while the first
1891 file download is incomplete. This insures that the values in the client’s attributes can be correlated to a
1892 single download instance.

1893 6.12.2 Query Downloaded ZigBee Stack and File versions


1894 The server may send ZCL read attribute command to a client to determine its downloaded ZigBee stack
1895 version and file version. The server should make sure that the client has downloaded the correct image
1896 prior to issuing the Upgrade End Response command.
1897

1898 6.12.3 Rate Limiting


1899 The OTA Upgrade Cluster server can rate limit how quickly clients download files by setting the Block
1900 Request Delay. This feature is only available if the client supports the attribute, and the server supports
1901 this optional feature. Client support can be determined by requesting the Block Request Delay attribute
1902 from the client, or if the Image Block Request message contains the Block Request Delay field.
1903
1904 The server has the ability to set the attribute while the client is downloading by responding to any
1905 Image Block Request with an Image Block Response with a status of WAIT_FOR_DATA . The Image
1906 Block Response shall include the Block Request field with the new delay desired by the server for all
1907 the client’s subsequent requests. Upon receipt of the Image Block Response the client will record the
1908 new value in its local BlockRequestDelay attribute and use it for the rest of the download.
1909
1910 The server can change the download delay of the client multiple times over the course of the download
1911 based on whatever criteria it deems appropriate. For example if the server detects only 1 client is
1912 downloading, it could allow that client to download at full speed (Minimum Block Request Period = 0),
1913 but if other clients simultaneously start downloads it could limit all clients to 1 Image Block Request
1914 every 500 ms. Alternatively it could give higher priority to certain clients to download their upgrade
1915 image and let them download at full speed, while slowing down other clients.
1916
1917 The MinimumBlockRequestPeriod is a minimum delay. The client may request data slower than what
1918 the server specifies (i.e. with a longer delay). Sleeping end devices may do this normally to conserve
1919 battery power.
1920
1921 Below is a diagram showing how the rate limiting process generally works.

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page 53


ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

1922
1923 Figure 3 - Rate Limiting Exchange
1924
1925

1926 6.12.4 Current Time, Request Time, and Minimum Block Request Delay
1927 When a server sends an Image Block Response with a status of WAIT_FOR_DATA, it can delay the
1928 client’s next Image Block Request. This can be done persistently for all subsequent requests, or
1929 temporarily as a onetime delay.
1930 The onetime delay can be created by setting the Current Time and Request Time fields as described in
1931 section Error! Reference source not found. Error! Reference source not found.. This might occur if
1932 the server does not immediately have access to the block of the upgrade image requested by the client,
1933 and the server must fetch the block from another location.
1934 The persistent delay can be enabled by setting the Minimum Block Request Period as described in
1935 section 6.10.8.2.9 Block Request , however this only works if the client and server support this
1936 functionality.
1937

1938 6 .1 3 O T A U p g ra d e P ro c e s s
1939 Once a device has completely downloaded the image and returned a status of SUCCESS in the
1940 Upgrade End Request, it shall obey the server’s directive based on when it should upgrade. However
1941 there are many failure scenarios where this may not be possible. In such failure case, the device should
1942 attempt to contact the server and determine what should be done, but if that has failed as well, then it
1943 may apply its update without an explicit command by the server.
1944

Page 54 Copyright ã 2016, The ZigBee Alliance. All rights reserved.


ZigBee Document – 095264
ZigBee OTA Upgrade Cluster

1945 After receiving an Upgrade End Response from the server the client will apply the upgrade according
1946 to time values specified in the message. If the response directs the device to wait forever, it shall
1947 periodically query the server about when it should apply the new upgrade. This shall happen at a
1948 period no more often than once every 60 minutes. If the server is unreachable after 3 retries, the device
1949 may apply the upgrade.
1950
1951 The client does not need to persistently store the time indicating when to apply the upgrade. If the
1952 client feels that it has lost connection to the upgrade server, it shall first try to rediscover the upgrade
1953 server perhaps by rejoining to the network and performing network address discovery using the stored
1954 UpgradeServerID attribute. Once the server is found, the client shall resend an Upgrade End Request
1955 command with a status of SUCCESS to the server, including the relevant upgrade file
1956 information. The server shall send it a response again indicating when it should upgrade. If the device
1957 is unable to communicate to the upgrade server or it cannot synchronize the time, it may apply the
1958 upgrade anyway.
1959
1960 When the time comes for the client to upgrade, the device should begin the manufacturer specific
1961 method to upgrade its image. The upgrade may involve one or more hardware resets. Once the device
1962 has completed the upgrade it should be able to reinitialize itself and start communicating on the
1963 network again. Previous network information such as channel, power, short pan id, extended pan id
1964 should be preserved across the upgrade.

1965 6 .1 4 A p p lic a tio n P r o file S p e c ific D e c is io n s


1966 Below are the decisions that each application profile needs to make in order to ensure successful OTA
1967 upgrade of devices in the network.
1968 - The following are security considerations that should be taken into account when using this
1969 cluster.
1970 o Whether image signatures will be used to sign the OTA upgrade file. If a signature is
1971 used, what type of image signature will it be (example: ECDSA).
1972 o What encryption will be used during the transport of OTA data
1973 • Whether to use offset or UTC time in Image Block Response and Upgrade End Response
1974 commands. Refer to section 6.8.4, 6.8.5, 6.10.7 and 6.10.9 for more details. If the application
1975 profile does not specify which type of (OTA upgrade) time to support, it is default to using the
1976 offset time since it does not require an implementation of ZCL time cluster. Once the
1977 application profile has decided which type of time to support, only that type of time shall be
1978 used consistently across the OTA upgrading. The profile shall avoid using both types of time
1979 simultaneously to avoid any confusion and inconsistency between the two time values.
1980 Other application profile wide decisions that should be answered are:
1981 • How often OTA client shall discovery OTA server until it finds one that is authorized to do
1982 the upgrade.
1983 • How often the ZED client shall query OTA server for new OTA upgrade image.
1984 • How often the ZED devices shall query for image data.

1985 6.14.1 SE Profile: OTA Upgrade from SE 1.x to SE 2.0


1986 The definition of SE Profile 2.0 is currently still being worked on by the ZigBee SE group. However,
1987 it is suggested that in order to successfully upgrade a device from SE 1.x to SE 2.0, such process may
1988 involve transferring new security data over-the-air from the server to the client device. OTA Upgrade
1989 cluster has provided a set of commands that may be used to obtain such security data. The security
1990 data will be requested separately by the client using Query Specific File Request command. The data is
1991 sent from the server to the client as an OTA upgrade file via similar set of commands used to request
1992 firmware image. This OTA security file will be specific to a particular client device.

Copyright ã 2016, The ZigBee Alliance. All rights reserved. Page 55


ZigBee Document - 095264 ZigBee OTA Upgrade Cluster

1993 A client should request new security data necessary for SE Profile 2.0 via Query Specific File Request
1994 command. After obtaining the security data file, the server will include the file information in the
1995 Query Specific File Response command in response to the client’s request. Upon reception the
1996 response, the client then shall obtain the file via Image Block or Page Request command. Query
1997 Specific File Request and Response commands are described in section 6.10.11 and 6.10.12
1998 respectively.

1999 6 .1 5 O T A U p g ra d e R e c o v e ry
2000 Each manufacturer is encouraged to implement a recovery method that should be used to recover the
2001 node in a case when the OTA upgrade fails. The recovery method is particularly important in a case
2002 where the device may not be able to communicate to the server over-the-air. The actual recovery
2003 implementation is manufacturer specific, however, some of the options are discussed in this section.
2004 One option for recovery method is the ability for the application bootloader to swap the images
2005 between its external flash and its internal flash, rather than just overwriting the internal with the
2006 external. A sample use case is where the upgraded device is functional enough to receive a message,
2007 but broken enough to not be able to initiate OTA upgrade process again. A manufacturer specific
2008 command may be sent from the server to notify the device to revert back to its previous image.
2009 In a case where the device is no longer able to communicate to the server over-the-air; the application
2010 bootloader could revert to the previous image via a button press on power up.
2011

Page 56 Copyright ã 2016, The ZigBee Alliance. All rights reserved.

You might also like