Skip to content

Commit

Permalink
[K32W0] SDK 2.6.13 additional changes (#31382)
Browse files Browse the repository at this point in the history
* [K32W] Fix a corner case when switching the TLV processors

After the current block is processed, if the block size is 0, it means
that the processed data was a multiple of received BDX block size (e.g.
8 blocks of 1024 bytes were transferred). After state for selecting next
processor is reset, a request for fetching next data must be sent.

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

* [K32W] Make Validate public

Change access modifier of Validate to public, to be used by K32W0
for factory data validation after factory data OTA.

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

* [K32W0] Add CRC validation during factory data OTA

After factory data is copied into internal flash, call Validate to ensure
the CRC of factory data matches the CRC in the header. If the check fails,
then OTA is aborted and factory data is restored to previous version.

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

* [K32W0] Add additional check for provider pointer

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

* [K32W0] Change root node revision to 2

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

* [K32W] Expose SearchForId in factory data provider public API

Removed additional checks on tags with the assumption that factory data is
strictly checked at manufacturing time.
Applications can now use the public API to search the factory data section
for an id, e.g. in the case of custom factory data provider, where the app
has additional factory data information besides the default one.

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

* [K32W0] Refactor custom factory data provider

The example now leverages the actual factory data provider API to
search the factory data section for some custom ids.

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

* [K32W] Add platform support for Product Appearance

Implement GetProductFinish and GetProductPrimaryColor defined in DeviceInstanceInfoProvider.

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

* [K32W] Remove maxLengths array

This array was used to store the maximum length of factory data fields.
It's no longer used, with the assumption that the factory data is strictly
checked in manufacturing.

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

* [K32W0] Remove usage of maxLength array

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

* [K32W0] remove unused code in LowPowerHook.cpp file

* [K32W0] use Encoding::HexToBytes to parse the ota encryption key

* [K32W0] remove extra PWR_DisallowDeviceToSleep() which will cause unsleep after commissioning

* [K32W] Revert removal of disallow to sleep and enclose it in specific tag

Only call disallow to sleep when the platform is K32W1.

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

* [K32W0] Update reference app readme files

This is a minor improvement to the building instructions.
It aims to clarify the usage of west SDK or package SDK.

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

* [K32W0] Fix ICD parameters

Name of the ICD parameters were updated according with the latest stack updates.

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

* Restyled by clang-format

* Restyled by gn

* Restyled by prettier-markdown

* [K32W0] Fix gn check error

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

* Restyled by gn

* [K32W1] Fix gn check errors

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

* Restyled by gn

* [K32W1] Fix another gn error

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

* Restyled by gn

* [K32W] Send a report before resetting the device during OTA

State-transition event from Downloading to Applying was not successfully sent
to a subscriber during OTA because the device would reset before actually sending
the ReportData message.

Added an explicit call to handle server shutting down, which will sync send all events.

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

* Restyled by clang-format

* [K32W0] Remove deprecated dependency

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

* [K32W1] Remove deprecated dependency

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

* Restyled by gn

---------

Signed-off-by: marius-alex-tache <[email protected]>
Signed-off-by: Andrei Menzopol <[email protected]>
Co-authored-by: Damien Vagner <[email protected]>
Co-authored-by: tanyue518 <[email protected]>
Co-authored-by: Ethan Tan <[email protected]>
Co-authored-by: Andrei Menzopol <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
6 people authored and pull[bot] committed Feb 21, 2024
1 parent 7a25f34 commit 394ce65
Show file tree
Hide file tree
Showing 33 changed files with 234 additions and 313 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1631,7 +1631,7 @@ cluster OccupancySensing = 1030 {
}

endpoint 0 {
device type ma_rootdevice = 22, version 1;
device type ma_rootdevice = 22, version 2;

binding cluster OtaSoftwareUpdateProvider;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
}
],
"deviceVersions": [
1
2
],
"deviceIdentifiers": [
22
Expand Down Expand Up @@ -4748,4 +4748,4 @@
}
],
"log": []
}
}
5 changes: 1 addition & 4 deletions examples/contact-sensor-app/nxp/k32w/k32w0/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,7 @@ k32w0_executable("contact_sensor_app") {
"${k32w0_platform_dir}/common/CustomFactoryDataProvider.h",
]

defines = [
"CHIP_DEVICE_CONFIG_USE_CUSTOM_PROVIDER=1",
"CHIP_DEVICE_CONFIG_CUSTOM_PROVIDER_NUMBER_IDS=3",
]
defines = [ "CHIP_DEVICE_CONFIG_USE_CUSTOM_PROVIDER=1" ]
}

deps = [
Expand Down
56 changes: 29 additions & 27 deletions examples/contact-sensor-app/nxp/k32w/k32w0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,56 +177,58 @@ contact status.
In order to build the Project CHIP example, we recommend using a Linux
distribution (the demo-application was compiled on Ubuntu 20.04).

- Start building the application either with Secure Element or without, SDK is
downloaded with west tool.
Activate the Matter environment:

- without Secure Element
```bash
user@ubuntu:~/Desktop/git/connectedhomeip$ source ./scripts/activate.sh
```

```
user@ubuntu:~/Desktop/git/connectedhomeip$ source ./scripts/activate.sh
To bring the SDK in the environment, the user can:

- download it with west tool, in which case it will be handled automatically
by gn:

```bash
user@ubuntu:~/Desktop/git/connectedhomeip$ cd third_party/nxp/k32w0_sdk/repo
user@ubuntu:~/Desktop/git/connectedhomeip/third_party/nxp/k32w0_sdk/repo$ west init -l manifest --mf west.yml
user@ubuntu:~/Desktop/git/connectedhomeip/third_party/nxp/k32w0_sdk/repo$ west update
```

In case there are local modification to the already installed git NXP SDK:
Use the below west `forall` command instead of the west init command to
reset the west workspace. Warning: all local changes will be lost after
In case there are local modification to the already installed github NXP
SDK, use the below `west forall` command instead of the `west init` command
to reset the west workspace. Warning: all local changes will be lost after
running this command.

```bash
user@ubuntu:~/Desktop/git/connectedhomeip$ cd third_party/nxp/k32w0_sdk/repo
user@ubuntu:~/Desktop/git/connectedhomeip/third_party/nxp/k32w0_sdk/repo$west forall -c "git reset --hard && git clean -xdf" -a
user@ubuntu:~/Desktop/git/connectedhomeip/third_party/nxp/k32w0_sdk/repo$ west forall -c "git reset --hard && git clean -xdf" -a
```

Build the application
Prior to building, the user can specify a custom `SDK` path by setting
`NXP_K32W0_SDK_ROOT`:
- set up a custom path to the SDK, in which case
`k32w0_sdk_root=\"${NXP_K32W0_SDK_ROOT}\"` must be added to the `gn gen`
command:

```
user@ubuntu:~/Desktop/git/connectedhomeip$ export NXP_K32W0_SDK_ROOT=$(pwd)/third_party/nxp/k32w0_sdk/repo/core
user@ubuntu:~/Desktop/git/connectedhomeip$ export NXP_K32W0_SDK_ROOT=/custom/path/to/SDK
```

If the environment variable `NXP_K32W0_SDK_ROOT` is not set, it will default
to the `SDK` found in `third_party/nxp/k32w0_sdk/repo/core`.
Start building the application:

```
user@ubuntu:~/Desktop/git/connectedhomeip$ cd examples/contact-sensor-app/nxp/k32w/k32w0
user@ubuntu:~/Desktop/git/connectedhomeip/examples/contact-sensor-app/nxp/k32w/k32w0$ gn gen out/debug --args="chip_with_OM15082=1 chip_with_ot_cli=0 is_debug=false chip_crypto=\"platform\" chip_with_se05x=0 chip_pw_tokenizer_logging=true"
user@ubuntu:~/Desktop/git/connectedhomeip/examples/contact-sensor-app/nxp/k32w/k32w0$ ninja -C out/debug
```
```bash
user@ubuntu:~/Desktop/git/connectedhomeip$ cd examples/contact-sensor-app/nxp/k32w/k32w0
user@ubuntu:~/Desktop/git/connectedhomeip/examples/contact-sensor-app/nxp/k32w/k32w0$ gn gen out/debug --args="chip_with_OM15082=1 chip_with_ot_cli=0 is_debug=false chip_crypto=\"platform\" chip_with_se05x=0 chip_pw_tokenizer_logging=true"
user@ubuntu:~/Desktop/git/connectedhomeip/examples/contact-sensor-app/nxp/k32w/k32w0$ ninja -C out/debug
```

- with Secure element Exactly the same steps as above but set
chip_with_se05x=1 in the gn command and add argument
chip_enable_ota_requestor=false
To build with Secure Element, follow the same steps as above but set
`chip_with_se05x=1 chip_enable_ota_requestor=false` in the `gn gen` command.

Note that option chip_enable_ota_requestor=false are required for building with
Secure Element. These can be changed if building without Secure Element
Note that option `chip_enable_ota_requestor=false` is required for building with
Secure Element due to flash constraints.

- K32W041AM flavor

Exactly the same steps as above but set argument build_for_k32w041am=1 in
Exactly the same steps as above but set argument `build_for_k32w041am=1` in
the gn command.

Also, in case the OM15082 Expansion Board is not attached to the DK6 board, the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,6 @@
#define CHIP_DEVICE_CONFIG_USE_CUSTOM_PROVIDER 0
#endif

#if CHIP_DEVICE_CONFIG_USE_CUSTOM_PROVIDER
#ifndef CHIP_DEVICE_CONFIG_CUSTOM_PROVIDER_NUMBER_IDS
// Set to 3: default number of custom Ids from CustomFactoryDataProvider example
#define CHIP_DEVICE_CONFIG_CUSTOM_PROVIDER_NUMBER_IDS 3
#endif
#endif

// VID/PID for product => will be used by Basic Information Cluster
#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0x1037
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0xA220
Expand Down
8 changes: 7 additions & 1 deletion examples/contact-sensor-app/nxp/k32w/k32w0/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ using namespace chip::app;

AppTask AppTask::sAppTask;
#if CONFIG_CHIP_LOAD_REAL_FACTORY_DATA
static AppTask::FactoryDataProvider sFactoryDataProvider;
static chip::DeviceLayer::FactoryDataProviderImpl sFactoryDataProvider;
#if CHIP_DEVICE_CONFIG_USE_CUSTOM_PROVIDER
static chip::DeviceLayer::CustomFactoryDataProvider sCustomFactoryDataProvider;
#endif
#endif

static Identify gIdentify = { chip::EndpointId{ 1 }, AppTask::OnIdentifyStart, AppTask::OnIdentifyStop,
Expand Down Expand Up @@ -199,6 +202,9 @@ CHIP_ERROR AppTask::Init()
SetDeviceInstanceInfoProvider(&sFactoryDataProvider);
SetDeviceAttestationCredentialsProvider(&sFactoryDataProvider);
SetCommissionableDataProvider(&sFactoryDataProvider);
#if CHIP_DEVICE_CONFIG_USE_CUSTOM_PROVIDER
sCustomFactoryDataProvider.ParseFunctionExample();
#endif
#else
#ifdef ENABLE_HSM_DEVICE_ATTESTATION
SetDeviceAttestationCredentialsProvider(Examples::GetExampleSe05xDACProvider());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,6 @@

class AppTask
{
public:
#if CONFIG_CHIP_LOAD_REAL_FACTORY_DATA
#if CHIP_DEVICE_CONFIG_USE_CUSTOM_PROVIDER
using FactoryDataProvider = chip::DeviceLayer::CustomFactoryDataProvider;
#else
using FactoryDataProvider = chip::DeviceLayer::FactoryDataProviderImpl;
#endif
#endif

public:
CHIP_ERROR StartAppTask();
static void AppTaskMain(void * pvParameter);
Expand Down
5 changes: 1 addition & 4 deletions examples/lighting-app/nxp/k32w/k32w0/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,7 @@ k32w0_executable("light_app") {
"${k32w0_platform_dir}/common/CustomFactoryDataProvider.h",
]

defines = [
"CHIP_DEVICE_CONFIG_USE_CUSTOM_PROVIDER=1",
"CHIP_DEVICE_CONFIG_CUSTOM_PROVIDER_NUMBER_IDS=3",
]
defines = [ "CHIP_DEVICE_CONFIG_USE_CUSTOM_PROVIDER=1" ]
}

deps = [
Expand Down
66 changes: 33 additions & 33 deletions examples/lighting-app/nxp/k32w/k32w0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,58 +192,58 @@ effects:
In order to build the Project CHIP example, we recommend using a Linux
distribution (the demo-application was compiled on Ubuntu 20.04).

- Start building the application either with Secure Element or without, SDK is
downloaded with west tool.
- without Secure Element
Activate the Matter environment:

```
```bash
user@ubuntu:~/Desktop/git/connectedhomeip$ source ./scripts/activate.sh
user@ubuntu:~/Desktop/git/connectedhomeip$ cd third_party/nxp/k32w0_sdk/repo
user@ubuntu:~/Desktop/git/connectedhomeip/third_party/nxp/k32w0_sdk/repo$ west init -l manifest --mf west.yml
user@ubuntu:~/Desktop/git/connectedhomeip/third_party/nxp/k32w0_sdk/repo$ west update
```

In case there are local modification to the already installed git NXP SDK: Use
the below west `forall` command instead of the west init command to reset the
west workspace. Warning: all local changes will be lost after running this
command.
To bring the SDK in the environment, the user can:

```bash
user@ubuntu:~/Desktop/git/connectedhomeip$ cd third_party/nxp/k32w0_sdk/repo
user@ubuntu:~/Desktop/git/connectedhomeip/third_party/nxp/k32w0_sdk/repo$west forall -c "git reset --hard && git clean -xdf" -a
```
- download it with west tool, in which case it will be handled automatically
by gn:

Build the application
```bash
user@ubuntu:~/Desktop/git/connectedhomeip$ cd third_party/nxp/k32w0_sdk/repo
user@ubuntu:~/Desktop/git/connectedhomeip/third_party/nxp/k32w0_sdk/repo$ west init -l manifest --mf west.yml
user@ubuntu:~/Desktop/git/connectedhomeip/third_party/nxp/k32w0_sdk/repo$ west update
```

Prior to building, the user can specify a custom `SDK` path by setting
`NXP_K32W0_SDK_ROOT`:
In case there are local modification to the already installed github NXP
SDK, use the below `west forall` command instead of the `west init` command
to reset the west workspace. Warning: all local changes will be lost after
running this command.

```
user@ubuntu:~/Desktop/git/connectedhomeip$ export NXP_K32W0_SDK_ROOT=$(pwd)/third_party/nxp/k32w0_sdk/repo/core
```
```bash
user@ubuntu:~/Desktop/git/connectedhomeip$ cd third_party/nxp/k32w0_sdk/repo
user@ubuntu:~/Desktop/git/connectedhomeip/third_party/nxp/k32w0_sdk/repo$ west forall -c "git reset --hard && git clean -xdf" -a
```

- set up a custom path to the SDK, in which case
`k32w0_sdk_root=\"${NXP_K32W0_SDK_ROOT}\"` must be added to the `gn gen`
command:

If the environment variable `NXP_K32W0_SDK_ROOT` is not set, it will default to
the `SDK` found in `third_party/nxp/k32w0_sdk/repo/core`.
```
user@ubuntu:~/Desktop/git/connectedhomeip$ export NXP_K32W0_SDK_ROOT=/custom/path/to/SDK
```

```
Start building the application:

```bash
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="chip_with_OM15082=1 chip_with_ot_cli=0 is_debug=false chip_crypto=\"platform\" chip_with_se05x=0 chip_pw_tokenizer_logging=true"
user@ubuntu:~/Desktop/git/connectedhomeip/examples/lighting-app/nxp/k32w/k32w0$ ninja -C out/debug
```

- with Secure element

```
Exactly the same steps as above but set chip_with_se05x=1 in the gn command
and add argument chip_enable_ota_requestor=false
```
To build with Secure Element, follow the same steps as above but set
`chip_with_se05x=1 chip_enable_ota_requestor=false` in the `gn gen` command.

Note that option chip_enable_ota_requestor=false are required for building with
Secure Element. These can be changed if building without Secure Element
Note that option `chip_enable_ota_requestor=false` is required for building with
Secure Element due to flash constraints.

- K32W041AM flavor

Exactly the same steps as above but set argument build_for_k32w041am=1 in
Exactly the same steps as above but set argument `build_for_k32w041am=1` in
the gn command.

Also, in case the OM15082 Expansion Board is not attached to the DK6 board, the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,6 @@
#define CHIP_DEVICE_CONFIG_USE_CUSTOM_PROVIDER 0
#endif

#if CHIP_DEVICE_CONFIG_USE_CUSTOM_PROVIDER
#ifndef CHIP_DEVICE_CONFIG_CUSTOM_PROVIDER_NUMBER_IDS
// Set to 3: default number of custom Ids from CustomFactoryDataProvider example
#define CHIP_DEVICE_CONFIG_CUSTOM_PROVIDER_NUMBER_IDS 3
#endif
#endif

// VID/PID for product => will be used by Basic Information Cluster
#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0x1037
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0xA220
Expand Down
8 changes: 7 additions & 1 deletion examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ using namespace chip::app;

AppTask AppTask::sAppTask;
#if CONFIG_CHIP_LOAD_REAL_FACTORY_DATA
static AppTask::FactoryDataProvider sFactoryDataProvider;
static chip::DeviceLayer::FactoryDataProviderImpl sFactoryDataProvider;
#if CHIP_DEVICE_CONFIG_USE_CUSTOM_PROVIDER
static chip::DeviceLayer::CustomFactoryDataProvider sCustomFactoryDataProvider;
#endif
#endif

// This key is for testing/certification only and should not be used in production devices.
Expand Down Expand Up @@ -190,6 +193,9 @@ CHIP_ERROR AppTask::Init()
SetDeviceInstanceInfoProvider(&sFactoryDataProvider);
SetDeviceAttestationCredentialsProvider(&sFactoryDataProvider);
SetCommissionableDataProvider(&sFactoryDataProvider);
#if CHIP_DEVICE_CONFIG_USE_CUSTOM_PROVIDER
sCustomFactoryDataProvider.ParseFunctionExample();
#endif
#else
#ifdef ENABLE_HSM_DEVICE_ATTESTATION
SetDeviceAttestationCredentialsProvider(Examples::GetExampleSe05xDACProvider());
Expand Down
9 changes: 0 additions & 9 deletions examples/lighting-app/nxp/k32w/k32w0/main/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,6 @@

class AppTask
{
public:
#if CONFIG_CHIP_LOAD_REAL_FACTORY_DATA
#if CHIP_DEVICE_CONFIG_USE_CUSTOM_PROVIDER
using FactoryDataProvider = chip::DeviceLayer::CustomFactoryDataProvider;
#else
using FactoryDataProvider = chip::DeviceLayer::FactoryDataProviderImpl;
#endif
#endif

public:
CHIP_ERROR StartAppTask();
static void AppTaskMain(void * pvParameter);
Expand Down
2 changes: 2 additions & 0 deletions examples/lighting-app/nxp/k32w/k32w1/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ k32w1_executable("light_app") {
"main/main.cpp",
]

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

deps = [
":sdk",
"${chip_root}/examples/common/QRCode",
Expand Down
5 changes: 1 addition & 4 deletions examples/lock-app/nxp/k32w/k32w0/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@ k32w0_executable("lock_app") {
"${k32w0_platform_dir}/common/CustomFactoryDataProvider.h",
]

defines = [
"CHIP_DEVICE_CONFIG_USE_CUSTOM_PROVIDER=1",
"CHIP_DEVICE_CONFIG_CUSTOM_PROVIDER_NUMBER_IDS=3",
]
defines = [ "CHIP_DEVICE_CONFIG_USE_CUSTOM_PROVIDER=1" ]
}

deps = [
Expand Down
Loading

0 comments on commit 394ce65

Please sign in to comment.