Skip to content

Commit

Permalink
[K32W0] Add platform changes and features (#22896) (#22984)
Browse files Browse the repository at this point in the history
* [K32W0] Add platform changes and features

* Add SVE2 fixes and other changes and features

* Add support for custom certificate policy.
* Certificate declaration: set certificate_type to 1
* Add new demo certificates
* Add demo certificates allowing testing with two different DUTs

* Add custom lighting app ZAP file - e.g.: removed generic and not needed clusters
  like the ones required for Ethernet/WiFi; removed the optional clusters for an
  On/Off Device Type;

* Add ksdk_mbedlts.c such that we redirect all the AES calls through SecLib.c

* Add TestEventTrigger Support

* Add functionality for ResetWatermarks()

* Add callback for PDM logs

* Fix NotifyUpdateApplied - message that is sent when booting for the first time
  with an OTA image was not being send due to a bug in the PDM read function:
  ReadConfigValue(...);
* Add delay when rebooting after OTA finishes
* Improve OTA mechanism

* Remove third parameter of ReadConfigValue() and use a TValue& parameter which can
  be used for extracting the value length

* Consume faster the RX buffer
* RX buffer should be processed with high priority because:
  * 15.4 packets are consumed on Thread task;
  * Thread task has a higher priority than the Matter one (3 > 2)

* Fix Low Power
  * fix 15.4 warm-up time: before this commit calibration time also
    included the time required for attaching to the Thread network
    This led to a large warm-up value that blocked some 15.4 operations
    Fix this by including in the warm-up time only the 15.4 radio
    initialization time
  * fix the warm-up initial value to avoid any conflicts
  * fix possible overflow in reading timestamp values
  * Make sure that all the logs are disabled when an application is compiled with low-power
	support; logging can interference with LP timings and break functionality;

* Fix time support for Matter
  * using FreeRTOS timers (based on FreeRTOS tickets) is inaccurate and leads to time drifting
  * use OT Timers API  (Wtimer-based) for getting us/ms timestamps

* Fix ExtractPubkeyFromX509Cert in CHIPCryptoPALTinyCrypt.cpp

* Fix BLE advertising interval + issue warning if the peer doesn't support 2Mbps

* Fix Diagnostic Data Provider

* Fix OnOff attribute persistence over hw reset

* Fix compilation issue for lock-app

* Disable by default on lighting-app BLE Set Phy Req to 2M to be extra cautious during interops

* Update readme files

Signed-off-by: Doru Gucea <[email protected]>
Signed-off-by: Marius Tache <[email protected]>
Signed-off-by: Andrei Menzopol <[email protected]>

* Fix gn includes, spelling, wordlist

Signed-off-by: Andrei Menzopol <[email protected]>

* Update ot-nxp submodule

Signed-off-by: Andrei Menzopol <[email protected]>

* Fix gn includes, exclude certs from restyle, fix messaging readme

Signed-off-by: Andrei Menzopol <[email protected]>

* Restyled by whitespace

* Restyled by clang-format

* Restyled by gn

* Restyled by prettier-markdown

* Restyled by shellharden

* Restyled by shfmt

* Restyled by autopep8

* Fix low-power build

Signed-off-by: Marius Tache <[email protected]>
Signed-off-by: Andrei Menzopol <[email protected]>

* Restyled by clang-format

* Fix SecLib compile issue

Signed-off-by: Andrei Menzopol <[email protected]>

* Restyled by clang-format

* Update worflows K32W0 examples yaml

Signed-off-by: Andrei Menzopol <[email protected]>

* Update docker version, expected gn gen

Signed-off-by: Andrei Menzopol <[email protected]>

* Hotfix nxp shell build

Signed-off-by: Andrei Menzopol <[email protected]>

Signed-off-by: Doru Gucea <[email protected]>
Signed-off-by: Marius Tache <[email protected]>
Signed-off-by: Andrei Menzopol <[email protected]>
Co-authored-by: Restyled.io <[email protected]>

Signed-off-by: Doru Gucea <[email protected]>
Signed-off-by: Marius Tache <[email protected]>
Signed-off-by: Andrei Menzopol <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
andrei-menzopol and restyled-commits authored Sep 30, 2022
1 parent 6c34fa8 commit 6ff45cf
Show file tree
Hide file tree
Showing 115 changed files with 20,067 additions and 1,553 deletions.
13 changes: 7 additions & 6 deletions .github/.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ accessor
AccountLogin
acdbc
ack
ACK
ACKed
ACL
ACLs
Expand Down Expand Up @@ -156,7 +155,6 @@ bootable
Bootloader
BorderRouterAP
bouffalolab
Bouffalolab
BRD
breakpoint
bredr
Expand Down Expand Up @@ -332,6 +330,7 @@ cxx
CY
CYW
DAC
DACs
dadbdcdddedf
DAP
DAPLINK
Expand Down Expand Up @@ -449,6 +448,7 @@ dryrun
DS
duplicative
DUT
DUTS
DV
DVK
dynload
Expand Down Expand Up @@ -596,9 +596,9 @@ GPL
GPLv
Gradle
gradlew
Groupcast
GroupId
GroupKeyManagement
Groupcast
groupKeySecurityPolicy
groupKeySetID
groupsettings
Expand Down Expand Up @@ -652,7 +652,6 @@ ignoreQueryImage
ihex
IlluminanceMeasurement
IM
IsInitiator
imager
imagetool
imageUri
Expand Down Expand Up @@ -990,6 +989,7 @@ PAAs
PacketBuffer
PAI
PairDevice
PAIs
PAKE
palletsprojects
pankore
Expand Down Expand Up @@ -1376,13 +1376,14 @@ uint
ULA
UNBLUR
uncommissioned
Unencrypted
unfocus
Unicast
UniFlash
UnitLocalization
Unencrypted
unpair
unprovisioned
Unsecure
untrusted
updateAvailable
updateNotAvailable
Expand All @@ -1400,7 +1401,6 @@ userConsentState
userguide
USERINTERFACE
UserLabel
Unsecure
usermod
usr
UTF
Expand All @@ -1419,6 +1419,7 @@ ver
Verifier
Verifiers
VID
vids
virtualenv
visualstudio
vlatest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/examples-k32w.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
if: github.actor != 'restyled-io[bot]'

container:
image: connectedhomeip/chip-build-k32w:0.5.99
image: connectedhomeip/chip-build-k32w:0.6.02
volumes:
- "/tmp/bloat_reports:/tmp/bloat_reports"
steps:
Expand Down
1 change: 1 addition & 0 deletions .restyled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ exclude:
- "examples/chef/zzz_generated/**/*"
- "src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm" # https://github.com/project-chip/connectedhomeip/issues/20236
- "src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h" # https://github.com/project-chip/connectedhomeip/issues/20236
- "examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/**/*"


changed_paths:
Expand Down
16 changes: 5 additions & 11 deletions examples/lighting-app/nxp/k32w/k32w0/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,13 @@ k32w0_executable("light_app") {
"main/main.cpp",
]

public = [ "${chip_root}/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.h" ]

deps = [
":sdk",
"${chip_root}/examples/common/QRCode",
"${chip_root}/examples/lighting-app/lighting-common/",
"${chip_root}/examples/lighting-app/nxp/zap/",
"${chip_root}/examples/providers:device_info_provider",
"${chip_root}/src/lib",
"${chip_root}/third_party/mbedtls:mbedtls",
"${k32w0_platform_dir}/app/support:freertos_mbedtls_utils",
Expand Down Expand Up @@ -113,16 +116,7 @@ k32w0_executable("light_app") {
"-Wl,--defsym",
"-Wl,__app_load_address__=0x4000",
"-Wl,--defsym",
"-Wl,__app_stated_size__=0x99A00",
]
}

if (chip_enable_ota_requestor) {
ldflags += [
"-Wl,--defsym",
"-Wl,__app_load_address__=0x4000",
"-Wl,--defsym",
"-Wl,__app_stated_size__=0x99A00",
"-Wl,__app_stated_size__=0x99200",
]
}

Expand Down
57 changes: 35 additions & 22 deletions examples/lighting-app/nxp/k32w/k32w0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ network.
- [Bluetooth LE Rendezvous](#bluetooth-le-rendezvous)
- [Device UI](#device-ui)
- [Building](#building)
- [Known issues](#building-issues)
- [Manufacturing data](#manufacturing)
- [Flashing and debugging](#flashdebug)
- [Pigweed Tokenizer](#tokenizer)
- [Detokenizer script](#detokenizer)
Expand Down Expand Up @@ -193,18 +195,15 @@ effects:
In order to build the Project CHIP example, we recommend using a Linux
distribution (the demo-application was compiled on Ubuntu 20.04).

- Download [K32W0 SDK 2.6.6 for Project CHIP](https://mcuxpresso.nxp.com/).
Creating an nxp.com account is required before being able to download the
SDK. Once the account is created, login and follow the steps for downloading
SDK_2_6_6_K32W061DK6 (required for K32W061 flavor). The SDK Builder UI
selection should be similar with the one from the image below.
![MCUXpresso SDK Download](../../../../platform/nxp/k32w/k32w0/doc/images/mcux-sdk-download.JPG)
- Download
[K32W0 SDK 2.6.7](https://cache.nxp.com/lgfiles/bsps/SDK_2_6_7_K32W061DK6.zip).

- Start building the application either with Secure Element or without
- without Secure Element

```
user@ubuntu:~/Desktop/git/connectedhomeip$ export NXP_K32W0_SDK_ROOT=/home/user/Desktop/SDK_2_6_6_K32W061DK6/
user@ubuntu:~/Desktop/git/connectedhomeip$ export NXP_K32W0_SDK_ROOT=/home/user/Desktop/SDK_2_6_7_K32W061DK6/
user@ubuntu:~/Desktop/git/connectedhomeip$ ./third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh
user@ubuntu:~/Desktop/git/connectedhomeip$ source ./scripts/activate.sh
user@ubuntu:~/Desktop/git/connectedhomeip$ cd examples/lighting-app/nxp/k32w/k32w0
user@ubuntu:~/Desktop/git/connectedhomeip/examples/lighting-app/nxp/k32w/k32w0$ gn gen out/debug --args="k32w0_sdk_root=\"${NXP_K32W0_SDK_ROOT}\" chip_with_OM15082=1 chip_with_ot_cli=0 is_debug=false chip_crypto=\"tinycrypt\" chip_with_se05x=0 chip_pw_tokenizer_logging=true mbedtls_repo=\"//third_party/connectedhomeip/third_party/nxp/libs/mbedtls\""
Expand Down Expand Up @@ -246,6 +245,20 @@ pycryptodome 3.9.8

The resulting output file can be found in out/debug/chip-k32w0x-light-example.

<a name="building-issues"></a>

## Known issues

- When using Secure element and cross-compiling on Linux, log messages from
the Plug&Trust middleware stack may not echo to the console.

<a name="manufacturing"></a>

## Manufacturing data

See
[Guide for writing manufacturing data on NXP devices](../../../../platform/nxp/doc/manufacturing_flow.md).

<a name="flashdebug"></a>

## Flashing and debugging
Expand Down Expand Up @@ -414,14 +427,14 @@ Here is the interpretation of the fields:
Second, image directory 1 must be written:

```
DK6Programmer.exe -V5 -s <COM port> -P 1000000 -w image_dir_1=00400000CD040101
DK6Programmer.exe -V5 -s <COM port> -P 1000000 -w image_dir_1=00400000C9040101
```

Here is the interpretation of the fields:

```
00400000 -> start address 0x00004000
CD04 -> 0x4CD pages of 512-bytes (= 614,5kB)
CD04 -> 0x4C9 pages of 512-bytes (= 612,5kB)
01 -> bootable flag
01 -> image type for the application
```
Expand Down Expand Up @@ -482,42 +495,42 @@ used for connecting the RPis to WiFi.
Build the Linux OTA provider application:

```
doru@computer1:~/connectedhomeip$ : ./scripts/examples/gn_build_example.sh examples/ota-provider-app/linux out/ota-provider-app chip_config_network_layer_ble=false
user@computer1:~/connectedhomeip$ : ./scripts/examples/gn_build_example.sh examples/ota-provider-app/linux out/ota-provider-app chip_config_network_layer_ble=false
```

Build OTA image and start the OTA Provider Application:

```
doru@computer1:~/connectedhomeip$ : ./src/app/ota_image_tool.py create -v 0xDEAD -p 0xBEEF -vn 1 -vs "1.0" -da sha256 chip-k32w0x-light-example.bin chip-k32w0x-light-example.ota
doru@computer1:~/connectedhomeip$ : rm -rf /tmp/chip_*
doru@computer1:~/connectedhomeip$ : ./out/ota-provider-app/chip-ota-provider-app -f chip-k32w0x-light-example.ota
user@computer1:~/connectedhomeip$ : ./src/app/ota_image_tool.py create -v 0xDEAD -p 0xBEEF -vn 1 -vs "1.0" -da sha256 chip-k32w0x-light-example.bin chip-k32w0x-light-example.ota
user@computer1:~/connectedhomeip$ : rm -rf /tmp/chip_*
user@computer1:~/connectedhomeip$ : ./out/ota-provider-app/chip-ota-provider-app -f chip-k32w0x-light-example.ota
```

Build Linux chip-tool:

```
doru@computer1:~/connectedhomeip$ : ./scripts/examples/gn_build_example.sh examples/chip-tool out/chip-tool-app
user@computer1:~/connectedhomeip$ : ./scripts/examples/gn_build_example.sh examples/chip-tool out/chip-tool-app
```

Provision the OTA provider application and assign node id _1_. Also, grant ACL
entries to allow OTA requestors:

```
doru@computer1:~/connectedhomeip$ : rm -rf /tmp/chip_*
doru@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool pairing onnetwork 1 20202021
doru@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
user@computer1:~/connectedhomeip$ : rm -rf /tmp/chip_*
user@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool pairing onnetwork 1 20202021
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
```

Provision the device and assign node id _2_:

```
doru@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool pairing ble-thread 2 hex:<operationalDataset> 20202021 3840
user@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool pairing ble-thread 2 hex:<operationalDataset> 20202021 3840
```

Start the OTA process:

```
doru@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool otasoftwareupdaterequestor announce-ota-provider 1 0 0 0 2 0
user@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool otasoftwareupdaterequestor announce-ota-provider 1 0 0 0 2 0
```

<a name="otaissues"></a>
Expand All @@ -537,16 +550,16 @@ doru@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool otasoftwareupd
command:

```
doru@computer1:~/connectedhomeip$ : sudo docker kill $container_id
user@computer1:~/connectedhomeip$ : sudo docker kill $container_id
```

- In order to avoid MDNS issues, only one interface should be active at one
time. E.g.: if WiFi is used then disable the Ethernet interface and also
disable multicast on that interface:

```
doru@computer1:~/connectedhomeip$ sudo ip link set dev eth0 down
doru@computer1:~/connectedhomeip$ sudo ifconfig eth0 -multicast
user@computer1:~/connectedhomeip$ sudo ip link set dev eth0 down
user@computer1:~/connectedhomeip$ sudo ifconfig eth0 -multicast
```

- If OTBR Docker image is used, then the "-B" parameter should point to the
Expand Down
Loading

0 comments on commit 6ff45cf

Please sign in to comment.