Skip to content

Commit

Permalink
[NXP] Integrating code updates for RW61X and K32W platforms (#32615)
Browse files Browse the repository at this point in the history
* [NXP][platform][common] Adding platform common code

* [NXP][platform][k32w] Adding platform code changes for k32w

* [NXP][platform][rw61x] Adding platform code changes for rw61x

* [NXP][tools][common] Adding nxp tools updates

* [NXP][examples][common] Adding examples common updates

* [NXP][examples][rw61x] Adding examples updates

* [NXP][examples][k32w] Adding examples updates

* [NXP][doc][common] Adding documentation updates

* [NXP][scripts][common] Add checkout_submodules NXP target

All submodules that don't have a platforms field will be selected
when the script is run. Additionally, if --platform nxp is used,
submodules that have nxp under their platform field will also be
checked out.

Signed-off-by: marius-alex-tache <[email protected]>

* [NXP][CI][rw61x] Enabling CI workflow for RW61x examples (all-clusters-app, thermostat, laundry-washer)

* [NXP][examples][common] Fix laundry-washer app by removing af-enums.h include in the operational-state-delegate-impl.h

* [NXP][platform][k32w1] Fix clang formatting

Signed-off-by: marius-alex-tache <[email protected]>

* [NXP][doc][rw61x] Adding information to run bootstrap script + submodule update script

+ Updating gn information to build Matter target that will support BR

Signed-off-by: Gatien Chapon <[email protected]>

* [NXP][platform] Fix string keys saving failure

The "NXPConfig" class member function which is supposed to save the
string keys to persistent storage was, in fact, invoking the
"NvSaveOnIdle" function using the INTEGER keys RAM buffer descriptor,
instead of using the STRING keys RAM buffer descriptor. Most likely
a typical copy-paste error.

Signed-off-by: Marian Chereji <[email protected]>

* [NXP][platform][k32w] Small fixes for k32w platform code

 * correct typos
 * remove executable access permissions
 * remove unused files
 * change openthread_root to ot-nxp/openthread-k32w1

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

* [NXP][examples][k32w] Fixes for k32w examples code

 * small changes for existing code

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

* [NXP][sdk][common] Remove chip_enable_icd_lit

 * argument has been moved to src/app/icd/icd.gni

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

* [NXP][examples][common] Fix missing QR code log

* [NXP][platform][k32w1] Fix gn issue

Signed-off-by: marius-alex-tache <[email protected]>

* [NXP][examples][k32w0] Update default args.gni for reference apps

Signed-off-by: marius-alex-tache <[email protected]>

* [NXP][examples][k32w1] Update default args.gni for reference apps

Signed-off-by: marius-alex-tache <[email protected]>

* [NXP][platform][k32w0] Move subscription and groups KVS keys to dedicated storages

To avoid a large KVS RAM buffer and memory allocation issues when running TC-RR-1.1,
move some specific keys in dedicated RAM storage instaces:
* subscription keys will be stored in sSubscriptionStorage.
* groups keys will be stored in sGroupsStorage. This RAM storage will use the extended
search feature, because its size will be greater than current backend region size (2K).

The key/value storage will be selected in each API based on some
criteria: if the key is related to either subscription/groups, then
both the key and the value will be stored in the same storage. Otherwise,
the default keys and values storages are used.

Signed-off-by: marius-alex-tache <[email protected]>

* [NXP][platform][k32w0] Add conversion for subscription and groups keys

When CONFIG_CHIP_K32W0_KVS_MOVE_KEYS_TO_SPECIFIC_STORAGE is set to 1,
the application can opt to move some keys from current KVS storage
to a dedicated storage, based on the key name.

Currently, the mechanism supports moving keys and values for:
* subscriptions
* groups

Note: the system is meant to ensure backwards compatibility. This should only
be used once, but, if this feature is still enabled after the first conversion,
the corresponding keys will not be found in KVS default storage. This does
not affect the functionality, but it introduces a delay in the initialization.

Signed-off-by: marius-alex-tache <[email protected]>

* [NXP][examples][common] Updating laundry washer zap file to be consistent with current PICS

* [NXP][examples][common] Updating thermostat zap files to be consistent with current PICS

* [NXP][platform][rw61x] Add define for encrypted factory data

CONFIG_CHIP_ENCRYPTED_FACTORY_DATA is defined by default when factory data
is enabled. The common code should leverage this flag to make some actions
when implicit encrypted factory data is enabled.

Signed-off-by: marius-alex-tache <[email protected]>

* [NXP][examples][common][factory-data] Enclose encryption code

Encrypted factory data related code should be enclosed based on the
CONFIG_CHIP_ENCRYPTED_FACTORY_DATA flag.

Signed-off-by: marius-alex-tache <[email protected]>

* [NXP][examples][common] Add a way to include a specific OTAImageProcessor header

CONFIG_CHIP_OTA_IMAGE_PROCESSOR_HEADER should specify an OTA image processor implementation
header. It can be a custom one, such as the header for OTA multi-image implementation.
This will ease the transition of current reference apps that are not using the processor
from the NXP common area.

Signed-off-by: marius-alex-tache <[email protected]>

* [NXP][examples][common] Enclose binding usage based on EMBER_AF_PLUGIN_BINDING

EMBER_AF_PLUGIN_BINDING is defined when the server side of the Binding cluster is used.
The common app task code should initialize Binding handlers only if this flag is defined.

Signed-off-by: marius-alex-tache <[email protected]>

* [NXP][examples][k32w][contact-sensor][zap] Enable Diagnostic Logs Cluster

Signed-off-by: Doru Gucea <[email protected]>

* [NXP][platform][common] Add Diagnostic Logs common

Signed-off-by: Doru Gucea <[email protected]>

* [NXP][platform][common] create nxp_diagnostic_logs

Signed-off-by: Doru Gucea <[email protected]>

* [NXP][examples][k32w1] enable Diagnostic Logs for contact-sensor app

Signed-off-by: Doru Gucea <[email protected]>

* [NXP][example][common] Fixing PLATFORM_InitTimerManager return value check issue

Signed-off-by: Gatien Chapon <[email protected]>

* [NXP][examples][common] Fix contact-sensor zap files

Signed-off-by: Doru Gucea <[email protected]>

* [NXP][examples][common] Fix laundry-washer-app build : remove zap_generated_dir from BUILD.gn as it does not exist anymore

* [NXP][doc] Adding support for the laundry-washer example inside docs/examples/index.md

* [NXP][doc][rw61x] Update readme to support SDK 2.13.3

* [NXP][examples][k32w][mw320] Remove not upstreamed and not supported apps

 * drop light-switch-combo-app as it isn't upstreamed yet
 * remove lock-app as it is not supported anymore
   (at least for the moment)
 * remove shell-app as it is not supported anymore
   (at least for the moment)

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

* [NXP][scripts] Remove unsused binaries

Signed-off-by: marius-alex-tache <[email protected]>

* [NXP][platform][k32w] Remove duplicated code introduced in a merge conflict

Signed-off-by: marius-alex-tache <[email protected]>

* [NXP][common] Update OT-NXP repo commit

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

* [NXP][CI][rw61x] Updating docker image version for SDK support

* [NXP][CI][k32w] Update workflows and docker image version for SDK support

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

* [NXP][examples][k32w] Fix spelling

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

* [NXP][rw61x] Fix doc, spelling and zap errors

* [NXP][rw61x] Fix doc spelling errors

* [NXP][k32w0] Fix SDK path

Signed-off-by: marius-alex-tache <[email protected]>

* Restyled by whitespace

* Restyled by clang-format

* Restyled by gn

* Restyled by prettier-markdown

* Restyled by autopep8

* Restyled by isort

* [NXP][doc][k32w] Fix docs issues

Signed-off-by: marius-alex-tache <[email protected]>

* [NXP][scripts][common] Fix lint errors

Signed-off-by: marius-alex-tache <[email protected]>

* [NXP][CI][k32w] Remove deprecated examples

Signed-off-by: marius-alex-tache <[email protected]>

* [NXP][docs] Remove lock app from commissioning guide

Signed-off-by: marius-alex-tache <[email protected]>

* [NXP][platform][common] Remove unused header

Signed-off-by: marius-alex-tache <[email protected]>

* [NXP][platform][k32w1] Remove custom openthread_root

Signed-off-by: marius-alex-tache <[email protected]>

* [NXP][platform][rw61x] Fix lint code error

* [NXP][k32w0] Fix gn import order

Signed-off-by: marius-alex-tache <[email protected]>

* [NXP][sdk][k32w0] Fix SDK path condition

When official repo CI is used, the docker image sets the west github SDK
to /opt/sdk/core. This caused gn SDK files to mistakenly treat the SDK
as a package SDK, which affected the paths.

Signed-off-by: marius-alex-tache <[email protected]>

* [NXP][scripts][k32w] Take into account low power flags for k32w0

Pigweed tokenizer logging and expansion board gn args are enabled by default
in the reference apps args.gni. Disable them explicitly for low power case.

Signed-off-by: marius-alex-tache <[email protected]>

* [NXP][examples][k32w1] Move diagnostic_logs to a common examples area

This type of app specific implementation should reside in the application
space, instead of the device layer.

Signed-off-by: marius-alex-tache <[email protected]>

---------

Signed-off-by: marius-alex-tache <[email protected]>
Signed-off-by: Gatien Chapon <[email protected]>
Signed-off-by: Marian Chereji <[email protected]>
Signed-off-by: Andrei Menzopol <[email protected]>
Signed-off-by: Doru Gucea <[email protected]>
Co-authored-by: marius-alex-tache <[email protected]>
Co-authored-by: Gatien Chapon <[email protected]>
Co-authored-by: Marian Chereji <[email protected]>
Co-authored-by: Andrei Menzopol <[email protected]>
Co-authored-by: Martin Girardot <[email protected]>
Co-authored-by: Doru Gucea <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
8 people authored Mar 20, 2024
1 parent 16ab164 commit 907883f
Show file tree
Hide file tree
Showing 237 changed files with 19,298 additions and 4,703 deletions.
13 changes: 2 additions & 11 deletions .github/workflows/examples-k32w.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
if: github.actor != 'restyled-io[bot]'

container:
image: ghcr.io/project-chip/chip-build-k32w:33
image: ghcr.io/project-chip/chip-build-k32w:38
volumes:
- "/tmp/bloat_reports:/tmp/bloat_reports"
steps:
Expand All @@ -46,7 +46,7 @@ jobs:
- name: Checkout submodules & Bootstrap
uses: ./.github/actions/checkout-submodules-and-bootstrap
with:
platform: k32w
platform: nxp

- name: Set up environment for size reports
uses: ./.github/actions/setup-size-reports
Expand All @@ -59,11 +59,8 @@ jobs:
scripts/run_in_build_env.sh "\
./scripts/build/build_examples.py \
--target k32w-k32w0-light-crypto-platform-tokenizer \
--target k32w-k32w0-lock-crypto-platform-tokenizer \
--target k32w-k32w0-lock-crypto-platform-low-power-nologs \
--target k32w-k32w0-contact-crypto-platform-tokenizer \
--target k32w-k32w0-contact-crypto-platform-low-power-nologs \
--target k32w-k32w0-shell-crypto-platform \
--target k32w-k32w1-light-crypto-platform-openthread-ftd \
--target k32w-k32w1-contact-crypto-platform-low-power-nologs \
build \
Expand All @@ -79,12 +76,6 @@ jobs:
k32w k32w1+release light \
out/artifacts/k32w-k32w1-light-crypto-platform-openthread-ftd/chip-k32w1-light-example.elf \
/tmp/bloat_reports/
- name: Get lock size stats
run: |
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
k32w k32w0+release lock \
out/artifacts/k32w-k32w0-lock-crypto-platform-tokenizer/chip-k32w0x-lock-example.elf \
/tmp/bloat_reports/
- name: Get contact size stats
run: |
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
Expand Down
87 changes: 87 additions & 0 deletions .github/workflows/examples-rw61x.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Copyright (c) 2023 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Build example - RW61X

on:
push:
pull_request:
merge_group:

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.number) || (github.event_name == 'workflow_dispatch' && github.run_number) || github.sha }}
cancel-in-progress: true

env:
CHIP_NO_LOG_TIMESTAMPS: true

jobs:
rw61x:
name: RW61X

env:
BUILD_TYPE: gn_rw61x

runs-on: ubuntu-latest
if: github.actor != 'restyled-io[bot]'

container:
image: ghcr.io/project-chip/chip-build-rw61x:37
volumes:
- "/tmp/bloat_reports:/tmp/bloat_reports"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout submodules & Bootstrap
uses: ./.github/actions/checkout-submodules-and-bootstrap
with:
platform: rw61x

- name: Set up environment for size reports
uses: ./.github/actions/setup-size-reports
if: ${{ !env.ACT }}
with:
gh-context: ${{ toJson(github) }}

- name: Build RW61X all clusters example app
run: |
scripts/run_in_build_env.sh "\
./scripts/build/build_examples.py \
--target rw61x-all-clusters-app-wifi \
build \
--copy-artifacts-to out/artifacts \
"
- name: Build RW61X thermostat example app
run: |
scripts/run_in_build_env.sh "\
./scripts/build/build_examples.py \
--target rw61x-thermostat-wifi \
build \
--copy-artifacts-to out/artifacts \
"
- name: Build RW61X laundry-washer example app
run: |
scripts/run_in_build_env.sh "\
./scripts/build/build_examples.py \
--target rw61x-laundry-washer-wifi \
build \
--copy-artifacts-to out/artifacts \
"
- name: Uploading Size Reports
uses: ./.github/actions/upload-size-reports
if: ${{ !env.ACT }}
with:
platform-name: RW61X
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@
path = third_party/freertos/repo
url = https://github.com/FreeRTOS/FreeRTOS-Kernel.git
branch = V10.3.1-kernel-only
platforms = ameba,cc13xx_26xx,bouffalolab,esp32,k32w,infineon,qpg,cc32xx
platforms = ameba,cc13xx_26xx,bouffalolab,esp32,infineon,qpg,cc32xx
[submodule "simw-top-mini"]
path = third_party/simw-top-mini/repo
url = https://github.com/NXP/plug-and-trust.git
branch = int/CHIPSE_Release
platforms = k32w
platforms = nxp
[submodule "third_party/openthread/ot-nxp"]
path = third_party/openthread/ot-nxp
url = https://github.com/NXP/ot-nxp.git
platforms = k32w
platforms = nxp
[submodule "third_party/openthread/ot-qorvo"]
path = third_party/openthread/ot-qorvo
url = https://github.com/openthread/ot-qorvo.git
Expand Down
9 changes: 9 additions & 0 deletions docs/examples/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ kotlin-matter-controller/README
virtual-device-app/**/README
```

## Laundry washer example

```{toctree}
:glob:
:maxdepth: 1
laundry-washer-app/**/README
```

## Lighting example

```{toctree}
Expand Down
23 changes: 9 additions & 14 deletions docs/guides/nxp_k32w_android_commissioning.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This article describes how to use
[CHIPTool](../../examples/android/CHIPTool/README.md) for Android smartphones to
commission an NXP K32W061 DK6 running
[NXP K32W Lock/Light Example Application](#building-and-programming-nxp-k32w-locklight-example-application)
[NXP K32W Light Example Application](#building-and-programming-nxp-k32w-light-example-application)
onto a CHIP-enabled Thread network.

<hr>
Expand All @@ -12,7 +12,7 @@ onto a CHIP-enabled Thread network.
- [Requirements](#requirements)
- [Building and programming OpenThread RCP firmware](#building-and-programming-openthread-rcp-firmware)
- [Configuring PC as Thread Border Router](#configuring-pc-as-a-thread-border-router)
- [Building and programming NXP K32W Lock/Light Example Application](#building-and-programming-nxp-k32w-locklight-example-application)
- [Building and programming NXP K32W Light Example Application](#building-and-programming-nxp-k32w-light-example-application)
- [Building and installing Android CHIPTool](#building-and-installing-android-chiptool)
- [Forming a Thread network on the Border Router](#forming-a-thread-network-on-the-border-router)
- [Preparing accessory device](#preparing-accessory-device)
Expand Down Expand Up @@ -44,7 +44,7 @@ with a spare Wi-Fi card and an
device.

The following diagram shows the connectivity between network components required
to allow communication between devices running the CHIPTool and Lock/Light
to allow communication between devices running the CHIPTool and Light
applications:

![nxp_hw_connectivity](../../examples/platform/nxp/k32w/k32w0/doc/images/nxp_hw_connectivity.JPG)
Expand Down Expand Up @@ -345,11 +345,7 @@ To make your PC work as a Thread Border Router, complete the following tasks:
<hr>
## Building and programming NXP K32W Lock/Light Example Application
See
[NXP K32W Lock Example Application README](../../examples/lock-app/nxp/k32w/k32w0/README.md)
to learn how to build and program the lock example onto an K32W061 DK6.
## Building and programming NXP K32W Light Example Application
See
[NXP K32W Light Example Application README](../../examples/lighting-app/nxp/k32w/k32w0/README.md)
Expand Down Expand Up @@ -491,11 +487,10 @@ section, complete the following steps:
2. Verify that the text box on the screen is not empty and contains the IPv6
address of the accessory device.
3. Tap the following buttons to change the lock/light state:
3. Tap the following buttons to change the light state:
- _ON_ and _OFF_ buttons lock/turn on and unlock/turn off the door/light
bulb, respectively.
- _TOGGLE_ changes the lock/light state to the opposite.
- _ON_ and _OFF_ buttons turn on and turn off the light bulb, respectively.
- _TOGGLE_ changes the light state to the opposite.
The _LED D3_ on the device turns on or off based on the changes of the
lock/light state.
The _LED D3_ on the device turns on or off based on the changes of the light
state.
86 changes: 60 additions & 26 deletions docs/guides/nxp_manufacturing_flow.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
---
orphan: true
---

# NXP manufacturing data guide
# NXP Manufacturing data

By default, the example application is configured to use generic test
certificates and provisioning data embedded with the application code. It is
Expand Down Expand Up @@ -112,30 +108,30 @@ Here is the interpretation of the **required** parameters:
--pai_cert -> path to the PAI (der format) location
--spake2p_path -> path to the spake2p tool
--out -> name of the binary that will be used for storing all the generated data


```

Here is the interpretation of the **optional** parameters:

```shell
--dac_key_password -> Password to decode DAC key
--dac_key_use_sss_blob -> Used when --dac_key contains a path to an encrypted blob, instead of the
actual DAC private key. The blob metadata size is 24, so the total length
of the resulting value is private key length (32) + 24 = 56. False by default.
--spake2p_verifier -> SPAKE2+ verifier (passed as base64 encoded string). If this option is set,
all SPAKE2+ inputs will be encoded in the final binary. The spake2p tool
will not be used to generate a new verifier on the fly.
--aes128_key -> 128 bits AES key used to encrypt the whole dataset. Please make sure
that the target application/board supports this feature: it has access to
the private key and implements a mechanism which can be used to decrypt
the factory data information.
--date -> Manufacturing Date (YYYY-MM-DD format)
--part_number -> Part number as string
--product_url -> Product URL as string
--product_label -> Product label as string
--serial_num -> Serial Number
--unique_id -> Unique id used for rotating device id generation
--dac_key_password -> Password to decode DAC key
--dac_key_use_sss_blob -> Used when --dac_key contains a path to an encrypted blob, instead of the
actual DAC private key. The blob metadata size is 24, so the total length
of the resulting value is private key length (32) + 24 = 56. False by default.
--spake2p_verifier -> SPAKE2+ verifier (passed as base64 encoded string). If this option is set,
all SPAKE2+ inputs will be encoded in the final binary. The spake2p tool
will not be used to generate a new verifier on the fly.
--aes128_key -> 128 bits AES key used to encrypt the whole dataset. Please make sure
that the target application/board supports this feature: it has access to
the private key and implements a mechanism which can be used to decrypt
the factory data information.
--date -> Manufacturing Date (YYYY-MM-DD format)
--part_number -> Part number as string
--product_url -> Product URL as string
--product_label -> Product label as string
--serial_num -> Serial Number
--unique_id -> Unique id used for rotating device id generation
--product_finish -> Visible finish of the product
--product_primary_color -> Representative color of the visible parts of the product
```

## 3. Write provisioning data
Expand All @@ -157,8 +153,18 @@ loadfile factory_data.bin 0xf4000
where `0xf4000` is the value of `__MATTER_FACTORY_DATA_START` in the
corresponding .map file (can be different if using a custom linker script).

For the **RT1060**, **RT1170** and **RW61X** platform, the binary needs to be
written using `MCUXpresso Flash Tool GUI` at the address value corresponding to
For **RW61X** platform, the binary needs to be written in the internal flash at
location given by `__MATTER_FACTORY_DATA_START`, using `JLink`:

```
loadfile factory_data.bin 0xBFFF000
```

where `0xBFFF000` is the value of `__FACTORY_DATA_START` in the corresponding
.map file (can be different if using a custom linker script).

For the **RT1060** and **RT1170** platform, the binary needs to be written using
`MCUXpresso Flash Tool GUI` at the address value corresponding to
`__FACTORY_DATA_START` (the map file of the application should be checked to get
the exact value).

Expand Down Expand Up @@ -198,6 +204,8 @@ Also, demo **DAC**, **PAI** and **PAA** certificates needed in case

## 6. Increased security for DAC private key

### 6.1 K32W1

Supported platforms:

- K32W1 - `src/plaftorm/nxp/k32w/k32w1/FactoryDataProviderImpl.h`
Expand Down Expand Up @@ -242,3 +250,29 @@ python3 ./scripts/tools/nxp/factory_data_generator/generate.py -i 10000 -s UXKLz

Please note that `--dac_key` now points to a binary file that contains the
encrypted blob.

### 6.2 RW61X

Supported platforms:

- RW61X - `src/plaftorm/nxp/rt/rw61x/FactoryDataProviderImpl.h`

For platforms that have a secure subsystem (`SE50`), the DAC private key can be
converted to an encrypted blob. This blob will overwrite the DAC private key in
factory data and will be imported in the `SE50` before to sign, by the factory
data provider instance.

The conversion process shall happen at manufacturing time and should be run one
time only:

- Write factory data binary.
- Build the application with
`chip_with_factory_data=1 chip_convert_dac_private_key=1` set.
- Write the application to the board and let it run.

After the conversion process:

- Make sure the application is built with `chip_with_factory_data=1`, but
without `chip_convert_dac_private_key` arg, since conversion already
happened.
- Write the application to the board.
Loading

0 comments on commit 907883f

Please sign in to comment.