Welcome to mirror list, hosted at ThFree Co, Russian Federation.

readme.txt « Zigbee_OTA_Client_Router « Zigbee « Applications « P-NUCLEO-WB55.Nucleo « Projects - github.com/Flipper-Zero/STM32CubeWB.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d448b85aa5c73cb8adc68543cdbd48de3d750aa3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
/**
  @page Zigbee_OTA_Client_Router application
  
  @verbatim
  ******************************************************************************
  * @file    Zigbee/Zigbee_OTA_Client_Router/readme.txt 
  * @author  MCD Application Team
  * @brief   Description of the Zigbee OTA Cluster application as a client  
  *          using a centralized network. 
  ******************************************************************************
  *
  * Copyright (c) 2020 STMicroelectronics. All rights reserved.
  *
  * This software component is licensed by ST under Ultimate Liberty license 
  * SLA0044, the "License"; You may not use this file except in compliance with 
  * the License. You may obtain a copy of the License at:
  *                               www.st.com/SLA0044
  *
  ******************************************************************************
  @endverbatim

@par Application Description 

How to use OTA cluster as a client on a centralized Zigbee network.

The purpose of this application is to show how to create a Zigbee centralized network, 
and how to operate a firmware upgrade using the OTA cluster. Once the Zigbee mesh network is created, 
the user can start an OTA upgrade from server to client through push buttons 
SW1 (M0 wireless coprocessor firmware) and SW2 (M4 application firmware).

In order for the client to persist its stack parameters data, Zigbee persistence data mechamisim
is used on the Zigbee_OTA_Client_Router appilcation. This allows the client to reconnect to the 
coordinator network after the upgrade procedure.

For this application it is requested to have:

- 1 STM32WB55xx (Nucleo or USB dongle) board loaded with: 
    - wireless coprocessor : stm32wb5x_Zigbee_FFD_fw.bin
    - application : Zigbee_OTA_Server_Coord
    
- 1 or more STM32WB55xx board loaded with: 
    - wireless coprocessor : stm32wb5x_Zigbee_FFD_fw.bin
    - application : Zigbee_OTA_Client_Router
    
    
IMPORTANT PREREQUISITES:
On Zigbee_OTA_Server_Coord a binary image has to be loaded at @0x08030000 before starting the process.
It can be FW application example (compatible with Ota settings, see Zigbee_OnOff_Client_Router_Ota for details)
or encrypted Copro Wireless binary.
    
    
Demo use case :

This demo shows how to use OTA cluster for a firmware upgrade.

1. Flash splitting on Zigbee_OTA_Client_Router application

The STM32WB55xx internal Flash division on the OTA client side is set as follow:

  @0x08000000 +-----------------------------+   
              |                             |
              |         OTA main app        |
              |                             | @0x0801FFFF
  @0x08020000 +-----------------------------+  
              |                             |
              |          NVM data           |
              |                             |
  @0x08030000 +-----------------------------+ @0x0802FFFF   
              |                             |      
              | OTA upgrade available space |
              |   (remaining free space)    |
              |                             | limit @ given by SFSA (Option Byte)
              +-----------------------------+      

2. OTA file format used by the server

The OTA upgrade process relies on OTA file format comaptible files.
As a result, the OTA file format used for STM32WB55xx upgrade is as folow:

   +----------------------------+   
   |       ZCL OTA Header       |
   +----------------------------+   
   |    OTA upgrade image tag   |
   +----------------------------+   
   |       Firmware data        |
   +----------------------------+   

3. Generation of the OTA file from raw firmware

If the OTA file format discribed above is used in the data exchange between 
the OTA client and server, the OTA server stored the raw binary in Flash.
The OTA file format exchanged during the upgrade process is dynamically generated
at running time during the data transfer (ZCL OTA block request/response sequence).


4. Update procedure diagram
                                                                            
          
   +---------------------------------+                                            +---------------------------------+                                                                               
   | Device 1                        |                                            | Device 2                        |                                                                                                               
   | Zigbee OTA server               |                                            | Zigbee OTA client               |                                  
   |                                 |                                            |                                 |    
   +---------------------------------+                                            +---------------------------------+
   |                                 |          /* Initalisation phase */         |                                 |
   | Before starting FW for update   |                                            |                                 |
   | must be written at following    |         /* OTA server discovering */       |                                 |
   | @ = 0x08030000                  |                                            |                                 |
   |                                 |           ZbZclOtaClientDiscover           |                                 |
   |                                 | <----------------------------------------- |                                 |
   |                                 | -----------------------------------------> |                                 |                                             
   |                                 |                                            |                                 |     
   |                                 |                                            | Application performs a delete   |      
   |                                 |                                            | of FLASH memory sectors         |                                
   |                                 |                                            | starting from @ = 0x08030000 to |                                         
   |                                 |                                            | SFSA (Option Byte) limit        |=> BLUE LED ON                                         
   |                                 |             /* Upgrade phase */            |                                 |   
   |                                 |                                            |                                 |  
   |                                 |          /* Image Notify request */        |                                 |  
   |                                 |                                            |                                 |            
   | Push Button                     |         ZbZclOtaServerImageNotifyReq       |                                 |               
   |  - SW1 (OTA for APP Update)     | -----------------------------------------> |                                 |
   |  - SW2 (OTA for Copro Update)   | <----------------------------------------- |                                 |
   |                                 |                                            |                                 |   
   |                                 |       /* Query Next Image request */       |                                 |
   |                                 |                                            |                                 |
   |                                 |       ZbZclOtaClientQueryNextImageReq      |                                 |
   |                                 | <----------------------------------------- |                                 |   
   |                                 | -----------------------------------------> |                                 |   
   |                                 |                                            |                                 | 
   |                                 |                                            |                                 |   
   |                                 |           /* OTA block transfer */         |                                 |   
   |                                 |                                         -->|                                 |   
   |                                 | /* ZbZclOtaClientImageTransferStart */ |   |                                 |=> GREEN LED TOGGLING   
   |                                 |                                         ---|                                 |                               
   |                                 |                                            |                                 |  
   |                                 |             /* Block request */            |                                 |
   |                                 | <----------------------------------------- |                                 |   
   | A RAM cache is used to send     | -----------------------------------------> | Each time update RAM cache is   |  
   | OTA file format data            |                     .                      | full (or going to be next time) | 
   | (reduce Flash reads)            |                     .                      | write it to Flash memory        | 
   |                                 |             /* Block request */            |                                 |
   |                                 | <----------------------------------------- |                                 |   
   |                                 | -----------------------------------------> |                                 |            
   |                                 |                                            |                                 |
   |                                 |                                            |                                 |
   |                                 |          /* Verifying the image */         |                                 |   
   |                                 |                                         -->| At the end of the block,        |   
   |                                 | /* ZbZclOtaClientImageTransferStart */ |   | transfer write the update RAM   |  
   |                                 |                                         ---| cache to Flash for the last     |   
   |                                 |                                            | time                            | 
   |                                 |                                            |                                 |   
   |                                 |                                            | Check the firmware validity     |=> GREEN LED ON   
   |                                 |                                            | with FUOTA magic keyword        |  
   |                                 |                                            |                                 |  
   |                                 |              /* Upgrade End */             |                                 |
   |                                 |                                            |                                 |
   |                                 |          /* Upgrade End request */         |                                 |
   |                                 | <----------------------------------------- |                                 |   
   |                                 | -----------------------------------------> |                                 |            
   |                                 |                                            | At the end of data transfer,    |                        
   | Display FUOTA Transfer details: |                                            | wait for the device to reboot   |                                
   |  - Transfer size                |                                            |  - BLUE LED OFF                 |    
   |  - Transfer time                |                                            |  - GREEN LED OFF                |     
   |  - Average throughput           |                                            |                                 |                      
   |                                 |                                         -->|                                 |                                    
   |                                 |                           /* Reboot */ |   | On Reboot:                      |     
   |                                 |                                         ---|                                 |  
   |                                 |                                            | If File_Type is FW_APP, boot on |
   |                                 |                                            | Zigbee_OnOff_Client_Router_Ota  |     
   |                                 |                                            | or any appilcation supporting   |     
   |                                 |                                            | OTA at @ 0x30000                |     
   |                                 |                                            | (Zigbee_OnOff_Client_Router_Ota)|  
   |                                 |                                            |                                 |  
   |                                 |                                            | If File_Type is                 |  
   |                                 |                                            | FW_COPRO_WIRELESS boot on FUS.  |  
   |                                 |                                            | FUS will then install encrypted |  
   |                                 |                                            | binary on Copro Wireless side.  |  
   |                                 |                                            |                                 |  
   |                                 |      /* Persistent data management */      |                                 |  
   |                                 |                                            |                                 | 
   |                                 |                                         -->|                                 |  
   |                                 |                   /* Clear NVM data */ |   |                                 |<= PushB SW2  
   |                                 |                                         ---|                                 |  
   |                                 |                                            |                                 |  
   +---------------------------------+                                            +---------------------------------+ 
             
             
To setup the application :

  a)  Open the project, build it and load your generated application on your STM32WB devices.
  
 To run the application :

  a)  Start the first board. It must be the coordinator of the Zigbee network so in this demo application it is
      the device running Zigbee_OTA_Server_Coord application (Device2 in the above diagram). 
      Wait for the Blue LED (LED1) ON. 
      
  b)  Start the second board. This board is configured as Zigbee router and will be attached to the network created 
      by the coordinator. Do the same for the other boards if applicable.
      
      At this stage the second board tries to start from persistence this leads to two choices:
        - Persistence Data read from NVM are valid -> the router takes back is role in the network. 
          GREEN LED2 is ON indicating a restart form persistence.
          
        - No persitence data found or wrong data,a fresh start is perfomed, the Zigbee network is automatically created 
          and BLUE LED (LED1) is ON on all devices.
      
 Note: On the Zigbee OTA client routers, the Blue LED is ON when the initialisation process 
      (see detailled procedure diagram above) is successfully done.
 
     
   c)  If the user power cycle the Device 2, Persistence Data are read back and cluster attribute (LED3 state) restored.
       The device start from persistence and GREEN LED LED2 is on.
   
   d)  Push Button SW2 is used to delete NVM (fresh start will be done on next start up ,reproduce a)
   
      
 Note: when LED1, LED2 and LED3 are toggling it is indicating an error has occurred on application.

@par Keywords

Zigbee
 
@par Hardware and Software environment

  - This example runs on STM32WB55xx devices.
  
  - For the Zigbee_OTA_Server_Coord application, a STM32WB55xx USB dongle can be used.
  
  - This example has been tested with an STMicroelectronics STM32WB55RG_Nucleo 
    board and can be easily tailored to any other supported device 
    and development board.
    
  - On STM32WB55RG_Nucleo, the jumpers must be configured as described
    in this section. Starting from the top left position up to the bottom 
    right position, the jumpers on the Board must be set as follows: 

     CN11:    GND         [OFF]
     JP4:     VDDRF       [ON]
     JP6:     VC0         [ON]
     JP2:     +3V3        [ON] 
     JP1:     USB_STL     [ON]   All others [OFF]
     CN12:    GND         [OFF]
     CN7:     <All>       [OFF]
     JP3:     VDD_MCU     [ON]
     JP5:     GND         [OFF]  All others [ON]
     CN10:    <All>       [OFF]


@par How to use it ? 

=> Loading of the stm32wb5x_Zigbee_FFD_fw.bin binary

  This application requests having the stm32wb5x_Zigbee_FFD_fw.bin binary flashed on the Wireless Coprocessor.
  If it is not the case, you need to use STM32CubeProgrammer to load the appropriate binary.
  All available binaries are located under /Projects/STM32_Copro_Wireless_Binaries directory.
  Refer to UM2237 to learn how to use/install STM32CubeProgrammer.
  Refer to /Projects/STM32_Copro_Wireless_Binaries/ReleaseNote.html for the detailed procedure to change the
  Wireless Coprocessor binary. 

=> Getting traces
  To get the traces you need to connect your Board to the Hyperterminal (through the STLink Virtual COM Port).
  The UART must be configured as follows:

    - BaudRate = 115200 baud  
    - Word Length = 8 Bits 
    - Stop Bit = 1 bit
    - Parity = none
    - Flow control = none

=> Running the application

  Refer to the Application description at the beginning of this readme.txt

 * <h3><center>&copy; COPYRIGHT STMicroelectronics</center></h3>