Skip to content

Commit 1541071

Browse files
Martin-NXPrestyled-commitsmarius-alex-tachechapongatiendinabenamar
authored andcommitted
[NXP][rw61x][k32w1] Rework reference apps (#35172)
* [NXP][third_party] Add new NXP SDK support Signed-off-by: Martin Girardot <[email protected]> * [NXP][examples] Update examples to support new NXP SDK Signed-off-by: Martin Girardot <[email protected]> * [NXP][src] Update src to support new NXP SDK Signed-off-by: Martin Girardot <[email protected]> * [NXP][docs] Update docs to support new NXP SDK Signed-off-by: Martin Girardot <[email protected]> * [NXP][scripts] Update scripts to support new NXP SDK Signed-off-by: Martin Girardot <[email protected]> * [NXP][workflows] Update rw61x workflow to support new NXP SDK Signed-off-by: Martin Girardot <[email protected]> * [NXP][submodules] Update submodules to support new NXP SDK Signed-off-by: Martin Girardot <[email protected]> * Restyled by gn * Restyled by prettier-markdown * [NXP] Spelling fixes Signed-off-by: Martin Girardot <[email protected]> * [NXP][examples][common] Add common README file for contact sensor and lighting app Add mcxw71/k32w1 specific OTA guide in nxp docs area. Signed-off-by: marius-alex-tache <[email protected]> * Restyled by prettier-markdown * [NXP][rw61x][examples][laundry-washer][thermostat][all-custer-app] Updating path to new nxp_matter_support repo Signed-off-by: Gatien Chapon <[email protected]> * [NXP][docs] Update RW61x OTA readme to specify the upgrade type used Signed-off-by: Dina Benamar <[email protected]> * [NXP] Doc and spelling fixes Signed-off-by: Martin Girardot <[email protected]> * Restyled by gn * Restyled by prettier-markdown * Restyled by prettier-markdown * [NXP][workflows] Update docker image version Signed-off-by: Martin Girardot <[email protected]> --------- Signed-off-by: Martin Girardot <[email protected]> Signed-off-by: marius-alex-tache <[email protected]> Signed-off-by: Gatien Chapon <[email protected]> Signed-off-by: Dina Benamar <[email protected]> Co-authored-by: Restyled.io <[email protected]> Co-authored-by: marius-alex-tache <[email protected]> Co-authored-by: Gatien Chapon <[email protected]> Co-authored-by: Dina Benamar <[email protected]>
1 parent d6edcd3 commit 1541071

File tree

116 files changed

+2219
-2812
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+2219
-2812
lines changed

.github/workflows/examples-nxp.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ jobs:
150150
if: github.actor != 'restyled-io[bot]'
151151

152152
container:
153-
image: ghcr.io/project-chip/chip-build-rw61x:74
153+
image: ghcr.io/project-chip/chip-build-nxp:74
154154
volumes:
155155
- "/tmp/bloat_reports:/tmp/bloat_reports"
156156
steps:

docs/guides/nxp/nxp_manufacturing_flow.md

+55-21
Original file line numberDiff line numberDiff line change
@@ -247,24 +247,58 @@ adding the following gn argument `chip_use_plain_dac_key=true`.
247247

248248
Supported platforms:
249249

250-
- RW61X - `src/plaftorm/nxp/rt/rw61x/FactoryDataProviderImpl.h`
251-
252-
For platforms that have a secure subsystem (`SE50`), the DAC private key can be
253-
converted to an encrypted blob. This blob will overwrite the DAC private key in
254-
factory data and will be imported in the `SE50` before to sign, by the factory
255-
data provider instance.
256-
257-
The conversion process shall happen at manufacturing time and should be run one
258-
time only:
259-
260-
- Write factory data binary.
261-
- Build the application with
262-
`chip_with_factory_data=1 chip_convert_dac_private_key=1` set.
263-
- Write the application to the board and let it run.
264-
265-
After the conversion process:
266-
267-
- Make sure the application is built with `chip_with_factory_data=1`, but
268-
without `chip_convert_dac_private_key` arg, since conversion already
269-
happened.
270-
- Write the application to the board.
250+
- RW61X
251+
252+
there are three implementations for factory data protection
253+
254+
- whole factory data protection with AES encryption ( chip_with_factory_data=1
255+
chip_enable_secure_whole_factory_data=true )
256+
`examples/platform/nxp/rt/rw61x/factory_data/source/AppFactoryDataExample.cpp`\
257+
`src/platform/nxp/rt/rw61x/FactoryDataProviderEncImpl.cpp`
258+
259+
- only dac private key protection ( chip_with_factory_data=1
260+
chip_enable_secure_dac_private_key_storage=true )
261+
`examples/platform/nxp/rt/rw61x/factory_data/source/AppFactoryDataExample.cpp`
262+
\
263+
`src/platform/nxp/rt/rw61x/FactoryDataProviderImpl.cpp`
264+
265+
- whole factory data protection with hard-coded AES key (
266+
chip_with_factory_data=1 )
267+
`examples/platform/nxp/common/factory_data/source/AppFactoryDataDefaultImpl.cpp`
268+
\
269+
`src/platform/nxp/common/factory_data/FactoryDataProviderFwkImpl.cpp`
270+
271+
for the first one, the whole factory data is encrypted by an AES-256 key, the
272+
AES key can be passed through serial link when in factory production mode, and
273+
will be provisioned into Edge Lock, and the returned AES Key blob (wrapped key)
274+
can be stored in the end of factory data region in TLV format. for the
275+
decryption process, the blob is retrieved and provisioned into Edge Lock and the
276+
whole factory data can be decrypted using the returned key index in Edge Lock.
277+
Compared with only dac private key protection solution, this solution can avoid
278+
tampering with the original factory data.
279+
280+
the factory data should be encrypted by an AES-256 key using "--aes256_key"
281+
option in "generate.py" script file.
282+
283+
it will check whether there is AES key blob in factory data region when in each
284+
initialization, if not, the default AES key is converted and the result is
285+
stored into flash, it run only once.
286+
287+
for the second one, it only protect the dac private key inside the factory data,
288+
the dac private key is retrieved and provisioned into Edge Lock, the returned
289+
key blob replace the previous dac private key, and also update the overall size
290+
and hash, and re-write the factory data. when device is doing matter
291+
commissioning, the blob is retrieved and provisioned into Edge Lock and the
292+
signing can be done using the returned key index in Edge Lock.
293+
294+
the factory data should be plain text for the first programming. it will check
295+
whether there is dac private key blob (base on the size of blob, should be 48)
296+
in factory data when in each initialization, if not, the dac private key is
297+
converted and the result is stored into flash, it run only once.
298+
299+
for the third one, it is a little similar to the first one, the whole factory
300+
data is encrypted by an AES key, but there are two differences:
301+
302+
- the AES key is hard-coded and not provisioned into Edge Lock
303+
- the factory data should be encrypted by AES-128 key using "--aes128_key"
304+
option in "generate.py" script file.
+179
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
# NXP `MCXW71/K32W1` OTA guide
2+
3+
### Convert `srec` into `sb3` file
4+
5+
The OTA image files must be encrypted using Over The Air Programming Tool
6+
([OTAP](https://www.nxp.com/design/microcontrollers-developer-resources/connectivity-tool-suite:CONNECTIVITY-TOOL-SUITE?#downloads)).
7+
Bootloader will load the new OTA image only if it detects that the file was
8+
encrypted with the `OTAP` correct keys.
9+
10+
`.srec` file is input for Over The air Programming (`OTAP`) application
11+
(unencrypted) and it's converted to `.sb3` format (encrypted).
12+
13+
In `OTAP` application
14+
15+
- select OTA protocol => `OTAP` Matter
16+
- Browse File
17+
- follow default options (KW45/K32W148, Preserve NVM)
18+
- image information: will update "Application Core (MCU)" - this will generate
19+
the image only for the CM33 core
20+
- keep other settings at default values
21+
22+
### Generate `ota` file
23+
24+
In order to build an OTA image, use the NXP wrapper over the standard tool
25+
`src/app/ota_image_tool.py`:
26+
27+
- `scripts/tools/nxp/ota/ota_image_tool.py`
28+
29+
The tool can be used to generate an OTA image with the following format:
30+
31+
```
32+
| OTA image header | TLV1 | TLV2 | ... | TLVn |
33+
```
34+
35+
where each TLV is in the form `|tag|length|value|`.
36+
37+
Note that "standard" TLV format is used. Matter TLV format is only used for
38+
factory data TLV value.
39+
40+
Please see more in the
41+
[OTA image tool guide](../../../scripts/tools/nxp/ota/README.md).
42+
43+
Here is an example that generates an OTA image with application update TLV from
44+
an `.sb3` file:
45+
46+
```
47+
./scripts/tools/nxp/ota/ota_image_tool.py create -v 0xDEAD -p 0xBEEF -vn 2 -vs "2.0" -da sha256 --app-input-file ~/binaries/chip-mcxw71-app.sb3 ~/binaries/chip-mcxw71-app.ota
48+
49+
```
50+
51+
A note regarding OTA image header version (`-vn` option). An application binary
52+
has its own software version (given by
53+
`CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION`, which can be overwritten). In
54+
order to have a correct OTA process, the OTA header version should be the same
55+
as the binary embedded software version. A user can set a custom software
56+
version in the gn build args by setting `nxp_software_version` to the wanted
57+
version.
58+
59+
### OTA factory data
60+
61+
A user can update the factory data through OTA, at the same time the application
62+
firmware is updated by enabling the following processor in the `gn args`:
63+
64+
- `chip_enable_ota_factory_data_processor=1` to enable default factory data
65+
update processor (disabled by default).
66+
67+
The OTA image used must be updated to include the new factory data.
68+
69+
[OTA image tool guide](../../../scripts/tools/nxp/ota/README.md).
70+
71+
### Running OTA
72+
73+
The OTA topology used for OTA testing is illustrated in the figure below.
74+
Topology is similar with the one used for Matter Test Events.
75+
76+
![OTA_TOPOLOGY](../../../examples/platform/nxp/mcxw71_k32w1/doc/images/ota_topology.JPG)
77+
78+
The concept for OTA is the next one:
79+
80+
- there is an OTA Provider Application that holds the OTA image. In our case,
81+
this is a Linux application running on an Ubuntu based-system;
82+
- the OTA Requestor functionality is embedded inside the reference
83+
application. It will be used for requesting OTA blocks from the OTA
84+
Provider;
85+
- the controller (a linux application called chip-tool) will be used for
86+
commissioning both the device and the OTA Provider App. The device will be
87+
commissioned using the standard Matter flow (BLE + IEEE 802.15.4) while the
88+
OTA Provider Application will be commissioned using the `onnetwork` option
89+
of `chip-tool`;
90+
- during commissioning, each device is assigned a node id by the chip-tool
91+
(can be specified manually by the user). Using the node id of the device and
92+
of the reference application, chip-tool triggers the OTA transfer by
93+
invoking the `announce-ota-provider` command - basically, the OTA Requestor
94+
is informed of the node id of the OTA Provider Application.
95+
96+
_Computer #1_ can be any system running an Ubuntu distribution. We recommand
97+
using CSA official instructions from
98+
[here](https://groups.csa-iot.org/wg/matter-csg/document/28566), where RPi 4 are
99+
proposed. Also, CSA official instructions document point to the OS/Docker images
100+
that should be used on the RPis. For compatibility reasons, we recommand
101+
compiling chip-tool and OTA Provider applications with the same commit id that
102+
was used for compiling the reference application. Also, please note that there
103+
is a single controller (chip-tool) running on Computer #1 which is used for
104+
commissioning both the device and the OTA Provider Application. If needed,
105+
[these instructions](https://itsfoss.com/connect-wifi-terminal-ubuntu/) could be
106+
used for connecting the RPis to WiFi.
107+
108+
Build the Linux OTA provider application:
109+
110+
```
111+
user@computer1:~/connectedhomeip$ : ./scripts/examples/gn_build_example.sh examples/ota-provider-app/linux out/ota-provider-app chip_config_network_layer_ble=false
112+
```
113+
114+
Build Linux `chip-tool`:
115+
116+
```
117+
user@computer1:~/connectedhomeip$ : ./scripts/examples/gn_build_example.sh examples/chip-tool out/chip-tool-app
118+
```
119+
120+
Start the OTA Provider Application:
121+
122+
```
123+
user@computer1:~/connectedhomeip$ : rm -rf /tmp/chip_*
124+
user@computer1:~/connectedhomeip$ : ./out/ota-provider-app/chip-ota-provider-app -f chip-mcxw71-app.ota
125+
```
126+
127+
Provision the OTA provider application and assign node id _1_. Also, grant ACL
128+
entries to allow OTA requestors:
129+
130+
```
131+
user@computer1:~/connectedhomeip$ : rm -rf /tmp/chip_*
132+
user@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool pairing onnetwork 1 20202021
133+
user@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool accesscontrol write acl '[{"fabricIndex": 1, "privilege": 5, "authMode": 2, "subjects": [112233], "targets": null}, {"fabricIndex": 1, "privilege": 3, "authMode": 2, "subjects": null, "targets": null}]' 1 0
134+
```
135+
136+
Provision the device and assign node id _2_:
137+
138+
```
139+
user@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool pairing ble-thread 2 hex:<operationalDataset> 20202021 3840
140+
```
141+
142+
Start the OTA process:
143+
144+
```
145+
user@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool otasoftwareupdaterequestor announce-ota-provider 1 0 0 0 2 0
146+
```
147+
148+
### Known issues
149+
150+
- SRP cache on the openthread border router needs to flushed each time a new
151+
commissioning process is attempted. For this, factory reset the device, then
152+
execute `ot-ctl server disable` followed by `ot-ctl server enable`. After
153+
this step, the commissioning process of the device can start;
154+
- Due to some MDNS issues, the commissioning of the OTA Provider Application
155+
may fail. Please make sure that the SRP cache is disabled
156+
(`ot-ctl srp server disable`) on the openthread border router while
157+
commissioning the OTA Provider Application;
158+
- No other Docker image should be running (e.g.: Docker image needed by Test
159+
Harness) except the OTBR one. A docker image can be killed using the
160+
command:
161+
162+
```
163+
user@computer1:~/connectedhomeip$ : sudo docker kill $container_id
164+
```
165+
166+
- In order to avoid MDNS issues, only one interface should be active at one
167+
time. E.g.: if WiFi is used then disable the Ethernet interface and also
168+
disable multicast on that interface:
169+
170+
```
171+
user@computer1:~/connectedhomeip$ sudo ip link set dev eth0 down
172+
user@computer1:~/connectedhomeip$ sudo ifconfig eth0 -multicast
173+
```
174+
175+
- If OTBR Docker image is used, then the "-B" parameter should point to the
176+
interface used for the backbone.
177+
178+
- If Wi-Fi is used on a RPI4, then a 5Ghz network should be selected.
179+
Otherwise, issues related to BLE-WiFi combo may appear.

0 commit comments

Comments
 (0)