[Infineon] Update CYW30739 to support CYW30739B2-P5-EVK-XX boards. (#33065)
* Remove the Infineon CYW30739 ota-requestor-app.
* [Infineon] Update CYW30739 to support CYW30739B2-P5-EVK-XX boards.
* Replace CYW30739 submodules with the matter-wpan-sdk submodule.
* Update README files for CYW30739 apps.
* Add CYW30739B2-P5-EVK-01, CYW30739B2-P5-EVK-02, and CYW30739B2-P5-EVK-03 boards for CYW30739.
* Add development DAC files for CYW30739.
* Add cyw30739_example, cyw30739_platform, and ifx_openthread template for board dependant targets.
* Update GN files for CYW30739 apps.
* Update CYW30739 builder scripts.
configuration in the .gitmodules file.
* Update the CYW30739 flashing script.
* Update the workflow to build all CYW30739-supported targets.
* Move shared codes to the matter_config.cpp file.
* Implemented FactoryDataProvider for CYW30739 to load factory data.
* Fix the job names in the examples-infineon.yaml.
* Update build scripts for CYW30739 to build one board at a time.
diff --git a/.github/workflows/examples-infineon.yaml b/.github/workflows/examples-infineon.yaml
index 3de5c1d..071905d 100644
--- a/.github/workflows/examples-infineon.yaml
+++ b/.github/workflows/examples-infineon.yaml
@@ -107,41 +107,89 @@
out/artifacts/infineon-psoc6-light/chip-psoc6-lighting-example.out \
/tmp/bloat_reports/
- - name: Build example CYW30739 Apps
+ - name: Build CYW30739 Lighting App
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
- --target cyw30739-cyw930739m2evb_01-light \
- --target cyw30739-cyw930739m2evb_01-lock \
- --target cyw30739-cyw930739m2evb_01-ota-requestor \
- --target cyw30739-cyw930739m2evb_01-switch \
+ --target cyw30739-cyw30739b2_p5_evk_01-light \
+ --target cyw30739-cyw30739b2_p5_evk_02-light \
+ --target cyw30739-cyw30739b2_p5_evk_03-light \
+ --target cyw30739-cyw930739m2evb_02-light \
build \
--copy-artifacts-to out/artifacts \
"
- name: Get light size stats
run: |
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
- cyw30739 cyw930739m2evb_01 light \
- out/artifacts/cyw30739-cyw930739m2evb_01-light/chip-cyw30739-lighting-example.elf \
+ cyw30739 CYW30739B2-P5-EVK-01 light \
+ out/artifacts/cyw30739-cyw30739b2_p5_evk_01-light/lighting_app-CYW30739B2-P5-EVK-01.elf \
/tmp/bloat_reports/
+ .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
+ cyw30739 CYW30739B2-P5-EVK-02 light \
+ out/artifacts/cyw30739-cyw30739b2_p5_evk_02-light/lighting_app-CYW30739B2-P5-EVK-02.elf \
+ /tmp/bloat_reports/
+ .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
+ cyw30739 CYW30739B2-P5-EVK-03 light \
+ out/artifacts/cyw30739-cyw30739b2_p5_evk_03-light/lighting_app-CYW30739B2-P5-EVK-03.elf \
+ /tmp/bloat_reports/
+ .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
+ cyw30739 CYW930739M2EVB-02 light \
+ out/artifacts/cyw30739-cyw930739m2evb_02-light/lighting_app-CYW930739M2EVB-02.elf \
+ /tmp/bloat_reports/
+ - name: Clean out build output
+ run: rm -rf ./out
+ - name: Build CYW30739 Light Switch App
+ run: |
+ ./scripts/run_in_build_env.sh \
+ "./scripts/build/build_examples.py \
+ --target cyw30739-cyw30739b2_p5_evk_01-light-switch \
+ --target cyw30739-cyw30739b2_p5_evk_02-light-switch \
+ --target cyw30739-cyw30739b2_p5_evk_03-light-switch \
+ build \
+ --copy-artifacts-to out/artifacts \
+ "
+ - name: Get light-switch size stats
+ run: |
+ .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
+ cyw30739 CYW30739B2-P5-EVK-01 light-switch \
+ out/artifacts/cyw30739-cyw30739b2_p5_evk_01-light-switch/light_switch_app-CYW30739B2-P5-EVK-01.elf \
+ /tmp/bloat_reports/
+ .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
+ cyw30739 CYW30739B2-P5-EVK-02 light-switch \
+ out/artifacts/cyw30739-cyw30739b2_p5_evk_02-light-switch/light_switch_app-CYW30739B2-P5-EVK-02.elf \
+ /tmp/bloat_reports/
+ .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
+ cyw30739 CYW30739B2-P5-EVK-03 light-switch \
+ out/artifacts/cyw30739-cyw30739b2_p5_evk_03-light-switch/light_switch_app-CYW30739B2-P5-EVK-03.elf \
+ /tmp/bloat_reports/
+ - name: Clean out build output
+ run: rm -rf ./out
+ - name: Build CYW30739 Lock App
+ run: |
+ ./scripts/run_in_build_env.sh \
+ "./scripts/build/build_examples.py \
+ --target cyw30739-cyw30739b2_p5_evk_01-lock \
+ --target cyw30739-cyw30739b2_p5_evk_02-lock \
+ --target cyw30739-cyw30739b2_p5_evk_03-lock \
+ build \
+ --copy-artifacts-to out/artifacts \
+ "
- name: Get lock size stats
run: |
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
- cyw30739 cyw930739m2evb_01 lock \
- out/artifacts/cyw30739-cyw930739m2evb_01-lock/chip-cyw30739-lock-example.elf \
+ cyw30739 CYW30739B2-P5-EVK-01 lock \
+ out/artifacts/cyw30739-cyw30739b2_p5_evk_01-lock/lock_app-CYW30739B2-P5-EVK-01.elf \
/tmp/bloat_reports/
- - name: Get ota-requestor size stats
- run: |
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
- cyw30739 cyw930739m2evb_01 ota-requestor \
- out/artifacts/cyw30739-cyw930739m2evb_01-ota-requestor/chip-cyw30739-ota-requestor-example.elf \
+ cyw30739 CYW30739B2-P5-EVK-02 lock \
+ out/artifacts/cyw30739-cyw30739b2_p5_evk_02-lock/lock_app-CYW30739B2-P5-EVK-02.elf \
/tmp/bloat_reports/
- - name: Get switch size stats
- run: |
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
- cyw30739 cyw930739m2evb_01 switch \
- out/artifacts/cyw30739-cyw930739m2evb_01-switch/chip-cyw30739-light-switch-example.elf \
+ cyw30739 CYW30739B2-P5-EVK-03 lock \
+ out/artifacts/cyw30739-cyw30739b2_p5_evk_03-lock/lock_app-CYW30739B2-P5-EVK-03.elf \
/tmp/bloat_reports/
+ - name: Clean out build output
+ run: rm -rf ./out
- name: Uploading Size Reports
uses: ./.github/actions/upload-size-reports
if: ${{ !env.ACT }}
diff --git a/.gitmodules b/.gitmodules
index c372f58..26fff51 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -76,8 +76,8 @@
[submodule "ot-stm32"]
path = third_party/openthread/ot-stm32
url = https://github.com/openthread/openthread
- branch = eb6377f
- platforms = stm32
+ branch = eb6377f
+ platforms = stm32
[submodule "third_party/openthread/ot-ifx"]
path = third_party/openthread/ot-ifx
url = https://github.com/Infineon/ot-ifx-release.git
@@ -189,22 +189,6 @@
[submodule "third_party/jsoncpp/repo"]
path = third_party/jsoncpp/repo
url = https://github.com/open-source-parsers/jsoncpp.git
-[submodule "cyw30739_sdk/30739A0"]
- path = third_party/infineon/cyw30739_sdk/repos/30739A0
- url = https://github.com/Infineon/OT-Matter-30739A0.git
- platforms = infineon
-[submodule "cyw30739_sdk/include"]
- path = third_party/infineon/cyw30739_sdk/repos/btsdk-include
- url = https://github.com/Infineon/btsdk-include.git
- platforms = infineon
-[submodule "cyw30739_sdk/target"]
- path = third_party/infineon/cyw30739_sdk/repos/CYW930739M2EVB-01
- url = https://github.com/Infineon/OT-Matter-TARGET_CYW930739M2EVB-01.git
- platforms = infineon
-[submodule "cyw30739_sdk/tools"]
- path = third_party/infineon/cyw30739_sdk/repos/btsdk-tools
- url = https://github.com/Infineon/btsdk-tools.git
- platforms = infineon
[submodule "third_party/p6/p6_sdk/libs/anycloud-ota"]
path = third_party/infineon/psoc6/psoc6_sdk/libs/anycloud-ota
url = https://github.com/Infineon/anycloud-ota
@@ -217,6 +201,12 @@
path = third_party/infineon/psoc6/psoc6_sdk/libs/serial-flash
url = https://github.com/Infineon/serial-flash
platforms = infineon
+[submodule "infineon/matter-wpan-sdk"]
+ path = third_party/infineon/repos/matter-wpan-sdk
+ url = https://github.com/Infineon/matter-wpan-sdk.git
+ branch = main
+ platforms = infineon
+ recursive = true
[submodule "ti_simplelink_sdk"]
path = third_party/ti_simplelink_sdk/repo_cc13xx_cc26xx
url = https://github.com/TexasInstruments/cc13xx_cc26xx_sdk.git
diff --git a/examples/build_overrides/cyw30739_sdk.gni b/examples/build_overrides/cyw30739_sdk.gni
index d98ac98..5c4fa9e 100644
--- a/examples/build_overrides/cyw30739_sdk.gni
+++ b/examples/build_overrides/cyw30739_sdk.gni
@@ -13,7 +13,10 @@
# limitations under the License.
declare_args() {
+ # Root directory for Matter WPAN SDK.
+ matter_wpan_sdk_build_root =
+ "//third_party/connectedhomeip/third_party/infineon/repos/matter-wpan-sdk"
+
# Root directory for CYW30739 SDK.
- cyw30739_sdk_build_root =
- "//third_party/connectedhomeip/third_party/infineon/cyw30739_sdk"
+ cyw30739_sdk_build_root = "//third_party/connectedhomeip/third_party/infineon/repos/matter-wpan-sdk/cyw30739"
}
diff --git a/examples/light-switch-app/infineon/cyw30739/BUILD.gn b/examples/light-switch-app/infineon/cyw30739/BUILD.gn
index 0a59438..a096888 100644
--- a/examples/light-switch-app/infineon/cyw30739/BUILD.gn
+++ b/examples/light-switch-app/infineon/cyw30739/BUILD.gn
@@ -12,71 +12,54 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")
import("//build_overrides/cyw30739_sdk.gni")
-import("${cyw30739_sdk_build_root}/cyw30739_executable.gni")
-import("${cyw30739_sdk_build_root}/cyw30739_sdk.gni")
+import("${chip_root}/examples/platform/infineon/cyw30739/args.gni")
+import("${matter_wpan_sdk_build_root}/matter_wpan_executable.gni")
+app_name = "light_switch_app"
cyw30739_project_dir =
"${chip_root}/examples/light-switch-app/infineon/cyw30739"
-examples_plat_dir = "${chip_root}/examples/platform/infineon/cyw30739"
-declare_args() {
- setupPinCode = 20202021
- setupDiscriminator = 3840
-}
-
-cyw30739_sdk("sdk") {
+matter_wpan_example("wpan_example") {
sources = [ "${cyw30739_project_dir}/include/CHIPProjectConfig.h" ]
- include_dirs = [
- "${cyw30739_project_dir}/include",
- "${examples_plat_dir}",
- ]
-
- defines = [
- "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
- "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}",
- ]
+ include_dirs = [ "${cyw30739_project_dir}/include" ]
}
-cyw30739_executable("light_switch_app") {
- output_name = "chip-cyw30739-light-switch-example.elf"
+template("matter_wpan_app") {
+ forward_variables_from(invoker, [ "board" ])
- sources = [
- "src/AppShellCommands.cpp",
- "src/BindingHandler.cpp",
- "src/ButtonHandler.cpp",
- "src/LightSwitch.cpp",
- "src/LightingManager.cpp",
- "src/ZclCallbacks.cpp",
- "src/main.cpp",
- ]
+ import("${matter_wpan_sdk_build_root}/boards/${board}/args.gni")
- deps = [
- ":sdk",
- "${chip_root}/examples/light-switch-app/light-switch-common",
- "${chip_root}/examples/providers:device_info_provider",
- "${chip_root}/examples/shell/shell_common:shell_common",
- "${chip_root}/src/lib",
- ]
-
- include_dirs = [ "include" ]
-
- if (chip_enable_ota_requestor) {
- sources += [
- "${examples_plat_dir}/OTAConfig.cpp",
- "${examples_plat_dir}/OTAConfig.h",
+ matter_wpan_executable(target_name) {
+ sources = [
+ "src/AppShellCommands.cpp",
+ "src/AppTask.cpp",
+ "src/BindingHandler.cpp",
+ "src/ButtonHandler.cpp",
+ "src/LightSwitch.cpp",
+ "src/ZclCallbacks.cpp",
]
+
+ deps = [
+ "${chip_root}/examples/shell/shell_common:shell_common",
+ app_data_model,
+ ]
+
+ include_dirs = [ "include" ]
}
}
-group("cyw30739") {
- deps = [ ":light_switch_app" ]
+foreach(board, matter_wpan_sdk_board_list) {
+ matter_wpan_app("${app_name}-${board}") {
+ }
}
group("default") {
- deps = [ ":cyw30739" ]
+ deps = []
+ foreach(board, matter_wpan_sdk_board_list) {
+ deps += [ ":${app_name}-${board}" ]
+ }
}
diff --git a/examples/light-switch-app/infineon/cyw30739/README.md b/examples/light-switch-app/infineon/cyw30739/README.md
index fc45a42..530cfde 100644
--- a/examples/light-switch-app/infineon/cyw30739/README.md
+++ b/examples/light-switch-app/infineon/cyw30739/README.md
@@ -9,14 +9,22 @@
- [Matter CYW30739 Light Switch Example](#matter-cyw30739-light-switch-example)
- [Table of Contents](#table-of-contents)
- [Introduction](#introduction)
+ - [Installing ModusToolbox™ Software](#installing-modustoolbox-software)
+ - [ModusToolbox™ tools package](#modustoolbox-tools-package)
+ - [Note for WSL (Windows Subsystem for Linux)](#note-for-wsl-windows-subsystem-for-linux)
+ - [Checkout Submodules](#checkout-submodules)
- [Building](#building)
- - [Building Options](#building-options)
+ - [Factory Data](#factory-data)
+ - [Commissionable Data](#commissionable-data)
+ - [Device Information](#device-information)
- [DAC / DAC Key / PAI Certificate / Certificate Declaration](#dac--dac-key--pai-certificate--certificate-declaration)
- [Flashing the Application](#flashing-the-application)
- [Enter Recovery Mode](#enter-recovery-mode)
- [Run Flash Script](#run-flash-script)
- [Running the Complete Example](#running-the-complete-example)
+---
+
## Introduction
The CYW30739 light switch example provides a baseline demonstration of a on-off
@@ -28,55 +36,130 @@
Rendez-vous procedure. Target Thread Network information including the active
dataset and CASE credentials are then provided.
+## Installing [ModusToolbox™ Software](https://www.infineon.com/cms/en/design-support/tools/sdk/modustoolbox-software)
+
+Follow the
+[Installation Guide](https://www.infineon.com/ModusToolboxInstallguide) to
+download and install the ModusToolbox™ Software.
+
+### ModusToolbox™ tools package
+
+ModusToolbox™ tools package should be automatically installed in the default
+location if you followed the
+[Installation Guide](https://www.infineon.com/ModusToolboxInstallguide). Please
+refer to the Installation Guide for the default location for different operating
+systems.
+
+If you need to install the ModusToolbox™ tools package in a custom location, you
+must set the environment variable `CY_TOOLS_PATHS` to the
+`/path/to/ModusToolbox/tools_x.x` to specify the location of tools.
+
+```bash
+export CY_TOOLS_PATHS="/path/to/ModusToolbox/tools_x.x"
+```
+
+#### Note for WSL (Windows Subsystem for Linux)
+
+If you are using WSL, please ensure you have installed the ModusToolbox™
+Software for Linux. Running Windows tools directly from the WSL command line
+would cause path resolution failure in the build process.
+
+### Checkout Submodules
+
+Before building the example, check out the Matter repository and sync submodules
+using the following command:
+
+```bash
+$ cd ~/connectedhomeip
+$ scripts/checkout_submodules.py --platform infineon
+```
+
## Building
- Build the example application:
```bash
$ cd ~/connectedhomeip
- $ git submodule update --init
- $ ./scripts/examples/gn_build_example.sh examples/light-switch-app/infineon/cyw30739 out/light-switch-app
+ $ scripts/examples/gn_build_example.sh examples/light-switch-app/infineon/cyw30739 out/cyw30739-light-switch
+ ```
+
+- OR use GN/Ninja directly
+
+ ```bash
+ $ cd ~/connectedhomeip
+ $ source scripts/activate.sh
+ $ gn gen --root=examples/light-switch-app/infineon/cyw30739 out/cyw30739-light-switch
+ $ ninja -C out/cyw30739-light-switch [light_switch_app-BOARD_NAME]
```
- To delete generated executable, libraries and object files use:
```bash
$ cd ~/connectedhomeip
- $ rm -rf ./out/
+ $ rm -rf out/cyw30739-light-switch
```
-- OR use GN/Ninja directly
+## Factory Data
+
+### Commissionable Data
+
+Infineon CYW30739 examples use test passcode, discriminator and PAKE parameters
+by default. For a production build, manufacturers should override commissionable
+data by the following arguments:
+
+- `matter_passcode`, `matter_discriminator`, `matter_pake_iteration_count`,
+ `matter_pake_salt`
```bash
- $ cd ~/connectedhomeip/examples/light-switch-app/infineon/cyw30739
- $ git submodule update --init
- $ source third_party/connectedhomeip/scripts/activate.sh
- $ gn gen out/debug
- $ ninja -C out/debug
+ $ cd ~/connectedhomeip
+ $ scripts/examples/gn_build_example.sh examples/light-switch-app/infineon/cyw30739 out/cyw30739-light-switch \
+ 'matter_passcode=20202021' \
+ 'matter_discriminator=3840' \
+ 'matter_pake_iteration_count=1000' \
+ 'matter_pake_salt="U1BBS0UyUCBLZXkgU2FsdA=="'
```
-- To delete generated executable, libraries and object files use:
+### Device Information
+
+Infineon CYW30739 examples support overriding the default device information by
+the following arguments:
+
+- matter_vendor_name
+- matter_vendor_id
+- matter_product_name
+- matter_product_id
+- matter_serial_number
+- matter_hardware_version
+- matter_hardware_version_string
+
+To override the default device information, pass the desired values to the
+`gn_build_example.sh` script as arguments.
```bash
- $ cd ~/connectedhomeip/examples/light-switch-app/infineon/cyw30739
- $ rm -rf out/
+ $ cd ~/connectedhomeip
+ $ scripts/examples/gn_build_example.sh examples/light-switch-app/infineon/cyw30739 out/cyw30739-light-switch \
+ 'matter_vendor_name="Infineon"' \
+ 'matter_vendor_id="0x1388"' \
+ 'matter_product_name="TEST_PRODUCT"' \
+ 'matter_product_id="0x0001"' \
+ 'matter_serial_number="TEST_SN"' \
+ 'matter_hardware_version=30739' \
+ 'matter_hardware_version_string="30739"'
```
-## Building Options
-
### DAC / DAC Key / PAI Certificate / Certificate Declaration
-Infineon CYW30739 examples use test certifications, keys, and CD by default. For
-a production build, manufacturers can provision certifications, keys, and CD by
-the following arguments:
+Infineon CYW30739 examples use development certifications, keys, and CD by
+default. For a production build, manufacturers can provision certifications,
+keys, and CD by the following arguments:
-- `matter_dac`, `matter_dac_key`, `matter_pai`, `matter_cd`
+- `matter_att_cert`, `matter_att_cert_password`, `matter_cd`
```bash
- $ ./scripts/examples/gn_build_example.sh examples/light-switch-app/infineon/cyw30739 out/light-switch-app \
- 'matter_dac="/path/to/dac.der"' \
- 'matter_dac_key="/path/to/dac_key.der"' \
- 'matter_pai="/path/to/pai.der"' \
+ $ cd ~/connectedhomeip
+ $ scripts/examples/gn_build_example.sh examples/light-switch-app/infineon/cyw30739 out/cyw30739-light-switch \
+ 'matter_att_cert="/path/to/att_cert.p12"' \
+ 'matter_att_cert_password="password"' \
'matter_cd="/path/to/cd.der"'
```
@@ -96,8 +179,8 @@
- On the command line:
```bash
- $ cd ~/connectedhomeip/examples/light-switch-app/infineon/cyw30739
- $ python3 out/debug/chip-cyw30739-light-switch-example.flash.py
+ $ cd ~/connectedhomeip
+ $ out/cyw30739-light-switch/light_switch_app-BOARD_NAME.flash.py --port <port>
```
## Running the Complete Example
diff --git a/examples/light-switch-app/infineon/cyw30739/args.gni b/examples/light-switch-app/infineon/cyw30739/args.gni
index 0f3c578..20db27e 100644
--- a/examples/light-switch-app/infineon/cyw30739/args.gni
+++ b/examples/light-switch-app/infineon/cyw30739/args.gni
@@ -16,14 +16,18 @@
import("${chip_root}/config/standalone/args.gni")
import("${chip_root}/src/platform/Infineon/CYW30739/args.gni")
-cyw30739_sdk_target = get_label_info(":sdk", "label_no_toolchain")
+app_data_model = "${chip_root}/examples/light-switch-app/light-switch-common"
chip_openthread_ftd = false
-enable_sleepy_device = true
-
+chip_enable_icd_server = true
chip_enable_ota_requestor = true
-chip_error_logging = false
-chip_progress_logging = false
-chip_detail_logging = false
-chip_automation_logging = false
+matter_product_id = "0x0005"
+matter_product_name = "CYW30739 Light-Switch App"
+matter_att_cert = "${chip_root}/examples/platform/infineon/credentials/development/attestation/Matter-Development-DAC-1388-0005.p12"
+
+matter_wpan_sdk_board_list = [
+ "CYW30739B2-P5-EVK-01",
+ "CYW30739B2-P5-EVK-02",
+ "CYW30739B2-P5-EVK-03",
+]
diff --git a/examples/light-switch-app/infineon/cyw30739/include/AppShellCommands.h b/examples/light-switch-app/infineon/cyw30739/include/AppTask.h
similarity index 71%
copy from examples/light-switch-app/infineon/cyw30739/include/AppShellCommands.h
copy to examples/light-switch-app/infineon/cyw30739/include/AppTask.h
index a139b9f..77eddf9 100644
--- a/examples/light-switch-app/infineon/cyw30739/include/AppShellCommands.h
+++ b/examples/light-switch-app/infineon/cyw30739/include/AppTask.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright (c) 2021 Project CHIP Authors
+ * Copyright (c) 2022 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,4 +18,8 @@
#pragma once
-void RegisterAppShellCommands();
+#include <platform/CHIPDeviceEvent.h>
+#include <platform/CHIPDeviceLayer.h>
+
+void AppChipEventHandler(const chip::DeviceLayer::ChipDeviceEvent * aEvent, intptr_t arg);
+void AppTaskMain(intptr_t args);
diff --git a/examples/light-switch-app/infineon/cyw30739/include/CHIPProjectConfig.h b/examples/light-switch-app/infineon/cyw30739/include/CHIPProjectConfig.h
index 82ea3f0..6cac0a9 100644
--- a/examples/light-switch-app/infineon/cyw30739/include/CHIPProjectConfig.h
+++ b/examples/light-switch-app/infineon/cyw30739/include/CHIPProjectConfig.h
@@ -30,35 +30,11 @@
/***********************************************************************************
* Device Identification Configuration
***********************************************************************************/
-/* The VendorName attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME "Infineon"
-
-/* The VendorID attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0xFFF2
-
-/* The ProductName attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME "CYW30739 Light-Switch App"
-
-/* The ProductID attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8002
-
-/* The HardwareVersionString attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING "30739"
-
-/* The HardwareVersion attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION 30739
-
/* The SoftwareVersionString attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "TE7.5"
+#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "1.3.1.327"
/* The SoftwareVersion attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x0705
-
-/* The SerialNumber attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER "TEST_SN"
+#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x00130547
// -------------------- Test Configuration --------------------
#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1
-
-// ------------------------- Debug use -------------------------
-#define CHIP_DEVICE_CONFIG_ENABLE_LOCAL_LEDSTATUS_DEBUG 1
diff --git a/examples/light-switch-app/infineon/cyw30739/include/LightSwitch.h b/examples/light-switch-app/infineon/cyw30739/include/LightSwitch.h
index 244c1bc..ac62bf4 100644
--- a/examples/light-switch-app/infineon/cyw30739/include/LightSwitch.h
+++ b/examples/light-switch-app/infineon/cyw30739/include/LightSwitch.h
@@ -19,8 +19,6 @@
#pragma once
#include <app/util/basic-types.h>
-#include <lib/core/CHIPError.h>
-
class LightSwitch
{
public:
diff --git a/examples/light-switch-app/infineon/cyw30739/src/AppShellCommands.cpp b/examples/light-switch-app/infineon/cyw30739/src/AppShellCommands.cpp
index 5a63cea..9be05fe 100644
--- a/examples/light-switch-app/infineon/cyw30739/src/AppShellCommands.cpp
+++ b/examples/light-switch-app/infineon/cyw30739/src/AppShellCommands.cpp
@@ -19,8 +19,9 @@
#include <App.h>
#include <AppShellCommands.h>
#include <BindingHandler.h>
+#include <LEDWidget.h>
#include <LightSwitch.h>
-#include <LightingManager.h>
+#include <cycfg.h>
#include <lib/shell/Engine.h>
#include <lib/shell/commands/Help.h>
#include <platform/CHIPDeviceLayer.h>
@@ -80,7 +81,7 @@
CHIP_ERROR OnCommandHandler(int argc, char ** argv)
{
streamer_printf(streamer_get(), "Turning the light on ...\n");
- LightMgr().Set(true, PLATFORM_LED_1);
+ LEDWid().Set(true, PLATFORM_LED_RED);
return CHIP_NO_ERROR;
}
@@ -88,7 +89,7 @@
CHIP_ERROR OffCommandHandler(int argc, char ** argv)
{
streamer_printf(streamer_get(), "Turning the light off ...\n");
- LightMgr().Set(false, PLATFORM_LED_1);
+ LEDWid().Set(false, PLATFORM_LED_RED);
return CHIP_NO_ERROR;
}
@@ -96,13 +97,13 @@
CHIP_ERROR ToggleCommandHandler(int argc, char ** argv)
{
streamer_printf(streamer_get(), "Toggling the light ...\n");
- if (LightMgr().IsLightOn())
+ if (LEDWid().IsLEDOn())
{
- LightMgr().Set(false, PLATFORM_LED_1);
+ LEDWid().Set(false, PLATFORM_LED_RED);
}
else
{
- LightMgr().Set(true, PLATFORM_LED_1);
+ LEDWid().Set(true, PLATFORM_LED_RED);
}
return CHIP_NO_ERROR;
diff --git a/examples/light-switch-app/infineon/cyw30739/src/AppTask.cpp b/examples/light-switch-app/infineon/cyw30739/src/AppTask.cpp
new file mode 100644
index 0000000..1bb443c
--- /dev/null
+++ b/examples/light-switch-app/infineon/cyw30739/src/AppTask.cpp
@@ -0,0 +1,203 @@
+/*
+ *
+ * Copyright (c) 2022 Project CHIP Authors
+ * All rights reserved.
+ *
+ * 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.
+ */
+
+#include "AppTask.h"
+#include "ButtonHandler.h"
+#include <BindingHandler.h>
+#include <LEDWidget.h>
+#include <LightSwitch.h>
+#include <app/clusters/identify-server/identify-server.h>
+#include <cycfg.h>
+#include <matter_config.h>
+#include <wiced_device_config.h>
+
+using namespace ::chip::DeviceLayer;
+using namespace ::chip::app;
+
+static bool sIsThreadProvisioned = false;
+static bool sIsThreadEnabled = false;
+static bool sIsThreadBLEAdvertising = false;
+static bool sHaveBLEConnections = false;
+
+constexpr chip::EndpointId kLightDimmerSwitchEndpointId = 1;
+
+static wiced_led_config_t chip_lighting_led_config[] = {
+ {
+ .led = PLATFORM_LED_RED,
+ .bright = 50,
+ },
+#if defined(PLATFORM_LED_YELLOW_ENABLED)
+ {
+ .led = PLATFORM_LED_YELLOW,
+ .bright = 50,
+ },
+#endif
+};
+
+void AppTaskMain(intptr_t args)
+{
+ wiced_result_t result;
+ result = app_button_init();
+ if (result != WICED_SUCCESS)
+ {
+ ChipLogError(Zcl, "ERROR app_button_init %d\n", result);
+ }
+ LEDWid().Init(chip_lighting_led_config, ArraySize(chip_lighting_led_config));
+ LightSwitch::GetInstance().Init(kLightDimmerSwitchEndpointId);
+
+ CYW30739MatterConfig::InitApp();
+}
+
+void OnIdentifyTriggerEffect(Identify * identify)
+{
+ switch (identify->mCurrentEffectIdentifier)
+ {
+ case Clusters::Identify::EffectIdentifierEnum::kBlink:
+ ChipLogProgress(Zcl, "Clusters::Identify::EffectIdentifierEnum::kBlink");
+ break;
+ case Clusters::Identify::EffectIdentifierEnum::kBreathe:
+ ChipLogProgress(Zcl, "Clusters::Identify::EffectIdentifierEnum::kBreathe");
+ break;
+ case Clusters::Identify::EffectIdentifierEnum::kOkay:
+ ChipLogProgress(Zcl, "Clusters::Identify::EffectIdentifierEnum::kOkay");
+ break;
+ case Clusters::Identify::EffectIdentifierEnum::kChannelChange:
+ ChipLogProgress(Zcl, "Clusters::Identify::EffectIdentifierEnum::kChannelChange");
+ break;
+ default:
+ ChipLogProgress(Zcl, "No identifier effect");
+ break;
+ }
+}
+
+static Identify gIdentify = {
+ chip::EndpointId{ 1 },
+ [](Identify *) { ChipLogProgress(Zcl, "onIdentifyStart"); },
+ [](Identify *) { ChipLogProgress(Zcl, "onIdentifyStop"); },
+ Clusters::Identify::IdentifyTypeEnum::kNone,
+ OnIdentifyTriggerEffect,
+};
+
+void UpdateStatusLED()
+{
+#if defined(PLATFORM_LED_YELLOW_ENABLED)
+ LEDWid().Set(false, PLATFORM_LED_YELLOW);
+ // Status LED indicates:
+ // - blinking 1 s - advertising, ready to commission
+ // - blinking 200 ms - commissioning in progress
+ // - constant lightning means commissioned with Thread network
+ if (sIsThreadBLEAdvertising && !sHaveBLEConnections)
+ {
+ LEDWid().Blink(PLATFORM_LED_YELLOW, 50, 950);
+ }
+ else if (sIsThreadProvisioned && sIsThreadEnabled)
+ {
+ LEDWid().Set(true, PLATFORM_LED_YELLOW);
+ }
+ else if (sHaveBLEConnections)
+ {
+ LEDWid().Blink(PLATFORM_LED_YELLOW, 50, 150);
+ }
+ else
+ {
+ /* back to default status */
+ LEDWid().Set(false, PLATFORM_LED_YELLOW);
+ }
+#endif /* PLATFORM_LED_YELLOW_ENABLED */
+}
+
+void AppChipEventHandler(const ChipDeviceEvent * aEvent, intptr_t arg)
+{
+ switch (aEvent->Type)
+ {
+ case DeviceEventType::kCHIPoBLEAdvertisingChange:
+ sIsThreadBLEAdvertising = true;
+ sHaveBLEConnections = ConnectivityMgr().NumBLEConnections() != 0;
+ UpdateStatusLED();
+ break;
+ case DeviceEventType::kThreadStateChange:
+ sIsThreadProvisioned = ConnectivityMgr().IsThreadProvisioned();
+ sIsThreadEnabled = ConnectivityMgr().IsThreadEnabled();
+ UpdateStatusLED();
+ break;
+ case DeviceEventType::kThreadConnectivityChange:
+ if (aEvent->ThreadConnectivityChange.Result == kConnectivity_Established)
+ sHaveBLEConnections = true;
+ break;
+ default:
+ if ((ConnectivityMgr().NumBLEConnections() == 0) && (!sIsThreadProvisioned || !sIsThreadEnabled))
+ {
+ printf("[Event] Commissioning with a Thread network has not been done. An error occurred\n");
+ sIsThreadBLEAdvertising = false;
+ sHaveBLEConnections = false;
+ UpdateStatusLED();
+ }
+ break;
+ }
+}
+
+CHIP_ERROR StartBLEAdvertisingHandler()
+{
+ CHIP_ERROR err = CHIP_NO_ERROR;
+ /// Don't allow on starting Matter service BLE advertising after Thread provisioning.
+ if (chip::Server::GetInstance().GetFabricTable().FabricCount() != 0)
+ {
+ printf("Matter service BLE advertising not started - device is already commissioned\n");
+ return err;
+ }
+
+ if (ConnectivityMgr().IsBLEAdvertisingEnabled())
+ {
+ printf("BLE advertising is already enabled\n");
+ return err;
+ }
+ else
+ {
+ printf("Start BLE advertising...\n");
+ err = ConnectivityMgr().SetBLEAdvertisingEnabled(true);
+ if (err != CHIP_NO_ERROR)
+ {
+ printf("Enable BLE advertising failed\n");
+ return err;
+ }
+ }
+
+ printf("Enabling BLE advertising...\n");
+ /* Check Commissioning Window*/
+ if (chip::Server::GetInstance().GetCommissioningWindowManager().OpenBasicCommissioningWindow() != CHIP_NO_ERROR)
+ {
+ printf("OpenBasicCommissioningWindow() failed\n");
+ err = CHIP_ERROR_UNEXPECTED_EVENT;
+ }
+
+ return err;
+}
+
+CHIP_ERROR StopBLEAdvertisingHandler()
+{
+ CHIP_ERROR err = CHIP_NO_ERROR;
+
+ printf("Stop BLE advertising...\n");
+ err = ConnectivityMgr().SetBLEAdvertisingEnabled(false);
+ if (err != CHIP_NO_ERROR)
+ {
+ printf("Disable BLE advertising failed\n");
+ return err;
+ }
+ return err;
+}
diff --git a/examples/light-switch-app/infineon/cyw30739/src/ButtonHandler.cpp b/examples/light-switch-app/infineon/cyw30739/src/ButtonHandler.cpp
index 5be809b..90dc68a 100644
--- a/examples/light-switch-app/infineon/cyw30739/src/ButtonHandler.cpp
+++ b/examples/light-switch-app/infineon/cyw30739/src/ButtonHandler.cpp
@@ -17,9 +17,10 @@
*/
#include <ButtonHandler.h>
+#include <LEDWidget.h>
#include <LightSwitch.h>
-#include <LightingManager.h>
#include <app-common/zap-generated/attributes/Accessors.h>
+#include <cycfg_pins.h>
#include <platform/CHIPDeviceLayer.h>
#include <wiced_button_manager.h>
#include <wiced_platform.h>
@@ -53,7 +54,7 @@
memset(app_button_configurations, 0, (sizeof(wiced_button_configuration_t) * APP_MAX_BUTTON_DEF));
memset(app_buttons, 0, (sizeof(button_manager_button_t) * APP_MAX_BUTTON_DEF));
- app_button_configurations[ON_OFF_BUTTON].button = PLATFORM_BUTTON_1;
+ app_button_configurations[ON_OFF_BUTTON].gpio = PLATFORM_BUTTON_USER;
app_button_configurations[ON_OFF_BUTTON].button_event_mask = BUTTON_CLICK_EVENT | BUTTON_HOLDING_EVENT;
app_buttons[ON_OFF_BUTTON].configuration = &app_button_configurations[ON_OFF_BUTTON];
@@ -69,11 +70,16 @@
void app_button_event_handler(const button_manager_button_t * button_mgr, button_manager_event_t event,
button_manager_button_state_t state)
{
- if (button_mgr[0].configuration->button == PLATFORM_BUTTON_1)
+ if (button_mgr[0].configuration->gpio == PLATFORM_BUTTON_USER)
{
if (event == BUTTON_CLICK_EVENT && state == BUTTON_STATE_RELEASED)
{
LightSwitch::GetInstance().InitiateActionSwitch(LightSwitch::Action::Toggle);
}
+ else if (event == BUTTON_HOLDING_EVENT)
+ {
+ printf("Button Performing factory reset ...\r\n");
+ chip::DeviceLayer::ConfigurationMgr().InitiateFactoryReset();
+ }
}
}
diff --git a/examples/light-switch-app/infineon/cyw30739/src/LightSwitch.cpp b/examples/light-switch-app/infineon/cyw30739/src/LightSwitch.cpp
index 10c68ff..848c665 100644
--- a/examples/light-switch-app/infineon/cyw30739/src/LightSwitch.cpp
+++ b/examples/light-switch-app/infineon/cyw30739/src/LightSwitch.cpp
@@ -16,11 +16,11 @@
* limitations under the License.
*/
-#include <LightSwitch.h>
-
#include <BindingHandler.h>
+#include <LightSwitch.h>
#include <app/util/binding-table.h>
#include <controller/InvokeInteraction.h>
+#include <matter_config.h>
#define CHIP_DEVICE_CONFIG_BRIGHTNESS_MAXIMUM 254
diff --git a/examples/light-switch-app/infineon/cyw30739/src/LightingManager.cpp b/examples/light-switch-app/infineon/cyw30739/src/LightingManager.cpp
deleted file mode 100644
index 497efd2..0000000
--- a/examples/light-switch-app/infineon/cyw30739/src/LightingManager.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- *
- * Copyright (c) 2021 Project CHIP Authors
- * All rights reserved.
- *
- * 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.
- */
-
-#include <LightingManager.h>
-
-#include <stdio.h>
-
-using namespace chip;
-
-LightingManager LightingManager::sLight;
-bool usr_LED1_OnOffStatus = false;
-
-/* config LED 1 */
-static wiced_led_config_t chip_lighting_led_config_1 = {
- .led = PLATFORM_LED_1,
- .bright = 50,
-};
-/* config LED 2 */
-static wiced_led_config_t chip_lighting_led_config_2 = {
- .led = PLATFORM_LED_2,
- .bright = 50,
-};
-
-wiced_result_t LightingManager::Init()
-{
- wiced_result_t result;
- result = wiced_led_manager_init(&chip_lighting_led_config_1);
- if (result != WICED_SUCCESS)
- printf("Init LED1 fail (%d)\n", result);
-
- result = wiced_led_manager_init(&chip_lighting_led_config_2);
- if (result != WICED_SUCCESS)
- printf("Init LED2 fail (%d)\n", result);
-
- return result;
-}
-
-void LightingManager::Set(bool state, uint8_t pin)
-{
- DoSetLEDOnOff(state, pin);
-}
-
-void LightingManager::Blink(wiced_led_t led_pin, uint32_t on_period_ms, uint32_t off_period_ms)
-{
- wiced_led_manager_blink_led(led_pin, on_period_ms, off_period_ms);
-}
-
-bool LightingManager::IsLightOn(void)
-{
- return usr_LED1_OnOffStatus;
-}
-
-void LightingManager::DoSetLEDOnOff(bool state, uint8_t pin)
-{
- if (pin == PLATFORM_LED_1)
- {
- usr_LED1_OnOffStatus = state;
- if (state)
- {
- wiced_led_manager_enable_led(PLATFORM_LED_1);
- }
- else
- {
- wiced_led_manager_disable_led(PLATFORM_LED_1);
- }
- }
- else if (pin == PLATFORM_LED_2)
- {
- if (state)
- {
- wiced_led_manager_enable_led(PLATFORM_LED_2);
- }
- else
- {
- wiced_led_manager_disable_led(PLATFORM_LED_2);
- }
- }
- else
- {
- printf("Invalid pin number\n");
- }
-}
diff --git a/examples/light-switch-app/infineon/cyw30739/src/main.cpp b/examples/light-switch-app/infineon/cyw30739/src/main.cpp
deleted file mode 100644
index 483a475..0000000
--- a/examples/light-switch-app/infineon/cyw30739/src/main.cpp
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- *
- * Copyright (c) 2022 Project CHIP Authors
- * All rights reserved.
- *
- * 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.
- */
-#include <platform/CHIPDeviceLayer.h>
-
-#include <AppShellCommands.h>
-#include <ButtonHandler.h>
-#include <ChipShellCollection.h>
-#include <DeviceInfoProviderImpl.h>
-#include <LightSwitch.h>
-#include <LightingManager.h>
-#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
-#include <OTAConfig.h>
-#endif
-#include <app/TestEventTriggerDelegate.h>
-#include <app/clusters/identify-server/identify-server.h>
-#include <app/clusters/ota-requestor/OTATestEventTriggerHandler.h>
-#include <app/server/OnboardingCodesUtil.h>
-#include <app/server/Server.h>
-#include <credentials/examples/DeviceAttestationCredsExample.h>
-#include <inet/EndPointStateOpenThread.h>
-#include <lib/shell/Engine.h>
-#include <lib/support/CHIPPlatformMemory.h>
-#include <mbedtls/platform.h>
-#include <platform/Infineon/CYW30739/FactoryDataProvider.h>
-#include <protocols/secure_channel/PASESession.h>
-#include <sparcommon.h>
-#include <stdio.h>
-#include <wiced_led_manager.h>
-#include <wiced_memory.h>
-#include <wiced_platform.h>
-
-using namespace ::chip::Credentials;
-using namespace ::chip::DeviceLayer;
-using namespace ::chip::Shell;
-using namespace ::chip::app;
-
-constexpr chip::EndpointId kLightDimmerSwitchEndpointId = 1;
-
-static chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider;
-static FactoryDataProvider sFactoryDataProvider;
-static bool sIsThreadProvisioned = false;
-static bool sIsThreadEnabled = false;
-static bool sIsThreadBLEAdvertising = false;
-static bool sHaveBLEConnections = false;
-
-static void InitApp(intptr_t args);
-static void ChipEventHandler(const chip::DeviceLayer::ChipDeviceEvent *, intptr_t);
-
-// NOTE! This key is for test/certification only and should not be available in production devices!
-uint8_t sTestEventTriggerEnableKey[chip::TestEventTriggerDelegate::kEnableKeyLength] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55,
- 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb,
- 0xcc, 0xdd, 0xee, 0xff };
-
-/**********************************************************
- * Identify Callbacks
- *********************************************************/
-
-void OnIdentifyTriggerEffect(Identify * identify)
-{
- switch (identify->mCurrentEffectIdentifier)
- {
- case Clusters::Identify::EffectIdentifierEnum::kBlink:
- ChipLogProgress(Zcl, "Clusters::Identify::EffectIdentifierEnum::kBlink");
- break;
- case Clusters::Identify::EffectIdentifierEnum::kBreathe:
- ChipLogProgress(Zcl, "Clusters::Identify::EffectIdentifierEnum::kBreathe");
- break;
- case Clusters::Identify::EffectIdentifierEnum::kOkay:
- ChipLogProgress(Zcl, "Clusters::Identify::EffectIdentifierEnum::kOkay");
- break;
- case Clusters::Identify::EffectIdentifierEnum::kChannelChange:
- ChipLogProgress(Zcl, "Clusters::Identify::EffectIdentifierEnum::kChannelChange");
- break;
- default:
- ChipLogProgress(Zcl, "No identifier effect");
- break;
- }
- return;
-}
-
-static Identify gIdentify = {
- chip::EndpointId{ 1 },
- [](Identify *) { ChipLogProgress(Zcl, "onIdentifyStart"); },
- [](Identify *) { ChipLogProgress(Zcl, "onIdentifyStop"); },
- Clusters::Identify::IdentifyTypeEnum::kNone,
- OnIdentifyTriggerEffect,
-};
-
-APPLICATION_START()
-{
- CHIP_ERROR err;
- wiced_result_t result;
-
- printf("\nChip Light-Switch App starting\n");
-
- mbedtls_platform_set_calloc_free(CHIPPlatformMemoryCalloc, CHIPPlatformMemoryFree);
-
- err = chip::Platform::MemoryInit();
- if (err != CHIP_NO_ERROR)
- {
- printf("ERROR MemoryInit %ld\n", err.AsInteger());
- }
-
- result = app_button_init();
- if (result != WICED_SUCCESS)
- {
- printf("ERROR app_button_init %d\n", result);
- }
-
- /* Init. LED Manager. */
- LightMgr().Init();
-
- printf("Initializing CHIP\n");
- err = PlatformMgr().InitChipStack();
- if (err != CHIP_NO_ERROR)
- {
- printf("ERROR InitChipStack %ld\n", err.AsInteger());
- }
-
-#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
- printf("Initializing OpenThread stack\n");
- err = ThreadStackMgr().InitThreadStack();
- if (err != CHIP_NO_ERROR)
- {
- printf("ERROR InitThreadStack %ld\n", err.AsInteger());
- }
-#endif
-
-#if CHIP_DEVICE_CONFIG_THREAD_FTD
- err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router);
-#else // !CHIP_DEVICE_CONFIG_THREAD_FTD
-#if CHIP_DEVICE_CONFIG_ENABLE_SED
- err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice);
-#else /* !CHIP_DEVICE_CONFIG_ENABLE_SED */
- err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice);
-#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */
-#endif // CHIP_DEVICE_CONFIG_THREAD_FTD
- if (err != CHIP_NO_ERROR)
- {
- printf("ERROR SetThreadDeviceType %ld\n", err.AsInteger());
- }
-
- PlatformMgr().AddEventHandler(ChipEventHandler, 0);
-
- printf("Starting event loop task\n");
- err = PlatformMgr().StartEventLoopTask();
- if (err != CHIP_NO_ERROR)
- {
- printf("ERROR StartEventLoopTask %ld\n", err.AsInteger());
- }
-
-#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
- printf("Starting thread task\n");
- err = ThreadStackMgr().StartThreadTask();
- if (err != CHIP_NO_ERROR)
- {
- printf("ERROR StartThreadTask %ld\n", err.AsInteger());
- }
-#endif
-
- PlatformMgr().ScheduleWork(InitApp, 0);
-
- const int ret = Engine::Root().Init();
- if (!chip::ChipError::IsSuccess(ret))
- {
- printf("ERROR Shell Init %d\n", ret);
- }
- RegisterAppShellCommands();
- Engine::Root().RunMainLoop();
-
- assert(!wiced_rtos_check_for_stack_overflow());
-}
-
-void InitApp(intptr_t args)
-{
- ConfigurationMgr().LogDeviceConfig();
-
- // Print QR Code URL
- PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE));
- /* Start CHIP datamodel server */
- static chip::SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{};
- static chip::OTATestEventTriggerHandler sOtaTestEventTriggerHandler{};
- VerifyOrDie(sTestEventTriggerDelegate.Init(chip::ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR);
- VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR);
- static chip::CommonCaseDeviceServerInitParams initParams;
- (void) initParams.InitializeStaticResourcesBeforeServerInit();
- initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
- gExampleDeviceInfoProvider.SetStorageDelegate(initParams.persistentStorageDelegate);
- chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider);
- chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams;
- nativeParams.lockCb = [] { ThreadStackMgr().LockThreadStack(); };
- nativeParams.unlockCb = [] { ThreadStackMgr().UnlockThreadStack(); };
- nativeParams.openThreadInstancePtr = chip::DeviceLayer::ThreadStackMgrImpl().OTInstance();
- initParams.endpointNativeParams = static_cast<void *>(&nativeParams);
- chip::Server::GetInstance().Init(initParams);
-
- SetDeviceAttestationCredentialsProvider(&sFactoryDataProvider);
-
- LightSwitch::GetInstance().Init(kLightDimmerSwitchEndpointId);
-
-#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
- OTAConfig::Init();
-#endif
-}
-
-void UpdateStatusLED()
-{
- LightMgr().Set(false, PLATFORM_LED_2);
- // Status LED indicates:
- // - blinking 1 s - advertising, ready to commission
- // - blinking 200 ms - commissioning in progress
- // - constant lightning means commissioned with Thread network
- if (sIsThreadBLEAdvertising && !sHaveBLEConnections)
- {
- LightMgr().Blink(PLATFORM_LED_2, 50, 950);
- }
- else if (sIsThreadProvisioned && sIsThreadEnabled)
- {
- LightMgr().Set(true, PLATFORM_LED_2);
- }
- else if (sHaveBLEConnections)
- {
- LightMgr().Blink(PLATFORM_LED_2, 50, 150);
- }
- else
- {
- /* back to default status */
- LightMgr().Set(false, PLATFORM_LED_2);
- }
-}
-
-void ChipEventHandler(const ChipDeviceEvent * aEvent, intptr_t arg)
-{
-#if CHIP_DEVICE_CONFIG_ENABLE_LOCAL_LEDSTATUS_DEBUG
- switch (aEvent->Type)
- {
- case DeviceEventType::kCHIPoBLEAdvertisingChange:
- sIsThreadBLEAdvertising = true;
- sHaveBLEConnections = ConnectivityMgr().NumBLEConnections() != 0;
- UpdateStatusLED();
- break;
- case DeviceEventType::kThreadStateChange:
- sIsThreadProvisioned = ConnectivityMgr().IsThreadProvisioned();
- sIsThreadEnabled = ConnectivityMgr().IsThreadEnabled();
- UpdateStatusLED();
- break;
- case DeviceEventType::kThreadConnectivityChange:
- if (aEvent->ThreadConnectivityChange.Result == kConnectivity_Established)
- sHaveBLEConnections = true;
- break;
- default:
- if ((ConnectivityMgr().NumBLEConnections() == 0) && (!sIsThreadProvisioned || !sIsThreadEnabled))
- {
- printf("[Event] Commissioning with a Thread network has not been done. An error occurred\n");
- sIsThreadBLEAdvertising = false;
- sHaveBLEConnections = false;
- UpdateStatusLED();
- }
- break;
- }
-#endif /* CHIP_DEVICE_CONFIG_ENABLE_LOCAL_LEDSTATUS_DEBUG */
-}
-
-CHIP_ERROR StartBLEAdvertisingHandler()
-{
- CHIP_ERROR err = CHIP_NO_ERROR;
- /// Don't allow on starting Matter service BLE advertising after Thread provisioning.
- if (chip::Server::GetInstance().GetFabricTable().FabricCount() != 0)
- {
- printf("Matter service BLE advertising not started - device is already commissioned\n");
- return err;
- }
-
- if (ConnectivityMgr().IsBLEAdvertisingEnabled())
- {
- printf("BLE advertising is already enabled\n");
- return err;
- }
- else
- {
- printf("Start BLE advertising...\n");
- err = ConnectivityMgr().SetBLEAdvertisingEnabled(true);
- if (err != CHIP_NO_ERROR)
- {
- printf("Enable BLE advertising failed\n");
- return err;
- }
- }
-
- printf("Enabling BLE advertising...\n");
- /* Check Commissioning Window*/
- if (chip::Server::GetInstance().GetCommissioningWindowManager().OpenBasicCommissioningWindow() != CHIP_NO_ERROR)
- {
- printf("OpenBasicCommissioningWindow() failed\n");
- err = CHIP_ERROR_UNEXPECTED_EVENT;
- }
-
- return err;
-}
-
-CHIP_ERROR StopBLEAdvertisingHandler()
-{
- CHIP_ERROR err = CHIP_NO_ERROR;
-
- printf("Stop BLE advertising...\n");
- err = ConnectivityMgr().SetBLEAdvertisingEnabled(false);
- if (err != CHIP_NO_ERROR)
- {
- printf("Disable BLE advertising failed\n");
- return err;
- }
- return err;
-}
diff --git a/examples/lighting-app/infineon/cyw30739/BUILD.gn b/examples/lighting-app/infineon/cyw30739/BUILD.gn
index be63607..8fce49a 100644
--- a/examples/lighting-app/infineon/cyw30739/BUILD.gn
+++ b/examples/lighting-app/infineon/cyw30739/BUILD.gn
@@ -12,68 +12,52 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")
import("//build_overrides/cyw30739_sdk.gni")
-import("${cyw30739_sdk_build_root}/cyw30739_executable.gni")
-import("${cyw30739_sdk_build_root}/cyw30739_sdk.gni")
+import("${chip_root}/examples/platform/infineon/cyw30739/args.gni")
+import("${matter_wpan_sdk_build_root}/matter_wpan_executable.gni")
+app_name = "lighting_app"
cyw30739_project_dir = "${chip_root}/examples/lighting-app/infineon/cyw30739"
-examples_plat_dir = "${chip_root}/examples/platform/infineon/cyw30739"
-declare_args() {
- setupPinCode = 20202021
- setupDiscriminator = 3840
-}
-
-cyw30739_sdk("sdk") {
+matter_wpan_example("wpan_example") {
sources = [ "${cyw30739_project_dir}/include/CHIPProjectConfig.h" ]
- include_dirs = [
- "${cyw30739_project_dir}/include",
- "${examples_plat_dir}",
- ]
-
- defines = [
- "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
- "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}",
- ]
+ include_dirs = [ "${cyw30739_project_dir}/include" ]
}
-cyw30739_executable("lighting_app") {
- output_name = "chip-cyw30739-lighting-example.elf"
+template("matter_wpan_app") {
+ forward_variables_from(invoker, [ "board" ])
- sources = [
- "src/AppShellCommands.cpp",
- "src/ButtonHandler.cpp",
- "src/LightingManager.cpp",
- "src/ZclCallbacks.cpp",
- "src/main.cpp",
- ]
+ import("${matter_wpan_sdk_build_root}/boards/${board}/args.gni")
- deps = [
- ":sdk",
- "${chip_root}/examples/lighting-app/lighting-common",
- "${chip_root}/examples/providers:device_info_provider",
- "${chip_root}/examples/shell/shell_common:shell_common",
- "${chip_root}/src/lib",
- ]
-
- include_dirs = [ "include" ]
-
- if (chip_enable_ota_requestor) {
- sources += [
- "${examples_plat_dir}/OTAConfig.cpp",
- "${examples_plat_dir}/OTAConfig.h",
+ matter_wpan_executable(target_name) {
+ sources = [
+ "src/AppShellCommands.cpp",
+ "src/AppTask.cpp",
+ "src/ButtonHandler.cpp",
+ "src/LightingManager.cpp",
+ "src/ZclCallbacks.cpp",
]
+
+ deps = [
+ "${chip_root}/examples/shell/shell_common:shell_common",
+ app_data_model,
+ ]
+
+ include_dirs = [ "include" ]
}
}
-group("cyw30739") {
- deps = [ ":lighting_app" ]
+foreach(board, matter_wpan_sdk_board_list) {
+ matter_wpan_app("${app_name}-${board}") {
+ }
}
group("default") {
- deps = [ ":cyw30739" ]
+ deps = []
+ foreach(board, matter_wpan_sdk_board_list) {
+ deps += [ ":${app_name}-${board}" ]
+ }
}
diff --git a/examples/lighting-app/infineon/cyw30739/README.md b/examples/lighting-app/infineon/cyw30739/README.md
index f085272..9dbfc23 100644
--- a/examples/lighting-app/infineon/cyw30739/README.md
+++ b/examples/lighting-app/infineon/cyw30739/README.md
@@ -7,9 +7,20 @@
## Table of Contents
- [CHIP CYW30739 Lighting Example](#matter-cyw30739-lighting-example)
+ - [Table of Contents](#table-of-contents)
- [Introduction](#introduction)
+ - [Installing ModusToolbox™ Software](#installing-modustoolbox-software)
+ - [ModusToolbox™ tools package](#modustoolbox-tools-package)
+ - [Note for WSL (Windows Subsystem for Linux)](#note-for-wsl-windows-subsystem-for-linux)
+ - [Checkout Submodules](#checkout-submodules)
- [Building](#building)
+ - [Factory Data](#factory-data)
+ - [Commissionable Data](#commissionable-data)
+ - [Device Information](#device-information)
+ - [DAC / DAC Key / PAI Certificate / Certificate Declaration](#dac--dac-key--pai-certificate--certificate-declaration)
- [Flashing the Application](#flashing-the-application)
+ - [Enter Recovery Mode](#enter-recovery-mode)
+ - [Run Flash Script](#run-flash-script)
- [Running the Complete Example](#running-the-complete-example)
---
@@ -25,55 +36,130 @@
Rendez-vous procedure. Target Thread Network information including the active
dataset and CASE credentials are then provided.
+## Installing [ModusToolbox™ Software](https://www.infineon.com/cms/en/design-support/tools/sdk/modustoolbox-software)
+
+Follow the
+[Installation Guide](https://www.infineon.com/ModusToolboxInstallguide) to
+download and install the ModusToolbox™ Software.
+
+### ModusToolbox™ tools package
+
+ModusToolbox™ tools package should be automatically installed in the default
+location if you followed the
+[Installation Guide](https://www.infineon.com/ModusToolboxInstallguide). Please
+refer to the Installation Guide for the default location for different operating
+systems.
+
+If you need to install the ModusToolbox™ tools package in a custom location, you
+must set the environment variable `CY_TOOLS_PATHS` to the
+`/path/to/ModusToolbox/tools_x.x` to specify the location of tools.
+
+```bash
+export CY_TOOLS_PATHS="/path/to/ModusToolbox/tools_x.x"
+```
+
+#### Note for WSL (Windows Subsystem for Linux)
+
+If you are using WSL, please ensure you have installed the ModusToolbox™
+Software for Linux. Running Windows tools directly from the WSL command line
+would cause path resolution failure in the build process.
+
+### Checkout Submodules
+
+Before building the example, check out the Matter repository and sync submodules
+using the following command:
+
+```bash
+$ cd ~/connectedhomeip
+$ scripts/checkout_submodules.py --platform infineon
+```
+
## Building
- Build the example application:
```bash
$ cd ~/connectedhomeip
- $ git submodule update --init
- $ ./scripts/examples/gn_build_example.sh examples/lighting-app/infineon/cyw30739 out/lighting-app
+ $ scripts/examples/gn_build_example.sh examples/lighting-app/infineon/cyw30739 out/cyw30739-light
+ ```
+
+- OR use GN/Ninja directly
+
+ ```bash
+ $ cd ~/connectedhomeip
+ $ source scripts/activate.sh
+ $ gn gen --root=examples/lighting-app/infineon/cyw30739 out/cyw30739-light
+ $ ninja -C out/cyw30739-light [lighting_app-BOARD_NAME]
```
- To delete generated executable, libraries and object files use:
```bash
$ cd ~/connectedhomeip
- $ rm -rf ./out/
+ $ rm -rf out/cyw30739-light
```
-- OR use GN/Ninja directly
+## Factory Data
+
+### Commissionable Data
+
+Infineon CYW30739 examples use test passcode, discriminator and PAKE parameters
+by default. For a production build, manufacturers should override commissionable
+data by the following arguments:
+
+- `matter_passcode`, `matter_discriminator`, `matter_pake_iteration_count`,
+ `matter_pake_salt`
```bash
- $ cd ~/connectedhomeip/examples/lighting-app/infineon/cyw30739
- $ git submodule update --init
- $ source third_party/connectedhomeip/scripts/activate.sh
- $ gn gen out/debug
- $ ninja -C out/debug
+ $ cd ~/connectedhomeip
+ $ scripts/examples/gn_build_example.sh examples/lighting-app/infineon/cyw30739 out/cyw30739-light \
+ 'matter_passcode=20202021' \
+ 'matter_discriminator=3840' \
+ 'matter_pake_iteration_count=1000' \
+ 'matter_pake_salt="U1BBS0UyUCBLZXkgU2FsdA=="'
```
-- To delete generated executable, libraries and object files use:
+### Device Information
+
+Infineon CYW30739 examples support overriding the default device information by
+the following arguments:
+
+- matter_vendor_name
+- matter_vendor_id
+- matter_product_name
+- matter_product_id
+- matter_serial_number
+- matter_hardware_version
+- matter_hardware_version_string
+
+To override the default device information, pass the desired values to the
+`gn_build_example.sh` script as arguments.
```bash
- $ cd ~/connectedhomeip/examples/lighting-app/infineon/cyw30739
- $ rm -rf out/
+ $ cd ~/connectedhomeip
+ $ scripts/examples/gn_build_example.sh examples/lighting-app/infineon/cyw30739 out/cyw30739-light \
+ 'matter_vendor_name="Infineon"' \
+ 'matter_vendor_id="0x1388"' \
+ 'matter_product_name="TEST_PRODUCT"' \
+ 'matter_product_id="0x0001"' \
+ 'matter_serial_number="TEST_SN"' \
+ 'matter_hardware_version=30739' \
+ 'matter_hardware_version_string="30739"'
```
-## Building Options
-
### DAC / DAC Key / PAI Certificate / Certificate Declaration
-Infineon CYW30739 examples use test certifications, keys, and CD by default. For
-a production build, manufacturers can provision certifications, keys, and CD by
-the following arguments:
+Infineon CYW30739 examples use development certifications, keys, and CD by
+default. For a production build, manufacturers can provision certifications,
+keys, and CD by the following arguments:
-- `matter_dac`, `matter_dac_key`, `matter_pai`, `matter_cd`
+- `matter_att_cert`, `matter_att_cert_password`, `matter_cd`
```bash
- $ ./scripts/examples/gn_build_example.sh examples/lighting-app/infineon/cyw30739 out/lighting-app \
- 'matter_dac="/path/to/dac.der"' \
- 'matter_dac_key="/path/to/dac_key.der"' \
- 'matter_pai="/path/to/pai.der"' \
+ $ cd ~/connectedhomeip
+ $ scripts/examples/gn_build_example.sh examples/lighting-app/infineon/cyw30739 out/cyw30739-light \
+ 'matter_att_cert="/path/to/att_cert.p12"' \
+ 'matter_att_cert_password="password"' \
'matter_cd="/path/to/cd.der"'
```
@@ -93,8 +179,8 @@
- On the command line:
```bash
- $ cd ~/connectedhomeip/examples/lighting-app/infineon/cyw30739
- $ python3 out/debug/chip-cyw30739-lighting-example.flash.py
+ $ cd ~/connectedhomeip
+ $ out/cyw30739-light/lighting_app-BOARD_NAME.flash.py --port <port>
```
## Running the Complete Example
diff --git a/examples/lighting-app/infineon/cyw30739/args.gni b/examples/lighting-app/infineon/cyw30739/args.gni
index 770d267..0dfb938 100644
--- a/examples/lighting-app/infineon/cyw30739/args.gni
+++ b/examples/lighting-app/infineon/cyw30739/args.gni
@@ -16,14 +16,18 @@
import("${chip_root}/config/standalone/args.gni")
import("${chip_root}/src/platform/Infineon/CYW30739/args.gni")
-cyw30739_sdk_target = get_label_info(":sdk", "label_no_toolchain")
+app_data_model = "${chip_root}/examples/lighting-app/lighting-common"
-chip_openthread_ftd = false
-enable_sleepy_device = false
-
+chip_openthread_ftd = true
chip_enable_ota_requestor = true
-chip_error_logging = false
-chip_progress_logging = false
-chip_detail_logging = false
-chip_automation_logging = false
+matter_product_id = "0x0001"
+matter_product_name = "CYW30739 Lighting App"
+matter_att_cert = "${chip_root}/examples/platform/infineon/credentials/development/attestation/Matter-Development-DAC-1388-0001.p12"
+
+matter_wpan_sdk_board_list = [
+ "CYW30739B2-P5-EVK-01",
+ "CYW30739B2-P5-EVK-02",
+ "CYW30739B2-P5-EVK-03",
+ "CYW930739M2EVB-02",
+]
diff --git a/examples/light-switch-app/infineon/cyw30739/include/AppShellCommands.h b/examples/lighting-app/infineon/cyw30739/include/AppTask.h
similarity index 74%
copy from examples/light-switch-app/infineon/cyw30739/include/AppShellCommands.h
copy to examples/lighting-app/infineon/cyw30739/include/AppTask.h
index a139b9f..8fc6b14 100644
--- a/examples/light-switch-app/infineon/cyw30739/include/AppShellCommands.h
+++ b/examples/lighting-app/infineon/cyw30739/include/AppTask.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright (c) 2021 Project CHIP Authors
+ * Copyright (c) 2022 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,4 +18,7 @@
#pragma once
-void RegisterAppShellCommands();
+#include <LightingManager.h>
+
+void AppTaskMain(intptr_t args);
+void LightManagerCallback(LightingManager::Actor_t actor, LightingManager::Action_t action, uint8_t level);
diff --git a/examples/lighting-app/infineon/cyw30739/include/CHIPProjectConfig.h b/examples/lighting-app/infineon/cyw30739/include/CHIPProjectConfig.h
index 26d7e65..f22fdc5 100644
--- a/examples/lighting-app/infineon/cyw30739/include/CHIPProjectConfig.h
+++ b/examples/lighting-app/infineon/cyw30739/include/CHIPProjectConfig.h
@@ -29,33 +29,11 @@
#pragma once
// -------------------- Device Identification Configuration --------------------
-
-/* The VendorName attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME "Infineon"
-
-/* The VendorID attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0xFFF2
-
-/* The ProductName attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME "CYW30739 Lighting App"
-
-/* The ProductID attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8002
-
-/* The HardwareVersionString attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING "30739"
-
-/* The HardwareVersion attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION 30739
-
/* The SoftwareVersionString attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "TE7.5"
+#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "1.3.1.327"
/* The SoftwareVersion attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x0705
-
-/* The SerialNumber attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER "TEST_SN"
+#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x00130547
// -------------------- Test Configuration --------------------
#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1
diff --git a/examples/lighting-app/infineon/cyw30739/include/LightingManager.h b/examples/lighting-app/infineon/cyw30739/include/LightingManager.h
index 917bb37..5da0557 100644
--- a/examples/lighting-app/infineon/cyw30739/include/LightingManager.h
+++ b/examples/lighting-app/infineon/cyw30739/include/LightingManager.h
@@ -19,6 +19,7 @@
#pragma once
#include <lib/core/CHIPError.h>
+#include <wiced_led_manager.h>
class LightingManager
{
@@ -47,7 +48,6 @@
ACTOR_BUTTON,
} Actor;
- CHIP_ERROR Init();
bool IsLightOn();
bool IsActionInProgress();
bool InitiateAction(Actor_t aActor, Action_t aAction, uint8_t vallue);
diff --git a/examples/lighting-app/infineon/cyw30739/src/AppTask.cpp b/examples/lighting-app/infineon/cyw30739/src/AppTask.cpp
new file mode 100644
index 0000000..620fd46
--- /dev/null
+++ b/examples/lighting-app/infineon/cyw30739/src/AppTask.cpp
@@ -0,0 +1,106 @@
+/*
+ *
+ * Copyright (c) 2022 Project CHIP Authors
+ * Copyright (c) 2019 Google LLC.
+ * All rights reserved.
+ *
+ * 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.
+ */
+
+#include "AppTask.h"
+#include "ButtonHandler.h"
+#include <LEDWidget.h>
+#include <app/clusters/identify-server/identify-server.h>
+#include <cycfg_pins.h>
+#include <matter_config.h>
+#include <platform/CHIPDeviceLayer.h>
+#include <wiced_led_manager.h>
+
+using namespace chip::app;
+
+/* config LED 1 */
+static wiced_led_config_t chip_lighting_led_config[] = {
+ {
+ .led = PLATFORM_LED_RED,
+ .bright = 50,
+ },
+};
+
+/**********************************************************
+ * Identify Callbacks
+ *********************************************************/
+
+void OnIdentifyTriggerEffect(Identify * identify)
+{
+ switch (identify->mCurrentEffectIdentifier)
+ {
+ case Clusters::Identify::EffectIdentifierEnum::kBlink:
+ ChipLogProgress(Zcl, "Clusters::Identify::EffectIdentifierEnum::kBlink");
+ break;
+ case Clusters::Identify::EffectIdentifierEnum::kBreathe:
+ ChipLogProgress(Zcl, "Clusters::Identify::EffectIdentifierEnum::kBreathe");
+ break;
+ case Clusters::Identify::EffectIdentifierEnum::kOkay:
+ ChipLogProgress(Zcl, "Clusters::Identify::EffectIdentifierEnum::kOkay");
+ break;
+ case Clusters::Identify::EffectIdentifierEnum::kChannelChange:
+ ChipLogProgress(Zcl, "Clusters::Identify::EffectIdentifierEnum::kChannelChange");
+ break;
+ default:
+ ChipLogProgress(Zcl, "No identifier effect");
+ break;
+ }
+}
+
+static Identify gIdentify = {
+ chip::EndpointId{ 1 },
+ [](Identify *) { ChipLogProgress(Zcl, "onIdentifyStart"); },
+ [](Identify *) { ChipLogProgress(Zcl, "onIdentifyStop"); },
+ Clusters::Identify::IdentifyTypeEnum::kNone,
+ OnIdentifyTriggerEffect,
+};
+
+void AppTaskMain(intptr_t args)
+{
+ wiced_result_t result;
+ result = app_button_init();
+ if (result != WICED_SUCCESS)
+ {
+ ChipLogError(Zcl, "ERROR app_button_init %d\n", result);
+ }
+ LEDWid().Init(chip_lighting_led_config, ArraySize(chip_lighting_led_config));
+ LightMgr().SetCallbacks(LightManagerCallback, nullptr);
+
+ CYW30739MatterConfig::InitApp();
+ LightMgr().WriteClusterLevel(127);
+}
+
+void LightManagerCallback(LightingManager::Actor_t actor, LightingManager::Action_t action, uint8_t level)
+{
+ if (action == LightingManager::ON_ACTION)
+ {
+ printf("Turning light ON\n");
+ wiced_led_manager_enable_led(PLATFORM_LED_RED);
+ }
+ else if (action == LightingManager::OFF_ACTION)
+ {
+ printf("Turning light OFF\n");
+ wiced_led_manager_disable_led(PLATFORM_LED_RED);
+ }
+ else if (action == LightingManager::LEVEL_ACTION)
+ {
+ printf("Set light level = %d\n", level);
+ chip_lighting_led_config[0].bright = (uint16_t) level * 100 / 0xfe;
+ wiced_led_manager_reconfig_led(chip_lighting_led_config[0].led);
+ }
+}
diff --git a/examples/lighting-app/infineon/cyw30739/src/ButtonHandler.cpp b/examples/lighting-app/infineon/cyw30739/src/ButtonHandler.cpp
index ebb6b74..965606a 100644
--- a/examples/lighting-app/infineon/cyw30739/src/ButtonHandler.cpp
+++ b/examples/lighting-app/infineon/cyw30739/src/ButtonHandler.cpp
@@ -21,6 +21,7 @@
#include <ButtonHandler.h>
#include <LightingManager.h>
#include <app-common/zap-generated/attributes/Accessors.h>
+#include <cycfg_pins.h>
#include <platform/CHIPDeviceLayer.h>
#include <stdio.h>
#include <wiced.h>
@@ -59,9 +60,10 @@
memset(app_button_configurations, 0, (sizeof(wiced_button_configuration_t) * APP_MAX_BUTTON_DEF));
memset(app_buttons, 0, (sizeof(button_manager_button_t) * APP_MAX_BUTTON_DEF));
- app_button_configurations[ON_OFF_BUTTON].button = PLATFORM_BUTTON_1;
- app_button_configurations[ON_OFF_BUTTON].button_event_mask = BUTTON_CLICK_EVENT | BUTTON_HOLDING_EVENT;
- app_buttons[ON_OFF_BUTTON].configuration = &app_button_configurations[ON_OFF_BUTTON];
+ app_button_configurations[ON_OFF_BUTTON].gpio = PLATFORM_BUTTON_USER;
+ app_button_configurations[ON_OFF_BUTTON].button_event_mask =
+ BUTTON_CLICK_EVENT | BUTTON_HOLDING_EVENT | BUTTON_LONG_DURATION_EVENT;
+ app_buttons[ON_OFF_BUTTON].configuration = &app_button_configurations[ON_OFF_BUTTON];
result = wiced_button_manager_init(&app_button_manager, &app_button_manager_configuration, app_buttons, 1);
@@ -76,26 +78,34 @@
button_manager_button_state_t state)
{
chip::BitMask<OccupancySensing::OccupancyBitmap> attributeValue;
- if (button_mgr[0].configuration->button == PLATFORM_BUTTON_1 && event == BUTTON_CLICK_EVENT && state == BUTTON_STATE_RELEASED)
+ if (button_mgr[0].configuration->gpio == PLATFORM_BUTTON_USER)
{
- if (LightMgr().IsLightOn())
+ if (event == BUTTON_CLICK_EVENT && state == BUTTON_STATE_RELEASED)
{
- printf("Button Toggle:ON -> OFF\n");
- LightMgr().InitiateAction(LightingManager::ACTOR_BUTTON, LightingManager::OFF_ACTION, 0);
+ if (LightMgr().IsLightOn())
+ {
+ printf("Button Toggle:ON -> OFF\n");
+ LightMgr().InitiateAction(LightingManager::ACTOR_BUTTON, LightingManager::OFF_ACTION, 0);
+ }
+ else
+ {
+ printf("Button Toggle:OFF -> ON\n");
+ LightMgr().InitiateAction(LightingManager::ACTOR_BUTTON, LightingManager::ON_ACTION, 0);
+ }
}
- else
+ else if (event == BUTTON_LONG_DURATION_EVENT && state == BUTTON_STATE_RELEASED)
{
- printf("Button Toggle:OFF -> ON\n");
- LightMgr().InitiateAction(LightingManager::ACTOR_BUTTON, LightingManager::ON_ACTION, 0);
+ // update the current occupancy here for hardcoded endpoint 1
+ OccupancySensing::Attributes::Occupancy::Get(1, &attributeValue);
+ uint8_t bitValue = attributeValue.Raw();
+ printf("Button Holding Toggle: %d -> %d\n", bitValue, !bitValue);
+ attributeValue.SetRaw(!bitValue);
+ OccupancySensing::Attributes::Occupancy::Set(1, attributeValue);
}
- }
- else if (button_mgr[0].configuration->button == PLATFORM_BUTTON_1 && event == BUTTON_HOLDING_EVENT)
- {
- // update the current occupancy here for hardcoded endpoint 1
- OccupancySensing::Attributes::Occupancy::Get(1, &attributeValue);
- uint8_t bitValue = attributeValue.Raw();
- printf("Button Holding Toggle: %d -> %d\n", bitValue, !bitValue);
- attributeValue.SetRaw(!bitValue);
- OccupancySensing::Attributes::Occupancy::Set(1, attributeValue);
+ else if (event == BUTTON_HOLDING_EVENT)
+ {
+ printf("Button Performing factory reset ...\r\n");
+ chip::DeviceLayer::ConfigurationMgr().InitiateFactoryReset();
+ }
}
}
diff --git a/examples/lighting-app/infineon/cyw30739/src/LightingManager.cpp b/examples/lighting-app/infineon/cyw30739/src/LightingManager.cpp
index a121801..eb70767 100644
--- a/examples/lighting-app/infineon/cyw30739/src/LightingManager.cpp
+++ b/examples/lighting-app/infineon/cyw30739/src/LightingManager.cpp
@@ -28,13 +28,6 @@
LightingManager LightingManager::sLight;
-CHIP_ERROR LightingManager::Init()
-{
- mState = kState_OffCompleted;
-
- return CHIP_NO_ERROR;
-}
-
void LightingManager::SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB)
{
mActionInitiated_CB = aActionInitiated_CB;
diff --git a/examples/lighting-app/infineon/cyw30739/src/main.cpp b/examples/lighting-app/infineon/cyw30739/src/main.cpp
deleted file mode 100644
index f851e2e..0000000
--- a/examples/lighting-app/infineon/cyw30739/src/main.cpp
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- *
- * Copyright (c) 2022 Project CHIP Authors
- * Copyright (c) 2019 Google LLC.
- * All rights reserved.
- *
- * 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.
- */
-#include <platform/CHIPDeviceLayer.h>
-
-#include <AppShellCommands.h>
-#include <ButtonHandler.h>
-#include <ChipShellCollection.h>
-#include <DeviceInfoProviderImpl.h>
-#include <LightingManager.h>
-#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
-#include <OTAConfig.h>
-#endif
-#include <app/TestEventTriggerDelegate.h>
-#include <app/clusters/identify-server/identify-server.h>
-#include <app/clusters/ota-requestor/OTATestEventTriggerHandler.h>
-#include <app/server/OnboardingCodesUtil.h>
-#include <app/server/Server.h>
-#include <credentials/examples/DeviceAttestationCredsExample.h>
-#include <inet/EndPointStateOpenThread.h>
-#include <lib/shell/Engine.h>
-#include <lib/support/CHIPPlatformMemory.h>
-#include <mbedtls/platform.h>
-#include <platform/Infineon/CYW30739/FactoryDataProvider.h>
-#include <protocols/secure_channel/PASESession.h>
-#include <sparcommon.h>
-#include <stdio.h>
-#include <wiced_led_manager.h>
-#include <wiced_memory.h>
-#include <wiced_platform.h>
-
-using namespace ::chip::Credentials;
-using namespace ::chip::DeviceLayer;
-using namespace ::chip::Shell;
-using namespace ::chip::app;
-
-static chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider;
-static FactoryDataProvider sFactoryDataProvider;
-
-static void InitApp(intptr_t args);
-static void LightManagerCallback(LightingManager::Actor_t actor, LightingManager::Action_t action, uint8_t value);
-
-static wiced_led_config_t chip_lighting_led_config = {
- .led = PLATFORM_LED_1,
- .bright = 50,
-};
-
-// NOTE! This key is for test/certification only and should not be available in production devices!
-uint8_t sTestEventTriggerEnableKey[chip::TestEventTriggerDelegate::kEnableKeyLength] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55,
- 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb,
- 0xcc, 0xdd, 0xee, 0xff };
-
-/**********************************************************
- * Identify Callbacks
- *********************************************************/
-
-void OnIdentifyTriggerEffect(Identify * identify)
-{
- switch (identify->mCurrentEffectIdentifier)
- {
- case Clusters::Identify::EffectIdentifierEnum::kBlink:
- ChipLogProgress(Zcl, "Clusters::Identify::EffectIdentifierEnum::kBlink");
- break;
- case Clusters::Identify::EffectIdentifierEnum::kBreathe:
- ChipLogProgress(Zcl, "Clusters::Identify::EffectIdentifierEnum::kBreathe");
- break;
- case Clusters::Identify::EffectIdentifierEnum::kOkay:
- ChipLogProgress(Zcl, "Clusters::Identify::EffectIdentifierEnum::kOkay");
- break;
- case Clusters::Identify::EffectIdentifierEnum::kChannelChange:
- ChipLogProgress(Zcl, "Clusters::Identify::EffectIdentifierEnum::kChannelChange");
- break;
- default:
- ChipLogProgress(Zcl, "No identifier effect");
- break;
- }
- return;
-}
-
-static Identify gIdentify = {
- chip::EndpointId{ 1 },
- [](Identify *) { ChipLogProgress(Zcl, "onIdentifyStart"); },
- [](Identify *) { ChipLogProgress(Zcl, "onIdentifyStop"); },
- Clusters::Identify::IdentifyTypeEnum::kNone,
- OnIdentifyTriggerEffect,
-};
-
-APPLICATION_START()
-{
- CHIP_ERROR err;
- wiced_result_t result;
-
- printf("\nChipLighting App starting\n");
-
- mbedtls_platform_set_calloc_free(CHIPPlatformMemoryCalloc, CHIPPlatformMemoryFree);
-
- err = chip::Platform::MemoryInit();
- if (err != CHIP_NO_ERROR)
- {
- printf("ERROR MemoryInit %ld\n", err.AsInteger());
- }
-
- result = app_button_init();
- if (result != WICED_SUCCESS)
- {
- printf("ERROR app_button_init %d\n", result);
- }
-
- /* Init. LED Manager. */
- result = wiced_led_manager_init(&chip_lighting_led_config);
- if (result != WICED_SUCCESS)
- printf("wiced_led_manager_init fail (%d)\n", result);
-
- printf("Initializing CHIP\n");
- err = PlatformMgr().InitChipStack();
- if (err != CHIP_NO_ERROR)
- {
- printf("ERROR InitChipStack %ld\n", err.AsInteger());
- }
-
-#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
- printf("Initializing OpenThread stack\n");
- err = ThreadStackMgr().InitThreadStack();
- if (err != CHIP_NO_ERROR)
- {
- printf("ERROR InitThreadStack %ld\n", err.AsInteger());
- }
-#endif
-
-#if CHIP_DEVICE_CONFIG_THREAD_FTD
- err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router);
-#else // !CHIP_DEVICE_CONFIG_THREAD_FTD
-#if CHIP_DEVICE_CONFIG_ENABLE_SED
- err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice);
-#else /* !CHIP_DEVICE_CONFIG_ENABLE_SED */
- err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice);
-#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */
-#endif // CHIP_DEVICE_CONFIG_THREAD_FTD
- if (err != CHIP_NO_ERROR)
- {
- printf("ERROR SetThreadDeviceType %ld\n", err.AsInteger());
- }
-
- printf("Starting event loop task\n");
- err = PlatformMgr().StartEventLoopTask();
- if (err != CHIP_NO_ERROR)
- {
- printf("ERROR StartEventLoopTask %ld\n", err.AsInteger());
- }
-
-#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
- printf("Starting thread task\n");
- err = ThreadStackMgr().StartThreadTask();
- if (err != CHIP_NO_ERROR)
- {
- printf("ERROR StartThreadTask %ld\n", err.AsInteger());
- }
-#endif
-
- PlatformMgr().ScheduleWork(InitApp, 0);
-
- const int ret = Engine::Root().Init();
- if (!chip::ChipError::IsSuccess(ret))
- {
- printf("ERROR Shell Init %d\n", ret);
- }
- RegisterAppShellCommands();
- Engine::Root().RunMainLoop();
-
- assert(!wiced_rtos_check_for_stack_overflow());
-}
-
-void InitApp(intptr_t args)
-{
- ConfigurationMgr().LogDeviceConfig();
-
- // Print QR Code URL
- PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE));
- /* Start CHIP datamodel server */
- static chip::SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{};
- static chip::OTATestEventTriggerHandler sOtaTestEventTriggerHandler{};
- VerifyOrDie(sTestEventTriggerDelegate.Init(chip::ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR);
- VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR);
- static chip::CommonCaseDeviceServerInitParams initParams;
- (void) initParams.InitializeStaticResourcesBeforeServerInit();
- initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
- gExampleDeviceInfoProvider.SetStorageDelegate(initParams.persistentStorageDelegate);
- chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider);
- chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams;
- nativeParams.lockCb = [] { ThreadStackMgr().LockThreadStack(); };
- nativeParams.unlockCb = [] { ThreadStackMgr().UnlockThreadStack(); };
- nativeParams.openThreadInstancePtr = chip::DeviceLayer::ThreadStackMgrImpl().OTInstance();
- initParams.endpointNativeParams = static_cast<void *>(&nativeParams);
- chip::Server::GetInstance().Init(initParams);
-
- SetDeviceAttestationCredentialsProvider(&sFactoryDataProvider);
-
- LightMgr().Init();
- LightMgr().SetCallbacks(LightManagerCallback, nullptr);
- LightMgr().WriteClusterLevel(254);
-
-#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
- OTAConfig::Init();
-#endif
-}
-
-void LightManagerCallback(LightingManager::Actor_t actor, LightingManager::Action_t action, uint8_t level)
-{
- if (action == LightingManager::ON_ACTION)
- {
- printf("Turning light ON\n");
- wiced_led_manager_enable_led(PLATFORM_LED_1);
- }
- else if (action == LightingManager::OFF_ACTION)
- {
- printf("Turning light OFF\n");
- wiced_led_manager_disable_led(PLATFORM_LED_1);
- }
- else if (action == LightingManager::LEVEL_ACTION)
- {
- printf("Set light level = %d\n", level);
- chip_lighting_led_config.bright = (uint16_t) level * 100 / 0xfe;
- wiced_led_manager_reconfig_led(&chip_lighting_led_config);
- }
-}
diff --git a/examples/lock-app/infineon/cyw30739/BUILD.gn b/examples/lock-app/infineon/cyw30739/BUILD.gn
index 8d0cc63..7ce4c26 100644
--- a/examples/lock-app/infineon/cyw30739/BUILD.gn
+++ b/examples/lock-app/infineon/cyw30739/BUILD.gn
@@ -12,68 +12,52 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")
import("//build_overrides/cyw30739_sdk.gni")
-import("${cyw30739_sdk_build_root}/cyw30739_executable.gni")
-import("${cyw30739_sdk_build_root}/cyw30739_sdk.gni")
+import("${chip_root}/examples/platform/infineon/cyw30739/args.gni")
+import("${matter_wpan_sdk_build_root}/matter_wpan_executable.gni")
+app_name = "lock_app"
cyw30739_project_dir = "${chip_root}/examples/lock-app/infineon/cyw30739"
-examples_plat_dir = "${chip_root}/examples/platform/infineon/cyw30739"
-declare_args() {
- setupPinCode = 20202021
- setupDiscriminator = 3840
-}
-
-cyw30739_sdk("sdk") {
+matter_wpan_example("wpan_example") {
sources = [ "${cyw30739_project_dir}/include/CHIPProjectConfig.h" ]
- include_dirs = [
- "${cyw30739_project_dir}/include",
- "${examples_plat_dir}",
- ]
-
- defines = [
- "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
- "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}",
- ]
+ include_dirs = [ "${cyw30739_project_dir}/include" ]
}
-cyw30739_executable("lock_app") {
- output_name = "chip-cyw30739-lock-example.elf"
+template("matter_wpan_app") {
+ forward_variables_from(invoker, [ "board" ])
- sources = [
- "src/AppShellCommands.cpp",
- "src/ButtonHandler.cpp",
- "src/LockManager.cpp",
- "src/ZclCallbacks.cpp",
- "src/main.cpp",
- ]
+ import("${matter_wpan_sdk_build_root}/boards/${board}/args.gni")
- deps = [
- ":sdk",
- "${chip_root}/examples/lock-app/lock-common",
- "${chip_root}/examples/providers:device_info_provider",
- "${chip_root}/examples/shell/shell_common:shell_common",
- "${chip_root}/src/lib",
- ]
-
- include_dirs = [ "include" ]
-
- if (chip_enable_ota_requestor) {
- sources += [
- "${examples_plat_dir}/OTAConfig.cpp",
- "${examples_plat_dir}/OTAConfig.h",
+ matter_wpan_executable(target_name) {
+ sources = [
+ "src/AppShellCommands.cpp",
+ "src/AppTask.cpp",
+ "src/ButtonHandler.cpp",
+ "src/LockManager.cpp",
+ "src/ZclCallbacks.cpp",
]
+
+ deps = [
+ "${chip_root}/examples/shell/shell_common:shell_common",
+ app_data_model,
+ ]
+
+ include_dirs = [ "include" ]
}
}
-group("cyw30739") {
- deps = [ ":lock_app" ]
+foreach(board, matter_wpan_sdk_board_list) {
+ matter_wpan_app("${app_name}-${board}") {
+ }
}
group("default") {
- deps = [ ":cyw30739" ]
+ deps = []
+ foreach(board, matter_wpan_sdk_board_list) {
+ deps += [ ":${app_name}-${board}" ]
+ }
}
diff --git a/examples/lock-app/infineon/cyw30739/README.md b/examples/lock-app/infineon/cyw30739/README.md
index b91f4b9..6623f77 100644
--- a/examples/lock-app/infineon/cyw30739/README.md
+++ b/examples/lock-app/infineon/cyw30739/README.md
@@ -7,17 +7,28 @@
## Table of Contents
- [CHIP CYW30739 Lock Example](#matter-cyw30739-lock-example)
+ - [Table of Contents](#table-of-contents)
- [Introduction](#introduction)
+ - [Installing ModusToolbox™ Software](#installing-modustoolbox-software)
+ - [ModusToolbox™ tools package](#modustoolbox-tools-package)
+ - [Note for WSL (Windows Subsystem for Linux)](#note-for-wsl-windows-subsystem-for-linux)
+ - [Checkout Submodules](#checkout-submodules)
- [Building](#building)
+ - [Factory Data](#factory-data)
+ - [Commissionable Data](#commissionable-data)
+ - [Device Information](#device-information)
+ - [DAC / DAC Key / PAI Certificate / Certificate Declaration](#dac--dac-key--pai-certificate--certificate-declaration)
- [Flashing the Application](#flashing-the-application)
+ - [Enter Recovery Mode](#enter-recovery-mode)
+ - [Run Flash Script](#run-flash-script)
- [Running the Complete Example](#running-the-complete-example)
---
## Introduction
-The CYW30739 lock example provides a baseline demonstration of a Light control
-device, built using Matter and the Infineon Modustoolbox SDK. It can be
+The CYW30739 lock example provides a baseline demonstration of a door lock
+control device, built using Matter and the Infineon Modustoolbox SDK. It can be
controlled by a Matter controller over Thread network.
The CYW30739 device can be commissioned over Bluetooth Low Energy where the
@@ -25,55 +36,130 @@
Rendez-vous procedure. Target Thread Network information including the active
dataset and CASE credentials are then provided.
+## Installing [ModusToolbox™ Software](https://www.infineon.com/cms/en/design-support/tools/sdk/modustoolbox-software)
+
+Follow the
+[Installation Guide](https://www.infineon.com/ModusToolboxInstallguide) to
+download and install the ModusToolbox™ Software.
+
+### ModusToolbox™ tools package
+
+ModusToolbox™ tools package should be automatically installed in the default
+location if you followed the
+[Installation Guide](https://www.infineon.com/ModusToolboxInstallguide). Please
+refer to the Installation Guide for the default location for different operating
+systems.
+
+If you need to install the ModusToolbox™ tools package in a custom location, you
+must set the environment variable `CY_TOOLS_PATHS` to the
+`/path/to/ModusToolbox/tools_x.x` to specify the location of tools.
+
+```bash
+export CY_TOOLS_PATHS="/path/to/ModusToolbox/tools_x.x"
+```
+
+#### Note for WSL (Windows Subsystem for Linux)
+
+If you are using WSL, please ensure you have installed the ModusToolbox™
+Software for Linux. Running Windows tools directly from the WSL command line
+would cause path resolution failure in the build process.
+
+### Checkout Submodules
+
+Before building the example, check out the Matter repository and sync submodules
+using the following command:
+
+```bash
+$ cd ~/connectedhomeip
+$ scripts/checkout_submodules.py --platform infineon
+```
+
## Building
- Build the example application:
```bash
$ cd ~/connectedhomeip
- $ git submodule update --init
- $ ./scripts/examples/gn_build_example.sh examples/lock-app/infineon/cyw30739 out/lock-app
+ $ scripts/examples/gn_build_example.sh examples/lock-app/infineon/cyw30739 out/cyw30739-lock
+ ```
+
+- OR use GN/Ninja directly
+
+ ```bash
+ $ cd ~/connectedhomeip
+ $ source scripts/activate.sh
+ $ gn gen --root=examples/lock-app/infineon/cyw30739 out/cyw30739-lock
+ $ ninja -C out/cyw30739-lock [lock_app-BOARD_NAME]
```
- To delete generated executable, libraries and object files use:
```bash
$ cd ~/connectedhomeip
- $ rm -rf ./out/
+ $ rm -rf out/cyw30739-lock
```
-- OR use GN/Ninja directly
+## Factory Data
+
+### Commissionable Data
+
+Infineon CYW30739 examples use test passcode, discriminator and PAKE parameters
+by default. For a production build, manufacturers should override commissionable
+data by the following arguments:
+
+- `matter_passcode`, `matter_discriminator`, `matter_pake_iteration_count`,
+ `matter_pake_salt`
```bash
- $ cd ~/connectedhomeip/examples/lock-app/infineon/cyw30739
- $ git submodule update --init
- $ source third_party/connectedhomeip/scripts/activate.sh
- $ gn gen out/debug
- $ ninja -C out/debug
+ $ cd ~/connectedhomeip
+ $ scripts/examples/gn_build_example.sh examples/lock-app/infineon/cyw30739 out/cyw30739-lock \
+ 'matter_passcode=20202021' \
+ 'matter_discriminator=3840' \
+ 'matter_pake_iteration_count=1000' \
+ 'matter_pake_salt="U1BBS0UyUCBLZXkgU2FsdA=="'
```
-- To delete generated executable, libraries and object files use:
+### Device Information
+
+Infineon CYW30739 examples support overriding the default device information by
+the following arguments:
+
+- matter_vendor_name
+- matter_vendor_id
+- matter_product_name
+- matter_product_id
+- matter_serial_number
+- matter_hardware_version
+- matter_hardware_version_string
+
+To override the default device information, pass the desired values to the
+`gn_build_example.sh` script as arguments.
```bash
- $ cd ~/connectedhomeip/examples/lock-app/infineon/cyw30739
- $ rm -rf out/
+ $ cd ~/connectedhomeip
+ $ scripts/examples/gn_build_example.sh examples/lock-app/infineon/cyw30739 out/cyw30739-lock \
+ 'matter_vendor_name="Infineon"' \
+ 'matter_vendor_id="0x1388"' \
+ 'matter_product_name="TEST_PRODUCT"' \
+ 'matter_product_id="0x0001"' \
+ 'matter_serial_number="TEST_SN"' \
+ 'matter_hardware_version=30739' \
+ 'matter_hardware_version_string="30739"'
```
-## Building Options
-
### DAC / DAC Key / PAI Certificate / Certificate Declaration
-Infineon CYW30739 examples use test certifications, keys, and CD by default. For
-a production build, manufacturers can provision certifications, keys, and CD by
-the following arguments:
+Infineon CYW30739 examples use development certifications, keys, and CD by
+default. For a production build, manufacturers can provision certifications,
+keys, and CD by the following arguments:
-- `matter_dac`, `matter_dac_key`, `matter_pai`, `matter_cd`
+- `matter_att_cert`, `matter_att_cert_password`, `matter_cd`
```bash
- $ ./scripts/examples/gn_build_example.sh examples/lighting-app/infineon/cyw30739 out/lighting-app \
- 'matter_dac="/path/to/dac.der"' \
- 'matter_dac_key="/path/to/dac_key.der"' \
- 'matter_pai="/path/to/pai.der"' \
+ $ cd ~/connectedhomeip
+ $ scripts/examples/gn_build_example.sh examples/lock-app/infineon/cyw30739 out/cyw30739-lock \
+ 'matter_att_cert="/path/to/att_cert.p12"' \
+ 'matter_att_cert_password="password"' \
'matter_cd="/path/to/cd.der"'
```
@@ -93,8 +179,8 @@
- On the command line:
```bash
- $ cd ~/connectedhomeip/examples/lock-app/infineon/cyw30739
- $ python3 out/debug/chip-cyw30739-lock-example.flash.py
+ $ cd ~/connectedhomeip
+ $ out/cyw30739-lock/lock_app-BOARD_NAME.flash.py --port <port>
```
## Running the Complete Example
diff --git a/examples/lock-app/infineon/cyw30739/args.gni b/examples/lock-app/infineon/cyw30739/args.gni
index 770d267..8b4b4d6 100644
--- a/examples/lock-app/infineon/cyw30739/args.gni
+++ b/examples/lock-app/infineon/cyw30739/args.gni
@@ -16,14 +16,18 @@
import("${chip_root}/config/standalone/args.gni")
import("${chip_root}/src/platform/Infineon/CYW30739/args.gni")
-cyw30739_sdk_target = get_label_info(":sdk", "label_no_toolchain")
+app_data_model = "${chip_root}/examples/lock-app/lock-common"
chip_openthread_ftd = false
-enable_sleepy_device = false
-
+chip_enable_icd_server = true
chip_enable_ota_requestor = true
-chip_error_logging = false
-chip_progress_logging = false
-chip_detail_logging = false
-chip_automation_logging = false
+matter_product_id = "0x0002"
+matter_product_name = "CYW30739 Lock App"
+matter_att_cert = "${chip_root}/examples/platform/infineon/credentials/development/attestation/Matter-Development-DAC-1388-0002.p12"
+
+matter_wpan_sdk_board_list = [
+ "CYW30739B2-P5-EVK-01",
+ "CYW30739B2-P5-EVK-02",
+ "CYW30739B2-P5-EVK-03",
+]
diff --git a/examples/light-switch-app/infineon/cyw30739/include/AppShellCommands.h b/examples/lock-app/infineon/cyw30739/include/AppTask.h
similarity index 85%
rename from examples/light-switch-app/infineon/cyw30739/include/AppShellCommands.h
rename to examples/lock-app/infineon/cyw30739/include/AppTask.h
index a139b9f..078484a 100644
--- a/examples/light-switch-app/infineon/cyw30739/include/AppShellCommands.h
+++ b/examples/lock-app/infineon/cyw30739/include/AppTask.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright (c) 2021 Project CHIP Authors
+ * Copyright (c) 2022 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,4 +18,6 @@
#pragma once
-void RegisterAppShellCommands();
+#include <cstdint>
+
+void AppTaskMain(intptr_t args);
diff --git a/examples/lock-app/infineon/cyw30739/include/CHIPProjectConfig.h b/examples/lock-app/infineon/cyw30739/include/CHIPProjectConfig.h
index ffe889f..f22fdc5 100644
--- a/examples/lock-app/infineon/cyw30739/include/CHIPProjectConfig.h
+++ b/examples/lock-app/infineon/cyw30739/include/CHIPProjectConfig.h
@@ -29,33 +29,11 @@
#pragma once
// -------------------- Device Identification Configuration --------------------
-
-/* The VendorName attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME "Infineon"
-
-/* The VendorID attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0xFFF2
-
-/* The ProductName attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME "CYW30739 Lock App"
-
-/* The ProductID attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8002
-
-/* The HardwareVersionString attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING "30739"
-
-/* The HardwareVersion attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION 30739
-
/* The SoftwareVersionString attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "TE7.5"
+#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "1.3.1.327"
/* The SoftwareVersion attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x0705
-
-/* The SerialNumber attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER "TEST_SN"
+#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x00130547
// -------------------- Test Configuration --------------------
#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1
diff --git a/examples/lock-app/infineon/cyw30739/src/AppTask.cpp b/examples/lock-app/infineon/cyw30739/src/AppTask.cpp
new file mode 100644
index 0000000..2277049
--- /dev/null
+++ b/examples/lock-app/infineon/cyw30739/src/AppTask.cpp
@@ -0,0 +1,218 @@
+/*
+ *
+ * Copyright (c) 2021 Project CHIP Authors
+ * Copyright (c) 2019 Google LLC.
+ * All rights reserved.
+ *
+ * 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.
+ */
+
+#include "AppTask.h"
+#include "ButtonHandler.h"
+#include <LEDWidget.h>
+#include <LockManager.h>
+#include <app-common/zap-generated/attributes/Accessors.h>
+#include <app-common/zap-generated/cluster-objects.h>
+#include <app/clusters/door-lock-server/door-lock-server.h>
+#include <app/clusters/identify-server/identify-server.h>
+#include <cycfg.h>
+#include <matter_config.h>
+#include <platform/CHIPDeviceLayer.h>
+#include <wiced_led_manager.h>
+
+using chip::app::Clusters::DoorLock::DlLockState;
+using chip::app::Clusters::DoorLock::OperationErrorEnum;
+using chip::app::Clusters::DoorLock::OperationSourceEnum;
+
+using namespace CYW30739DoorLock::LockInitParams;
+using namespace chip::app;
+
+wiced_bool_t syncClusterToButtonAction = false;
+
+static Identify gIdentify = {
+ chip::EndpointId{ 1 },
+ [](Identify *) { ChipLogProgress(Zcl, "onIdentifyStart"); },
+ [](Identify *) { ChipLogProgress(Zcl, "onIdentifyStop"); },
+ Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator,
+};
+
+static wiced_led_config_t chip_lighting_led_config[] = {
+ {
+ .led = PLATFORM_LED_RED,
+ .bright = 50,
+ },
+#if defined(PLATFORM_LED_YELLOW_ENABLED)
+ {
+ .led = PLATFORM_LED_YELLOW,
+ .bright = 50,
+ },
+#endif
+};
+
+static void ActionInitiated(LockManager::Action_t aAction, int32_t aActor);
+static void ActionCompleted(LockManager::Action_t aAction);
+static void UpdateClusterState(intptr_t context);
+
+void AppTaskMain(intptr_t args)
+{
+ wiced_result_t result;
+ result = app_button_init();
+ if (result != WICED_SUCCESS)
+ {
+ ChipLogError(Zcl, "ERROR app_button_init %d\n", result);
+ }
+ LEDWid().Init(chip_lighting_led_config, ArraySize(chip_lighting_led_config));
+
+ CYW30739MatterConfig::InitApp();
+
+ chip::app::DataModel::Nullable<chip::app::Clusters::DoorLock::DlLockState> state;
+ chip::EndpointId endpointId{ 1 };
+ chip::DeviceLayer::PlatformMgr().LockChipStack();
+ chip::app::Clusters::DoorLock::Attributes::LockState::Get(endpointId, state);
+
+ uint8_t numberOfCredentialsPerUser = 0;
+ if (!DoorLockServer::Instance().GetNumberOfCredentialsSupportedPerUser(endpointId, numberOfCredentialsPerUser))
+ {
+ ChipLogError(Zcl,
+ "Unable to get number of credentials supported per user when initializing lock endpoint, defaulting to 5 "
+ "[endpointId=%d]",
+ endpointId);
+ numberOfCredentialsPerUser = 5;
+ }
+
+ uint16_t numberOfUsers = 0;
+ if (!DoorLockServer::Instance().GetNumberOfUserSupported(endpointId, numberOfUsers))
+ {
+ ChipLogError(Zcl,
+ "Unable to get number of supported users when initializing lock endpoint, defaulting to 10 [endpointId=%d]",
+ endpointId);
+ numberOfUsers = 10;
+ }
+
+ uint8_t numberOfWeekdaySchedulesPerUser = 0;
+ if (!DoorLockServer::Instance().GetNumberOfWeekDaySchedulesPerUserSupported(endpointId, numberOfWeekdaySchedulesPerUser))
+ {
+ ChipLogError(
+ Zcl,
+ "Unable to get number of supported weekday schedules when initializing lock endpoint, defaulting to 10 [endpointId=%d]",
+ endpointId);
+ numberOfWeekdaySchedulesPerUser = 10;
+ }
+
+ uint8_t numberOfYeardaySchedulesPerUser = 0;
+ if (!DoorLockServer::Instance().GetNumberOfYearDaySchedulesPerUserSupported(endpointId, numberOfYeardaySchedulesPerUser))
+ {
+ ChipLogError(
+ Zcl,
+ "Unable to get number of supported yearday schedules when initializing lock endpoint, defaulting to 10 [endpointId=%d]",
+ endpointId);
+ numberOfYeardaySchedulesPerUser = 10;
+ }
+
+ uint8_t numberOfHolidaySchedules = 0;
+ if (!DoorLockServer::Instance().GetNumberOfHolidaySchedulesSupported(endpointId, numberOfHolidaySchedules))
+ {
+ ChipLogError(
+ Zcl,
+ "Unable to get number of supported holiday schedules when initializing lock endpoint, defaulting to 10 [endpointId=%d]",
+ endpointId);
+ numberOfHolidaySchedules = 10;
+ }
+
+ chip::DeviceLayer::PlatformMgr().UnlockChipStack();
+
+ LockMgr().Init(state,
+ ParamBuilder()
+ .SetNumberOfUsers(numberOfUsers)
+ .SetNumberOfCredentialsPerUser(numberOfCredentialsPerUser)
+ .SetNumberOfWeekdaySchedulesPerUser(numberOfWeekdaySchedulesPerUser)
+ .SetNumberOfYeardaySchedulesPerUser(numberOfYeardaySchedulesPerUser)
+ .SetNumberOfHolidaySchedules(numberOfHolidaySchedules)
+ .GetLockParam());
+
+ LockMgr().SetCallbacks(ActionInitiated, ActionCompleted);
+}
+
+static void ActionInitiated(LockManager::Action_t aAction, int32_t aActor)
+{
+ // If the action has been initiated by the lock, update the bolt lock trait
+ // and start flashing the LEDs rapidly to indicate action initiation.
+ if (aAction == LockManager::LOCK_ACTION)
+ {
+ ChipLogDetail(Zcl, "Lock Action has been initiated");
+ }
+ else if (aAction == LockManager::UNLOCK_ACTION)
+ {
+ ChipLogDetail(Zcl, "Unlock Action has been initiated");
+ }
+
+ if (aActor == AppEvent::kEventType_Button)
+ {
+ syncClusterToButtonAction = true;
+ }
+
+ // Action initiated, update the light led
+ if (aAction == LockManager::LOCK_ACTION)
+ {
+ ChipLogDetail(Zcl, "Lock Action has been initiated");
+#if defined(PLATFORM_LED_YELLOW_ENABLED)
+ wiced_led_manager_disable_led(PLATFORM_LED_YELLOW);
+#endif
+ }
+ else if (aAction == LockManager::UNLOCK_ACTION)
+ {
+ ChipLogDetail(Zcl, "Unlock Action has been initiated");
+#if defined(PLATFORM_LED_YELLOW_ENABLED)
+ wiced_led_manager_enable_led(PLATFORM_LED_YELLOW);
+#endif
+ }
+}
+
+static void UpdateClusterState(intptr_t context)
+{
+ bool unlocked = LockMgr().NextState();
+ DlLockState newState = unlocked ? DlLockState::kUnlocked : DlLockState::kLocked;
+
+ OperationSourceEnum source = OperationSourceEnum::kUnspecified;
+
+ // write the new lock value
+ Protocols::InteractionModel::Status status = DoorLockServer::Instance().SetLockState(1, newState, source)
+ ? Protocols::InteractionModel::Status::Success
+ : Protocols::InteractionModel::Status::Failure;
+
+ if (status != Protocols::InteractionModel::Status::Success)
+ {
+ ChipLogError(Zcl, "ERR: updating lock state %x", to_underlying(status));
+ }
+}
+
+static void ActionCompleted(LockManager::Action_t aAction)
+{
+ // if the action has been completed by the lock, update the bolt lock trait.
+ // Turn on the lock LED if in a LOCKED state OR
+ // Turn off the lock LED if in an UNLOCKED state.
+ if (aAction == LockManager::LOCK_ACTION)
+ {
+ ChipLogDetail(Zcl, "Lock Action has been completed");
+ }
+ else if (aAction == LockManager::UNLOCK_ACTION)
+ {
+ ChipLogDetail(Zcl, "Unlock Action has been completed");
+ }
+
+ if (syncClusterToButtonAction)
+ {
+ chip::DeviceLayer::PlatformMgr().ScheduleWork(UpdateClusterState, reinterpret_cast<intptr_t>(nullptr));
+ syncClusterToButtonAction = false;
+ }
+}
diff --git a/examples/lock-app/infineon/cyw30739/src/ButtonHandler.cpp b/examples/lock-app/infineon/cyw30739/src/ButtonHandler.cpp
index 4023332..37451eb 100644
--- a/examples/lock-app/infineon/cyw30739/src/ButtonHandler.cpp
+++ b/examples/lock-app/infineon/cyw30739/src/ButtonHandler.cpp
@@ -20,7 +20,8 @@
#include <ButtonHandler.h>
#include <LockManager.h>
-#include <stdio.h>
+#include <cycfg_pins.h>
+#include <platform/CHIPDeviceLayer.h>
#include <wiced.h>
#include <wiced_button_manager.h>
#include <wiced_platform.h>
@@ -55,9 +56,10 @@
memset(app_button_configurations, 0, (sizeof(wiced_button_configuration_t) * APP_MAX_BUTTON_DEF));
memset(app_buttons, 0, (sizeof(button_manager_button_t) * APP_MAX_BUTTON_DEF));
- app_button_configurations[ON_OFF_BUTTON].button = PLATFORM_BUTTON_1;
- app_button_configurations[ON_OFF_BUTTON].button_event_mask = (BUTTON_CLICK_EVENT | BUTTON_LONG_DURATION_EVENT);
- app_buttons[ON_OFF_BUTTON].configuration = &app_button_configurations[ON_OFF_BUTTON];
+ app_button_configurations[ON_OFF_BUTTON].gpio = PLATFORM_BUTTON_USER;
+ app_button_configurations[ON_OFF_BUTTON].button_event_mask =
+ (BUTTON_CLICK_EVENT | BUTTON_LONG_DURATION_EVENT | BUTTON_HOLDING_EVENT);
+ app_buttons[ON_OFF_BUTTON].configuration = &app_button_configurations[ON_OFF_BUTTON];
result = wiced_button_manager_init(&app_button_manager, &app_button_manager_configuration, app_buttons, 1);
@@ -74,30 +76,31 @@
bool initiated = false;
LockManager::Action_t action;
- ChipLogProgress(Zcl, "app_button_event_handler. button=%d, event=%d, state=%d\n",
- button_mgr[ON_OFF_BUTTON].configuration->button, event, state);
-
- /* This app is interested in PLATFORM_BUTTON_1 only */
- if (button_mgr[0].configuration->button != PLATFORM_BUTTON_1)
- return;
-
- /* This callback is invoked both for held and released state, we want to process on the released event to avoid duplication */
- if (state != BUTTON_STATE_RELEASED)
- return;
+ ChipLogProgress(Zcl, "app_button_event_handler. gpio=%d, event=%d, state=%d\n", button_mgr[ON_OFF_BUTTON].configuration->gpio,
+ event, state);
/* single click to Lock/Unlock
long press to generate Jammed event */
- if (event == BUTTON_CLICK_EVENT)
+ if (button_mgr[0].configuration->gpio == PLATFORM_BUTTON_USER)
{
- action = (LockMgr().NextState() == true) ? LockManager::LOCK_ACTION : LockManager::UNLOCK_ACTION;
- }
- else if (event == BUTTON_LONG_DURATION_EVENT)
- {
- action = LockManager::LOCK_JAMMED;
- }
- else
- {
- return;
+ if (event == BUTTON_CLICK_EVENT && state == BUTTON_STATE_RELEASED)
+ {
+ action = (LockMgr().NextState() == true) ? LockManager::LOCK_ACTION : LockManager::UNLOCK_ACTION;
+ }
+ else if (event == BUTTON_LONG_DURATION_EVENT && state == BUTTON_STATE_RELEASED)
+ {
+ action = LockManager::LOCK_JAMMED;
+ }
+ else if (event == BUTTON_HOLDING_EVENT)
+ {
+ printf("Button Performing factory reset ...\r\n");
+ chip::DeviceLayer::ConfigurationMgr().InitiateFactoryReset();
+ return;
+ }
+ else
+ {
+ return;
+ }
}
initiated = LockMgr().InitiateAction(AppEvent::kEventType_Button, action);
diff --git a/examples/lock-app/infineon/cyw30739/src/main.cpp b/examples/lock-app/infineon/cyw30739/src/main.cpp
deleted file mode 100644
index c82cc89..0000000
--- a/examples/lock-app/infineon/cyw30739/src/main.cpp
+++ /dev/null
@@ -1,356 +0,0 @@
-/*
- *
- * Copyright (c) 2021 Project CHIP Authors
- * Copyright (c) 2019 Google LLC.
- * All rights reserved.
- *
- * 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.
- */
-#include <platform/CHIPDeviceLayer.h>
-
-#include <AppShellCommands.h>
-#include <ButtonHandler.h>
-#include <ChipShellCollection.h>
-#include <DeviceInfoProviderImpl.h>
-#include <LockManager.h>
-#include <app-common/zap-generated/attributes/Accessors.h>
-#include <app-common/zap-generated/cluster-objects.h>
-#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
-#include <OTAConfig.h>
-#endif
-#include <app/TestEventTriggerDelegate.h>
-#include <app/clusters/door-lock-server/door-lock-server.h>
-#include <app/clusters/identify-server/identify-server.h>
-#include <app/clusters/ota-requestor/OTATestEventTriggerHandler.h>
-#include <app/server/OnboardingCodesUtil.h>
-#include <app/server/Server.h>
-#include <credentials/examples/DeviceAttestationCredsExample.h>
-#include <inet/EndPointStateOpenThread.h>
-#include <lib/shell/Engine.h>
-#include <lib/support/CHIPPlatformMemory.h>
-#include <mbedtls/platform.h>
-#include <platform/Infineon/CYW30739/FactoryDataProvider.h>
-#include <protocols/secure_channel/PASESession.h>
-#include <sparcommon.h>
-#include <stdio.h>
-#include <wiced_led_manager.h>
-#include <wiced_memory.h>
-#include <wiced_platform.h>
-
-using chip::app::Clusters::DoorLock::DlLockState;
-using chip::app::Clusters::DoorLock::OperationErrorEnum;
-using chip::app::Clusters::DoorLock::OperationSourceEnum;
-
-using namespace chip;
-using namespace chip::app;
-using namespace ::chip::DeviceLayer::Internal;
-
-using namespace ::chip::Credentials;
-using namespace ::chip::DeviceLayer;
-using namespace ::chip::Shell;
-using namespace CYW30739DoorLock::LockInitParams;
-
-wiced_bool_t syncClusterToButtonAction = false;
-
-static chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider;
-static FactoryDataProvider sFactoryDataProvider;
-
-static void InitApp(intptr_t args);
-static void ActionInitiated(LockManager::Action_t aAction, int32_t aActor);
-static void ActionCompleted(LockManager::Action_t aAction);
-static void UpdateClusterState(intptr_t context);
-
-#ifndef _countof
-#define _countof(a) (sizeof(a) / sizeof(a[0]))
-#endif
-
-// NOTE! This key is for test/certification only and should not be available in production devices!
-uint8_t sTestEventTriggerEnableKey[chip::TestEventTriggerDelegate::kEnableKeyLength] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55,
- 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb,
- 0xcc, 0xdd, 0xee, 0xff };
-
-static wiced_led_config_t chip_lighting_led_config[2] = {
- {
- .led = PLATFORM_LED_1,
- .bright = 50,
- },
- {
- .led = PLATFORM_LED_2,
- .bright = 50,
- },
-};
-
-static Identify gIdentify = {
- chip::EndpointId{ 1 },
- [](Identify *) { ChipLogProgress(Zcl, "onIdentifyStart"); },
- [](Identify *) { ChipLogProgress(Zcl, "onIdentifyStop"); },
- Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator,
-};
-
-APPLICATION_START()
-{
- CHIP_ERROR err;
- wiced_result_t result;
- uint32_t i;
-
- ChipLogProgress(Zcl, "ChipLock App starting");
-
- mbedtls_platform_set_calloc_free(CHIPPlatformMemoryCalloc, CHIPPlatformMemoryFree);
-
- err = chip::Platform::MemoryInit();
- if (err != CHIP_NO_ERROR)
- {
- ChipLogError(Zcl, "ERROR MemoryInit %ld", err.AsInteger());
- }
-
- result = app_button_init();
- if (result != WICED_SUCCESS)
- {
- ChipLogError(Zcl, "ERROR app_button_init %d", result);
- }
-
- /* Init. LED Manager. */
- for (i = 0; i < _countof(chip_lighting_led_config); i++)
- {
- result = wiced_led_manager_init(&chip_lighting_led_config[i]);
- if (result != WICED_SUCCESS)
- ChipLogError(Zcl, "wiced_led_manager_init fail i=%ld, (%d)", i, result);
- }
-
- ChipLogProgress(Zcl, "Initializing CHIP");
- err = PlatformMgr().InitChipStack();
- if (err != CHIP_NO_ERROR)
- {
- ChipLogError(Zcl, "ERROR InitChipStack %ld", err.AsInteger());
- }
-
-#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
- ChipLogProgress(Zcl, "Initializing OpenThread stack");
- err = ThreadStackMgr().InitThreadStack();
- if (err != CHIP_NO_ERROR)
- {
- ChipLogError(Zcl, "ERROR InitThreadStack %ld", err.AsInteger());
- }
-#endif
-
-#if CHIP_DEVICE_CONFIG_THREAD_FTD
- err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router);
-#else // !CHIP_DEVICE_CONFIG_THREAD_FTD
-#if CHIP_DEVICE_CONFIG_ENABLE_SED
- err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice);
-#else /* !CHIP_DEVICE_CONFIG_ENABLE_SED */
- err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice);
-#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */
-#endif // CHIP_DEVICE_CONFIG_THREAD_FTD
- if (err != CHIP_NO_ERROR)
- {
- printf("ERROR SetThreadDeviceType %ld\n", err.AsInteger());
- }
-
- ChipLogProgress(Zcl, "Starting event loop task");
- err = PlatformMgr().StartEventLoopTask();
- if (err != CHIP_NO_ERROR)
- {
- ChipLogError(Zcl, "ERROR StartEventLoopTask %ld", err.AsInteger());
- }
-
-#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
- ChipLogProgress(Zcl, "Starting thread task");
- err = ThreadStackMgr().StartThreadTask();
- if (err != CHIP_NO_ERROR)
- {
- ChipLogError(Zcl, "ERROR StartThreadTask %ld", err.AsInteger());
- }
-#endif
-
- PlatformMgr().ScheduleWork(InitApp, 0);
-
- const int ret = Engine::Root().Init();
- if (!chip::ChipError::IsSuccess(ret))
- {
- ChipLogError(Zcl, "ERROR Shell Init %d", ret);
- }
- RegisterAppShellCommands();
- Engine::Root().RunMainLoop();
-
- assert(!wiced_rtos_check_for_stack_overflow());
-}
-
-void InitApp(intptr_t args)
-{
- CHIP_ERROR err = CHIP_NO_ERROR;
- // Print QR Code URL
- PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE));
- /* Start CHIP datamodel server */
- static chip::SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{};
- static chip::OTATestEventTriggerHandler sOtaTestEventTriggerHandler{};
- VerifyOrDie(sTestEventTriggerDelegate.Init(chip::ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR);
- VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR);
- static chip::CommonCaseDeviceServerInitParams initParams;
- (void) initParams.InitializeStaticResourcesBeforeServerInit();
- initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
- gExampleDeviceInfoProvider.SetStorageDelegate(initParams.persistentStorageDelegate);
- chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider);
- chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams;
- nativeParams.lockCb = [] { ThreadStackMgr().LockThreadStack(); };
- nativeParams.unlockCb = [] { ThreadStackMgr().UnlockThreadStack(); };
- nativeParams.openThreadInstancePtr = chip::DeviceLayer::ThreadStackMgrImpl().OTInstance();
- initParams.endpointNativeParams = static_cast<void *>(&nativeParams);
- chip::Server::GetInstance().Init(initParams);
-
- SetDeviceAttestationCredentialsProvider(&sFactoryDataProvider);
-
- // Initial lock state
- chip::app::DataModel::Nullable<chip::app::Clusters::DoorLock::DlLockState> state;
- chip::EndpointId endpointId{ 1 };
- chip::DeviceLayer::PlatformMgr().LockChipStack();
- chip::app::Clusters::DoorLock::Attributes::LockState::Get(endpointId, state);
-
- uint8_t numberOfCredentialsPerUser = 0;
- if (!DoorLockServer::Instance().GetNumberOfCredentialsSupportedPerUser(endpointId, numberOfCredentialsPerUser))
- {
- ChipLogError(Zcl,
- "Unable to get number of credentials supported per user when initializing lock endpoint, defaulting to 5 "
- "[endpointId=%d]",
- endpointId);
- numberOfCredentialsPerUser = 5;
- }
-
- uint16_t numberOfUsers = 0;
- if (!DoorLockServer::Instance().GetNumberOfUserSupported(endpointId, numberOfUsers))
- {
- ChipLogError(Zcl,
- "Unable to get number of supported users when initializing lock endpoint, defaulting to 10 [endpointId=%d]",
- endpointId);
- numberOfUsers = 10;
- }
-
- uint8_t numberOfWeekdaySchedulesPerUser = 0;
- if (!DoorLockServer::Instance().GetNumberOfWeekDaySchedulesPerUserSupported(endpointId, numberOfWeekdaySchedulesPerUser))
- {
- ChipLogError(
- Zcl,
- "Unable to get number of supported weekday schedules when initializing lock endpoint, defaulting to 10 [endpointId=%d]",
- endpointId);
- numberOfWeekdaySchedulesPerUser = 10;
- }
-
- uint8_t numberOfYeardaySchedulesPerUser = 0;
- if (!DoorLockServer::Instance().GetNumberOfYearDaySchedulesPerUserSupported(endpointId, numberOfYeardaySchedulesPerUser))
- {
- ChipLogError(
- Zcl,
- "Unable to get number of supported yearday schedules when initializing lock endpoint, defaulting to 10 [endpointId=%d]",
- endpointId);
- numberOfYeardaySchedulesPerUser = 10;
- }
-
- uint8_t numberOfHolidaySchedules = 0;
- if (!DoorLockServer::Instance().GetNumberOfHolidaySchedulesSupported(endpointId, numberOfHolidaySchedules))
- {
- ChipLogError(
- Zcl,
- "Unable to get number of supported holiday schedules when initializing lock endpoint, defaulting to 10 [endpointId=%d]",
- endpointId);
- numberOfHolidaySchedules = 10;
- }
-
- chip::DeviceLayer::PlatformMgr().UnlockChipStack();
-
- err = LockMgr().Init(state,
- ParamBuilder()
- .SetNumberOfUsers(numberOfUsers)
- .SetNumberOfCredentialsPerUser(numberOfCredentialsPerUser)
- .SetNumberOfWeekdaySchedulesPerUser(numberOfWeekdaySchedulesPerUser)
- .SetNumberOfYeardaySchedulesPerUser(numberOfYeardaySchedulesPerUser)
- .SetNumberOfHolidaySchedules(numberOfHolidaySchedules)
- .GetLockParam());
-
- LockMgr().SetCallbacks(ActionInitiated, ActionCompleted);
-
- ConfigurationMgr().LogDeviceConfig();
-
-#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
- OTAConfig::Init();
-#endif
-}
-
-void ActionInitiated(LockManager::Action_t aAction, int32_t aActor)
-{
- // If the action has been initiated by the lock, update the bolt lock trait
- // and start flashing the LEDs rapidly to indicate action initiation.
- if (aAction == LockManager::LOCK_ACTION)
- {
- ChipLogDetail(Zcl, "Lock Action has been initiated");
- }
- else if (aAction == LockManager::UNLOCK_ACTION)
- {
- ChipLogDetail(Zcl, "Unlock Action has been initiated");
- }
-
- if (aActor == AppEvent::kEventType_Button)
- {
- syncClusterToButtonAction = true;
- }
-
- // Action initiated, update the light led
- if (aAction == LockManager::LOCK_ACTION)
- {
- ChipLogDetail(Zcl, "Lock Action has been initiated");
- wiced_led_manager_disable_led(PLATFORM_LED_2);
- }
- else if (aAction == LockManager::UNLOCK_ACTION)
- {
- ChipLogDetail(Zcl, "Unlock Action has been initiated");
- wiced_led_manager_enable_led(PLATFORM_LED_2);
- }
-}
-
-void UpdateClusterState(intptr_t context)
-{
- bool unlocked = LockMgr().NextState();
- DlLockState newState = unlocked ? DlLockState::kUnlocked : DlLockState::kLocked;
-
- OperationSourceEnum source = OperationSourceEnum::kUnspecified;
-
- // write the new lock value
- Protocols::InteractionModel::Status status = DoorLockServer::Instance().SetLockState(1, newState, source)
- ? Protocols::InteractionModel::Status::Success
- : Protocols::InteractionModel::Status::Failure;
-
- if (status != Protocols::InteractionModel::Status::Success)
- {
- ChipLogError(Zcl, "ERR: updating lock state %x", to_underlying(status));
- }
-}
-
-void ActionCompleted(LockManager::Action_t aAction)
-{
- // if the action has been completed by the lock, update the bolt lock trait.
- // Turn on the lock LED if in a LOCKED state OR
- // Turn off the lock LED if in an UNLOCKED state.
- if (aAction == LockManager::LOCK_ACTION)
- {
- ChipLogDetail(Zcl, "Lock Action has been completed");
- }
- else if (aAction == LockManager::UNLOCK_ACTION)
- {
- ChipLogDetail(Zcl, "Unlock Action has been completed");
- }
-
- if (syncClusterToButtonAction)
- {
- chip::DeviceLayer::PlatformMgr().ScheduleWork(UpdateClusterState, reinterpret_cast<intptr_t>(nullptr));
- syncClusterToButtonAction = false;
- }
-}
diff --git a/examples/ota-requestor-app/infineon/cyw30739/.gn b/examples/ota-requestor-app/infineon/cyw30739/.gn
deleted file mode 100644
index 90115e4..0000000
--- a/examples/ota-requestor-app/infineon/cyw30739/.gn
+++ /dev/null
@@ -1,28 +0,0 @@
-# Copyright (c) 2020 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.
-
-import("//build_overrides/build.gni")
-
-# The location of the build configuration file.
-buildconfig = "${build_root}/config/BUILDCONFIG.gn"
-
-# CHIP uses angle bracket includes.
-check_system_includes = true
-
-default_args = {
- target_cpu = "arm"
- target_os = "cyw30739"
-
- import("//args.gni")
-}
diff --git a/examples/ota-requestor-app/infineon/cyw30739/BUILD.gn b/examples/ota-requestor-app/infineon/cyw30739/BUILD.gn
deleted file mode 100644
index 3701330..0000000
--- a/examples/ota-requestor-app/infineon/cyw30739/BUILD.gn
+++ /dev/null
@@ -1,73 +0,0 @@
-# Copyright (c) 2020 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.
-
-import("//build_overrides/build.gni")
-import("//build_overrides/chip.gni")
-import("//build_overrides/cyw30739_sdk.gni")
-
-import("${cyw30739_sdk_build_root}/cyw30739_executable.gni")
-import("${cyw30739_sdk_build_root}/cyw30739_sdk.gni")
-
-cyw30739_project_dir =
- "${chip_root}/examples/ota-requestor-app/infineon/cyw30739"
-examples_plat_dir = "${chip_root}/examples/platform/infineon/cyw30739"
-
-declare_args() {
- setupPinCode = 20202021
- setupDiscriminator = 3840
-}
-
-cyw30739_sdk("sdk") {
- sources = [ "${cyw30739_project_dir}/include/CHIPProjectConfig.h" ]
-
- include_dirs = [
- "${cyw30739_project_dir}/include",
- "${examples_plat_dir}",
- ]
-
- defines = [
- "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
- "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}",
- ]
-}
-
-cyw30739_executable("ota_requestor_app") {
- output_name = "chip-cyw30739-ota-requestor-example.elf"
-
- sources = [ "src/main.cpp" ]
-
- deps = [
- ":sdk",
- "${chip_root}/examples/ota-requestor-app/ota-requestor-common",
- "${chip_root}/examples/shell/shell_common:shell_common",
- "${chip_root}/src/lib",
- ]
-
- include_dirs = [ "include" ]
-
- if (chip_enable_ota_requestor) {
- sources += [
- "${examples_plat_dir}/OTAConfig.cpp",
- "${examples_plat_dir}/OTAConfig.h",
- ]
- }
-}
-
-group("cyw30739") {
- deps = [ ":ota_requestor_app" ]
-}
-
-group("default") {
- deps = [ ":cyw30739" ]
-}
diff --git a/examples/ota-requestor-app/infineon/cyw30739/README.md b/examples/ota-requestor-app/infineon/cyw30739/README.md
deleted file mode 100644
index 629418c..0000000
--- a/examples/ota-requestor-app/infineon/cyw30739/README.md
+++ /dev/null
@@ -1,139 +0,0 @@
-# Matter CYW30739 OTA Requestor Example
-
-An example showing the use of the Matter OTA Requestor functionality on the
-Infineon CYW30739 platform.
-
----
-
-## Table of Contents
-
-- [CHIP CYW30739 OTA Requestor Example](#matter-cyw30739-ota-requestor-example)
- - [Introduction](#introduction)
- - [Building](#building)
- - [Flashing the Application](#flashing-the-application)
- - [Running the Complete Example](#running-the-complete-example)
-
----
-
-## Introduction
-
-The CYW30739 OTA Requestor example provides a baseline demonstration the Matter
-OTA Requestor functionality built with the Infineon Modustoolbox SDK. It can be
-controlled by a Matter controller over Thread network.
-
-The CYW30739 device can be commissioned over Bluetooth Low Energy where the
-device and the Matter controller will exchange security information with the
-Rendez-vous procedure. Target Thread Network information including the active
-dataset and CASE credentials are then provided.
-
-## Building
-
-- Build the example application:
-
- ```bash
- $ cd ~/connectedhomeip
- $ git submodule update --init
- $ ./scripts/examples/gn_build_example.sh examples/ota-requestor-app/infineon/cyw30739 out/ota-requestor-app
- ```
-
-- To delete generated executable, libraries and object files use:
-
- ```bash
- $ cd ~/connectedhomeip
- $ rm -rf ./out/
- ```
-
-- OR use GN/Ninja directly
-
- ```bash
- $ cd ~/connectedhomeip/examples/ota-requestor-app/infineon/cyw30739
- $ git submodule update --init
- $ source third_party/connectedhomeip/scripts/activate.sh
- $ gn gen out/debug
- $ ninja -C out/debug
- ```
-
-- To delete generated executable, libraries and object files use:
-
- ```bash
- $ cd ~/connectedhomeip/examples/ota-requestor-app/infineon/cyw30739
- $ rm -rf out/
- ```
-
-## Building Options
-
-### DAC / DAC Key / PAI Certificate / Certificate Declaration
-
-Infineon CYW30739 examples use test certifications, keys, and CD by default. For
-a production build, manufacturers can provision certifications, keys, and CD by
-the following arguments:
-
-- `matter_dac`, `matter_dac_key`, `matter_pai`, `matter_cd`
-
- ```bash
- $ ./scripts/examples/gn_build_example.sh examples/lighting-app/infineon/cyw30739 out/lighting-app \
- 'matter_dac="/path/to/dac.der"' \
- 'matter_dac_key="/path/to/dac_key.der"' \
- 'matter_pai="/path/to/pai.der"' \
- 'matter_cd="/path/to/cd.der"'
- ```
-
-## Flashing the Application
-
-### Enter Recovery Mode
-
-Put the CYW30739 in to the recovery mode before running the flash script.
-
-1. Press and hold the `RECOVERY` button on the board.
-2. Press and hold the `RESET` button on the board.
-3. Release the `RESET` button.
-4. After one second, release the `RECOVERY` button.
-
-### Run Flash Script
-
-- On the command line:
-
- ```bash
- $ cd ~/connectedhomeip/examples/ota-requestor-app/infineon/cyw30739
- $ python3 out/debug/chip-cyw30739-ota-requestor-example.flash.py
- ```
-
-## Running the Complete Example
-
-- It is assumed here that you already have an OpenThread border router
- configured and running. If not see the following guide
- [Openthread_border_router](https://github.com/project-chip/connectedhomeip/blob/master/docs/guides/openthread_border_router_pi.md)
- for more information on how to setup a border router on a raspberryPi.
-
- - Get the active dataset hex for the chip-tool.
- ```bash
- ot-ctl dataset active -x
- ```
-
-- You can provision and control the Chip device using the python controller,
- Chip tool standalone, Android or iOS app
-
- [Chip tool](https://github.com/project-chip/connectedhomeip/blob/master/examples/chip-tool/README.md)
-
- Here is an example with the chip tool:
-
- - Start a Linux OTA Provider.
-
- ```bash
- # Start the OTA provider server with an OTA binary file
- chip-ota-provider-app -f <path/to/ota/binary>
- ```
-
- - Setup the CYW30739 OTA Requestor the the Linux OTA Provider by the
- controller.
-
- ```bash
- # Pair the OTA Requestor
- chip-tool pairing ble-thread 1234 hex:0e080000000000000000000300000b35060004001fffe00208dead00beef00cafe0708fddead00beef000005108e11d8ea8ffaa875713699f59e8807e0030a4f70656e5468726561640102c2980410edc641eb63b100b87e90a9980959befc0c0402a0fff8 20202021 3840
-
- # Pair the OTA Provider
- chip-tool pairing onnetwork-vendor 4321 20202021 9050
-
- # Announce the OTA provider to the requestor
- chip-tool otasoftwareupdaterequestor announce-otaprovider 4321 9 0 0 1234 0
- ```
diff --git a/examples/ota-requestor-app/infineon/cyw30739/args.gni b/examples/ota-requestor-app/infineon/cyw30739/args.gni
deleted file mode 100644
index 6f4645a..0000000
--- a/examples/ota-requestor-app/infineon/cyw30739/args.gni
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright (c) 2020 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.
-
-import("//build_overrides/chip.gni")
-import("${chip_root}/config/standalone/args.gni")
-import("${chip_root}/src/platform/Infineon/CYW30739/args.gni")
-
-cyw30739_sdk_target = get_label_info(":sdk", "label_no_toolchain")
-
-chip_openthread_ftd = false
-enable_sleepy_device = false
-
-chip_enable_ota_requestor = true
diff --git a/examples/ota-requestor-app/infineon/cyw30739/build_overrides b/examples/ota-requestor-app/infineon/cyw30739/build_overrides
deleted file mode 120000
index ee19c06..0000000
--- a/examples/ota-requestor-app/infineon/cyw30739/build_overrides
+++ /dev/null
@@ -1 +0,0 @@
-../../../build_overrides/
\ No newline at end of file
diff --git a/examples/ota-requestor-app/infineon/cyw30739/include/CHIPProjectConfig.h b/examples/ota-requestor-app/infineon/cyw30739/include/CHIPProjectConfig.h
deleted file mode 100644
index 82a8899..0000000
--- a/examples/ota-requestor-app/infineon/cyw30739/include/CHIPProjectConfig.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- *
- * Copyright (c) 2020 Project CHIP Authors
- * Copyright (c) 2019 Google LLC.
- * All rights reserved.
- *
- * 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.
- */
-
-/**
- * @file
- * Example project configuration file for CHIP.
- *
- * This is a place to put application or project-specific overrides
- * to the default configuration values for general CHIP features.
- *
- */
-
-#pragma once
-
-// -------------------- Device Identification Configuration --------------------
-
-/* The VendorName attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME "Infineon"
-
-/* The VendorID attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0xFFF2
-
-/* The ProductName attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME "CYW30739 OTA Requestor App"
-
-/* The ProductID attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8002
-
-/* The HardwareVersionString attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING "30739"
-
-/* The HardwareVersion attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION 30739
-
-/* The SoftwareVersionString attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "TE7.5"
-
-/* The SoftwareVersion attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x0705
-
-/* The SerialNumber attribute of the Basic cluster. */
-#define CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER "TEST_SN"
-
-// -------------------- Test Configuration --------------------
-#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1
diff --git a/examples/ota-requestor-app/infineon/cyw30739/src/main.cpp b/examples/ota-requestor-app/infineon/cyw30739/src/main.cpp
deleted file mode 100644
index 14ce588..0000000
--- a/examples/ota-requestor-app/infineon/cyw30739/src/main.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- *
- * Copyright (c) 2021 Project CHIP Authors
- * Copyright (c) 2019 Google LLC.
- * All rights reserved.
- *
- * 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.
- */
-#include <platform/CHIPDeviceLayer.h>
-
-#include <ChipShellCollection.h>
-#include <OTAConfig.h>
-#include <app/server/Server.h>
-#include <credentials/examples/DeviceAttestationCredsExample.h>
-#include <inet/EndPointStateOpenThread.h>
-#include <lib/shell/Engine.h>
-#include <lib/support/CHIPPlatformMemory.h>
-#include <mbedtls/platform.h>
-#include <platform/Infineon/CYW30739/FactoryDataProvider.h>
-#include <protocols/secure_channel/PASESession.h>
-#include <sparcommon.h>
-#include <stdio.h>
-#include <wiced_memory.h>
-#include <wiced_platform.h>
-
-using namespace chip;
-using namespace chip::Credentials;
-using namespace chip::DeviceLayer;
-using namespace chip::Shell;
-
-static FactoryDataProvider sFactoryDataProvider;
-
-static void InitApp(intptr_t args);
-
-APPLICATION_START()
-{
- CHIP_ERROR err;
- wiced_result_t result;
-
- printf("\nOtaRequestor App starting\n");
-
- mbedtls_platform_set_calloc_free(CHIPPlatformMemoryCalloc, CHIPPlatformMemoryFree);
-
- err = Platform::MemoryInit();
- if (err != CHIP_NO_ERROR)
- {
- printf("ERROR MemoryInit %ld\n", err.AsInteger());
- }
-
- /* Init. LED Manager. */
- printf("Initializing CHIP\n");
- err = PlatformMgr().InitChipStack();
- if (err != CHIP_NO_ERROR)
- {
- printf("ERROR InitChipStack %ld\n", err.AsInteger());
- }
-
-#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
- printf("Initializing OpenThread stack\n");
- err = ThreadStackMgr().InitThreadStack();
- if (err != CHIP_NO_ERROR)
- {
- printf("ERROR InitThreadStack %ld\n", err.AsInteger());
- }
-#endif
-
-#if CHIP_DEVICE_CONFIG_THREAD_FTD
- err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router);
-#else // !CHIP_DEVICE_CONFIG_THREAD_FTD
-#if CHIP_DEVICE_CONFIG_ENABLE_SED
- err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice);
-#else /* !CHIP_DEVICE_CONFIG_ENABLE_SED */
- err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice);
-#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */
-#endif // CHIP_DEVICE_CONFIG_THREAD_FTD
- if (err != CHIP_NO_ERROR)
- {
- printf("ERROR SetThreadDeviceType %ld\n", err.AsInteger());
- }
-
- printf("Starting event loop task\n");
- err = PlatformMgr().StartEventLoopTask();
- if (err != CHIP_NO_ERROR)
- {
- printf("ERROR StartEventLoopTask %ld\n", err.AsInteger());
- }
-
-#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
- printf("Starting thread task\n");
- err = ThreadStackMgr().StartThreadTask();
- if (err != CHIP_NO_ERROR)
- {
- printf("ERROR StartThreadTask %ld\n", err.AsInteger());
- }
-#endif
-
- PlatformMgr().ScheduleWork(InitApp, 0);
-
- const int ret = Engine::Root().Init();
- if (!ChipError::IsSuccess(ret))
- {
- printf("ERROR Shell Init %d\n", ret);
- }
- Engine::Root().RunMainLoop();
-
- assert(!wiced_rtos_check_for_stack_overflow());
-}
-
-void InitApp(intptr_t args)
-{
- ConfigurationMgr().LogDeviceConfig();
-
- /* Start CHIP datamodel server */
- static chip::CommonCaseDeviceServerInitParams initParams;
- (void) initParams.InitializeStaticResourcesBeforeServerInit();
- chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams;
- nativeParams.lockCb = [] { ThreadStackMgr().LockThreadStack(); };
- nativeParams.unlockCb = [] { ThreadStackMgr().UnlockThreadStack(); };
- nativeParams.openThreadInstancePtr = chip::DeviceLayer::ThreadStackMgrImpl().OTInstance();
- initParams.endpointNativeParams = static_cast<void *>(&nativeParams);
- chip::Server::GetInstance().Init(initParams);
-
- SetDeviceAttestationCredentialsProvider(&sFactoryDataProvider);
-
- OTAConfig::Init();
-}
diff --git a/examples/ota-requestor-app/infineon/cyw30739/third_party/connectedhomeip b/examples/ota-requestor-app/infineon/cyw30739/third_party/connectedhomeip
deleted file mode 120000
index 3efed95..0000000
--- a/examples/ota-requestor-app/infineon/cyw30739/third_party/connectedhomeip
+++ /dev/null
@@ -1 +0,0 @@
-../../../../../
\ No newline at end of file
diff --git a/examples/platform/infineon/credentials/development/attestation/Matter-Development-DAC-1388-0001.p12 b/examples/platform/infineon/credentials/development/attestation/Matter-Development-DAC-1388-0001.p12
new file mode 100644
index 0000000..fb8f0e9
--- /dev/null
+++ b/examples/platform/infineon/credentials/development/attestation/Matter-Development-DAC-1388-0001.p12
Binary files differ
diff --git a/examples/platform/infineon/credentials/development/attestation/Matter-Development-DAC-1388-0002.p12 b/examples/platform/infineon/credentials/development/attestation/Matter-Development-DAC-1388-0002.p12
new file mode 100644
index 0000000..cf8bc38
--- /dev/null
+++ b/examples/platform/infineon/credentials/development/attestation/Matter-Development-DAC-1388-0002.p12
Binary files differ
diff --git a/examples/platform/infineon/credentials/development/attestation/Matter-Development-DAC-1388-0005.p12 b/examples/platform/infineon/credentials/development/attestation/Matter-Development-DAC-1388-0005.p12
new file mode 100644
index 0000000..b914556
--- /dev/null
+++ b/examples/platform/infineon/credentials/development/attestation/Matter-Development-DAC-1388-0005.p12
Binary files differ
diff --git a/examples/platform/infineon/credentials/development/attestation/Matter-Development-DAC-1388-0006.p12 b/examples/platform/infineon/credentials/development/attestation/Matter-Development-DAC-1388-0006.p12
new file mode 100644
index 0000000..15d1ab7
--- /dev/null
+++ b/examples/platform/infineon/credentials/development/attestation/Matter-Development-DAC-1388-0006.p12
Binary files differ
diff --git a/examples/platform/infineon/credentials/development/certification-declaration/Matter-Development-CD-1388-0001-0008.der b/examples/platform/infineon/credentials/development/certification-declaration/Matter-Development-CD-1388-0001-0008.der
new file mode 100644
index 0000000..35a1158
--- /dev/null
+++ b/examples/platform/infineon/credentials/development/certification-declaration/Matter-Development-CD-1388-0001-0008.der
Binary files differ
diff --git a/examples/lighting-app/infineon/cyw30739/include/AppShellCommands.h b/examples/platform/infineon/cyw30739/AppShellCommands.h
similarity index 100%
rename from examples/lighting-app/infineon/cyw30739/include/AppShellCommands.h
rename to examples/platform/infineon/cyw30739/AppShellCommands.h
diff --git a/examples/platform/infineon/cyw30739/BUILD.gn b/examples/platform/infineon/cyw30739/BUILD.gn
index 8390dd6..0673c55 100644
--- a/examples/platform/infineon/cyw30739/BUILD.gn
+++ b/examples/platform/infineon/cyw30739/BUILD.gn
@@ -13,6 +13,26 @@
# limitations under the License.
import("//build_overrides/chip.gni")
+import("//build_overrides/cyw30739_sdk.gni")
+
+import("${chip_root}/examples/platform/infineon/cyw30739/args.gni")
+import("${cyw30739_sdk_build_root}/cyw30739_sdk.gni")
+
+static_library("platform") {
+ sources = [
+ "LEDWidget.h",
+ "OTAConfig.h",
+ "main.cpp",
+ ]
+
+ public_configs = [ ":${target_name}-config" ]
+
+ deps = [ app_data_model ]
+}
+
+config("platform-config") {
+ include_dirs = [ "." ]
+}
config("chip_examples_project_config") {
include_dirs = [ "project_include" ]
diff --git a/examples/platform/infineon/cyw30739/LEDWidget.cpp b/examples/platform/infineon/cyw30739/LEDWidget.cpp
new file mode 100644
index 0000000..cfea4d6
--- /dev/null
+++ b/examples/platform/infineon/cyw30739/LEDWidget.cpp
@@ -0,0 +1,65 @@
+/*
+ *
+ * Copyright (c) 2021 Project CHIP Authors
+ * Copyright (c) 2019 Google LLC.
+ * All rights reserved.
+ *
+ * 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.
+ */
+
+#include "LEDWidget.h"
+
+#include <cycfg_pins.h>
+#include <stdio.h>
+
+LEDWidget LEDWidget::sLEDWidget;
+bool usr_LED1_OnOffStatus = false;
+
+void LEDWidget::Init(wiced_led_config_t * config, size_t count)
+{
+ const wiced_result_t result = wiced_led_manager_init(config, count);
+ if (result != WICED_SUCCESS)
+ printf("wiced_led_manager_init failed %d\n", result);
+}
+
+void LEDWidget::Set(bool state, wiced_led_t pin)
+{
+ DoSetLEDOnOff(state, pin);
+}
+
+void LEDWidget::Blink(wiced_led_t led_pin, uint32_t on_period_ms, uint32_t off_period_ms)
+{
+ wiced_led_manager_blink_led(led_pin, on_period_ms, off_period_ms);
+}
+
+bool LEDWidget::IsLEDOn(void)
+{
+ return usr_LED1_OnOffStatus;
+}
+
+void LEDWidget::DoSetLEDOnOff(bool state, wiced_led_t pin)
+{
+ if (pin == PLATFORM_LED_RED)
+ {
+ usr_LED1_OnOffStatus = state;
+ }
+
+ if (state)
+ {
+ wiced_led_manager_enable_led(pin);
+ }
+ else
+ {
+ wiced_led_manager_disable_led(pin);
+ }
+}
diff --git a/examples/light-switch-app/infineon/cyw30739/include/LightingManager.h b/examples/platform/infineon/cyw30739/LEDWidget.h
similarity index 70%
rename from examples/light-switch-app/infineon/cyw30739/include/LightingManager.h
rename to examples/platform/infineon/cyw30739/LEDWidget.h
index 21a3b38..67f4d56 100644
--- a/examples/light-switch-app/infineon/cyw30739/include/LightingManager.h
+++ b/examples/platform/infineon/cyw30739/LEDWidget.h
@@ -17,28 +17,24 @@
*/
#pragma once
-#include <lib/core/CHIPError.h>
#include <wiced_led_manager.h>
-class LightingManager
+class LEDWidget
{
public:
- wiced_result_t Init();
- void Set(bool state, uint8_t pin);
+ void Init(wiced_led_config_t * config, size_t count);
+ void Set(bool state, wiced_led_t pin);
void Blink(wiced_led_t led_pin, uint32_t on_period_ms, uint32_t off_period_ms);
- bool IsLightOn();
+ bool IsLEDOn();
private:
- void DoSetLEDOnOff(bool state, uint8_t pin);
-
- friend LightingManager & LightMgr(void);
-
+ void DoSetLEDOnOff(bool state, wiced_led_t pin);
+ friend LEDWidget & LEDWid(void);
bool usr_LED1_OnOffStatus;
-
- static LightingManager sLight;
+ static LEDWidget sLEDWidget;
};
-inline LightingManager & LightMgr(void)
+inline LEDWidget & LEDWid(void)
{
- return LightingManager::sLight;
+ return LEDWidget::sLEDWidget;
}
diff --git a/examples/platform/infineon/cyw30739/args.gni b/examples/platform/infineon/cyw30739/args.gni
index 4c1695e..3659eb4 100644
--- a/examples/platform/infineon/cyw30739/args.gni
+++ b/examples/platform/infineon/cyw30739/args.gni
@@ -17,3 +17,7 @@
chip_project_config_include = "<CHIPProjectConfig.h>"
chip_inet_project_config_include = "<CHIPProjectConfig.h>"
chip_system_project_config_include = "<CHIPProjectConfig.h>"
+
+declare_args() {
+ app_data_model = ""
+}
diff --git a/examples/platform/infineon/cyw30739/cyw30739_example.gni b/examples/platform/infineon/cyw30739/cyw30739_example.gni
new file mode 100644
index 0000000..df8e50e
--- /dev/null
+++ b/examples/platform/infineon/cyw30739/cyw30739_example.gni
@@ -0,0 +1,46 @@
+# Copyright (c) 2024 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.
+
+import("//build_overrides/chip.gni")
+import("//build_overrides/cyw30739_sdk.gni")
+
+import("${chip_root}/examples/platform/infineon/cyw30739/args.gni")
+
+cyw30739_example_dir = "${chip_root}/examples/platform/infineon/cyw30739"
+
+template("cyw30739_example") {
+ forward_variables_from(invoker, [ "board" ])
+
+ static_library(target_name) {
+ sources = [
+ "${cyw30739_example_dir}/LEDWidget.cpp",
+ "${cyw30739_example_dir}/OTAConfig.cpp",
+ "${cyw30739_example_dir}/matter_config.cpp",
+ ]
+
+ configs += [
+ "${matter_wpan_sdk_build_root}:emwin-config",
+ "${matter_wpan_sdk_build_root}:wpan_sdk-config",
+ ]
+
+ deps = [
+ "${chip_root}/examples/providers:device_info_provider",
+ "${chip_root}/examples/shell/shell_common:shell_common",
+ "${matter_wpan_sdk_build_root}:${board}",
+ app_data_model,
+ ]
+
+ public_deps = [ "${cyw30739_example_dir}:platform" ]
+ }
+}
diff --git a/examples/lock-app/infineon/cyw30739/include/AppShellCommands.h b/examples/platform/infineon/cyw30739/main.cpp
similarity index 70%
rename from examples/lock-app/infineon/cyw30739/include/AppShellCommands.h
rename to examples/platform/infineon/cyw30739/main.cpp
index 575d6c2..71689ca 100644
--- a/examples/lock-app/infineon/cyw30739/include/AppShellCommands.h
+++ b/examples/platform/infineon/cyw30739/main.cpp
@@ -1,6 +1,6 @@
/*
*
- * Copyright (c) 2021 Project CHIP Authors
+ * Copyright (c) 2022 Project CHIP Authors
* Copyright (c) 2019 Google LLC.
* All rights reserved.
*
@@ -16,7 +16,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <matter_config.h>
+#include <sparcommon.h>
+#include <stdio.h>
-#pragma once
+APPLICATION_START()
+{
+ printf("\nApp starting\n");
-void RegisterAppShellCommands();
+ if (CYW30739MatterConfig::InitMatter() != CHIP_NO_ERROR)
+ printf("\nERROR InitMatter\n");
+}
diff --git a/examples/platform/infineon/cyw30739/matter_config.cpp b/examples/platform/infineon/cyw30739/matter_config.cpp
new file mode 100644
index 0000000..6b0b567
--- /dev/null
+++ b/examples/platform/infineon/cyw30739/matter_config.cpp
@@ -0,0 +1,227 @@
+/*
+ *
+ * Copyright (c) 2022 Project CHIP Authors
+ * Copyright (c) 2019 Google LLC.
+ * All rights reserved.
+ *
+ * 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.
+ */
+
+#include "matter_config.h"
+#include "AppTask.h"
+#ifdef BOARD_ENABLE_DISPLAY
+#include "GUI.h"
+#endif
+#include "cy_serial_flash.h"
+#include <AppShellCommands.h>
+#include <ChipShellCollection.h>
+#include <DeviceInfoProviderImpl.h>
+#include <LEDWidget.h>
+#include <cycfg_pins.h>
+#include <matter_config.h>
+#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
+#include <OTAConfig.h>
+#endif
+#ifdef BOARD_ENABLE_I2C
+#include "wiced_hal_i2c.h"
+#endif
+#include <app/clusters/ota-requestor/OTATestEventTriggerHandler.h>
+#include <app/server/OnboardingCodesUtil.h>
+#include <app/server/Server.h>
+#include <credentials/examples/DeviceAttestationCredsExample.h>
+#include <inet/EndPointStateOpenThread.h>
+#include <lib/shell/Engine.h>
+#include <lib/support/CHIPPlatformMemory.h>
+#include <mbedtls/platform.h>
+#include <platform/DeviceInstanceInfoProvider.h>
+#include <platform/Infineon/CYW30739/FactoryDataProvider.h>
+#include <platform/KeyValueStoreManager.h>
+#include <protocols/secure_channel/PASESession.h>
+#ifdef BOARD_ENABLE_OPTIGA
+#include "wiced_optiga.h"
+#endif
+#include <wiced_rtos.h>
+
+using namespace ::chip;
+using namespace ::chip::Inet;
+using namespace ::chip::Credentials;
+using namespace ::chip::DeviceLayer;
+using namespace ::chip::Shell;
+using namespace ::chip::app;
+
+static DeviceInfoProviderImpl sExampleDeviceInfoProvider;
+static FactoryDataProvider sFactoryDataProvider;
+
+// NOTE! This key is for test/certification only and should not be available in production devices!
+uint8_t sTestEventTriggerEnableKey[chip::TestEventTriggerDelegate::kEnableKeyLength] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55,
+ 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb,
+ 0xcc, 0xdd, 0xee, 0xff };
+
+void __attribute__((weak)) AppChipEventHandler(const chip::DeviceLayer::ChipDeviceEvent * aEvent, intptr_t arg)
+{
+ (void) aEvent;
+ (void) arg;
+}
+
+void __attribute__((weak)) RegisterAppShellCommands();
+
+#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
+void LockOpenThreadTask(void)
+{
+ ThreadStackMgr().LockThreadStack();
+}
+
+void UnlockOpenThreadTask(void)
+{
+ ThreadStackMgr().UnlockThreadStack();
+}
+
+CHIP_ERROR CYW30739MatterConfig::InitOpenThread(void)
+{
+ CHIP_ERROR err;
+
+ ReturnLogErrorOnFailure(ThreadStackMgr().InitThreadStack());
+
+#if CHIP_DEVICE_CONFIG_THREAD_FTD
+ err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router);
+#else // !CHIP_DEVICE_CONFIG_THREAD_FTD
+#if CHIP_CONFIG_ENABLE_ICD_SERVER
+ err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice);
+#else /* !CHIP_CONFIG_ENABLE_ICD_SERVER */
+ err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice);
+#endif /* CHIP_CONFIG_ENABLE_ICD_SERVER */
+#endif // CHIP_DEVICE_CONFIG_THREAD_FTD
+ if (err != CHIP_NO_ERROR)
+ {
+ printf("ERROR SetThreadDeviceType %ld\n", err.AsInteger());
+ }
+
+ printf("Starting thread task\n");
+ ReturnLogErrorOnFailure(ThreadStackMgr().StartThreadTask());
+
+ return err;
+}
+#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD
+
+void CYW30739MatterConfig::InitShell(void)
+{
+ const int ret = Engine::Root().Init();
+ if (!chip::ChipError::IsSuccess(ret))
+ {
+ printf("ERROR Shell Init %d\n", ret);
+ }
+ RegisterAppShellCommands();
+ Engine::Root().RunMainLoop();
+}
+
+void CYW30739MatterConfig::InitBoard(void)
+{
+#ifdef BOARD_ENABLE_I2C
+ /* Init. I2C interface. */
+ wiced_hal_i2c_select_pads(PLATFORM_I2C_1_SCL, PLATFORM_I2C_1_SDA);
+ wiced_hal_i2c_init();
+ wiced_hal_i2c_set_speed(I2CM_SPEED_400KHZ);
+#endif
+#ifdef BOARD_ENABLE_DISPLAY
+ GUI_Init();
+#endif
+#ifdef BOARD_ENABLE_OPTIGA
+ wiced_optiga_init();
+#endif
+}
+
+CHIP_ERROR CYW30739MatterConfig::InitMatter(void)
+{
+ InitBoard();
+
+#ifdef MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT
+ mbedtls_platform_setup(NULL);
+#endif
+ mbedtls_platform_set_calloc_free(CHIPPlatformMemoryCalloc, CHIPPlatformMemoryFree);
+
+ // Init Chip memory management before the stack
+ ReturnLogErrorOnFailure(chip::Platform::MemoryInit());
+
+ printf("Initializing CHIP\n");
+ ReturnLogErrorOnFailure(PlatformMgr().InitChipStack());
+
+ SetCommissionableDataProvider(&sFactoryDataProvider);
+ SetDeviceInstanceInfoProvider(&sFactoryDataProvider);
+ SetDeviceAttestationCredentialsProvider(&sFactoryDataProvider);
+
+#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
+ printf("Initializing OpenThread stack\n");
+ ReturnLogErrorOnFailure(InitOpenThread());
+#endif
+
+ PlatformMgr().ScheduleWork(AppTaskMain, 0);
+
+ // Add CHIP event handler and start CHIP thread.
+ // Note that all the initialization code should happen prior to this point to avoid data races
+ // between the main and the CHIP threads.
+ PlatformMgr().AddEventHandler(AppChipEventHandler, 0);
+
+ printf("Starting event loop task\n");
+ ReturnLogErrorOnFailure(PlatformMgr().StartEventLoopTask());
+
+ InitShell();
+
+ assert(!wiced_rtos_check_for_stack_overflow());
+
+ return CHIP_NO_ERROR;
+}
+
+void CYW30739MatterConfig::InitApp(void)
+{
+ LogAppInit();
+ ConfigurationMgr().LogDeviceConfig();
+
+ // Print QR Code URL
+ PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE));
+ /* Start CHIP datamodel server */
+ static chip::SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{};
+ static chip::OTATestEventTriggerHandler sOtaTestEventTriggerHandler{};
+ VerifyOrDie(sTestEventTriggerDelegate.Init(chip::ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR);
+ VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR);
+ // Create initParams with SDK example defaults here
+ static chip::CommonCaseDeviceServerInitParams initParams;
+ (void) initParams.InitializeStaticResourcesBeforeServerInit();
+ initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
+ sExampleDeviceInfoProvider.SetStorageDelegate(initParams.persistentStorageDelegate);
+ SetDeviceInfoProvider(&sExampleDeviceInfoProvider);
+
+#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
+ // Set up OpenThread configuration when OpenThread is included
+ chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams;
+ nativeParams.lockCb = [] { ThreadStackMgr().LockThreadStack(); };
+ nativeParams.unlockCb = [] { ThreadStackMgr().UnlockThreadStack(); };
+ nativeParams.openThreadInstancePtr = ThreadStackMgrImpl().OTInstance();
+ initParams.endpointNativeParams = static_cast<void *>(&nativeParams);
+#endif
+
+ // Init Matter Server
+ chip::Server::GetInstance().Init(initParams);
+
+#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
+ OTAConfig::Init();
+#endif
+}
+
+void CYW30739MatterConfig::LogAppInit(void)
+{
+ char productName[ConfigurationManager::kMaxProductNameLength + 1];
+ if (CHIP_NO_ERROR == GetDeviceInstanceInfoProvider()->GetProductName(productName, sizeof(productName)))
+ {
+ printf("Initializing %s\n", productName);
+ }
+}
diff --git a/examples/lock-app/infineon/cyw30739/include/AppShellCommands.h b/examples/platform/infineon/cyw30739/matter_config.h
similarity index 65%
copy from examples/lock-app/infineon/cyw30739/include/AppShellCommands.h
copy to examples/platform/infineon/cyw30739/matter_config.h
index 575d6c2..a8df274 100644
--- a/examples/lock-app/infineon/cyw30739/include/AppShellCommands.h
+++ b/examples/platform/infineon/cyw30739/matter_config.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright (c) 2021 Project CHIP Authors
+ * Copyright (c) 2022 Project CHIP Authors
* Copyright (c) 2019 Google LLC.
* All rights reserved.
*
@@ -16,7 +16,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
#pragma once
-void RegisterAppShellCommands();
+#include <lib/core/CHIPError.h>
+class CYW30739MatterConfig
+{
+public:
+ static CHIP_ERROR InitMatter(void);
+ static void InitApp(void);
+
+private:
+ static CHIP_ERROR InitOpenThread(void);
+ static void LogAppInit(void);
+ static void InitShell(void);
+ static void InitBoard(void);
+};
diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py
index 9eb2ebf..ece157d 100755
--- a/scripts/build/build/targets.py
+++ b/scripts/build/build/targets.py
@@ -537,15 +537,18 @@
target = BuildTarget('cyw30739', Cyw30739Builder)
# board
target.AppendFixedTargets([
+ TargetPart('cyw30739b2_p5_evk_01', board=Cyw30739Board.CYW30739B2_P5_EVK_01),
+ TargetPart('cyw30739b2_p5_evk_02', board=Cyw30739Board.CYW30739B2_P5_EVK_02),
+ TargetPart('cyw30739b2_p5_evk_03', board=Cyw30739Board.CYW30739B2_P5_EVK_03),
TargetPart('cyw930739m2evb_01', board=Cyw30739Board.CYW930739M2EVB_01),
+ TargetPart('cyw930739m2evb_02', board=Cyw30739Board.CYW930739M2EVB_02),
])
# apps
target.AppendFixedTargets([
TargetPart('light', app=Cyw30739App.LIGHT),
+ TargetPart('light-switch', app=Cyw30739App.LIGHT_SWITCH),
TargetPart('lock', app=Cyw30739App.LOCK),
- TargetPart('ota-requestor', app=Cyw30739App.OTA_REQUESTOR),
- TargetPart('switch', app=Cyw30739App.SWITCH),
])
return target
diff --git a/scripts/build/builders/cyw30739.py b/scripts/build/builders/cyw30739.py
index 722a075..41bfecc 100644
--- a/scripts/build/builders/cyw30739.py
+++ b/scripts/build/builders/cyw30739.py
@@ -20,44 +20,44 @@
class Cyw30739App(Enum):
LIGHT = auto()
+ LIGHT_SWITCH = auto()
LOCK = auto()
- OTA_REQUESTOR = auto()
- SWITCH = auto()
def ExampleName(self):
if self == Cyw30739App.LIGHT:
return "lighting-app"
+ elif self == Cyw30739App.LIGHT_SWITCH:
+ return "light-switch-app"
elif self == Cyw30739App.LOCK:
return "lock-app"
- elif self == Cyw30739App.OTA_REQUESTOR:
- return "ota-requestor-app"
- elif self == Cyw30739App.SWITCH:
- return "light-switch-app"
else:
raise Exception("Unknown app type: %r" % self)
def AppNamePrefix(self):
- if self == Cyw30739App.LIGHT:
- return "chip-cyw30739-lighting-example"
- elif self == Cyw30739App.LOCK:
- return "chip-cyw30739-lock-example"
- elif self == Cyw30739App.OTA_REQUESTOR:
- return "chip-cyw30739-ota-requestor-example"
- elif self == Cyw30739App.SWITCH:
- return "chip-cyw30739-light-switch-example"
- else:
- raise Exception("Unknown app type: %r" % self)
+ return self.ExampleName().replace("-", "_")
def BuildRoot(self, root):
return os.path.join(root, "examples", self.ExampleName(), "infineon/cyw30739")
class Cyw30739Board(Enum):
- CYW930739M2EVB_01 = 1
+ CYW30739B2_P5_EVK_01 = auto()
+ CYW30739B2_P5_EVK_02 = auto()
+ CYW30739B2_P5_EVK_03 = auto()
+ CYW930739M2EVB_01 = auto()
+ CYW930739M2EVB_02 = auto()
def GnArgName(self):
- if self == Cyw30739Board.CYW930739M2EVB_01:
+ if self == Cyw30739Board.CYW30739B2_P5_EVK_01:
+ return "CYW30739B2-P5-EVK-01"
+ elif self == Cyw30739Board.CYW30739B2_P5_EVK_02:
+ return "CYW30739B2-P5-EVK-02"
+ elif self == Cyw30739Board.CYW30739B2_P5_EVK_03:
+ return "CYW30739B2-P5-EVK-03"
+ elif self == Cyw30739Board.CYW930739M2EVB_01:
return "CYW930739M2EVB-01"
+ elif self == Cyw30739Board.CYW930739M2EVB_02:
+ return "CYW930739M2EVB-02"
else:
raise Exception("Unknown board #: %r" % self)
@@ -68,7 +68,7 @@
root,
runner,
app: Cyw30739App = Cyw30739App.LIGHT,
- board: Cyw30739Board = Cyw30739Board.CYW930739M2EVB_01,
+ board: Cyw30739Board = Cyw30739Board.CYW30739B2_P5_EVK_01,
release: bool = False,
):
super(Cyw30739Builder, self).__init__(
@@ -76,6 +76,19 @@
self.app = app
self.board = board
self.release = release
+ self.build_command = f"{app.AppNamePrefix()}-{board.GnArgName()}"
+ self._output_dir = None
+
+ @property
+ def output_dir(self):
+ return self._output_dir
+
+ @output_dir.setter
+ def output_dir(self, value):
+ if hasattr(self, "board"):
+ board = self.board.GnArgName().lower().replace("-", "_")
+ value = value.replace(f"-{board}", "")
+ self._output_dir = value
def GnBuildArgs(self):
args = []
@@ -88,6 +101,6 @@
def build_outputs(self):
items = {}
for extension in ["elf", "elf.map"]:
- name = "%s.%s" % (self.app.AppNamePrefix(), extension)
+ name = "%s-%s.%s" % (self.app.AppNamePrefix(), self.board.GnArgName(), extension)
items[name] = os.path.join(self.output_dir, name)
return items
diff --git a/scripts/build/testdata/all_targets_linux_x64.txt b/scripts/build/testdata/all_targets_linux_x64.txt
index a1d6a46..4bd269b 100644
--- a/scripts/build/testdata/all_targets_linux_x64.txt
+++ b/scripts/build/testdata/all_targets_linux_x64.txt
@@ -4,7 +4,7 @@
bouffalolab-{bl602-iot-matter-v1,bl602-night-light,xt-zb6-devkit,bl706-night-light,bl706dk,bl704ldk}-light[-shell][-115200][-rpc][-cdc][-resetcnt][-rotating_device_id][-mfd][-mfdtest][-ethernet][-wifi][-thread][-fp][-memmonitor][-mot]
cc32xx-{lock,air-purifier}
ti-cc13x4_26x4-{all-clusters,lighting,lock,pump,pump-controller}[-mtd][-ftd]
-cyw30739-cyw930739m2evb_01-{light,lock,ota-requestor,switch}
+cyw30739-{cyw30739b2_p5_evk_01,cyw30739b2_p5_evk_02,cyw30739b2_p5_evk_03,cyw930739m2evb_01,cyw930739m2evb_02}-{light,light-switch,lock}
efr32-{brd4161a,brd4187c,brd4186c,brd4163a,brd4164a,brd4166a,brd4170a,brd4186a,brd4187a,brd4304a,brd4338a}-{window-covering,switch,unit-test,light,lock,thermostat,pump}[-rpc][-with-ota-requestor][-icd][-low-power][-shell][-no-logging][-openthread-mtd][-heap-monitoring][-no-openthread-cli][-show-qr-code][-wifi][-rs9116][-wf200][-siwx917][-ipv4][-additional-data-advertising][-use-ot-lib][-use-ot-coap-lib][-no-version][-skip-rps-generation]
esp32-{m5stack,c3devkit,devkitc,qemu}-{all-clusters,all-clusters-minimal,energy-management,ota-provider,ota-requestor,shell,light,lock,bridge,temperature-measurement,ota-requestor,tests}[-rpc][-ipv6only][-tracing]
genio-lighting-app
diff --git a/scripts/flashing/cyw30739_firmware_utils.py b/scripts/flashing/cyw30739_firmware_utils.py
index 0b671bf..b741c25 100644
--- a/scripts/flashing/cyw30739_firmware_utils.py
+++ b/scripts/flashing/cyw30739_firmware_utils.py
@@ -19,6 +19,7 @@
For `Flasher`, see the class documentation.
"""
+import pathlib
import sys
import firmware_utils
@@ -43,17 +44,37 @@
"default": None,
"argparse": {"action": "store"},
},
+ "hci_id": {
+ "help": "The HCI ID file.",
+ "default": None,
+ "argparse": {"type": pathlib.Path},
+ },
+ "btp": {
+ "help": "The BTP file.",
+ "default": None,
+ "argparse": {"type": pathlib.Path},
+ },
+ "minidriver": {
+ "help": "The minidriver.",
+ "default": None,
+ "argparse": {"type": pathlib.Path},
+ },
+ "flags": {
+ "help": "The additional flags file.",
+ "default": None,
+ "argparse": {"type": pathlib.Path},
+ },
"program": {
"help": "The script to program the flash.",
"command": [
- "bash",
- "--norc",
- "--noprofile",
- "{sdk_scripts_dir}/bt_program.bash",
- "--tools={sdk_tools_dir}",
- "--scripts={sdk_scripts_dir}",
- "--elf={application}",
- "--direct={direct}",
+ "perl",
+ "{sdk_scripts_dir}/ChipLoad.pl",
+ "-tools_path", "{sdk_tools_dir}",
+ "-id", "{hci_id}",
+ "-btp", "{btp}",
+ "-mini", "{minidriver}",
+ "-flags", "{flags}",
+ "-direct", "{direct}",
(),
],
},
@@ -65,6 +86,18 @@
},
}
+FLASH_SUCCESS_MESSAGES = "Download succeeded."
+FLASH_FAIL_MESSAGES = """Download failed.
+
+If the serial port was not detected, make sure no other program such as ClientControl has the port open.
+
+If you have issues downloading to the kit, follow the steps below:
+
+Press and hold the 'Recover' button on the kit.
+Press and hold the 'Reset' button on the kit.
+Release the 'Reset' button.
+After one second, release the 'Recover' button."""
+
class Flasher(firmware_utils.Flasher):
"""Manage CYW30739 flashing."""
@@ -89,16 +122,13 @@
"""Flash image."""
arguments = [
- "--hex={}/{}_download.hex".format(
- self.option.application.parent, self.option.application.stem
- ),
+ "-build_path", self.option.application.parent,
+ "-hex", self.option.application.with_suffix(".hex"),
]
if self.option.port:
- arguments.append("--uart={port}")
- if self.option.verbose > 0:
- arguments.append("--verbose")
+ arguments.extend(["-uart", "{port}"])
- return self.run_tool("program", arguments, name="Flash")
+ return self.run_tool("program", arguments, pass_message=FLASH_SUCCESS_MESSAGES, fail_message=FLASH_FAIL_MESSAGES)
def reset(self):
"""Not supported"""
diff --git a/src/lib/shell/streamer_cyw30739.cpp b/src/lib/shell/streamer_cyw30739.cpp
index 6c8e5ac..f2b3db1 100644
--- a/src/lib/shell/streamer_cyw30739.cpp
+++ b/src/lib/shell/streamer_cyw30739.cpp
@@ -18,8 +18,8 @@
#include <lib/core/CHIPSafeCasts.h>
#include <lib/shell/streamer.h>
#include <platform/PlatformManager.h>
+#include <wiced_hal_platform.h>
#include <wiced_hal_puart.h>
-#include <wiced_platform.h>
namespace chip {
namespace Shell {
diff --git a/src/platform/Infineon/CYW30739/BUILD.gn b/src/platform/Infineon/CYW30739/BUILD.gn
index 7da725e..7613847 100644
--- a/src/platform/Infineon/CYW30739/BUILD.gn
+++ b/src/platform/Infineon/CYW30739/BUILD.gn
@@ -13,6 +13,7 @@
# limitations under the License.
import("//build_overrides/chip.gni")
+import("//build_overrides/cyw30739_sdk.gni")
import("${chip_root}/src/platform/device.gni")
@@ -25,53 +26,38 @@
static_library("CYW30739") {
sources = [
"../../SingletonConfigurationManager.cpp",
- "BLEManagerImpl.cpp",
"BLEManagerImpl.h",
"BlePlatformConfig.h",
"CHIPDevicePlatformConfig.h",
"CHIPDevicePlatformEvent.h",
"CHIPPlatformConfig.h",
- "CYW30739Config.cpp",
- "CYW30739Config.h",
- "ConfigurationManagerImpl.cpp",
"ConfigurationManagerImpl.h",
"ConnectivityManagerImpl.cpp",
"ConnectivityManagerImpl.h",
- "DiagnosticDataProviderImpl.cpp",
- "DiagnosticDataProviderImpl.h",
- "EventFlags.cpp",
- "EventFlags.h",
"FactoryDataProvider.cpp",
"FactoryDataProvider.h",
"InetPlatformConfig.h",
"KeyValueStoreManagerImpl.cpp",
"KeyValueStoreManagerImpl.h",
- "Logging.cpp",
- "PlatformManagerImpl.cpp",
+ "OTAImageProcessorImpl.h",
"PlatformManagerImpl.h",
"SystemPlatformConfig.h",
- "SystemTimeSupport.cpp",
- "cycfg_gatt_db.c",
- "cycfg_gatt_db.h",
"cyw30739-chip-mbedtls-config.h",
]
- if (chip_enable_ota_requestor) {
- sources += [
- "OTAImageProcessorImpl.cpp",
- "OTAImageProcessorImpl.h",
- ]
- }
-
deps = [
"${chip_root}/src/crypto",
- "${chip_root}/src/platform/logging:headers",
+ "${matter_wpan_sdk_build_root}:wpan_sdk",
]
public = [
"${chip_root}/src/credentials/DeviceAttestationCredsProvider.h",
+ "CYW30739Config.h",
+ "DiagnosticDataProviderImpl.h",
+ "EventFlags.h",
"FactoryDataProvider.h",
"OTAImageProcessorImpl.h",
+ "cycfg_gatt_db.h",
]
public_deps = [ "${chip_root}/src/platform:platform_base" ]
@@ -79,7 +65,6 @@
if (chip_enable_openthread) {
sources += [
"../../OpenThread/OpenThreadUtils.cpp",
- "ThreadStackManagerImpl.cpp",
"ThreadStackManagerImpl.h",
]
diff --git a/src/platform/Infineon/CYW30739/CYW30739Config.cpp b/src/platform/Infineon/CYW30739/CYW30739Config.cpp
index 15438ce..1b50c56 100644
--- a/src/platform/Infineon/CYW30739/CYW30739Config.cpp
+++ b/src/platform/Infineon/CYW30739/CYW30739Config.cpp
@@ -45,7 +45,14 @@
CHIP_ERROR CYW30739Config::ReadConfigValueStr(Key key, char * buf, size_t bufSize, size_t & outLen)
{
- return ReadConfigValueBin(key, buf, bufSize, outLen);
+ const CHIP_ERROR err = ReadConfigValueBin(key, buf, bufSize, outLen);
+
+ if (outLen >= bufSize)
+ return CHIP_ERROR_BUFFER_TOO_SMALL;
+
+ buf[outLen] = '\0';
+
+ return err;
}
CHIP_ERROR CYW30739Config::ReadConfigValueBin(Key key, uint8_t * buf, size_t bufSize, size_t & outLen)
@@ -75,6 +82,7 @@
}
template CHIP_ERROR CYW30739Config::ReadConfigValue(Key key, bool & val);
+template CHIP_ERROR CYW30739Config::ReadConfigValue(Key key, uint16_t & val);
template CHIP_ERROR CYW30739Config::ReadConfigValue(Key key, uint32_t & val);
template CHIP_ERROR CYW30739Config::ReadConfigValue(Key key, uint64_t & val);
diff --git a/src/platform/Infineon/CYW30739/CYW30739Config.h b/src/platform/Infineon/CYW30739/CYW30739Config.h
index 80f0895..f5e56f0 100644
--- a/src/platform/Infineon/CYW30739/CYW30739Config.h
+++ b/src/platform/Infineon/CYW30739/CYW30739Config.h
@@ -54,21 +54,23 @@
// Key definitions for well-known keys.
// Factory config keys
- static constexpr Key kConfigKey_SerialNum = CYW30739ConfigKey(kChipFactory_KeyBase, 0x00);
- static constexpr Key kConfigKey_MfrDeviceId = CYW30739ConfigKey(kChipFactory_KeyBase, 0x01);
- static constexpr Key kConfigKey_MfrDeviceCert = CYW30739ConfigKey(kChipFactory_KeyBase, 0x02);
- static constexpr Key kConfigKey_MfrDevicePrivateKey = CYW30739ConfigKey(kChipFactory_KeyBase, 0x03);
- static constexpr Key kConfigKey_ManufacturingDate = CYW30739ConfigKey(kChipFactory_KeyBase, 0x04);
- static constexpr Key kConfigKey_SetupPinCode = CYW30739ConfigKey(kChipFactory_KeyBase, 0x05);
- static constexpr Key kConfigKey_MfrDeviceICACerts = CYW30739ConfigKey(kChipFactory_KeyBase, 0x06);
- static constexpr Key kConfigKey_SetupDiscriminator = CYW30739ConfigKey(kChipFactory_KeyBase, 0x07);
- static constexpr Key kConfigKey_Spake2pIterationCount = CYW30739ConfigKey(kChipFactory_KeyBase, 0x08);
- static constexpr Key kConfigKey_Spake2pSalt = CYW30739ConfigKey(kChipFactory_KeyBase, 0x09);
- static constexpr Key kConfigKey_Spake2pVerifier = CYW30739ConfigKey(kChipFactory_KeyBase, 0x0a);
- static constexpr Key kConfigKey_DAC = CYW30739ConfigKey(kChipFactory_KeyBase, 0x0b);
- static constexpr Key kConfigKey_DACKey = CYW30739ConfigKey(kChipFactory_KeyBase, 0x0c);
- static constexpr Key kConfigKey_PAICert = CYW30739ConfigKey(kChipFactory_KeyBase, 0x0d);
- static constexpr Key kConfigKey_CertDeclaration = CYW30739ConfigKey(kChipFactory_KeyBase, 0x0e);
+ static constexpr Key kConfigKey_VendorName = CYW30739ConfigKey(kChipFactory_KeyBase, 0x00);
+ static constexpr Key kConfigKey_VendorId = CYW30739ConfigKey(kChipFactory_KeyBase, 0x01);
+ static constexpr Key kConfigKey_ProductName = CYW30739ConfigKey(kChipFactory_KeyBase, 0x02);
+ static constexpr Key kConfigKey_ProductId = CYW30739ConfigKey(kChipFactory_KeyBase, 0x03);
+ static constexpr Key kConfigKey_SerialNum = CYW30739ConfigKey(kChipFactory_KeyBase, 0x04);
+ static constexpr Key kConfigKey_ManufacturingDate = CYW30739ConfigKey(kChipFactory_KeyBase, 0x05);
+ static constexpr Key kConfigKey_HardwareVersion = CYW30739ConfigKey(kChipFactory_KeyBase, 0x06);
+ static constexpr Key kConfigKey_HardwareVersionString = CYW30739ConfigKey(kChipFactory_KeyBase, 0x07);
+ static constexpr Key kConfigKey_SetupPinCode = CYW30739ConfigKey(kChipFactory_KeyBase, 0x10);
+ static constexpr Key kConfigKey_SetupDiscriminator = CYW30739ConfigKey(kChipFactory_KeyBase, 0x11);
+ static constexpr Key kConfigKey_Spake2pIterationCount = CYW30739ConfigKey(kChipFactory_KeyBase, 0x12);
+ static constexpr Key kConfigKey_Spake2pSalt = CYW30739ConfigKey(kChipFactory_KeyBase, 0x13);
+ static constexpr Key kConfigKey_Spake2pVerifier = CYW30739ConfigKey(kChipFactory_KeyBase, 0x14);
+ static constexpr Key kConfigKey_DAC = CYW30739ConfigKey(kChipFactory_KeyBase, 0x20);
+ static constexpr Key kConfigKey_DACKey = CYW30739ConfigKey(kChipFactory_KeyBase, 0x21);
+ static constexpr Key kConfigKey_PAICert = CYW30739ConfigKey(kChipFactory_KeyBase, 0x22);
+ static constexpr Key kConfigKey_CertDeclaration = CYW30739ConfigKey(kChipFactory_KeyBase, 0x23);
// CHIP Config Keys
static constexpr Key kConfigKey_ServiceConfig = CYW30739ConfigKey(kChipConfig_KeyBase, 0x00);
static constexpr Key kConfigKey_PairedAccountId = CYW30739ConfigKey(kChipConfig_KeyBase, 0x01);
@@ -76,7 +78,6 @@
static constexpr Key kConfigKey_LastUsedEpochKeyId = CYW30739ConfigKey(kChipConfig_KeyBase, 0x03);
static constexpr Key kConfigKey_FailSafeArmed = CYW30739ConfigKey(kChipConfig_KeyBase, 0x04);
static constexpr Key kConfigKey_GroupKey = CYW30739ConfigKey(kChipConfig_KeyBase, 0x05);
- static constexpr Key kConfigKey_HardwareVersion = CYW30739ConfigKey(kChipConfig_KeyBase, 0x06);
static constexpr Key kConfigKey_RegulatoryLocation = CYW30739ConfigKey(kChipConfig_KeyBase, 0x07);
static constexpr Key kConfigKey_CountryCode = CYW30739ConfigKey(kChipConfig_KeyBase, 0x08);
static constexpr Key kConfigKey_RebootCount = CYW30739ConfigKey(kChipConfig_KeyBase, 0x09);
diff --git a/src/platform/Infineon/CYW30739/EventFlags.cpp b/src/platform/Infineon/CYW30739/EventFlags.cpp
index 4a29984..4b6b5d8 100644
--- a/src/platform/Infineon/CYW30739/EventFlags.cpp
+++ b/src/platform/Infineon/CYW30739/EventFlags.cpp
@@ -44,15 +44,12 @@
return err;
}
-CHIP_ERROR EventFlags::Set(uint32_t flags)
+__attribute__((section(".text_in_ram"))) CHIP_ERROR EventFlags::Set(uint32_t flags)
{
assert(!wiced_rtos_check_for_stack_overflow());
- if (wiced_rtos_set_event_flags(mFlags, flags) != WICED_SUCCESS)
- {
- ChipLogError(DeviceLayer, "wiced_rtos_set_event_flags %08lx", flags);
- return CHIP_ERROR_INTERNAL;
- }
+ assert(wiced_rtos_set_event_flags(mFlags, flags) == WICED_SUCCESS);
+
return CHIP_NO_ERROR;
}
diff --git a/src/platform/Infineon/CYW30739/FactoryDataProvider.cpp b/src/platform/Infineon/CYW30739/FactoryDataProvider.cpp
index 0c33a27..0ece03d 100644
--- a/src/platform/Infineon/CYW30739/FactoryDataProvider.cpp
+++ b/src/platform/Infineon/CYW30739/FactoryDataProvider.cpp
@@ -25,6 +25,54 @@
using namespace chip::DeviceLayer::Internal;
+/*
+ * Members functions that implement the CommissionableDataProvider
+ */
+CHIP_ERROR FactoryDataProvider::GetSetupDiscriminator(uint16_t & setupDiscriminator)
+{
+ return CYW30739Config::ReadConfigValue(CYW30739Config::kConfigKey_SetupDiscriminator, setupDiscriminator);
+}
+
+CHIP_ERROR FactoryDataProvider::SetSetupDiscriminator(uint16_t setupDiscriminator)
+{
+ return CHIP_ERROR_NOT_IMPLEMENTED;
+}
+
+CHIP_ERROR FactoryDataProvider::GetSpake2pIterationCount(uint32_t & iterationCount)
+{
+ return CYW30739Config::ReadConfigValue(CYW30739Config::kConfigKey_Spake2pIterationCount, iterationCount);
+}
+
+CHIP_ERROR FactoryDataProvider::GetSpake2pSalt(MutableByteSpan & saltBuf)
+{
+ size_t read_size;
+ ReturnErrorOnFailure(
+ CYW30739Config::ReadConfigValueBin(CYW30739Config::kConfigKey_Spake2pSalt, saltBuf.data(), saltBuf.size(), read_size));
+ saltBuf.reduce_size(read_size);
+ return CHIP_NO_ERROR;
+}
+
+CHIP_ERROR FactoryDataProvider::GetSpake2pVerifier(MutableByteSpan & verifierBuf, size_t & outVerifierLen)
+{
+ ReturnErrorOnFailure(CYW30739Config::ReadConfigValueBin(CYW30739Config::kConfigKey_Spake2pVerifier, verifierBuf.data(),
+ verifierBuf.size(), outVerifierLen));
+ verifierBuf.reduce_size(outVerifierLen);
+ return CHIP_NO_ERROR;
+}
+
+CHIP_ERROR FactoryDataProvider::GetSetupPasscode(uint32_t & setupPasscode)
+{
+ return CYW30739Config::ReadConfigValue(CYW30739Config::kConfigKey_SetupPinCode, setupPasscode);
+}
+
+CHIP_ERROR FactoryDataProvider::SetSetupPasscode(uint32_t setupPasscode)
+{
+ return CHIP_ERROR_NOT_IMPLEMENTED;
+}
+
+/*
+ * Members functions that implement the DeviceAttestationCredentialsProvider
+ */
CHIP_ERROR FactoryDataProvider::GetCertificationDeclaration(MutableByteSpan & out_cd_buffer)
{
size_t read_size;
@@ -77,6 +125,90 @@
return CopySpanToMutableSpan(ByteSpan{ signature.ConstBytes(), signature.Length() }, out_signature_buffer);
}
+/*
+ * Members functions that implement the DeviceInstanceInfoProvider
+ */
+CHIP_ERROR FactoryDataProvider::GetVendorName(char * buf, size_t bufSize)
+{
+ size_t read_size;
+ return CYW30739Config::ReadConfigValueStr(CYW30739Config::kConfigKey_VendorName, buf, bufSize, read_size);
+}
+
+CHIP_ERROR FactoryDataProvider::GetVendorId(uint16_t & vendorId)
+{
+ return CYW30739Config::ReadConfigValue(CYW30739Config::kConfigKey_VendorId, vendorId);
+}
+
+CHIP_ERROR FactoryDataProvider::GetProductName(char * buf, size_t bufSize)
+{
+ size_t read_size;
+ return CYW30739Config::ReadConfigValueStr(CYW30739Config::kConfigKey_ProductName, buf, bufSize, read_size);
+}
+
+CHIP_ERROR FactoryDataProvider::GetProductId(uint16_t & productId)
+{
+ return CYW30739Config::ReadConfigValue(CYW30739Config::kConfigKey_ProductId, productId);
+}
+
+CHIP_ERROR FactoryDataProvider::GetPartNumber(char * buf, size_t bufSize)
+{
+ return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
+}
+
+CHIP_ERROR FactoryDataProvider::GetProductURL(char * buf, size_t bufSize)
+{
+ return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
+}
+
+CHIP_ERROR FactoryDataProvider::GetProductLabel(char * buf, size_t bufSize)
+{
+ return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
+}
+
+CHIP_ERROR FactoryDataProvider::GetSerialNumber(char * buf, size_t bufSize)
+{
+ size_t read_size;
+ return CYW30739Config::ReadConfigValueStr(CYW30739Config::kConfigKey_SerialNum, buf, bufSize, read_size);
+}
+
+CHIP_ERROR FactoryDataProvider::GetManufacturingDate(uint16_t & year, uint8_t & month, uint8_t & day)
+{
+ return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
+}
+
+CHIP_ERROR FactoryDataProvider::GetHardwareVersion(uint16_t & hardwareVersion)
+{
+ return CYW30739Config::ReadConfigValue(CYW30739Config::kConfigKey_HardwareVersion, hardwareVersion);
+}
+
+CHIP_ERROR FactoryDataProvider::GetHardwareVersionString(char * buf, size_t bufSize)
+{
+ size_t read_size;
+ return CYW30739Config::ReadConfigValueStr(CYW30739Config::kConfigKey_HardwareVersionString, buf, bufSize, read_size);
+}
+
+CHIP_ERROR FactoryDataProvider::GetRotatingDeviceIdUniqueId(MutableByteSpan & uniqueIdSpan)
+{
+ ChipError err = CHIP_ERROR_WRONG_KEY_TYPE;
+#if CHIP_ENABLE_ROTATING_DEVICE_ID && defined(CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID)
+ if (chip::DeviceLayer::ConfigurationMgr().GetRotatingDeviceIdUniqueId(uniqueIdSpan) != CHIP_NO_ERROR)
+ {
+ static_assert(ConfigurationManager::kRotatingDeviceIDUniqueIDLength >=
+ ConfigurationManager::kMinRotatingDeviceIDUniqueIDLength,
+ "Length of unique ID for rotating device ID is smaller than minimum.");
+
+ constexpr uint8_t uniqueId[] = CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID;
+
+ ReturnErrorCodeIf(sizeof(uniqueId) > uniqueIdSpan.size(), CHIP_ERROR_BUFFER_TOO_SMALL);
+ ReturnErrorCodeIf(sizeof(uniqueId) != ConfigurationManager::kRotatingDeviceIDUniqueIDLength, CHIP_ERROR_BUFFER_TOO_SMALL);
+ memcpy(uniqueIdSpan.data(), uniqueId, sizeof(uniqueId));
+ uniqueIdSpan.reduce_size(sizeof(uniqueId));
+ }
+ return CHIP_NO_ERROR;
+#endif
+ return err;
+}
+
CHIP_ERROR FactoryDataProvider::GetDeviceAttestationCertKey(MutableByteSpan & out_key_buffer)
{
size_t read_size;
diff --git a/src/platform/Infineon/CYW30739/FactoryDataProvider.h b/src/platform/Infineon/CYW30739/FactoryDataProvider.h
index 6fc22b9..def6973 100644
--- a/src/platform/Infineon/CYW30739/FactoryDataProvider.h
+++ b/src/platform/Infineon/CYW30739/FactoryDataProvider.h
@@ -19,13 +19,26 @@
#include <credentials/DeviceAttestationCredsProvider.h>
#include <crypto/CHIPCryptoPAL.h>
+#include <platform/CommissionableDataProvider.h>
+#include <platform/DeviceInstanceInfoProvider.h>
namespace chip {
namespace DeviceLayer {
-class FactoryDataProvider : public chip::Credentials::DeviceAttestationCredentialsProvider
+class FactoryDataProvider : public CommissionableDataProvider,
+ public chip::Credentials::DeviceAttestationCredentialsProvider,
+ public DeviceInstanceInfoProvider
{
public:
+ // ===== Members functions that implement the CommissionableDataProvider
+ CHIP_ERROR GetSetupDiscriminator(uint16_t & setupDiscriminator);
+ CHIP_ERROR SetSetupDiscriminator(uint16_t setupDiscriminator);
+ CHIP_ERROR GetSpake2pIterationCount(uint32_t & iterationCount);
+ CHIP_ERROR GetSpake2pSalt(MutableByteSpan & saltBuf);
+ CHIP_ERROR GetSpake2pVerifier(MutableByteSpan & verifierBuf, size_t & outVerifierLen);
+ CHIP_ERROR GetSetupPasscode(uint32_t & setupPasscode);
+ CHIP_ERROR SetSetupPasscode(uint32_t setupPasscode);
+
// ===== Members functions that implement the DeviceAttestationCredentialsProvider
CHIP_ERROR GetCertificationDeclaration(MutableByteSpan & out_cd_buffer) override;
CHIP_ERROR GetFirmwareInformation(MutableByteSpan & out_firmware_info_buffer) override;
@@ -33,6 +46,20 @@
CHIP_ERROR GetProductAttestationIntermediateCert(MutableByteSpan & out_pai_buffer) override;
CHIP_ERROR SignWithDeviceAttestationKey(const ByteSpan & message_to_sign, MutableByteSpan & out_signature_buffer) override;
+ // ===== Members functions that implement the DeviceInstanceInfoProvider
+ CHIP_ERROR GetVendorName(char * buf, size_t bufSize) override;
+ CHIP_ERROR GetVendorId(uint16_t & vendorId) override;
+ CHIP_ERROR GetProductName(char * buf, size_t bufSize) override;
+ CHIP_ERROR GetProductId(uint16_t & productId) override;
+ CHIP_ERROR GetPartNumber(char * buf, size_t bufSize) override;
+ CHIP_ERROR GetProductURL(char * buf, size_t bufSize) override;
+ CHIP_ERROR GetProductLabel(char * buf, size_t bufSize) override;
+ CHIP_ERROR GetSerialNumber(char * buf, size_t bufSize) override;
+ CHIP_ERROR GetManufacturingDate(uint16_t & year, uint8_t & month, uint8_t & day) override;
+ CHIP_ERROR GetHardwareVersion(uint16_t & hardwareVersion) override;
+ CHIP_ERROR GetHardwareVersionString(char * buf, size_t bufSize) override;
+ CHIP_ERROR GetRotatingDeviceIdUniqueId(MutableByteSpan & uniqueIdSpan) override;
+
private:
CHIP_ERROR GetDeviceAttestationCertKey(MutableByteSpan & out_key_buffer);
CHIP_ERROR LoadKeypairFromDer(const ByteSpan & der_buffer, Crypto::P256Keypair & keypair);
diff --git a/src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.cpp b/src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.cpp
index f78d639..079acbe 100644
--- a/src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.cpp
+++ b/src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.cpp
@@ -121,8 +121,7 @@
err = CHIP_ERROR_INVALID_ARGUMENT);
entry = AllocateEntry(key);
- VerifyOrExit(entry != nullptr, ChipLogError(DeviceLayer, "%s AllocateEntry %s", __func__, ErrorStr(err));
- err = CHIP_ERROR_NO_MEMORY);
+ VerifyOrExit(entry != nullptr, ChipLogError(DeviceLayer, "%s AllocateEntry failed", __func__); err = CHIP_ERROR_NO_MEMORY);
if (value_size != 0)
{
diff --git a/src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.h b/src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.h
index 9d16dd4..9f51a3e 100644
--- a/src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.h
+++ b/src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.h
@@ -55,7 +55,7 @@
private:
using Config = Internal::CYW30739Config;
- static constexpr uint8_t mMaxEntryCount = 128;
+ static constexpr uint8_t mMaxEntryCount = 192;
struct KeyStorage
{
diff --git a/src/platform/Infineon/CYW30739/PlatformManagerImpl.cpp b/src/platform/Infineon/CYW30739/PlatformManagerImpl.cpp
index 643cecc..c6c2698 100644
--- a/src/platform/Infineon/CYW30739/PlatformManagerImpl.cpp
+++ b/src/platform/Infineon/CYW30739/PlatformManagerImpl.cpp
@@ -29,7 +29,7 @@
#include <crypto/CHIPCryptoPAL.h>
#include <hal/wiced_memory.h>
-#include <wiced_platform.h>
+#include <wiced_hal_platform.h>
namespace chip {
namespace DeviceLayer {
@@ -218,12 +218,11 @@
int PlatformManagerImpl::GetEntropy(void * data, unsigned char * output, size_t len, size_t * olen)
{
- const wiced_result_t result = wiced_platform_entropy_get(output, static_cast<uint16_t>(len));
+ const wiced_result_t result = wiced_hal_platform_random_get(output, len, olen);
if (result != WICED_SUCCESS)
{
return -1;
}
- *olen = len;
return 0;
}
diff --git a/src/platform/Infineon/CYW30739/ThreadStackManagerImpl.cpp b/src/platform/Infineon/CYW30739/ThreadStackManagerImpl.cpp
index 21297d7..58e905a 100644
--- a/src/platform/Infineon/CYW30739/ThreadStackManagerImpl.cpp
+++ b/src/platform/Infineon/CYW30739/ThreadStackManagerImpl.cpp
@@ -28,7 +28,6 @@
#include <lib/support/CHIPPlatformMemory.h>
#include <openthread-system.h>
-#include <wiced_platform.h>
namespace chip {
namespace DeviceLayer {
@@ -73,7 +72,7 @@
mEventFlags.Set(kActivityPendingEventFlag);
}
-void ThreadStackManagerImpl::SignalThreadActivityPendingFromISR()
+__attribute__((section(".text_in_ram"))) void ThreadStackManagerImpl::SignalThreadActivityPendingFromISR()
{
mEventFlags.Set(kActivityPendingFromISREventFlag);
}
@@ -150,7 +149,7 @@
ThreadStackMgrImpl().SignalThreadActivityPending();
}
-extern "C" void otSysEventSignalPending(void)
+extern "C" __attribute__((section(".text_in_ram"))) void otSysEventSignalPending(void)
{
ThreadStackMgrImpl().SignalThreadActivityPendingFromISR();
}
diff --git a/src/platform/Infineon/CYW30739/args.gni b/src/platform/Infineon/CYW30739/args.gni
index 252c5e6..11bfab9 100644
--- a/src/platform/Infineon/CYW30739/args.gni
+++ b/src/platform/Infineon/CYW30739/args.gni
@@ -41,9 +41,13 @@
chip_system_config_locking = "none"
chip_system_config_use_sockets = false
+chip_use_transitional_commissionable_data_provider = false
+
optimize_debug_level = "s"
+is_debug = true
lwip_debug = false
default_configs_optimize = [ "$dir_pw_build:optimize_size" ]
+default_configs_specs = [ "${cyw30739_sdk_build_root}:specs-config" ]
chip_build_tests = false
@@ -53,9 +57,6 @@
openthread_project_core_config_file = "OpenThreadConfig.h"
openthread_core_config_deps = [ "${chip_root}/examples/platform/infineon/cyw30739:openthread_core_config_ifx_chip_examples" ]
-openthread_external_platform =
- "${chip_root}/third_party/openthread/platforms/ifx:libopenthread-ifx"
-
openthread_enable_core_config_args = true
openthread_config_dhcp6_client_enable = true
openthread_config_dns_client_enable = true
@@ -64,9 +65,3 @@
openthread_config_joiner_enable = true
openthread_config_log_output = "platform_defined"
openthread_config_srp_client_enable = true
-
-# TODO: this should be removed once sufficient flash for things
-# like:
-#
-# ./scripts/build/build_examples.py --target cyw30739-cyw930739m2evb_01-ota-requestor build
-chip_detail_logging = false
diff --git a/src/platform/Infineon/CYW30739/cyw30739-chip-mbedtls-config.h b/src/platform/Infineon/CYW30739/cyw30739-chip-mbedtls-config.h
index 1dda5aa..1446a2d 100644
--- a/src/platform/Infineon/CYW30739/cyw30739-chip-mbedtls-config.h
+++ b/src/platform/Infineon/CYW30739/cyw30739-chip-mbedtls-config.h
@@ -17,6 +17,8 @@
#pragma once
+#define MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT
+
/**
* \def MBEDTLS_AES_ALT
*
@@ -67,6 +69,17 @@
// #define MBEDTLS_SHA512_ALT
// #define MBEDTLS_XTEA_ALT
+/*
+ * When replacing the elliptic curve module, please consider, that it is
+ * implemented with two .c files:
+ * - ecp.c
+ * - ecp_curves.c
+ * You can replace them very much like all the other MBEDTLS__MODULE_NAME__ALT
+ * macros as described above. The only difference is that you have to make sure
+ * that you provide functionality for both .c files.
+ */
+#define MBEDTLS_ECP_ALT
+
/**
* \def MBEDTLS_ERROR_STRERROR_DUMMY
*
diff --git a/src/platform/Infineon/CYW30739/cyw30739_platform.gni b/src/platform/Infineon/CYW30739/cyw30739_platform.gni
new file mode 100644
index 0000000..3677272
--- /dev/null
+++ b/src/platform/Infineon/CYW30739/cyw30739_platform.gni
@@ -0,0 +1,57 @@
+# Copyright (c) 2024 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.
+
+import("//build_overrides/chip.gni")
+import("//build_overrides/cyw30739_sdk.gni")
+
+import("${chip_root}/src/platform/Infineon/CYW30739/args.gni")
+
+cyw30739_platform_dir = "${chip_root}/src/platform/Infineon/CYW30739"
+
+template("cyw30739_platform") {
+ forward_variables_from(invoker, [ "chip_family" ])
+
+ static_library(target_name) {
+ sources = [
+ "${cyw30739_platform_dir}/BLEManagerImpl.cpp",
+ "${cyw30739_platform_dir}/CYW30739Config.cpp",
+ "${cyw30739_platform_dir}/ConfigurationManagerImpl.cpp",
+ "${cyw30739_platform_dir}/DiagnosticDataProviderImpl.cpp",
+ "${cyw30739_platform_dir}/EventFlags.cpp",
+ "${cyw30739_platform_dir}/Logging.cpp",
+ "${cyw30739_platform_dir}/OTAImageProcessorImpl.cpp",
+ "${cyw30739_platform_dir}/PlatformManagerImpl.cpp",
+ "${cyw30739_platform_dir}/SystemTimeSupport.cpp",
+ "${cyw30739_platform_dir}/cycfg_gatt_db.c",
+ ]
+
+ if (chip_enable_openthread) {
+ sources += [ "${cyw30739_platform_dir}/ThreadStackManagerImpl.cpp" ]
+ }
+
+ configs +=
+ [ "${matter_wpan_sdk_build_root}:wpan_sdk-${chip_family}-config" ]
+
+ deps = [
+ "${chip_root}/src/platform:platform",
+ "${chip_root}/src/platform/logging:headers",
+ ]
+
+ if (chip_enable_openthread) {
+ deps += [
+ "${chip_root}/third_party/openthread/platforms:libopenthread-platform",
+ ]
+ }
+ }
+}
diff --git a/third_party/infineon/cyw30739_sdk/BUILD.gn b/third_party/infineon/cyw30739_sdk/BUILD.gn
deleted file mode 100644
index 46ca83b..0000000
--- a/third_party/infineon/cyw30739_sdk/BUILD.gn
+++ /dev/null
@@ -1,56 +0,0 @@
-# Copyright (c) 2020 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.
-
-import("//build_overrides/chip.gni")
-import("//build_overrides/mbedtls.gni")
-import("//build_overrides/openthread.gni")
-
-import("${mbedtls_root}/mbedtls.gni")
-
-declare_args() {
- # Build target to use for CYW30739 SDK. Use this to set global SDK defines.
- cyw30739_sdk_target = ""
-}
-
-assert(cyw30739_sdk_target != "", "cyw30739_sdk_target must be specified")
-
-config("cyw30739_sdk_no_warn_rwx") {
- ldflags = [ "-Wl,--no-warn-rwx-segment" ]
-}
-
-group("cyw30739_sdk") {
- public_deps = [ cyw30739_sdk_target ]
- all_dependent_configs = [ ":cyw30739_sdk_no_warn_rwx" ]
-}
-
-config("mbedtls_cyw30739_config") {
- defines = [
- "MBEDTLS_CONFIG_FILE=<third_party/openthread/repo/third_party/mbedtls/mbedtls-config.h>",
- "MBEDTLS_USER_CONFIG_FILE=<src/platform/Infineon/CYW30739/cyw30739-chip-mbedtls-config.h>",
- ]
-
- include_dirs = [ chip_root ]
-}
-
-mbedtls_target("mbedtls") {
- sources = [
- "${chip_root}/third_party/openthread/ot-ifx/src/cyw30739/mbedtls/library/aes_alt.c",
- "${chip_root}/third_party/openthread/ot-ifx/src/cyw30739/mbedtls/library/ccm_alt.c",
- "${chip_root}/third_party/openthread/ot-ifx/src/cyw30739/mbedtls/library/sha256_alt.c",
- ]
-
- public_configs = [ ":mbedtls_cyw30739_config" ]
-
- public_deps = [ "${openthread_root}/src/core:libopenthread_core_headers" ]
-}
diff --git a/third_party/infineon/cyw30739_sdk/bsp_design_modus/cycfg_notices.h b/third_party/infineon/cyw30739_sdk/bsp_design_modus/cycfg_notices.h
deleted file mode 100644
index 3d64d12..0000000
--- a/third_party/infineon/cyw30739_sdk/bsp_design_modus/cycfg_notices.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * File Name: cycfg_notices.h
- *
- * Description:
- * Contains warnings and errors that occurred while generating code for the
- * design.
- * This file was automatically generated and should not be modified.
- * Tools Package 2.4.0.5880
- * 20739B2 CSP
- * personalities 1.0.0.31
- * udd 3.0.0.1454
- *
- ********************************************************************************
- * Copyright 2021 Cypress Semiconductor Corporation (an Infineon company) or
- * an affiliate of Cypress Semiconductor Corporation.
- * SPDX-License-Identifier: Apache-2.0
- *
- * 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.
- ********************************************************************************/
-
-#if !defined(CYCFG_NOTICES_H)
-#define CYCFG_NOTICES_H
-
-#ifdef CY_SUPPORTS_DEVICE_VALIDATION
-#ifndef LBCA1KU1WA
-#error \
- "Unexpected target MCU; expected LBCA1KU1WA. There may be an inconsistency between the *.modus file and the makefile target configuration device sets."
-#endif
-#endif
-
-#endif /* CYCFG_NOTICES_H */
diff --git a/third_party/infineon/cyw30739_sdk/bsp_design_modus/cycfg_pins.c b/third_party/infineon/cyw30739_sdk/bsp_design_modus/cycfg_pins.c
deleted file mode 100644
index ec8bc6a..0000000
--- a/third_party/infineon/cyw30739_sdk/bsp_design_modus/cycfg_pins.c
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * File Name: cycfg_pins.c
- *
- * Description:
- * Pin configuration
- * This file was automatically generated and should not be modified.
- * Tools Package 2.3.0.4276
- * 30739A0 CSP
- * personalities 1.0.0.31
- * udd 3.0.0.1636
- *
- ********************************************************************************
- * Copyright 2022 Cypress Semiconductor Corporation
- * SPDX-License-Identifier: Apache-2.0
- *
- * 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.
- ********************************************************************************/
-
-#include "cycfg_pins.h"
-
-#if CHIP_PACKAGE_WLCSP
-#define BUTTON_USER_config \
- { \
- .gpio = (wiced_bt_gpio_numbers_t *) &platform_gpio_pins[PLATFORM_GPIO_0].gpio_pin, \
- .config = GPIO_INPUT_ENABLE | GPIO_PULL_UP, .default_state = GPIO_PIN_OUTPUT_HIGH, \
- .button_pressed_value = GPIO_PIN_OUTPUT_LOW, \
- }
-#define GPIO3_config \
- { \
- .gpio = (wiced_bt_gpio_numbers_t *) &platform_gpio_pins[PLATFORM_GPIO_5].gpio_pin, \
- .config = GPIO_OUTPUT_ENABLE | GPIO_INPUT_DISABLE, .default_state = GPIO_PIN_OUTPUT_LOW, \
- }
-#define GPIO4_config \
- { \
- .gpio = (wiced_bt_gpio_numbers_t *) &platform_gpio_pins[PLATFORM_GPIO_9].gpio_pin, \
- .config = GPIO_INPUT_ENABLE | GPIO_PULL_UP_DOWN_NONE, .default_state = GPIO_PIN_OUTPUT_LOW, \
- }
-#define GPIO5_config \
- { \
- .gpio = (wiced_bt_gpio_numbers_t *) &platform_gpio_pins[PLATFORM_GPIO_11].gpio_pin, \
- .config = GPIO_INPUT_ENABLE | GPIO_PULL_UP_DOWN_NONE, .default_state = GPIO_PIN_OUTPUT_LOW, \
- }
-#define GPIO6_config \
- { \
- .gpio = (wiced_bt_gpio_numbers_t *) &platform_gpio_pins[PLATFORM_GPIO_12].gpio_pin, \
- .config = GPIO_INPUT_ENABLE | GPIO_PULL_UP_DOWN_NONE, .default_state = GPIO_PIN_OUTPUT_LOW, \
- }
-#define DEBUG_UART_TXD_config \
- { \
- .gpio = (wiced_bt_gpio_numbers_t *) &platform_gpio_pins[PLATFORM_GPIO_15].gpio_pin, \
- .config = GPIO_INPUT_ENABLE | GPIO_PULL_UP_DOWN_NONE, .default_state = GPIO_PIN_OUTPUT_LOW, \
- }
-#define LED1_config \
- { \
- .gpio = (wiced_bt_gpio_numbers_t *) &platform_gpio_pins[PLATFORM_GPIO_16].gpio_pin, \
- .config = GPIO_OUTPUT_ENABLE | GPIO_PULL_UP, .default_state = GPIO_PIN_OUTPUT_HIGH, \
- }
-#define LED2_config \
- { \
- .gpio = (wiced_bt_gpio_numbers_t *) &platform_gpio_pins[PLATFORM_GPIO_17].gpio_pin, \
- .config = GPIO_OUTPUT_ENABLE | GPIO_PULL_UP, .default_state = GPIO_PIN_OUTPUT_HIGH, \
- }
-#define GPIO2_config \
- { \
- .gpio = (wiced_bt_gpio_numbers_t *) &platform_gpio_pins[PLATFORM_GPIO_3].gpio_pin, \
- .config = GPIO_INPUT_ENABLE | GPIO_PULL_UP_DOWN_NONE, .default_state = GPIO_PIN_OUTPUT_LOW, \
- }
-#else // !CHIP_PACKAGE_WLCSP
-#define BUTTON_USER_config \
- { \
- .gpio = (wiced_bt_gpio_numbers_t *) &platform_gpio_pins[PLATFORM_GPIO_0].gpio_pin, \
- .config = GPIO_INPUT_ENABLE | GPIO_PULL_UP, .default_state = GPIO_PIN_OUTPUT_HIGH, \
- .button_pressed_value = GPIO_PIN_OUTPUT_LOW, \
- }
-#define DEBUG_UART_TXD_config \
- { \
- .gpio = (wiced_bt_gpio_numbers_t *) &platform_gpio_pins[PLATFORM_GPIO_11].gpio_pin, \
- .config = GPIO_INPUT_ENABLE | GPIO_PULL_UP_DOWN_NONE, .default_state = GPIO_PIN_OUTPUT_LOW, \
- }
-#define LED1_config \
- { \
- .gpio = (wiced_bt_gpio_numbers_t *) &platform_gpio_pins[PLATFORM_GPIO_12].gpio_pin, \
- .config = GPIO_OUTPUT_ENABLE | GPIO_PULL_UP, .default_state = GPIO_PIN_OUTPUT_HIGH, \
- }
-#define LED2_config \
- { \
- .gpio = (wiced_bt_gpio_numbers_t *) &platform_gpio_pins[PLATFORM_GPIO_13].gpio_pin, \
- .config = GPIO_OUTPUT_ENABLE | GPIO_PULL_UP, .default_state = GPIO_PIN_OUTPUT_HIGH, \
- }
-#define GPIO2_config \
- { \
- .gpio = (wiced_bt_gpio_numbers_t *) &platform_gpio_pins[PLATFORM_GPIO_3].gpio_pin, \
- .config = GPIO_INPUT_ENABLE | GPIO_PULL_UP_DOWN_NONE, .default_state = GPIO_PIN_OUTPUT_LOW, \
- }
-#endif // CHIP_PACKAGE_WLCSP
-
-const wiced_platform_gpio_t platform_gpio_pins[] = {
-#if CHIP_PACKAGE_WLCSP
- [PLATFORM_GPIO_0] = { WICED_P00, WICED_GPIO },
- [PLATFORM_GPIO_1] = { WICED_P04, pwm_0_pwm_0_TRIGGER_IN },
- [PLATFORM_GPIO_2] = { WICED_P06, uart_1_rxd_0_TRIGGER_IN },
- [PLATFORM_GPIO_3] = { WICED_P07, WICED_GPIO },
- [PLATFORM_GPIO_4] = { WICED_P10, uart_1_txd_0_TRIGGER_IN },
- [PLATFORM_GPIO_5] = { WICED_P16, WICED_GPIO },
- [PLATFORM_GPIO_6] = { WICED_P17, amplifiers_0_rx_pu_0_TRIGGER_IN },
- [PLATFORM_GPIO_7] = { WICED_P23, spi_1_mosi_0_TRIGGER_IN },
- [PLATFORM_GPIO_8] = { WICED_P24, spi_1_miso_0_TRIGGER_IN },
- [PLATFORM_GPIO_9] = { WICED_P25, WICED_GPIO },
- [PLATFORM_GPIO_10] = { WICED_P26, amplifiers_0_tx_pu_0_TRIGGER_IN },
- [PLATFORM_GPIO_11] = { WICED_P28, WICED_GPIO },
- [PLATFORM_GPIO_12] = { WICED_P29, WICED_GPIO },
- [PLATFORM_GPIO_13] = { WICED_P30, spi_1_cs_0_TRIGGER_IN },
- [PLATFORM_GPIO_14] = { WICED_P31, spi_1_clk_0_TRIGGER_IN },
- [PLATFORM_GPIO_15] = { WICED_P33, WICED_GPIO },
- [PLATFORM_GPIO_16] = { WICED_P34, WICED_GPIO },
- [PLATFORM_GPIO_17] = { WICED_P38, WICED_GPIO },
-#else // !CHIP_PACKAGE_WLCSP
- [PLATFORM_GPIO_0] = { WICED_P00, WICED_GPIO },
- [PLATFORM_GPIO_1] = { WICED_P04, pwm_0_pwm_0_TRIGGER_IN },
- [PLATFORM_GPIO_2] = { WICED_P06, uart_1_rxd_0_TRIGGER_IN },
- [PLATFORM_GPIO_3] = { WICED_P07, WICED_GPIO },
- [PLATFORM_GPIO_4] = { WICED_P10, uart_1_txd_0_TRIGGER_IN },
- [PLATFORM_GPIO_5] = { WICED_P16, spi_1_clk_0_TRIGGER_IN },
- [PLATFORM_GPIO_6] = { WICED_P17, amplifiers_0_rx_pu_0_TRIGGER_IN },
- [PLATFORM_GPIO_7] = { WICED_P25, spi_1_cs_0_TRIGGER_IN },
- [PLATFORM_GPIO_8] = { WICED_P26, amplifiers_0_tx_pu_0_TRIGGER_IN },
- [PLATFORM_GPIO_9] = { WICED_P28, spi_1_mosi_0_TRIGGER_IN },
- [PLATFORM_GPIO_10] = { WICED_P29, spi_1_miso_0_TRIGGER_IN },
- [PLATFORM_GPIO_11] = { WICED_P33, WICED_GPIO },
- [PLATFORM_GPIO_12] = { WICED_P34, WICED_GPIO },
- [PLATFORM_GPIO_13] = { WICED_P38, WICED_GPIO },
-#endif // CHIP_PACKAGE_WLCSP
-};
-const size_t platform_gpio_pin_count = (sizeof(platform_gpio_pins) / sizeof(wiced_platform_gpio_t));
-const wiced_platform_led_config_t platform_led[] = {
- [WICED_PLATFORM_LED_1] = LED1_config,
- [WICED_PLATFORM_LED_2] = LED2_config,
-};
-const size_t led_count = (sizeof(platform_led) / sizeof(wiced_platform_led_config_t));
-const wiced_platform_button_config_t platform_button[] = {
- [WICED_PLATFORM_BUTTON_1] = BUTTON_USER_config,
-};
-const size_t button_count = (sizeof(platform_button) / sizeof(wiced_platform_button_config_t));
-const wiced_platform_gpio_config_t platform_gpio[] = {
-#if CHIP_PACKAGE_WLCSP
- [WICED_PLATFORM_GPIO_2] = GPIO2_config, [WICED_PLATFORM_GPIO_3] = GPIO3_config, [WICED_PLATFORM_GPIO_4] = GPIO4_config,
- [WICED_PLATFORM_GPIO_5] = GPIO5_config, [WICED_PLATFORM_GPIO_6] = GPIO6_config, [WICED_PLATFORM_GPIO_7] = DEBUG_UART_TXD_config,
-#else // !CHIP_PACKAGE_WLCSP
- [WICED_PLATFORM_GPIO_2] = GPIO2_config,
- [WICED_PLATFORM_GPIO_7] = DEBUG_UART_TXD_config,
-#endif // CHIP_PACKAGE_WLCSP
-};
-const size_t gpio_count = (sizeof(platform_gpio) / sizeof(wiced_platform_gpio_config_t));
diff --git a/third_party/infineon/cyw30739_sdk/bsp_design_modus/cycfg_pins.h b/third_party/infineon/cyw30739_sdk/bsp_design_modus/cycfg_pins.h
deleted file mode 100644
index d8e3c8a..0000000
--- a/third_party/infineon/cyw30739_sdk/bsp_design_modus/cycfg_pins.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * File Name: cycfg_pins.h
- *
- * Description:
- * Pin configuration
- * This file was automatically generated and should not be modified.
- * Tools Package 2.3.0.4276
- * 30739A0 CSP
- * personalities 1.0.0.31
- * udd 3.0.0.1636
- *
- ********************************************************************************
- * Copyright 2022 Cypress Semiconductor Corporation
- * SPDX-License-Identifier: Apache-2.0
- *
- * 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.
- ********************************************************************************/
-
-#if !defined(CYCFG_PINS_H)
-#define CYCFG_PINS_H
-
-#include "cycfg_notices.h"
-#include "cycfg_routing.h"
-#include "wiced_platform.h"
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-#define amplifiers_0_ENABLED 1U
-#define bluetooth_0_ENABLED 1U
-#define ioss_0_ENABLED 1U
-#define WICED_GET_PIN_FOR_LED(idx) (*(platform_led[(idx)].gpio))
-#define WICED_GET_PIN_FOR_BUTTON(idx) (*(platform_button[(idx)].gpio))
-#define WICED_GET_PIN_FOR_IO(idx) (*(platform_gpio[(idx)].gpio))
-#define BUTTON_USER_ENABLED 1U
-#define BUTTON_USER WICED_P00
-#define PUART_TXD_ENABLED 1U
-#define PUART_TXD WICED_P10
-//#define GPIO3_ENABLED 1U
-//#define GPIO3 WICED_P16
-#define RX_PU_ENABLED 1U
-#define RX_PU WICED_P17
-//#define GPIO4_ENABLED 1U
-//#define GPIO4 WICED_P25
-#define TX_PU_ENABLED 1U
-#define TX_PU WICED_P26
-//#define GPIO5_ENABLED 1U
-//#define GPIO5 WICED_P28
-//#define GPIO6_ENABLED 1U
-//#define GPIO6 WICED_P29
-#define DEBUG_UART_TXD_ENABLED 1U
-#define DEBUG_UART_TXD WICED_P33
-#define LED1_ENABLED 1U
-#define LED1 WICED_P34
-#define LED2_ENABLED 1U
-#define LED2 WICED_P38
-#define PWM0_ENABLED 1U
-#define PWM0 WICED_P04
-#define PUART_RXD_ENABLED 1U
-#define PUART_RXD WICED_P06
-#define GPIO2_ENABLED 1U
-#define GPIO2 WICED_P07
-#define pwm_0_ENABLED 1U
-#define spi_1_ENABLED 1U
-#define uart_1_ENABLED 1U
-
-extern const wiced_platform_gpio_t platform_gpio_pins[];
-extern const size_t platform_gpio_pin_count;
-extern const wiced_platform_led_config_t platform_led[];
-extern const size_t led_count;
-extern const wiced_platform_button_config_t platform_button[];
-extern const size_t button_count;
-extern const wiced_platform_gpio_config_t platform_gpio[];
-extern const size_t gpio_count;
-
-#if defined(__cplusplus)
-}
-#endif
-
-#endif /* CYCFG_PINS_H */
diff --git a/third_party/infineon/cyw30739_sdk/bsp_design_modus/cycfg_routing.h b/third_party/infineon/cyw30739_sdk/bsp_design_modus/cycfg_routing.h
deleted file mode 100644
index b4e1a38..0000000
--- a/third_party/infineon/cyw30739_sdk/bsp_design_modus/cycfg_routing.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * File Name: cycfg_routing.h
- *
- * Description:
- * Establishes all necessary connections between hardware elements.
- * This file was automatically generated and should not be modified.
- * Tools Package 2.3.0.4276
- * 30739A0 CSP
- * personalities 1.0.0.31
- * udd 3.0.0.1636
- *
- ********************************************************************************
- * Copyright 2022 Cypress Semiconductor Corporation
- * SPDX-License-Identifier: Apache-2.0
- *
- * 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.
- ********************************************************************************/
-
-#if !defined(CYCFG_ROUTING_H)
-#define CYCFG_ROUTING_H
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-#include "cycfg_notices.h"
-static inline void init_cycfg_routing(void) {}
-#define init_cycfg_connectivity() init_cycfg_routing()
-#if CHIP_PACKAGE_WLCSP
-#define ioss_0_pin_4_AUX UNKNOWN
-#define ioss_0_pin_6_AUX UNKNOWN
-#define ioss_0_pin_10_AUX UNKNOWN
-#define ioss_0_pin_17_AUX UNKNOWN
-#define ioss_0_pin_26_AUX UNKNOWN
-#else // !CHIP_PACKAGE_WLCSP
-#define ioss_0_pin_4_AUX UNKNOWN
-#define ioss_0_pin_6_AUX UNKNOWN
-#define ioss_0_pin_10_AUX UNKNOWN
-#define ioss_0_pin_16_AUX UNKNOWN
-#define ioss_0_pin_17_AUX UNKNOWN
-#define ioss_0_pin_25_AUX UNKNOWN
-#define ioss_0_pin_26_AUX UNKNOWN
-#define ioss_0_pin_28_AUX UNKNOWN
-#define ioss_0_pin_29_AUX UNKNOWN
-#endif
-
-#define amplifiers_0_rx_pu_0_TRIGGER_IN WICED_RX_PU
-#define amplifiers_0_tx_pu_0_TRIGGER_IN WICED_TX_PU
-#define pwm_0_pwm_0_TRIGGER_IN WICED_PWM0
-#define spi_1_clk_0_TRIGGER_IN WICED_SPI_2_CLK
-#define spi_1_cs_0_TRIGGER_IN WICED_SPI_2_CS
-#define spi_1_miso_0_TRIGGER_IN WICED_SPI_2_MISO
-#define spi_1_mosi_0_TRIGGER_IN WICED_SPI_2_MOSI
-#define uart_1_rxd_0_TRIGGER_IN WICED_UART_2_RXD
-#define uart_1_txd_0_TRIGGER_IN WICED_UART_2_TXD
-
-#if defined(__cplusplus)
-}
-#endif
-
-#endif /* CYCFG_ROUTING_H */
diff --git a/third_party/infineon/cyw30739_sdk/btp_reader.py b/third_party/infineon/cyw30739_sdk/btp_reader.py
deleted file mode 100644
index 69ee219..0000000
--- a/third_party/infineon/cyw30739_sdk/btp_reader.py
+++ /dev/null
@@ -1,77 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (c) 2022 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.
-#
-"""BTP file reader
-
-This is a helper script to parse BTP file into json.
-
-"""
-
-import argparse
-import json
-import pathlib
-import sys
-
-
-def main():
- parser = argparse.ArgumentParser()
- parser.add_argument("--btp", required=True, type=pathlib.Path)
- parser.add_argument("--enable_ota", action="store_true")
-
- option = parser.parse_args()
-
- items = {}
- with open(option.btp) as btp:
- for line in btp:
- item = line.strip().split("=")
- if len(item) == 2:
- key = item[0].strip()
- value = item[1].strip()
-
- if value.startswith('"'):
- items[key] = value.strip('"')
- else:
- items[key] = int(value, 0)
-
- ds_len = items["ConfigDS2Location"] - items["ConfigDSLocation"]
- xs_location_end = 0x00600000
-
- items["ConfigXS1Location"] = items["ConfigDS2Location"] + ds_len
-
- if option.enable_ota:
- items["ConfigXS1Length"] = 0x00073000
- items["ConfigXS2Location"] = (
- items["ConfigXS1Location"] + items["ConfigXS1Length"]
- )
- items["ConfigXS2Length"] = xs_location_end - items["ConfigXS2Location"]
- else:
- items["ConfigXS1Length"] = xs_location_end - items["ConfigXS1Location"]
- items["ConfigXS2Length"] = 0
- items["ConfigXS2Location"] = xs_location_end
-
- items["ConfigXS1DS1Offset"] = items["ConfigXS1Location"] - \
- items["ConfigDSLocation"]
-
- for key in items:
- if type(items[key]) is int:
- items[key] = "0x{:08x}".format(items[key])
-
- print(json.dumps(items))
- return 0
-
-
-if __name__ == "__main__":
- sys.exit(main())
diff --git a/third_party/infineon/cyw30739_sdk/compress_cgs_data.py b/third_party/infineon/cyw30739_sdk/compress_cgs_data.py
deleted file mode 100644
index 8034153..0000000
--- a/third_party/infineon/cyw30739_sdk/compress_cgs_data.py
+++ /dev/null
@@ -1,237 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (c) 2022 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.
-#
-"""CGS data entry compressor
-
-This script compresses "Data" entries into "Compressed data" entries
-from the input CGS file to the output CGS file with the given LZSS tool.
-
-"Data" entries that are smaller than 512 bytes would be skipped.
-
-"""
-
-import argparse
-import io
-import pathlib
-import re
-import subprocess
-import sys
-from collections import namedtuple
-
-Item = namedtuple('Item', 'line type nested_data')
-Entry = namedtuple('Entry', 'items name remark')
-CommentedBytes = namedtuple('CommentedBytes', 'items data')
-
-
-def main():
- parser = argparse.ArgumentParser()
- parser.add_argument("--output", required=True, type=pathlib.Path)
- parser.add_argument("--input", required=True, type=pathlib.Path)
- parser.add_argument("--lzss_tool", required=True, type=pathlib.Path)
-
- option = parser.parse_args()
-
- cgs = parse_cgs(option.input)
- compress_cgs(option, cgs)
- export_cgs(option.output, cgs)
-
-
-def parse_cgs(file_name):
- cgs = []
-
- with open(file_name, mode="r") as file:
- for line in file:
- if len(line) == 0:
- break
-
- striped_line = line.strip()
- item_type = None
- nested_data = None
-
- if striped_line.startswith('ENTRY'):
- item_type = "entry"
- nested_data = parse_entry(file, line)
- elif striped_line.startswith('#') or striped_line.startswith('//'):
- item_type = "comment"
- elif striped_line.startswith('DEFINITION'):
- item_type = "definition"
-
- cgs.append(Item(line, item_type, nested_data))
-
- return cgs
-
-
-def parse_entry(file: io.TextIOBase, line):
-
- # compile the regex for extracting name and remark of the entry.
- data_re = re.compile(r"""
- ^\s* # Allow leading spaces
- ENTRY\s+"([^"]+)" # Parse the entry name
- (?: # Optional non-capturing part begin
- \s*=\s* # Allow leading and trailing spaces
- "([^"]+)" # Parse the entry remark
- )? # Optional non-capturing part end
- \s*$ # Allow trailing spaces
- """, re.VERBOSE)
-
- items = []
- name = None
- remark = None
-
- while len(line) != 0:
- striped_line = line.strip()
- item_type = None
- nested_data = None
-
- if striped_line.startswith('ENTRY'):
- item_type = "entry"
- match = data_re.match(striped_line)
- if match:
- name = match[1]
- remark = match[2]
- elif striped_line.startswith('COMMENTED_BYTES'):
- item_type = "commented_bytes"
- nested_data = parse_commented_bytes(file, line)
- elif striped_line.startswith('{'):
- item_type = "start"
- elif striped_line.startswith('}'):
- item_type = "end"
-
- items.append(Item(line, item_type, nested_data))
- if item_type == "end":
- break
-
- line = file.readline()
-
- return Entry(items, name, remark)
-
-
-def parse_commented_bytes(file: io.TextIOBase, line):
- items = []
- data = bytearray()
-
- while len(line) != 0:
- striped_line = line.strip()
- name = None
-
- if striped_line.startswith('COMMENTED_BYTES'):
- name = "commented_bytes"
- elif striped_line.startswith('<hex>'):
- name = "hex"
- elif striped_line.startswith('{'):
- name = "start"
- elif striped_line.startswith('}'):
- name = "end"
- else:
- name = "data"
- data += bytearray.fromhex(striped_line)
-
- items.append(Item(line, name, None))
- if name == "end":
- break
-
- line = file.readline()
-
- return CommentedBytes(items, data)
-
-
-def compress_cgs(option, cgs):
- for item in cgs:
- if item.nested_data is None:
- continue
- entry = compress_entry(option, item.nested_data)
- if entry is None:
- continue
-
- cgs.insert(cgs.index(item), Item(item.line, item.type, entry))
- cgs.remove(item)
-
-
-def compress_entry(option, entry):
- if entry.name != 'Data':
- return None
-
- for item in entry.items:
- if item.nested_data is None:
- continue
- commented_bytes = compress_commented_bytes(option, item.nested_data)
- if commented_bytes is None:
- return None
-
- entry.items.insert(entry.items.index(item), Item(item.line, item.type, commented_bytes))
- entry.items.remove(item)
-
- return Entry(entry.items, 'Compressed data', entry.remark)
-
-
-def compress_commented_bytes(option, commented_bytes):
- if len(commented_bytes.data) < 512:
- return None
- return CommentedBytes(commented_bytes.items, compress_data(option, commented_bytes.data))
-
-
-def compress_data(option, data):
- raw_file = str(option.input.with_suffix('.tmp'))
- compressed_file = str(option.input.with_suffix('.tmp.lz'))
-
- with open(raw_file, mode="wb") as binary:
- binary.write(data)
-
- subprocess.run([option.lzss_tool, "e", raw_file,
- compressed_file, ], check=True)
-
- with open(compressed_file, mode="rb") as binary:
- return binary.read()
-
-
-def export_cgs(file_name, cgs):
- with open(file_name, mode="w") as file:
- for item in cgs:
- if item.nested_data is None:
- file.write(item.line)
- else:
- export_entry(file, item.nested_data)
-
-
-def export_entry(file: io.TextIOBase, entry):
- for item in entry.items:
- if item.type == 'entry':
- file.write('ENTRY "{}"'.format(entry.name))
- if entry.remark:
- file.write(' = "{}"'.format(entry.remark))
- file.write('\n')
- elif item.nested_data is None:
- file.write(item.line)
- else:
- export_commented_bytes(file, item.nested_data, entry.name == 'Compressed data')
-
-
-def export_commented_bytes(file: io.TextIOBase, commented_bytes, is_compressed_data):
- for item in commented_bytes.items:
- if is_compressed_data and item.type == 'data':
- continue
-
- file.write(item.line)
-
- if is_compressed_data and item.type == 'hex':
- indent = item.line.rstrip()[:-len('<hex>')]
-
- for i in range(0, len(commented_bytes.data), 16):
- file.write(indent + commented_bytes.data[i:i + 16].hex(' ') + '\n')
-
-
-if __name__ == "__main__":
- sys.exit(main())
diff --git a/third_party/infineon/cyw30739_sdk/cyw30739_arm.gni b/third_party/infineon/cyw30739_sdk/cyw30739_arm.gni
deleted file mode 100644
index 44b76f7..0000000
--- a/third_party/infineon/cyw30739_sdk/cyw30739_arm.gni
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright (c) 2020 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.
-
-arm_cpu = "cortex-m4"
-arm_float_abi = "hard"
-arm_fpu = "fpv4-sp-d16"
diff --git a/third_party/infineon/cyw30739_sdk/cyw30739_executable.gni b/third_party/infineon/cyw30739_sdk/cyw30739_executable.gni
deleted file mode 100644
index 0251a1d..0000000
--- a/third_party/infineon/cyw30739_sdk/cyw30739_executable.gni
+++ /dev/null
@@ -1,83 +0,0 @@
-# Copyright (c) 2020 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.
-
-import("//build_overrides/build.gni")
-import("//build_overrides/chip.gni")
-import("//build_overrides/cyw30739_sdk.gni")
-
-import("${build_root}/toolchain/flashable_executable.gni")
-import("${cyw30739_sdk_build_root}/cyw30739_sdk.gni")
-
-template("cyw30739_executable") {
- if (!defined(invoker.output_dir)) {
- invoker.output_dir = root_out_dir
- }
-
- output_base_name = get_path_info(invoker.output_name, "name")
- ldscript_file = "${root_build_dir}/${output_base_name}.ld"
- flashable_target = "${target_name}.flashable"
- pre_build_target = "${target_name}.pre_build"
- post_build_target = "${target_name}.post_build"
-
- cyw30739_sdk_pre_build(pre_build_target) {
- }
-
- cyw30739_sdk_post_build(post_build_target) {
- executable_target = "${flashable_target}.executable"
- }
-
- group(target_name) {
- deps = [
- ":${flashable_target}",
- ":${post_build_target}",
- ]
- }
-
- # Copy flashing dependencies to the output directory so that the output
- # is collectively self-contained; this allows flashing to work reliably
- # even if the build and flashing steps take place on different machines
- # or in different containers.
-
- flashing_runtime_target = target_name + ".flashing_runtime"
- flashing_script_inputs = [
- "${chip_root}/scripts/flashing/cyw30739_firmware_utils.py",
- "${chip_root}/scripts/flashing/firmware_utils.py",
- ]
- copy(flashing_runtime_target) {
- sources = flashing_script_inputs
- outputs = [ "${root_out_dir}/{{source_file_part}}" ]
- }
-
- flashing_script_generator =
- "${chip_root}/scripts/flashing/gen_flashing_script.py"
- flashing_script_name = output_base_name + ".flash.py"
- flashing_options = [
- "cyw30739",
- "--sdk-scripts-dir",
- rebase_path(invoker.cyw30739_sdk_scripts_dir),
- "--sdk-tools-dir",
- rebase_path(invoker.cyw30739_sdk_tools_dir),
- ]
-
- flashable_executable(flashable_target) {
- forward_variables_from(invoker, "*")
- data_deps = [ ":${flashing_runtime_target}" ]
-
- deps += [ ":${pre_build_target}" ]
-
- inputs = [ ldscript_file ]
-
- ldflags = [ "-T" + rebase_path(ldscript_file, root_build_dir) ]
- }
-}
diff --git a/third_party/infineon/cyw30739_sdk/cyw30739_sdk.gni b/third_party/infineon/cyw30739_sdk/cyw30739_sdk.gni
deleted file mode 100644
index 8bb9a47..0000000
--- a/third_party/infineon/cyw30739_sdk/cyw30739_sdk.gni
+++ /dev/null
@@ -1,599 +0,0 @@
-# Copyright (c) 2020 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.
-
-import("//build_overrides/build.gni")
-import("//build_overrides/chip.gni")
-import("//build_overrides/cyw30739_sdk.gni")
-
-import("${chip_root}/src/platform/device.gni")
-
-declare_args() {
- # Enable sleepy end device
- enable_sleepy_device = false
-
- # Location of the CYW30739 SDK.
- cyw30739_sdk_root = "${cyw30739_sdk_build_root}/repos"
- cyw30739_sdk_verbose = false
- cyw30739_sdk_debug = 0
-
- # Matter DAC in the DER format.
- matter_dac = "${chip_root}/credentials/test/attestation/Chip-Test-DAC-FFF2-8002-0010-Cert.der"
-
- # Matter DAC EC key in the DER format.
- matter_dac_key = "${chip_root}/credentials/test/attestation/Chip-Test-DAC-FFF2-8002-0010-Key.der"
-
- # Matter PAI certificate in the DER format.
- matter_pai = "${chip_root}/credentials/test/attestation/Chip-Test-PAI-FFF2-NoPID-Cert.der"
-
- # Matter Certification Declaration in the DER format.
- matter_cd = "${chip_root}/credentials/test/certification-declaration/Chip-Test-CD-FFF2-8001-8002.der"
-}
-
-assert(cyw30739_sdk_root != "", "cyw30739_sdk_root must be specified")
-
-cyw30739_sdk_bsp_design_modus_dir =
- "${cyw30739_sdk_build_root}/bsp_design_modus"
-cyw30739_sdk_baselib_dir = "${cyw30739_sdk_root}/30739A0/COMPONENT_30739A0"
-cyw30739_sdk_board_dir = "${cyw30739_sdk_root}/CYW930739M2EVB-01"
-cyw30739_sdk_include_dir = "${cyw30739_sdk_root}/btsdk-include"
-cyw30739_sdk_patch_dir =
- "${cyw30739_sdk_baselib_dir}/internal/30739A0/patches_CYW930739M2EVB_01"
-cyw30739_sdk_platform_dir = "${cyw30739_sdk_baselib_dir}/platforms"
-cyw30739_sdk_scripts_dir = "${cyw30739_sdk_baselib_dir}/make/scripts"
-cyw30739_sdk_btp_file = "${cyw30739_sdk_build_root}/flash.btp"
-cyw30739_sdk_patch_sym_file = "${cyw30739_sdk_patch_dir}/patch.sym"
-
-cyw30739_sdk_tools_dir = "${cyw30739_sdk_root}/btsdk-tools/"
-if (host_os == "linux") {
- cyw30739_sdk_tools_dir += "Linux64"
-} else if (host_os == "mac") {
- cyw30739_sdk_tools_dir += "OSX"
-} else if (host_os == "win") {
- cyw30739_sdk_tools_dir += "Windows"
-}
-
-btp_reader_args =
- [ "--btp=" + rebase_path(cyw30739_sdk_btp_file, root_build_dir) ]
-if (chip_enable_ota_requestor) {
- btp_reader_args += [ "--enable_ota" ]
-}
-btp = exec_script("${cyw30739_sdk_build_root}/btp_reader.py",
- btp_reader_args,
- "json",
- [ cyw30739_sdk_btp_file ])
-
-cyw30739_sdk_crt_entry = "spar_crt_setup"
-
-template("cyw30739_sdk_script") {
- action(target_name) {
- forward_variables_from(invoker,
- [
- "deps",
- "script_file_name",
- "sources",
- "outputs",
- ])
-
- script_file = "${cyw30739_sdk_scripts_dir}/${script_file_name}"
-
- script = "${build_root}/gn_run_binary.py"
-
- inputs = [ script_file ]
-
- args = [
- "bash",
- "--norc",
- "--noprofile",
- rebase_path(script_file, root_build_dir),
- "--scripts=" + rebase_path(cyw30739_sdk_scripts_dir, root_build_dir),
- ]
- if (defined(invoker.args)) {
- args += invoker.args
- }
- if (cyw30739_sdk_verbose) {
- args += [ "--verbose" ]
- }
- }
-}
-
-# Defines a CYW30739 SDK build target.
-#
-# Parameters:
-# cyw30739_sdk_root - The location of the erf32 SDK.
-# sources - The sources files to build.
-template("cyw30739_sdk") {
- if (defined(invoker.cyw30739_sdk_root)) {
- cyw30739_sdk_root = invoker.cyw30739_sdk_root
- }
-
- assert(cyw30739_sdk_root != "", "cyw30739_sdk_root must be specified")
-
- config("${target_name}_config") {
- include_dirs = []
- defines = []
- libs = []
-
- if (defined(invoker.include_dirs)) {
- include_dirs += invoker.include_dirs
- }
-
- if (defined(invoker.defines)) {
- defines += invoker.defines
- }
- if (enable_sleepy_device) {
- assert(!chip_openthread_ftd, "OpenThread SED must run with FTD disabled.")
- defines += [ "CHIP_DEVICE_CONFIG_ENABLE_SED=1" ]
- }
-
- include_dirs += [
- "${cyw30739_sdk_baselib_dir}/WICED/common",
- "${cyw30739_sdk_baselib_dir}/include",
- "${cyw30739_sdk_baselib_dir}/include/hal",
- "${cyw30739_sdk_baselib_dir}/include/internal",
- "${cyw30739_sdk_baselib_dir}/include/stack",
- "${cyw30739_sdk_baselib_dir}/platforms",
- "${cyw30739_sdk_board_dir}",
- "${cyw30739_sdk_build_root}/include",
- "${cyw30739_sdk_include_dir}",
- ]
-
- cflags = [ "--specs=nano.specs" ]
- if (is_debug) {
- cflags += [ "-Wno-unused" ]
- }
-
- ldflags = [
- "--specs=nano.specs",
- "-Wl,--entry=${cyw30739_sdk_crt_entry}",
- "-Wl,--just-symbols=" +
- rebase_path(cyw30739_sdk_patch_sym_file, root_build_dir),
- "-nostartfiles",
- ]
- }
-
- cyw30739_sdk_script("${target_name}_gen_lib_installer") {
- script_file_name = "bt_gen_lib_installer.bash"
-
- lib_installer_file = "${root_gen_dir}/lib_installer.c"
-
- args = [ "--out=" + rebase_path(lib_installer_file, root_build_dir) ]
-
- outputs = [ lib_installer_file ]
- }
-
- source_set(target_name) {
- sources = [
- "${cyw30739_sdk_baselib_dir}/WICED/common/spar_setup.c",
- "${cyw30739_sdk_baselib_dir}/platforms/platform_entropy.c",
- "${cyw30739_sdk_baselib_dir}/platforms/platform_nvram.h",
- "${cyw30739_sdk_baselib_dir}/platforms/platform_retarget_lock.h",
- "${cyw30739_sdk_baselib_dir}/platforms/platform_stdio.c",
- "${cyw30739_sdk_baselib_dir}/platforms/wiced_platform.c",
- "${cyw30739_sdk_baselib_dir}/platforms/wiced_platform_bt_cfg.c",
- "${cyw30739_sdk_baselib_dir}/platforms/wiced_platform_bt_cfg.h",
- "${cyw30739_sdk_baselib_dir}/platforms/wiced_platform_memory.c",
- "${cyw30739_sdk_baselib_dir}/platforms/wiced_platform_os.c",
- "${cyw30739_sdk_board_dir}/gpio_button.c",
- "${cyw30739_sdk_board_dir}/gpio_button.h",
- "${cyw30739_sdk_board_dir}/platform.c",
- "${cyw30739_sdk_board_dir}/platform_button.c",
- "${cyw30739_sdk_board_dir}/wiced_platform.h",
- "${cyw30739_sdk_board_dir}/wiced_platform_memory.h",
- "${cyw30739_sdk_board_dir}/wiced_platform_os.h",
- "${cyw30739_sdk_bsp_design_modus_dir}/cycfg_notices.h",
- "${cyw30739_sdk_bsp_design_modus_dir}/cycfg_pins.c",
- "${cyw30739_sdk_bsp_design_modus_dir}/cycfg_pins.h",
- "${cyw30739_sdk_bsp_design_modus_dir}/cycfg_routing.h",
- "${cyw30739_sdk_build_root}/include/auto_flags.h",
- "${cyw30739_sdk_build_root}/include/wiced_button_manager.h",
- "${cyw30739_sdk_build_root}/include/wiced_led_manager.h",
- "${cyw30739_sdk_build_root}/src/platform_retarget_lock.c",
- "${cyw30739_sdk_build_root}/src/wiced_button_manager.c",
- "${cyw30739_sdk_build_root}/src/wiced_led_manager.c",
- ]
-
- if (chip_enable_ota_requestor) {
- sources += [
- "${cyw30739_sdk_build_root}/include/ota_fw_upgrade.h",
- "${cyw30739_sdk_build_root}/src/ota_fw_upgrade.c",
- ]
- }
-
- sources += get_target_outputs(":${target_name}_gen_lib_installer")
-
- if (defined(invoker.sources)) {
- sources += invoker.sources
- }
-
- defines = [
- "CHIP_HAVE_CONFIG_H=1",
- "CY_PLATFORM_SWDCK=WICED_P05",
- "CY_PLATFORM_SWDIO=WICED_P03",
- "ENABLE_DEBUG=${cyw30739_sdk_debug}",
- "SPAR_CRT_SETUP=${cyw30739_sdk_crt_entry}",
- "XS_LOCATION_ACTIVE=${btp.ConfigXS1Location}",
- "XS_LOCATION_UPGRADE=${btp.ConfigXS2Location}",
- ]
- if (chip_enable_ota_requestor) {
- defines += [ "BLE_OTA_FW_UPGRADE=1" ]
- }
-
- public_configs = [ ":${target_name}_config" ]
-
- deps = [ ":${target_name}_gen_lib_installer" ]
- }
-}
-
-template("cyw30739_sdk_pre_build") {
- action(target_name) {
- script_file = "${cyw30739_sdk_build_root}/scripts/wiced-gen-ld.pl"
-
- script = "${build_root}/gn_run_binary.py"
-
- inputs = [
- "${cyw30739_sdk_build_root}/btp_reader.py",
- script_file,
- ]
-
- sources = [
- cyw30739_sdk_btp_file,
- cyw30739_sdk_patch_sym_file,
- ]
-
- outputs = [ invoker.ldscript_file ]
-
- args = [
- "perl",
- "-I",
- rebase_path(cyw30739_sdk_scripts_dir, root_build_dir),
- rebase_path(script_file, root_build_dir),
- "FLASH0_BEGIN_ADDR=${btp.DLConfigSSLocation}",
- "FLASH0_LENGTH=0x00100000",
- "XIP_DS_OFFSET=${btp.ConfigXS1DS1Offset}",
- "XIP_LEN=${btp.ConfigXS1Length}",
- "SRAM_BEGIN_ADDR=0x00200000",
- "SRAM_LENGTH=0x00070000",
- "AON_AREA_END=0x00284000",
- "ISTATIC_BEGIN=0x500C00",
- "ISTATIC_LEN=0x400",
- "NUM_PATCH_ENTRIES=256",
- "BTP=" + rebase_path(cyw30739_sdk_btp_file, root_build_dir),
- rebase_path(cyw30739_sdk_patch_sym_file, root_build_dir),
- "out=" + rebase_path(invoker.ldscript_file, root_build_dir),
- ]
- }
-}
-
-template("cyw30739_sdk_post_build") {
- output_base_path = "${root_out_dir}/${invoker.output_base_name}"
- elf = "${output_base_path}.elf"
- hex = "${output_base_path}_download.hex"
- ss_hex = "${output_base_path}.ss.hex"
- ds_hex = "${output_base_path}.ds.hex"
- xs_hex = "${output_base_path}.xs.hex"
- ss_hdf = "${output_base_path}.ss.hdf"
- ss_cgs = "${output_base_path}.ss.cgs"
- empty_cgs = "${output_base_path}.empty.cgs"
- cgs = "${output_base_path}.cgs"
- cx_cgs = "${output_base_path}.cx.cgs"
- hdf = "${root_out_dir}/configdef30739A0.hdf"
-
- patched_cgs_args =
- exec_script("${build_root}/gn_run_binary.py",
- [
- "perl",
- rebase_path("${cyw30739_sdk_scripts_dir}/wiced-bdaddr.pl",
- root_build_dir),
- "30739A0",
- rebase_path(cyw30739_sdk_btp_file, root_build_dir),
- "-O",
- "DLConfigBD_ADDRBase:default",
- ],
- "list lines",
- [ "${cyw30739_sdk_scripts_dir}/wiced-bdaddr.pl" ])
-
- cgs_args = []
- foreach(arg, patched_cgs_args) {
- cgs_args += string_split(arg)
- }
-
- group(target_name) {
- deps = [ ":${target_name}_merge_hex" ]
- if (chip_enable_ota_requestor) {
- deps += [ ":${target_name}_ota_image" ]
- }
-
- data_deps = [
- ":${target_name}_btp",
- ":${target_name}_disassemble",
- ":${target_name}_hci_id",
- ":${target_name}_minidriver",
- ]
- }
-
- action("${target_name}_merge_hex") {
- config_header =
- "${chip_root}/src/platform/Infineon/CYW30739/CYW30739Config.h"
-
- script = "${cyw30739_sdk_build_root}/merge_hex.py"
-
- outputs = [ hex ]
-
- sources = [
- config_header,
- ds_hex,
- matter_cd,
- matter_dac,
- matter_dac_key,
- matter_pai,
- ss_hex,
- xs_hex,
- ]
-
- args = [
- "--output=" + rebase_path(hex, root_build_dir),
- "--ss_hex=" + rebase_path(ss_hex, root_build_dir),
- "--ds_hex=" + rebase_path(ds_hex, root_build_dir),
- "--xs_hex=" + rebase_path(xs_hex, root_build_dir),
- "--config_header=" + rebase_path(config_header, root_build_dir),
- "--config=DAC:file:" + rebase_path(matter_dac, root_build_dir),
- "--config=DACKey:file:" + rebase_path(matter_dac_key, root_build_dir),
- "--config=PAICert:file:" + rebase_path(matter_pai, root_build_dir),
- "--config=CertDeclaration:file:" + rebase_path(matter_cd, root_build_dir),
- ]
- foreach(arg, cgs_args) {
- options = []
- options = string_split(arg, ":")
- if (options[0] == "DLConfigBD_ADDRBase") {
- args += [ "--config=ExtendedAddress:address:" + options[1] ]
- }
- }
-
- deps = [
- ":${invoker.target_name}_gen_ds_hex",
- ":${invoker.target_name}_gen_ss_hex",
- ":${invoker.target_name}_gen_xs_hex",
- ]
- }
-
- action("${target_name}_gen_ss_hex") {
- script = "${build_root}/gn_run_binary.py"
-
- outputs = [ ss_hex ]
-
- sources = [
- cyw30739_sdk_btp_file,
- empty_cgs,
- ]
-
- args = [
- rebase_path("${cyw30739_sdk_tools_dir}/CGS/cgs", root_build_dir),
- "-D",
- rebase_path(root_out_dir, root_build_dir),
- "-I",
- rebase_path(ss_hex, root_build_dir),
- "-B",
- rebase_path(cyw30739_sdk_btp_file, root_build_dir),
- "--cgs-files",
- rebase_path(empty_cgs, root_build_dir),
- ]
- args += cgs_args
-
- deps = [ ":${invoker.target_name}_gen_ss_cgs" ]
- }
-
- action("${target_name}_gen_ds_hex") {
- cgs_map = "${cgs}.map"
- script = "${build_root}/gn_run_binary.py"
-
- outputs = [
- cgs_map,
- ds_hex,
- ]
-
- sources = [
- cx_cgs,
- cyw30739_sdk_btp_file,
- ]
-
- inputs = [ hdf ]
-
- args = [
- rebase_path("${cyw30739_sdk_tools_dir}/CGS/cgs", root_build_dir),
- "-D",
- rebase_path(root_out_dir, root_build_dir),
- "-M",
- rebase_path(cgs_map, root_build_dir),
- "-I",
- rebase_path(ds_hex, root_build_dir),
- "-B",
- rebase_path(cyw30739_sdk_btp_file, root_build_dir),
- "--cgs-files",
- rebase_path(cx_cgs, root_build_dir),
- "--paramoverride",
- "DLConfigFixedHeader:0",
- ]
-
- deps = [
- ":${invoker.target_name}_compress_cgs_data",
- ":${invoker.target_name}_hdf",
- ]
- }
-
- action("${target_name}_gen_xs_hex") {
- script = "${build_root}/gn_run_binary.py"
-
- outputs = [ xs_hex ]
-
- sources = [ elf ]
-
- args = [
- "arm-none-eabi-objcopy",
- "--only-section=.app_xip_area",
- "--output-target=ihex",
- rebase_path(elf, root_build_dir),
- rebase_path(xs_hex, root_build_dir),
- ]
-
- deps = [ ":${invoker.executable_target}" ]
- }
-
- action("${target_name}_compress_cgs_data") {
- script = "${cyw30739_sdk_build_root}/compress_cgs_data.py"
-
- outputs = [ cx_cgs ]
-
- sources = [ cgs ]
-
- args = [
- "--output=" + rebase_path(cx_cgs, root_build_dir),
- "--input=" + rebase_path(cgs, root_build_dir),
- "--lzss_tool=" +
- rebase_path(cyw30739_sdk_tools_dir + "/lzss/lzss", root_build_dir),
- ]
-
- deps = [ ":${invoker.target_name}_gen_cgs" ]
- }
-
- action("${target_name}_gen_ss_cgs") {
- script = "${cyw30739_sdk_build_root}/scripts/gen_ss_cgs.py"
-
- outputs = [
- ss_hdf,
- ss_cgs,
- empty_cgs,
- ]
-
- args = [
- "--ss_hdf=" + rebase_path(ss_hdf, root_build_dir),
- "--ss_cgs=" + rebase_path(ss_cgs, root_build_dir),
- "--empty_cgs=" + rebase_path(empty_cgs, root_build_dir),
- ]
- }
-
- action("${target_name}_gen_cgs") {
- script_file = "${cyw30739_sdk_scripts_dir}/wiced-gen-cgs.pl"
-
- script = "${build_root}/gn_run_binary.py"
-
- inputs = [ script_file ]
-
- sources = [
- "${cyw30739_sdk_patch_dir}/patch.cgs",
- "${cyw30739_sdk_platform_dir}/platform.cgs",
- "${cyw30739_sdk_platform_dir}/platform_xip.cgs",
- cyw30739_sdk_btp_file,
- elf,
- hdf,
- invoker.ldscript_file,
- ]
-
- outputs = [ cgs ]
-
- args = [
- "perl",
- "-I",
- rebase_path(cyw30739_sdk_scripts_dir, root_build_dir),
- rebase_path(script_file, root_build_dir),
- "${cyw30739_sdk_crt_entry}.entry",
- "out=" + rebase_path(cgs, root_build_dir),
- ]
- foreach(source, sources) {
- args += [ rebase_path(source, root_build_dir) ]
- }
-
- deps = [
- ":${invoker.executable_target}",
- ":${invoker.pre_build_target}",
- ":${invoker.target_name}_hdf",
- ]
- }
-
- action("${target_name}_disassemble") {
- asm = "${output_base_path}.asm"
-
- script = "${build_root}/gn_run_binary.py"
-
- outputs = [ asm ]
-
- sources = [ elf ]
-
- args = [
- "bash",
- "--norc",
- "--noprofile",
- "-c",
- "arm-none-eabi-objdump --disassemble " +
- rebase_path(elf, root_build_dir) + " > " +
- rebase_path(asm, root_build_dir),
- ]
-
- deps = [ ":${invoker.executable_target}" ]
- }
-
- copy("${target_name}_btp") {
- sources = [ "${cyw30739_sdk_btp_file}" ]
- outputs = [ "${output_base_path}.btp" ]
- }
-
- copy("${target_name}_hdf") {
- sources =
- [ "${cyw30739_sdk_baselib_dir}/internal/30739A0/configdef30739A0.hdf" ]
- outputs = [ hdf ]
- }
-
- copy("${target_name}_hci_id") {
- sources = [ "${cyw30739_sdk_platform_dir}/IDFILE.txt" ]
- outputs = [ "${output_base_path}_hci_id.txt" ]
- }
-
- copy("${target_name}_minidriver") {
- sources = [ "${cyw30739_sdk_platform_dir}/minidriver.hex" ]
- outputs = [ "${root_out_dir}/{{source_file_part}}" ]
- }
-
- write_file("${root_out_dir}/chipload_flags.txt", "-NOHCIRESET")
-
- action("${target_name}_ota_image") {
- script = "${cyw30739_sdk_build_root}/gen_ota_image.py"
-
- binary = "${output_base_path}.bin"
-
- outputs = [ binary ]
-
- sources = [
- ds_hex,
- xs_hex,
- ]
-
- args = [
- "--binary=" + rebase_path(binary, root_build_dir),
- "--ds_hex=" + rebase_path(ds_hex, root_build_dir),
- "--xs_hex=" + rebase_path(xs_hex, root_build_dir),
- "--lzss_tool=" +
- rebase_path(cyw30739_sdk_tools_dir + "/lzss/lzss", root_build_dir),
- "--active_xs_len=${btp.ConfigXS1Length}",
- "--upgrade_xs_len=${btp.ConfigXS2Length}",
- "--project_config=" +
- rebase_path("//include/CHIPProjectConfig.h", root_build_dir),
- "--ota_image_tool=" +
- rebase_path("${chip_root}/src/app/ota_image_tool.py", root_build_dir),
- ]
-
- deps = [
- ":${invoker.target_name}_gen_ds_hex",
- ":${invoker.target_name}_gen_xs_hex",
- ]
- }
-}
diff --git a/third_party/infineon/cyw30739_sdk/flash.btp b/third_party/infineon/cyw30739_sdk/flash.btp
deleted file mode 100644
index e57581e..0000000
--- a/third_party/infineon/cyw30739_sdk/flash.btp
+++ /dev/null
@@ -1,53 +0,0 @@
-DevicePreset "30739 Flash"
-{
- ConfigFSOffset = 0
- DLReadWriteMode = "Cortex M3 HCI"
- DLWriteVerifyMode = "Write and verify"
- DLMaxWriteSize = 240
- DLSectorEraseMode = "Chip erase"
- MinidriverRebaudRate = 3000000
- DLDTRReset = 0
- DLPostResetDelay_ms = 100
- DLAutobaud = 0
- DLAutobaudRepeat = 1
- DLAutobaudRepeatDelay_ms = 200
- DLWaitForLaunchAnnounce = 0
- DLConfigReprogramIF_PLL = 0
- DLUsbBulkPipe = 0
- DLMinidriver = 1
- DLMinidriverPathUSB = "[MINIDRIVERS]\30739\INVALID.hex"
- DLMinidriverPathNET = "[MINIDRIVERS]\30739\INVALID.hex"
- DLMinidriverPathSDIO = "[MINIDRIVERS]\30739\INVALID.hex"
- DLMinidriverPathUPRX = "[MINIDRIVERS]\30739\INVALID.hex"
- DLMinidriverPathUART = "[MINIDRIVERS]\30739\uart.hex"
- DLFirmware = 1
- DLFirmwareTargeting = "Standard"
- DLConfig = 1
- DLConfigTargeting = "Flash absolute"
- ConfigPath = ""
- DLConfigFixedHeader = 1
- DLConfigFixedHeaderFromBurnImage = 0
- DLConfigOmitRF_PLL = 1
- DLConfigIncludeChargerConfig = 0
- DLConfigDFUKey = 4294967295
- DLConfigCrystalFreqMHzX10000 = 240000
- DLConfigOutputPowerAdjust = 40
- DLConfigImpedanceMatchTuning = 31
- DLConfigSerialControlBaudRate = 115200
- DLConfigEEPROMAccessSpeed = 100
- DLConfigVSOffset = 0
- ConfigDSLocation = 0x509000
- ConfigDS2Location = 0x51d000
- DLConfigSSLocation = 0x500000
- DLConfigIncludeBTWSecurityKey = 0
- DLConfigVSLocation = 0x501000
- DLConfigVSLength = 0x4000
- DLConfigRemoteDeviceCount = 0
- DLConfigBD_ADDRBase = "30739A0*****"
- DLConfigFixedBD_ADDRFlag = "Can change"
- OTAFWUAckAllRecords = 0
- OTAFWUUpdateFirmware = 1
- OTAFWUUpdateConfig = 1
- CustomSkipInitialHCIReset = 0
- CustomHCIResetTimeoutMS = 5000
-}
diff --git a/third_party/infineon/cyw30739_sdk/gen_ota_image.py b/third_party/infineon/cyw30739_sdk/gen_ota_image.py
deleted file mode 100644
index edd51c6..0000000
--- a/third_party/infineon/cyw30739_sdk/gen_ota_image.py
+++ /dev/null
@@ -1,211 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (c) 2022 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.
-#
-"""OTA image generator
-
-This script generates OTA image file from the input hex files.
-
-The XS data would be compressed into OTA image with the given LZSS tool.
-
-"""
-
-import argparse
-import pathlib
-import subprocess
-import sys
-import zlib
-from struct import pack, pack_into
-
-from intelhex import IntelHex
-
-
-def main():
- parser = argparse.ArgumentParser()
- parser.add_argument("--binary", required=True, type=pathlib.Path)
- parser.add_argument("--ds_hex", required=True, type=pathlib.Path)
- parser.add_argument("--xs_hex", required=True, type=pathlib.Path)
- parser.add_argument("--lzss_tool", required=True, type=pathlib.Path)
- parser.add_argument("--active_xs_len", required=True,
- type=lambda x: int(x, 0))
- parser.add_argument("--upgrade_xs_len", required=True,
- type=lambda x: int(x, 0))
- parser.add_argument("--project_config", required=True, type=pathlib.Path)
- parser.add_argument("--ota_image_tool", required=True, type=pathlib.Path)
-
- option = parser.parse_args()
-
- intel_hex = IntelHex(str(option.ds_hex))
- intel_hex.loadhex(str(option.xs_hex))
- ds_segment, xs_segment = intel_hex.segments()[0:2]
-
- ds_header = intel_hex.tobinarray(
- start=ds_segment[0], end=ds_segment[0] + 0x10 - 1)
- ds_data = intel_hex.tobinarray(
- start=ds_segment[0] + 0x10, end=ds_segment[1] - 1)
- xs_data = intel_hex.tobinarray(start=xs_segment[0], end=xs_segment[1] - 1)
-
- # Align to 4 bytes
- ds_data = pad_data(ds_data, 4)
- xs_data = pad_data(xs_data, 4)
-
- # Pad XS data CRC to DS data
- xs_crc = zlib.crc32(xs_data)
- ds_data += pack("<L", xs_crc)
-
- # Compressed data
- cx_data = compress_data(option, xs_data, ".xs.bin")
- cx_crc = zlib.crc32(cx_data)
-
- # DS header
- ds_crc = zlib.crc32(ds_data)
- pack_into("<LL", ds_header, 0x08, ds_crc, len(ds_data))
-
- # XS header
- xs_header = ds_header.tobytes()
- xs_header += pack("<LL", xs_crc, len(xs_data))
- xs_header += pack("<LL", cx_crc, len(cx_data))
-
- print("DS: Length 0x{:08x}, CRC 0x{:08x}".format(len(ds_data), ds_crc))
- print("XS: Length 0x{:08x}, CRC 0x{:08x}".format(len(xs_data), xs_crc))
- print("CX: Length 0x{:08x}, CRC 0x{:08x}".format(len(cx_data), cx_crc))
-
- print(
- "Active XS: Used {:7,}, Free {:7,}".format(
- len(xs_data), option.active_xs_len - len(xs_data)
- )
- )
- upgrade_xs_len = len(xs_header) + len(cx_data)
- print(
- "Upgrade XS: Used {:7,}, Free {:7,}".format(
- upgrade_xs_len, option.upgrade_xs_len - upgrade_xs_len
- )
- )
-
- if option.upgrade_xs_len < upgrade_xs_len:
- print("Error: Insufficient space for the upgrade XS.")
- return -1
-
- gen_image(option, ds_header, ds_data, xs_header, cx_data)
-
- return 0
-
-
-def compress_data(option, data, file_suffix):
- raw_file = str(option.binary.with_suffix(file_suffix))
- compressed_file = str(option.binary.with_suffix(file_suffix + ".lz"))
-
- with open(raw_file, mode="wb") as binary:
- binary.write(data)
-
- subprocess.run([option.lzss_tool, "e", raw_file,
- compressed_file, ], check=True)
-
- with open(compressed_file, mode="rb") as binary:
- return binary.read()
-
-
-def pad_data(data, aligned_size):
- data = bytearray(data)
- remained_length = len(data) % aligned_size
- if remained_length != 0:
- data += bytes(aligned_size - remained_length)
- return data
-
-
-def gen_image(option, ds_header, ds_data, xs_header, cx_data):
-
- configs = parse_config(option)
-
- write_binary(option, ds_header, ds_data, xs_header, cx_data)
- run_ota_image_tool(option, configs)
-
- # Get the header size
- header_size = 0
- for line in subprocess.run(
- [option.ota_image_tool, "show", option.binary.with_suffix(".ota"), ],
- check=True,
- capture_output=True,
- text=True,
- ).stdout.splitlines():
- if line.startswith("Header Size:"):
- header_size = int(line.split(":")[1])
- break
-
- if header_size % 4 == 0:
- return
-
- # Insert zeroes to align sections to word
- inserted_zero_count = 4 - header_size % 4
- write_binary(option, ds_header, ds_data, xs_header,
- cx_data, inserted_zero_count)
- run_ota_image_tool(option, configs)
-
-
-def parse_config(option):
- configs = {}
- with open(option.project_config, "r") as config_file:
- for line in config_file.readlines():
-
- tokens = line.strip().split()
- if not tokens or not tokens[0].endswith("define"):
- continue
-
- key = tokens[1]
- value = tokens[2]
-
- if value.startswith('"'):
- configs[key] = value.strip('"')
- else:
- configs[key] = int(value, 0)
-
- return configs
-
-
-def write_binary(option, ds_header, ds_data, xs_header, cx_data, inserted_zero_count=0):
- with open(str(option.binary), mode="wb") as binary:
- binary.write(bytes(inserted_zero_count))
- binary.write(ds_header)
- binary.write(ds_data)
- binary.write(xs_header)
- binary.write(cx_data)
-
-
-def run_ota_image_tool(option, configs):
- subprocess.run(
- [
- option.ota_image_tool,
- "create",
- "--vendor-id={}".format(
- configs["CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID"]),
- "--product-id={}".format(
- configs["CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID"]),
- "--version={}".format(
- configs["CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION"]
- ),
- "--version-str={}".format(
- configs["CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING"]
- ),
- "--digest-algorithm=sha256",
- option.binary,
- option.binary.with_suffix(".ota"),
- ],
- stderr=subprocess.STDOUT,
- check=True,
- )
-
-
-if __name__ == "__main__":
- sys.exit(main())
diff --git a/third_party/infineon/cyw30739_sdk/include/auto_flags.h b/third_party/infineon/cyw30739_sdk/include/auto_flags.h
deleted file mode 100644
index 6e09909..0000000
--- a/third_party/infineon/cyw30739_sdk/include/auto_flags.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#pragma once
-
-#define ALWAYS_ON_MEMORY_SUPPORT 1
-#define CPU_CM4 1
-#define DYNAMIC_MEMORY_NUM_POOLS 4
-#define MICRO_BCS 1
-#define TOOLCHAIN_wiced 1
diff --git a/third_party/infineon/cyw30739_sdk/include/ota_fw_upgrade.h b/third_party/infineon/cyw30739_sdk/include/ota_fw_upgrade.h
deleted file mode 100644
index 422da82..0000000
--- a/third_party/infineon/cyw30739_sdk/include/ota_fw_upgrade.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2016-2021, Cypress Semiconductor Corporation (an Infineon company) or
- * an affiliate of Cypress Semiconductor Corporation. All rights reserved.
- *
- * This software, including source code, documentation and related
- * materials ("Software") is owned by Cypress Semiconductor Corporation
- * or one of its affiliates ("Cypress") and is protected by and subject to
- * worldwide patent protection (United States and foreign),
- * United States copyright laws and international treaty provisions.
- * Therefore, you may use this Software only as provided in the license
- * agreement accompanying the software package from which you
- * obtained this Software ("EULA").
- * If no EULA applies, Cypress hereby grants you a personal, non-exclusive,
- * non-transferable license to copy, modify, and compile the Software
- * source code solely for use in connection with Cypress's
- * integrated circuit products. Any reproduction, modification, translation,
- * compilation, or representation of this Software except as specified
- * above is prohibited without the express written permission of Cypress.
- *
- * Disclaimer: THIS SOFTWARE IS PROVIDED AS-IS, WITH NO WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, NONINFRINGEMENT, IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress
- * reserves the right to make changes to the Software without notice. Cypress
- * does not assume any liability arising out of the application or use of the
- * Software or any product or circuit described in the Software. Cypress does
- * not authorize its products for use in any products where a malfunction or
- * failure of the Cypress product may reasonably be expected to result in
- * significant property damage, injury or death ("High Risk Product"). By
- * including Cypress's product in a High Risk Product, the manufacturer
- * of such system or application assumes all risk of such use and in doing
- * so agrees to indemnify Cypress against all liability.
- */
-
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdbool.h>
-#include <stdint.h>
-
-void wiced_firmware_upgrade_bootloader(void);
-bool wiced_firmware_upgrade_prepare(void);
-uint32_t wiced_firmware_upgrade_process_block(uint32_t offset, const uint8_t * data, uint32_t len);
-bool wiced_firmware_upgrade_finalize(void);
-bool wiced_firmware_upgrade_apply(void);
-void wiced_firmware_upgrade_abort(void);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/third_party/infineon/cyw30739_sdk/include/wiced_button_manager.h b/third_party/infineon/cyw30739_sdk/include/wiced_button_manager.h
deleted file mode 100644
index 6509125..0000000
--- a/third_party/infineon/cyw30739_sdk/include/wiced_button_manager.h
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * Copyright 2016-2021, Cypress Semiconductor Corporation (an Infineon company) or
- * an affiliate of Cypress Semiconductor Corporation. All rights reserved.
- *
- * This software, including source code, documentation and related
- * materials ("Software") is owned by Cypress Semiconductor Corporation
- * or one of its affiliates ("Cypress") and is protected by and subject to
- * worldwide patent protection (United States and foreign),
- * United States copyright laws and international treaty provisions.
- * Therefore, you may use this Software only as provided in the license
- * agreement accompanying the software package from which you
- * obtained this Software ("EULA").
- * If no EULA applies, Cypress hereby grants you a personal, non-exclusive,
- * non-transferable license to copy, modify, and compile the Software
- * source code solely for use in connection with Cypress's
- * integrated circuit products. Any reproduction, modification, translation,
- * compilation, or representation of this Software except as specified
- * above is prohibited without the express written permission of Cypress.
- *
- * Disclaimer: THIS SOFTWARE IS PROVIDED AS-IS, WITH NO WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, NONINFRINGEMENT, IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress
- * reserves the right to make changes to the Software without notice. Cypress
- * does not assume any liability arising out of the application or use of the
- * Software or any product or circuit described in the Software. Cypress does
- * not authorize its products for use in any products where a malfunction or
- * failure of the Cypress product may reasonably be expected to result in
- * significant property damage, injury or death ("High Risk Product"). By
- * including Cypress's product in a High Risk Product, the manufacturer
- * of such system or application assumes all risk of such use and in doing
- * so agrees to indemnify Cypress against all liability.
- */
-/** @file
- *
- * Button manager defines generic interface for button events and button type configurations.
- * It exposes interface to configure platform button events (like click,long press) with user configurable timing.
- */
-#pragma once
-
-#include "platform_button.h"
-#include "wiced.h"
-#include "wiced_rtos.h"
-#include "wiced_timer.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/******************************************************
- * Macros
- ******************************************************/
-
-/******************************************************
- * Constants
- ******************************************************/
-
-/******************************************************
- * Enumerations
- ******************************************************/
-
-/**
- * @brief Button Manager events.
- *
- */
-typedef enum
-{
- BUTTON_CLICK_EVENT = (1 << 0), /**< A click is a combination of press and release button events. Typically ~ < 200 ms. */
- BUTTON_SHORT_DURATION_EVENT = (1 << 1), /**< Short duration click event */
- BUTTON_MEDIUM_DURATION_EVENT = (1 << 2), /**< Medium duration click event */
- BUTTON_LONG_DURATION_EVENT = (1 << 3), /**< Long duration click event */
- BUTTON_VERY_LONG_DURATION_EVENT = (1 << 4), /**< Very long duration click event */
- BUTTON_DOUBLE_CLICK_EVENT =
- (1 << 5), /**< A double click is a combination of two single clicks with some delay between them */
- BUTTON_HOLDING_EVENT = (1 << 6), /**< Button is holding over at least two long duration. */
-} button_manager_event_t;
-
-/**
- * @brief Button states.
- *
- */
-typedef enum
-{
- BUTTON_STATE_HELD = (0), /**< Button state held */
- BUTTON_STATE_RELEASED = (1), /**< Button state released */
-} button_manager_button_state_t;
-
-/******************************************************
- * Type Definitions
- ******************************************************/
-
-/**
- * @brief Worker thread structure.
- *
- */
-typedef struct
-{
- wiced_thread_t * thread; /**< Button event thread */
- wiced_queue_t * event_queue; /**< Button event queue */
-} button_worker_thread_t;
-
-/**
- * @brief Button Event Message.
- *
- */
-typedef struct
-{
- event_handler_t function; /**< Button event handler function */
- void * arg; /**< Button event message arguments to be passed */
-} button_event_message_t;
-/******************************************************
- * Structures
- ******************************************************/
-
-/**
- * @brief Button configuration.
- *
- */
-typedef struct
-{
- platform_button_t button; /**< Logical Button-ids which map to physical buttons on the board */
- uint16_t button_event_mask; /**< Button event mask */
- uint32_t application_event; /**< Application event */
-} wiced_button_configuration_t;
-
-/**
- * @brief Button Information.
- *
- */
-typedef struct
-{
- const wiced_button_configuration_t * configuration; /**< Button configuration */
- button_manager_button_state_t current_state; /**< Button current state */
- button_manager_event_t last_sent_event; /**< Button last sent event */
- uint64_t pressed_timestamp; /**< Button pressed time stamp (us) */
- uint64_t released_timestamp; /**< Button released time stamp (us) */
- uint32_t last_released_timestamp; /**< Button last released time stamp */
- wiced_bool_t check_for_double_click; /**< Button double click event or not */
- uint32_t repeat; /**< Button holding counter */
- int32_t debounce_counter; /**< Button debounce counter */
- wiced_timer_t debounce_timer; /**< Button debounce timer */
- wiced_bool_t debouncing; /**< Button debounce state indication */
- wiced_timer_t long_press_timer; /**< Button long press detection timer */
- uint64_t timer_timestamp; /**< Button event time stamp (us) */
-} button_manager_button_t;
-
-/**
- * Button event handler
- *
- * @param button Which button in the list has been pressed/released/held
- * @param event What exact event the button is generating.
- * @param state What exact state the button is in.
- *
- * @return void Library should not care whether app handled the button-events correctly or not.
- *
- */
-typedef void (*wiced_button_event_handler_t)(const button_manager_button_t * button, button_manager_event_t event,
- button_manager_button_state_t state);
-
-/**
- * @brief Button manager Configuration.
- *
- */
-typedef struct
-{
- uint16_t short_hold_duration; /**< held for short duration (ms) */
- uint16_t medium_hold_duration; /**< held for medium duration (ms) */
- uint16_t long_hold_duration; /**< held for long duration (ms) */
- uint16_t very_long_hold_duration; /**< held for very long duration (ms) */
- uint16_t debounce_duration; /**< duration taken to de-bounce (ms) */
- uint16_t double_click_interval; /**< Time interval between two RELEASE events */
- wiced_bool_t continuous_hold_detect; /**< Flag to enable button holding detection.\n
- If this is set to true, the BUTTON_VERY_LONG_DURATION_EVENT is disabled
- and a BUTTON_HOLDING_EVENT will be triggered if a button is pressed over
- twice the long_hold_duration.\n
- The BUTTON_HOLDING_EVENT will continuous be sent every long_hold_duration
- after the first BUTTON_HOLDING_EVENT event been sent. */
- wiced_button_event_handler_t event_handler;
-} wiced_button_manager_configuration_t;
-
-/**
- * @brief Button Manager structure.
- *
- */
-typedef struct
-{
- const wiced_button_manager_configuration_t * configuration; /**< Button manager configuration */
- button_manager_button_t * buttons; /**< Button information */
- uint32_t number_of_buttons; /**< Number of buttons */
- wiced_button_event_handler_t button_callback; /**< Button event handler */
-} button_manager_t;
-
-/**
- * Button's state change call back
- *
- * @param id Id of the button
- * @param new_state What exact new state the button is going to.
- *
- * @return void Library should not care whether app handled the button-events correctly or not.
- */
-
-typedef void (*wiced_button_state_change_callback_t)(platform_button_t id, wiced_bool_t new_state);
-
-/******************************************************
- * Global Variables
- ******************************************************/
-
-/******************************************************
- * Function Declarations
- ******************************************************/
-
-/**
- * The application should call this function to Initialize the Button Manager
- *
- * @param manager : pointer to button manager.
- * @param configuration : Configuration for the button.
- * @param buttons : Button information.
- * @param number_of_buttons : Number of buttons.
- * @return : result.
- */
-extern wiced_result_t wiced_button_manager_init(button_manager_t * manager,
- const wiced_button_manager_configuration_t * configuration,
- button_manager_button_t * buttons, uint32_t number_of_buttons);
-
-/**
- * The application should call this function to de-Initialize the Button Manager
- *
- * @param manager : Pointer to button manager to de-initialize.
- * @return : result.
- */
-extern wiced_result_t wiced_button_manager_deinit(button_manager_t * manager);
-
-/**
- * Checks if there is pending event and then re-send the event.
- *
- * @return void : no return value is expected.
- */
-extern void wiced_button_manager_pending_event_handle(void);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
diff --git a/third_party/infineon/cyw30739_sdk/include/wiced_led_manager.h b/third_party/infineon/cyw30739_sdk/include/wiced_led_manager.h
deleted file mode 100644
index c23f367..0000000
--- a/third_party/infineon/cyw30739_sdk/include/wiced_led_manager.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright 2016-2021, Cypress Semiconductor Corporation (an Infineon company) or
- * an affiliate of Cypress Semiconductor Corporation. All rights reserved.
- *
- * This software, including source code, documentation and related
- * materials ("Software") is owned by Cypress Semiconductor Corporation
- * or one of its affiliates ("Cypress") and is protected by and subject to
- * worldwide patent protection (United States and foreign),
- * United States copyright laws and international treaty provisions.
- * Therefore, you may use this Software only as provided in the license
- * agreement accompanying the software package from which you
- * obtained this Software ("EULA").
- * If no EULA applies, Cypress hereby grants you a personal, non-exclusive,
- * non-transferable license to copy, modify, and compile the Software
- * source code solely for use in connection with Cypress's
- * integrated circuit products. Any reproduction, modification, translation,
- * compilation, or representation of this Software except as specified
- * above is prohibited without the express written permission of Cypress.
- *
- * Disclaimer: THIS SOFTWARE IS PROVIDED AS-IS, WITH NO WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, NONINFRINGEMENT, IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress
- * reserves the right to make changes to the Software without notice. Cypress
- * does not assume any liability arising out of the application or use of the
- * Software or any product or circuit described in the Software. Cypress does
- * not authorize its products for use in any products where a malfunction or
- * failure of the Cypress product may reasonably be expected to result in
- * significant property damage, injury or death ("High Risk Product"). By
- * including Cypress's product in a High Risk Product, the manufacturer
- * of such system or application assumes all risk of such use and in doing
- * so agrees to indemnify Cypress against all liability.
- */
-/** @file
- *
- * This file provides definitions of the LED Manager library interface.
- * LED Manager library provides API's to enable/disable, blink and set brightness of a LED.
- */
-#pragma once
-
-#include "platform_led.h"
-#include "wiced.h"
-#include "wiced_rtos.h"
-#include "wiced_timer.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/******************************************************
- * Macros
- ******************************************************/
-
-/******************************************************
- * Constants
- ******************************************************/
-
-/******************************************************
- * Enumerations
- ******************************************************/
-
-/**
- * @brief Logical LED-id's which map to physical LED's on the board
- *
- */
-typedef platform_led_t wiced_led_t;
-
-/**
- * @brief LED configuration
- *
- */
-typedef struct
-{
- wiced_led_t led; /**< LED id */
- uint16_t bright; /**< in % from 1 to 100 */
-} wiced_led_config_t;
-/******************************************************
- * Global Variables
- ******************************************************/
-
-/******************************************************
- * Function Declarations
- ******************************************************/
-
-/**
- * Function to Initialize the LED Manager
- *
- * @param config : Configuration for the LED.
- * @return : result.
- */
-extern wiced_result_t wiced_led_manager_init(wiced_led_config_t * config);
-
-/**
- * Function to de-initialize the LED Manager
- *
- * @param void : No arguments.
- * @return : result.
- */
-extern wiced_result_t wiced_led_manager_deinit(void);
-
-/**
- * Enables the selected LED
- *
- * @param led : LED to be enabled.
- * @return : result.
- */
-extern wiced_result_t wiced_led_manager_enable_led(wiced_led_t led);
-
-/**
- * Disables the selected LED
- *
- * @param led : LED to be disabled.
- * @return : result.
- */
-extern wiced_result_t wiced_led_manager_disable_led(wiced_led_t led);
-
-/**
- * Reconfigures the LED
- *
- * @param config : Configuration for the LED.
- * @return : result.
- */
-extern wiced_result_t wiced_led_manager_reconfig_led(wiced_led_config_t * config);
-
-/**
- * Function called to blink a LED
- *
- * @param led : LED to be blinked.
- * @param on_period : on period (ms)
- * @param off_period : off period (ms)
- * @return : result.
- */
-wiced_result_t wiced_led_manager_blink_led(wiced_led_t led, uint32_t on_period, uint32_t off_period);
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
diff --git a/third_party/infineon/cyw30739_sdk/merge_hex.py b/third_party/infineon/cyw30739_sdk/merge_hex.py
deleted file mode 100644
index ed9c034..0000000
--- a/third_party/infineon/cyw30739_sdk/merge_hex.py
+++ /dev/null
@@ -1,143 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (c) 2022 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.
-#
-"""Hex file merger
-
-This is a helper script for merging SS, DS and XS into a single hex file.
-
-"""
-
-import argparse
-import os
-import pathlib
-import re
-import zlib
-from collections import OrderedDict
-from struct import pack, unpack
-
-import leb128
-from intelhex import IntelHex
-
-THREAD_FACTORY_KEY_BASE = 0x2000
-MATTER_FACTORY_KEY_BASE = 0x2100
-
-
-def main():
- args = parse_args()
-
- configs = gen_thread_factory_config()
- configs.update(gen_matter_factory_config(args.config_header))
-
- parse_config_args(configs, args.config)
-
- merged_hex = insert_config(IntelHex(str(args.ss_hex)), configs)
- merged_hex.merge(IntelHex(str(args.ds_hex)))
- merged_hex.merge(IntelHex(str(args.xs_hex)))
- merged_hex.write_hex_file(args.output)
-
-
-def parse_args():
- parser = argparse.ArgumentParser()
- parser.add_argument("--output", required=True, type=pathlib.Path)
- parser.add_argument("--ss_hex", required=True, type=pathlib.Path)
- parser.add_argument("--ds_hex", required=True, type=pathlib.Path)
- parser.add_argument("--xs_hex", required=True, type=pathlib.Path)
- parser.add_argument("--config_header", required=True, type=pathlib.Path)
- parser.add_argument("--config", action="append", type=str)
- return parser.parse_args()
-
-
-def gen_thread_factory_config() -> OrderedDict:
- configs = OrderedDict()
- configs["ExtendedAddress"] = {"key": THREAD_FACTORY_KEY_BASE, "value": os.urandom(8)}
- return configs
-
-
-def gen_matter_factory_config(path: pathlib.Path) -> OrderedDict:
- # compile the regex for extracting name and key of factory configurations.
- factory_config_re = re.compile(r"""
- .* # Prefix
- kConfigKey_(\w+) # Parse the config name
- \s*=.* # Allow spaces
- kChipFactory_KeyBase # Only match factory configurations
- \s*,\s* # Allow spaces
- (0x[0-9a-fA-F]+) # Parse the config key
- """, re.VERBOSE)
-
- configs = OrderedDict()
- with open(str(path), mode="r") as config_file:
- for line in config_file:
- match = factory_config_re.match(line.strip())
- if match:
- name = match[1]
- key = MATTER_FACTORY_KEY_BASE + int(match[2], 0)
- configs[name] = {"key": key}
- return configs
-
-
-def parse_config_args(configs: OrderedDict, args: list):
- for arg in args:
- name, category, value = arg.split(":")
-
- if name not in configs:
- print(f"[Warning] Ignored unknown config: {name}")
- continue
-
- if category == "address":
- addr = bytearray.fromhex(value)
-
- if len(addr) == 6:
- # RFC 4291 Appendix A
- addr[3:3] = b'\xff\xfe'
- elif len(addr) != 8:
- print(f"[Warning] Ignored config {name}: Invalid length: {len(addr)}")
- return
-
- configs[name]["value"] = addr[::-1]
- elif category == "file":
- with open(value, mode="rb") as file:
- configs[name]["value"] = file.read()
- else:
- print(f"[Warning] Ignored config {name}: Invalid category: {category}")
-
-
-def insert_config(origin_hex: IntelHex, configs: OrderedDict):
- ss_segment = origin_hex.segments()[0]
-
- origin_ss_header = origin_hex.tobinarray(
- start=ss_segment[0], end=ss_segment[0] + 0x10 - 1)
- origin_ss_data = origin_hex.tobinarray(
- start=ss_segment[0] + 0x10, end=ss_segment[1] - 1)
-
- signature, _, _ = unpack("<8sLL", origin_ss_header)
-
- ss_data = bytearray()
- for config in configs.values():
- if "value" in config:
- ss_data += config["key"].to_bytes(2, byteorder="little")
- ss_data += leb128.u.encode(len(config["value"]))
- ss_data += config["value"]
- ss_data += origin_ss_data
-
- ss_header = pack("<8sLL", signature, zlib.crc32(ss_data), len(ss_data))
-
- ss_hex = IntelHex()
- ss_hex.puts(ss_segment[0], ss_header + ss_data)
- return ss_hex
-
-
-if __name__ == "__main__":
- main()
diff --git a/third_party/infineon/cyw30739_sdk/repos/30739A0 b/third_party/infineon/cyw30739_sdk/repos/30739A0
deleted file mode 160000
index f951c7d..0000000
--- a/third_party/infineon/cyw30739_sdk/repos/30739A0
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit f951c7d3d3c37e995b38ea1fdfe1cdae9a5e9cc8
diff --git a/third_party/infineon/cyw30739_sdk/repos/CYW930739M2EVB-01 b/third_party/infineon/cyw30739_sdk/repos/CYW930739M2EVB-01
deleted file mode 160000
index d3e46e8..0000000
--- a/third_party/infineon/cyw30739_sdk/repos/CYW930739M2EVB-01
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit d3e46e83a248fdd4617839761ce2333f8eac1f2c
diff --git a/third_party/infineon/cyw30739_sdk/repos/btsdk-include b/third_party/infineon/cyw30739_sdk/repos/btsdk-include
deleted file mode 160000
index b9a1aac..0000000
--- a/third_party/infineon/cyw30739_sdk/repos/btsdk-include
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit b9a1aac342f2399ccd4894b0fe6f9e323a613b68
diff --git a/third_party/infineon/cyw30739_sdk/repos/btsdk-tools b/third_party/infineon/cyw30739_sdk/repos/btsdk-tools
deleted file mode 160000
index 0943e94..0000000
--- a/third_party/infineon/cyw30739_sdk/repos/btsdk-tools
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 0943e94ccca9ed871b0e9a6ebfbc126ad50a6d11
diff --git a/third_party/infineon/cyw30739_sdk/scripts/gen_ss_cgs.py b/third_party/infineon/cyw30739_sdk/scripts/gen_ss_cgs.py
deleted file mode 100644
index aaf1ef4..0000000
--- a/third_party/infineon/cyw30739_sdk/scripts/gen_ss_cgs.py
+++ /dev/null
@@ -1,128 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (c) 2022 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.
-#
-"""SS CGS generator
-
-This script generates SS CGS and HDF files.
-
-"""
-
-import argparse
-import io
-import os
-import pathlib
-import sys
-from collections import OrderedDict
-
-THREAD_FACTORY_KEY_BASE = 0x2000
-MATTER_FACTORY_KEY_BASE = 0x2100
-
-
-def main():
- args = parse_args()
-
- configs = gen_thread_factory_config()
-
- gen_ss_hdf(args.ss_hdf, configs)
- gen_ss_cgs(args.ss_cgs, args.ss_hdf, configs)
- gen_empty_cgs(args.empty_cgs, args.ss_hdf, configs)
-
-
-def parse_args():
- parser = argparse.ArgumentParser()
- parser.add_argument("--ss_hdf", required=True, type=pathlib.Path)
- parser.add_argument("--ss_cgs", required=True, type=pathlib.Path)
- parser.add_argument("--empty_cgs", required=True, type=pathlib.Path)
- return parser.parse_args()
-
-
-def gen_thread_factory_config() -> OrderedDict:
- configs = OrderedDict()
- configs["ExtendedAddress"] = {"key": THREAD_FACTORY_KEY_BASE, "value": os.urandom(8)}
- return configs
-
-
-def gen_ss_hdf(path: pathlib.Path, configs: OrderedDict):
- with open(str(path), mode="w") as hdf:
- hdf.write("""\
-SECTION "Config Data Entries" 0
-{
-""")
- for name, config in configs.items():
- if "value" in config:
- write_hdf_command(hdf, name, config["key"])
-
- hdf.write("}")
-
-
-def write_hdf_command(hdf: io.TextIOBase, name: str, key: int):
- hdf.write(f"""\
- COMMAND "{name}" {key:#x}
- {{
- PARAM "Data"
- uint8[0xff00] omit_pad_bytes;
- }}
-""")
-
-
-def gen_ss_cgs(cgs_path: pathlib.Path, hdf_path: pathlib.Path, configs: OrderedDict):
- with open(str(cgs_path), mode="w") as cgs:
- write_cgs_header(cgs, hdf_path)
-
- for name, config in configs.items():
- if "value" in config:
- write_cgs_data(cgs, name, config["value"])
-
-
-def gen_empty_cgs(cgs_path: pathlib.Path, hdf_path: pathlib.Path, configs: OrderedDict):
- with open(str(cgs_path), mode="w") as cgs:
- write_cgs_header(cgs, hdf_path)
-
- for name, config in configs.items():
- if "value" in config:
- write_cgs_data(cgs, name)
- break
-
-
-def write_cgs_header(cgs: io.TextIOBase, hdf_path: pathlib.Path):
- cgs.write(f"""\
-# DO NOT EDIT MANUALLY! FW2 VERSION INCLUDESSCRC32 INCLUDEDSCRC32
-DEFINITION <{hdf_path}>
-""")
-
-
-def write_cgs_data(cgs: io.TextIOBase, name: str, data: bytes = b""):
- cgs.write(f"""\
-ENTRY "{name}"
-{{
- "Data" =
- COMMENTED_BYTES
- {{
- <hex>
-""")
-
- indent = " "
- for i in range(0, len(data), 16):
- cgs.write(indent + data[i:i+16].hex(' ') + "\n")
-
- cgs.write("""\
- } END_COMMENTED_BYTES
-}
-""")
-
-
-if __name__ == "__main__":
- main()
diff --git a/third_party/infineon/cyw30739_sdk/scripts/wiced-gen-ld.pl b/third_party/infineon/cyw30739_sdk/scripts/wiced-gen-ld.pl
deleted file mode 100644
index 28c3cff..0000000
--- a/third_party/infineon/cyw30739_sdk/scripts/wiced-gen-ld.pl
+++ /dev/null
@@ -1,549 +0,0 @@
-#!/usr/bin/perl
-#
-# Copyright 2016-2021, Cypress Semiconductor Corporation (an Infineon company) or
-# an affiliate of Cypress Semiconductor Corporation. All rights reserved.
-#
-# This software, including source code, documentation and related
-# materials ("Software") is owned by Cypress Semiconductor Corporation
-# or one of its affiliates ("Cypress") and is protected by and subject to
-# worldwide patent protection (United States and foreign),
-# United States copyright laws and international treaty provisions.
-# Therefore, you may use this Software only as provided in the license
-# agreement accompanying the software package from which you
-# obtained this Software ("EULA").
-# If no EULA applies, Cypress hereby grants you a personal, non-exclusive,
-# non-transferable license to copy, modify, and compile the Software
-# source code solely for use in connection with Cypress's
-# integrated circuit products. Any reproduction, modification, translation,
-# compilation, or representation of this Software except as specified
-# above is prohibited without the express written permission of Cypress.
-#
-# Disclaimer: THIS SOFTWARE IS PROVIDED AS-IS, WITH NO WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, NONINFRINGEMENT, IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress
-# reserves the right to make changes to the Software without notice. Cypress
-# does not assume any liability arising out of the application or use of the
-# Software or any product or circuit described in the Software. Cypress does
-# not authorize its products for use in any products where a malfunction or
-# failure of the Cypress product may reasonably be expected to result in
-# significant property damage, injury or death ("High Risk Product"). By
-# including Cypress's product in a High Risk Product, the manufacturer
-# of such system or application assumes all risk of such use and in doing
-# so agrees to indemnify Cypress against all liability.
-#
-use READELF;
-# read patch.elf and generate linker directive file
-
-# call with "perl wiced-gen-ld.pl <args> patch.elf out=<*.ld>"
-# the "patch.elf" is parsed to determine where to start the application memory
-# the "out=<*.ld>" file is the output linker script
-# arguments:
-# SRAM_BEGIN_ADDR=0x123456, SRAM_LENGTH=0x1234: start and length of SRAM section for app code and data
-# NUM_PATCH_ENTRIES=256: used to calculate reserved space in SRAM for patch entries
-# ISTATIC_BEGIN=0x123456, ISTATIC_LEN=0x1234: start and length of static section data, typically encrypted keys
-# PRAM_OBJ=abc.o;def.o;ghi.o: code/rodata for patch ram
-# XIP_LEN=0x1234, XIP_OBJ=abc.o;def.o;ghi.o: execute in place area for on-chip-flash starting at 0x504000, contains code and rodata from listed object files
-# UNUSED_BEGIN=0x123456, UNUSED_LEN=0x1234: start and length of an UNUSED section defined to avoid loading anything into
-# DIRECT_LOAD=1: indicates RAM download rather than FLASH
-# overlay=overlays.ld: a linker script snippet generated for an overlay section
-
-# ram is extended with PRAM (taking from patch space) or XIP (taking from on-chip-flash, code or rodata only)
-# .dsp_pram_section is for dsp download (libraries/codec_ak4679_lib/akm4679_dsp_*.h)
-
-# look up for memory map and section input/output information
-my $mem_lut = {
- ".app_xip_area" => {
- "sections" => [
- "KEEP(*(.xs_header))",
-# argument XIP_OBJ will add section matches $(XIP_OBJ)(.text.* .gnu.linkonce.t.* .rodata .constdata* .rodata.* .gnu.linkonce.r.* )
-# special section for Position Independent trampoline functions.
- "*(.pisec_*)",
- "KEEP(*(.data_in_xip_area))",
- "KEEP(*(.dsp_pram_section))",],
- "mem_type" => "xip_section",
- "pre" => ["xip_area_begin"],
- "post" => ["spar_irom_end","xip_area_end"],},
- ".setup" => {
- "sections" => [
- "*(.init_code)",
- "*(.init_text)",
- "*(.init_data)",
- "*(.spar_setup)"],
- "mem_type" => "ram",
- "pre" => [],
- "post" => [],},
- ".text" => {
- "sections" => [
- "*(.app_init_code)",
- "*(.emb_text)",
- "*(.text)",
- "*(.text_in_ram)",
- "*(.text.*)",
- "*(EmHeAacDec)",
- "*(.gnu.linkonce.t.*)",
- "*(.glue_7t)",
- "*(.glue_7)",
- "*(.vfp11_veneer)",
- "*(.v4_bx)",
- "*(.ARM.extab*)",
- "*(.gnu.linkonce.armextab.*)",
- "*(.ARM.exidx*)",
- "*(.gnu.linkonce.armexidx.*)",
- "*(.vpc_decoder_section)",
- "PROVIDE_HIDDEN (__init_array_start = .);",
- "KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))",
- "KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))",
- "PROVIDE_HIDDEN (__init_array_end = .);"],
- "mem_type" => "ram",
- "pre" => [],
- "post" => [],},
- ".text.mbedtls" => {
- "sections" => [
- "libmbedtls.*.o(.text.*)",
- ],
- "mem_type" => "ram",
- "pre" => [],
- "post" => [],
- },
- ".rodata" => {
- "sections" => [
- "*(const_drom_var)",
- "*(.rodata)",
- "*(.constdata*)",
- "*(.rodata.*)",
- "*(.gnu.linkonce.r.*)",
- "*(.data.rom)"],
- "mem_type" => "ram",
- "pre" => [],
- "post" => ["spar_irom_end"],},
- ".data" => {
- "sections" => [
- "*(.data)",
- "*(.data.*)",
- "*(.gnu.linkonce.d.*)",
- "*(.init_patch_table)"],
- "mem_type" => "ram",
- "pre" => ["spar_iram_begin", "spar_iram_data_begin"],
- "post" => ["spar_iram_data_end"],},
- ".bss" => {
- "sections" => [
- "*(.bss)",
- "*(.bss.*)",
- "*(.gnu.linkonce.b.*)",
- "*(COMMON)"],
- "mem_type" => "ram",
- "pre" => ["spar_iram_bss_begin"],
- "post" => ["spar_iram_bss_end", "spar_iram_end"],},
- ".unused" => {
- "sections" => [
- "*(.code_in_retention_ram)",
- "*(.data_in_retention_ram)"],
- "mem_type" => "unused",
- "pre" => ["unused_iram_begin"],
- "post" => ["unused_iram_end"],},
- ".aon" => {
- "sections" => [
- "*(always_on_ram_var)",
- "*(.aon_code)",
- "*(.data_in_retention_ram)",
- "*(.code_in_retention_ram)"],
- "mem_type" => "aon",
- "pre" => ["aon_iram_begin"],
- "post" => ["aon_iram_end"],},
- ".static_area" => {
- "sections" => [
- "KEEP(*(.data_in_static_area))"],
- "mem_type" => "static_section",
- "pre" => ["static_area_begin"],
- "post" => ["static_area_end"],},
- ".pram_rodata" => {
- "sections" => [
- "KEEP(*(.dsp_pram_section))"],
- "mem_type" => "pram",
- "pre" => [],
- "post" => ["pram_area_end"],},
- ".log_section" => {
- "sections" => [
- "KEEP(*(log_data))"],
- "mem_type" => "log_section",
- "pre" => [],
- "post" => [],},
-};
-
-my $xip_extra_in = [
- "PROVIDE_HIDDEN (__init_array_start = .);",
- "KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))",
- "KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))",
- "PROVIDE_HIDDEN (__init_array_end = .);",
- "*(.app_init_code)",
- "*(.emb_text)",
- "*(.text)",
- "*(EmHeAacDec)",
- "*(.text.*)",
- "*(.gnu.linkonce.t.*)",
- "*(i.*)",
- "*(.glue_7t)",
- "*(.glue_7)",
- "*(.vfp11_veneer)",
- "*(.v4_bx)",
- "*(.ARM.extab*)",
- "*(.gnu.linkonce.armextab.*)",
- "*(.ARM.exidx*)",
- "*(.gnu.linkonce.armexidx.*)",
- "*(const_drom_var)",
- "*(.rodata)",
- "*(.constdata*)",
- "*(.rodata.*)",
- "*(.gnu.linkonce.r.*)",
- "*(.data.rom)",
-];
-
-main();
-
-sub main
-{
- my $param;
-# print "args: @ARGS\n";
-
- foreach my $arg (@ARGV) {
- if($arg =~ /\.elf$/) {
- $param->{'elf'} = $arg;
- }
- if($arg =~ /\.sym$/) {
- $param->{'sym'} = $arg;
- }
- elsif($arg =~ /^ISTATIC_BEGIN=(\w+)/) {
- $param->{'ISTATIC_BEGIN'} = hex($1);
- }
- elsif($arg =~ /^ISTATIC_LEN=(\w+)/) {
- $param->{'ISTATIC_LEN'} = hex($1);
- }
- elsif($arg =~ /^UNUSED_BEGIN=(\w+)/) {
- $param->{'UNUSED_BEGIN'} = hex($1);
- }
- elsif($arg =~ /^UNUSED_LEN=(\w+)/) {
- $param->{'UNUSED_LEN'} = hex($1);
- }
- elsif($arg =~ /^AON_AREA_END=(\w+)/) {
- $param->{'AON_AREA_END'} = hex($1);
- }
- elsif($arg =~ /^SRAM_BEGIN_ADDR=(\w+)/) {
- $param->{'SRAM_BEGIN_ADDR'} = hex($1);
- }
- elsif($arg =~ /^SRAM_LENGTH=(\w+)/) {
- $param->{'SRAM_LENGTH'} = hex($1);
- }
- elsif($arg =~ /^PATCH_RAM_OBJ=(.*)/) {
- $param->{'PATCH_RAM_OBJ'} = $1;
- my @patch_ram_obj = split ";", $1;
- my @patch_ram_o;
- foreach my $obj (@patch_ram_obj) {
- $obj =~ s/^\./\*/;
- $obj .= " (.text.* .gnu.linkonce.t.* .rodata .constdata* .rodata.* .gnu.linkonce.r.*)";
- push @patch_ram_o, $obj;
- }
- unshift @{$mem_lut->{'.pram_rodata'}->{sections}}, @patch_ram_o;
- }
- elsif($arg =~ /^NUM_PATCH_ENTRIES=(\d+)/) {
- $param->{'NUM_PATCH_ENTRIES'} = $1;
- }
- elsif($arg =~ /^DIRECT_LOAD=(\d)/) {
- $param->{'direct_load'} = $1;
- }
- elsif($arg =~ /^BTP=(.*)/) {
- $param->{'btp'} = $1;
- }
- elsif($arg =~ /^FLASH0_BEGIN_ADDR=(\w+)/) {
- $param->{'FLASH0_BEGIN_ADDR'} = hex($1);
- }
- elsif($arg =~ /^FLASH0_LENGTH=(\w+)/) {
- $param->{'FLASH0_LENGTH'} = hex($1);
- }
- elsif($arg =~ /^XIP_DS_OFFSET=(\w+)/) {
- $param->{'XIP_DS_OFFSET'} = hex($1);
- $param->{'xip'} = 1;
- push @{$mem_lut->{'.app_xip_area'}->{sections}}, @{$xip_extra_in};
- }
- elsif($arg =~ /^XIP_LEN=(\w+)/) {
- $param->{'XIP_LEN'} = hex($1);
- }
- elsif($arg =~ /^XIP_OBJ=(.*)/) {
- my @xip_obj = split ";", $1;
- my @xip_o;
- foreach my $obj (@xip_obj) {
- $obj =~ s/^\./\*/;
- $obj .= " (.text.* .gnu.linkonce.t.* .rodata .constdata* .rodata.* .gnu.linkonce.r.*)";
- push @xip_o, $obj;
- }
- unshift @{$mem_lut->{'.app_xip_area'}->{sections}}, @xip_o;
- }
- elsif($arg =~ /^APP_DS2_LEN=(\w+)/) {
- $param->{'APP_DS2_LEN'} = hex($1);
- }
- elsif($arg =~ /^DS_LOCATION=(\w+)/) {
- $param->{'DS_LOCATION'} = hex($1);
- }
- elsif($arg =~ /^OTA_UPGRADE_STORE=(\w+)/) {
- $param->{'OTA_UPGRADE_STORE'} = $1;
- }
- elsif($arg =~ /^overlay=(.*)$/) {
- $param->{'overlay'} = $1;
- warn "overlay is $1\n";
- }
- elsif($arg =~ /^out=(.*)/) {
- $param->{'outfile'} = $1;
- }
- }
-
- if(defined $param->{btp} && defined $param->{FLASH0_BEGIN_ADDR} && defined $param->{FLASH0_LENGTH}) {
- open(my $BTP, "<", $param->{btp}) || die "Could not open *.btp file \"$param->{btp}\", $!";
- while(defined(my $line = <$BTP>)) {
- if($line =~ /\s*(\w+)\s*\=\s*(0x[0-9a-fA-F]+)/) {
- $param->{$1} = hex($2);
- }
- elsif($line =~ /\s*(\w+)\s*\=\s*([0-9]+)/) {
- $param->{$1} = int($2);
- }
- }
- close $BTP;
- }
- # override ConfigDSLocation if DS_LOCATION provided on command line
- if(defined $param->{ConfigDSLocation} && defined $param->{DS_LOCATION}) {
- $param->{ConfigDSLocation} = $param->{DS_LOCATION};
- }
-
- my $section_lut = {};
- if(defined $param->{elf}) {
- my $sections = [];
- my $stringtable = {};
- my $sym_str_tbl = {};
- my $symbol_entries = [];
- parse_elf($param->{elf}, $sections, $stringtable, $sym_str_tbl, $symbol_entries, 1);
-
- #printf "got %d sections\n", scalar(@{$sections});
- foreach my $section (@{$sections}) {
- if(!defined $section->{name}) {
- #print "section name index $section->{sh_name}\n";
- #printf("%s\n", $stringtable->{$section->{sh_name}}) if defined $section->{sh_name};
- $section->{name} = $stringtable->{$section->{sh_name}};
- }
- $section_lut->{$section->{name}} = $section;
- #printf "section %s: start 0x%x len 0x%x\n", $section->{name}, $section->{sh_addr}, $section->{sh_size};
- }
- }
- elsif(defined $param->{sym}) {
- # using sym file, so fake reading section headers from elf
- open(my $SYM, "<", $param->{sym}) or die "Could not read $param->{sym}, $!\n";
- while(defined(my $line = <$SYM>)) {
- if($line =~ /(\w+)\s*=\s*0x([0-9A-Fa-f]+)/) {
- last if $1 eq "END_SECTION_INFO";
- $section_lut->{$1} = { sh_addr => hex($2) };
- }
- }
- close $SYM;
- }
- $param->{SRAM_START_ADDR} = $section_lut->{first_free_section_in_SRAM}->{sh_addr}
- if defined $section_lut->{first_free_section_in_SRAM}->{sh_addr};
- $param->{SRAM_START_ADDR} = $section_lut->{FIRST_FREE_SECTION_IN_SRAM}->{sh_addr}
- if defined $section_lut->{FIRST_FREE_SECTION_IN_SRAM}->{sh_addr};
- # for DIRECT_LOAD, add app code after init sections (including SlimBoot)
- $param->{SRAM_START_ADDR} = $section_lut->{POST_INIT_SECTION_IN_SRAM}->{sh_addr}
- if defined $section_lut->{POST_INIT_SECTION_IN_SRAM}->{sh_addr} &&
- defined $param->{direct_load} && $param->{direct_load};
- die "Ram start undefined\n" if !defined $param->{SRAM_START_ADDR};
- output_ld($section_lut, $param);
-}
-
-sub output_ld
-{
- my ($sections, $param) = @_;
- my ($ram_start, $ram_begin, $ram_end, $ram_len,
- $rom_start, $rom_begin, $rom_end, $rom_len,
- $aon_begin, $aon_end, $aon_len,
- $xip_start, $xip_len);
- $rom_start = $sections->{CODE_AREA}->{sh_addr} if defined $sections->{CODE_AREA};
- die "Could not locate CODE_AREA in patch elf\n" if !defined $rom_start;
-
- $ram_start = $param->{SRAM_START_ADDR};
- my $num_patches = $param->{NUM_PATCH_ENTRIES};
- $num_patches = 256 if !defined $num_patches;
-
- $ram_begin = $param->{SRAM_BEGIN_ADDR};
- $ram_end = $ram_begin + $param->{SRAM_LENGTH};
- die "Could not locate data ram start in patch elf\n" if !defined $ram_begin;
- die "Could not locate data ram end in patch elf\n" if !defined $ram_end;
- if (defined $sections->{FIRST_FREE_SECTION_IN_PROM}) {
- $rom_begin = $sections->{FIRST_FREE_SECTION_IN_PROM}->{sh_addr};
- $rom_end = $sections->{PATCH_CODE_END}->{sh_addr};
- die "Could not locate code ram start in patch elf\n" if !defined $rom_begin;
- die "Could not locate code ram end in patch elf\n" if !defined $rom_end;
- }
-
- if(defined $sections->{FIRST_FREE_SECTION_IN_AON}) {
- $aon_begin = $sections->{FIRST_FREE_SECTION_IN_AON}->{sh_addr};
- $aon_end = $sections->{AON_AREA_END}->{sh_addr};
- $aon_end = $param->{AON_AREA_END} if !defined $aon_end;
- die "Could not locate aon ram start in patch elf\n" if !defined $aon_begin;
- die "Could not locate aon ram end in patch elf\n" if !defined $aon_end;
- }
-
- my $patch_replace_area = $num_patches * 4;
- $ram_len = $ram_end - $ram_start - $patch_replace_area;
- $rom_len = $rom_end - $rom_begin if defined $rom_begin;
- $aon_len = $aon_end - $aon_begin if defined $aon_begin;
-
-# $(eval LINK_LOC_FLAGS += ISTATIC_BEGIN=$(PLATFORM_APP_SPECIFIC_STATIC_DATA) ISTATIC_LEN=$(PLATFORM_APP_SPECIFIC_STATIC_LEN) IRAM_BEGIN=$(IRAM_BEGIN) IRAM_LEN=$(IRAM_LEN) IROM_BEGIN=$(IROM_BEGIN) IROM_LEN=$(IROM_LEN) IAON_BEGIN=$(IAON_BEGIN) IAON_LEN=$(IAON_LEN) )
-# $(QUIET)$(XCC) -E -x c -P $(addprefix -D,$(LINK_LOC_FLAGS)) -I $(dir $(ELF_OUT)) -o $@ $<
- $param->{ISTATIC_BEGIN} = $param->{ISTATIC_BEGIN} if defined $param->{ISTATIC_BEGIN};
- $param->{ISTATIC_LEN} = $param->{ISTATIC_LEN} if defined $param->{ISTATIC_LEN};
- $param->{'direct_load'} = 0 if !defined $param->{direct_load};
-
- open(my $OUT, ">", $param->{outfile}) || die "ERROR: Cannot open $param->{outfile}, $!";
-
- print $OUT "OUTPUT_FORMAT (\"elf32-littlearm\", \"elf32-bigarm\", \"elf32-littlearm\")\n";
- print $OUT "SEARCH_DIR(.)\n";
-# print $OUT "/* @ARGV */\n";
-# print $OUT "/*\n";
-# foreach my$key (sort(keys(%{$param}))) {
-# print $OUT "$key => $param->{$key}\n";
-# }
-# print $OUT "*/\n";
- if(defined $rom_start) {
- print $OUT sprintf "/* pram_patch_begin=0x%06X pram_patch_end=0x%06X pram_end=0x%06X */\n", $rom_start, $rom_begin, $rom_end;
- }
- print $OUT sprintf "/* ram_patch_begin=0x%06X ram_patch_end=0x%06X ram_end=0x%06X */\n", $sections->{SRAM_AREA}->{sh_addr}, $ram_start, $ram_end;
- if(defined $aon_len) {
- print $OUT sprintf "/* aon_patch_begin=0x%06X aon_patch_end=0x%06X aon_end=0x%06X */\n", $sections->{AON_AREA}->{sh_addr}, $aon_begin, $aon_end;
- }
- if(defined $aon_len) {
- print $OUT sprintf "/* app_ram_begin=0x%06X app_ram_end=0x%06X */\n", $ram_start, $ram_start+$ram_len;
- }
- if(defined $param->{FLASH0_BEGIN_ADDR} && defined $param->{FLASH0_LENGTH}) {
- print $OUT sprintf "/* FLASH0_BEGIN_ADDR=0x%06X FLASH0_LENGTH=0x%06X */\n", $param->{FLASH0_BEGIN_ADDR}, $param->{FLASH0_LENGTH};
- }
- if(defined $param->{DLConfigSSLocation}) {
- print $OUT sprintf "/* FLASH0_SS=0x%06X */\n", $param->{DLConfigSSLocation};
- }
- if(defined $param->{DLConfigVSLocation}) {
- print $OUT sprintf "/* FLASH0_VS=0x%06X */\n", $param->{DLConfigVSLocation};
- }
- if(defined $param->{ConfigDSLocation}) {
- print $OUT sprintf "/* FLASH0_DS=0x%06X */\n", $param->{ConfigDSLocation};
- }
- if(defined $param->{ConfigDS2Location}) {
- if(defined $param->{APP_DS2_LEN}) {
- $param->{ConfigDS2Location} = $param->{FLASH0_BEGIN_ADDR} + $param->{FLASH0_LENGTH} - $param->{APP_DS2_LEN};
- }
- print $OUT sprintf "/* FLASH0_DS2=0x%06X */\n", $param->{ConfigDS2Location};
- }
- if(defined $param->{ConfigDSLocation}) {
- my $store = $param->{ConfigDS2Location} - $param->{ConfigDSLocation};
- $param->{'OTA_UPGRADE_STORE'} = 'off_chip_sflash' if !defined $param->{OTA_UPGRADE_STORE};
- $store /=2 if $param->{OTA_UPGRADE_STORE} eq 'on_chip_flash';
- print $OUT sprintf "/* UPGRADE_STORAGE_LENGTH=0x%06X (%s) */\n", $store, $param->{OTA_UPGRADE_STORE};
- }
-
- print $OUT "MEMORY\n";
- print $OUT "{\n";
- print $OUT sprintf "\tram (rwx) : ORIGIN = 0x%X, LENGTH = 0x%X\n", $ram_start, $ram_len;
- if(defined $aon_len) {
- print $OUT sprintf "\taon (rwx) : ORIGIN = 0x%X, LENGTH = 0x%X\n", $aon_begin, $aon_len;
- }
- if(defined $param->{UNUSED_LEN}) {
- print $OUT sprintf "\tunused (rwx) : ORIGIN = 0x%X, LENGTH = %d\n", $param->{UNUSED_BEGIN}, $param->{UNUSED_LEN};
- }
- if(defined $param->{ISTATIC_BEGIN}) {
- print $OUT sprintf "\tstatic_section (r) : ORIGIN = 0x%X, LENGTH = 0x%X\n", $param->{ISTATIC_BEGIN}, $param->{ISTATIC_LEN};
- }
- if(defined $param->{xip}) {
- $xip_start = $param->{ConfigDSLocation} + $param->{XIP_DS_OFFSET};
- $xip_len = $param->{XIP_LEN};
- $xip_len = $param->{FLASH0_LENGTH} - ($xip_start - $param->{ConfigDSLocation}) if !defined $xip_len;
- print $OUT sprintf "\txip_section (rx) : ORIGIN = 0x%X, LENGTH = 0x%X\n", $xip_start, $xip_len;
- }
- if(defined $param->{PATCH_RAM_OBJ}) {
- print $OUT sprintf "\tpram (rwx) : ORIGIN = 0x%X, LENGTH = 0x%X\n", $rom_begin, $rom_end - $rom_begin;
- }
- print $OUT sprintf "\tlog_section (r) : ORIGIN = 0x81000004, LENGTH = 0x100000\n";
- print $OUT "}\n";
-
- print $OUT "EXTERN(spar_irom_begin spar_irom_end spar_irom_length);\n";
- print $OUT "EXTERN(spar_iram_begin spar_iram_end spar_iram_length);\n";
- print $OUT "EXTERN(spar_iram_data_begin spar_iram_data_end spar_iram_data_length);\n";
- print $OUT "EXTERN(spar_iram_bss_begin spar_iram_bss_end spar_iram_bss_length);\n";
- print $OUT "EXTERN(spar_irom_data_begin);\n";
- print $OUT "EXTERN(aon_iram_end);\n" if defined $aon_len;
- print $OUT "EXTERN(xip_area_begin);\n" if defined $xip_start;
- print $OUT "EXTERN(xip_area_end);\n" if defined $xip_len;
-
- print $OUT "PROVIDE(spar_irom_length = spar_irom_end - spar_irom_begin);\n";
- print $OUT "PROVIDE(spar_iram_length = spar_iram_end - spar_iram_begin);\n";
- print $OUT "PROVIDE(spar_iram_data_length = spar_iram_data_end - spar_iram_data_begin);\n";
- print $OUT "PROVIDE(spar_iram_bss_length = spar_iram_bss_end - spar_iram_bss_begin);\n";
-
- print $OUT "SECTIONS\n";
- print $OUT "{\n";
- printf $OUT sprintf "\tspar_irom_begin = 0x%X;\n", $ram_start;
-
-# print "\t#include \"spar_ram_overlays.ld\"\n";
- if(defined $param->{overlay}) {
- open(my $OVER, "<", $param->{overlay}) || die "Could not open overlay *.ld file \"$param->{overlay}\", $!";
- while(defined(my $line = <$OVER>)) {
- print $OUT $line;
- }
- close $OVER;
- }
-
- output_section('.text.mbedtls', $mem_lut, $OUT);
-
- # if objects are assigned to XIP, match their .text and .rodata
- output_section('.app_xip_area', $mem_lut, $OUT) if defined $param->{xip};
-
- # When direct loading, don't overlap init code with dynamic allocation.
- if($param->{direct_load})
- {
- output_section('.setup', $mem_lut, $OUT);
- }
- output_section('.pram_rodata', $mem_lut, $OUT) if defined $param->{PATCH_RAM_OBJ};
- output_section('.text', $mem_lut, $OUT);
- output_section('.rodata', $mem_lut, $OUT);
- output_section('.data', $mem_lut, $OUT);
-
- # Nothing to load because it is loaded from EEPROM/SF at boot.
- print $OUT "\tspar_irom_data_begin = spar_iram_data_begin;\n";
- output_section('.bss', $mem_lut, $OUT);
-
- if(!$param->{direct_load}) {
- # Place the setup area after bss so that when dynamic allocation occurs
- # after spar setup, it will reclaim the RAM taken up by the setup function.
- output_section('.setup', $mem_lut, $OUT);
- }
- output_section('.aon', $mem_lut, $OUT) if defined $aon_len;
- output_section('.static_area', $mem_lut, $OUT) if defined $param->{ISTATIC_BEGIN};
- output_section('.log_section', $mem_lut, $OUT);
- print $OUT "}\n";
-}
-
-sub output_section
-{
- my ($name, $lut, $fh, $pre, $post) = @_;
- my $info = $lut->{$name};
- die "Could not find ld table entry for $name\n" if !defined $info;
-
- my $align = "ALIGN (4)";
- $align = "" if $name eq '.text';
-
- print $fh "\t$name : $align\n\t{\n";
- print $fh "\t\tCREATE_OBJECT_SYMBOLS\n";
- foreach my $sym (@{$info->{pre}}) {
- print $fh "\t\t$sym = .;\n";
- }
- foreach my $sect (@{$info->{sections}}) {
- print $fh "\t\t$sect\n";
- }
- foreach my $sym (@{$info->{post}}) {
- print $fh "\t\t$sym = .;\n";
- }
- print $fh "\t} >$info->{mem_type}\n";
-# print "\n";
-}
diff --git a/third_party/infineon/cyw30739_sdk/src/ota_fw_upgrade.c b/third_party/infineon/cyw30739_sdk/src/ota_fw_upgrade.c
deleted file mode 100644
index a741a1a..0000000
--- a/third_party/infineon/cyw30739_sdk/src/ota_fw_upgrade.c
+++ /dev/null
@@ -1,569 +0,0 @@
-/*
- * Copyright 2016-2021, Cypress Semiconductor Corporation (an Infineon company) or
- * an affiliate of Cypress Semiconductor Corporation. All rights reserved.
- *
- * This software, including source code, documentation and related
- * materials ("Software") is owned by Cypress Semiconductor Corporation
- * or one of its affiliates ("Cypress") and is protected by and subject to
- * worldwide patent protection (United States and foreign),
- * United States copyright laws and international treaty provisions.
- * Therefore, you may use this Software only as provided in the license
- * agreement accompanying the software package from which you
- * obtained this Software ("EULA").
- * If no EULA applies, Cypress hereby grants you a personal, non-exclusive,
- * non-transferable license to copy, modify, and compile the Software
- * source code solely for use in connection with Cypress's
- * integrated circuit products. Any reproduction, modification, translation,
- * compilation, or representation of this Software except as specified
- * above is prohibited without the express written permission of Cypress.
- *
- * Disclaimer: THIS SOFTWARE IS PROVIDED AS-IS, WITH NO WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, NONINFRINGEMENT, IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress
- * reserves the right to make changes to the Software without notice. Cypress
- * does not assume any liability arising out of the application or use of the
- * Software or any product or circuit described in the Software. Cypress does
- * not authorize its products for use in any products where a malfunction or
- * failure of the Cypress product may reasonably be expected to result in
- * significant property damage, injury or death ("High Risk Product"). By
- * including Cypress's product in a High Risk Product, the manufacturer
- * of such system or application assumes all risk of such use and in doing
- * so agrees to indemnify Cypress against all liability.
- */
-
-/** @file
- *
- * WICED Firmware Upgrade internal definitions specific to shim layer
- *
- * This file provides common functions required to support WICED Smart Ready Upgrade
- * whether it is being done over the air, UART, or SPI. Primarily the
- * functionality is provided for storing and retrieving information from Serial Flash
- * The data being stored is DS portion of burn image generated from CGS.
- */
-#include <ota_fw_upgrade.h>
-#include <stdio.h>
-#include <wiced_bt_ota_firmware_upgrade.h>
-#include <wiced_hal_eflash.h>
-#include <wiced_hal_wdog.h>
-
-#define EF_PAGE_SIZE (0x1000u)
-
-//==================================================================================================
-// Types
-//==================================================================================================
-//! Structure for FOUNDATION_CONFIG_ITEM_ID_CONFIG_LAYOUT.
-#pragma pack(1)
-typedef struct
-{
- //! Base address or offset of the failsafe (not upgradable) dynamic section base. This field
- //! must be present.
- UINT32 failsafe_ds_base;
-
- //! Base address or offset of the upgradable dynamic section base. This field is optional for
- //! media types for which DFU is supported.
- UINT32 upgradable_ds_base;
-
- //! Base address or offset to the area reserved for volatile section copy 1. Whether this is an
- //! address or offset depends on the media type, and is an internal detail of those media types'
- //! access functions. Double-buffering of the volatile section alternates between the two
- //! copies when the active copy fills up and has to be consolidated to the other. The volatile
- //! section stores information that is mutable at runtime, and is therefore subject to loss if a
- //! write operation is interrupted by loss of power. Only an item that is currently being
- //! written is subject to loss. Generally, NVRAM media with large page sizes (like flash) use
- //! double-buffering, while media with small page sizes (like EEPROM) allocate one or more
- //! complete pages per volatile section item.
- UINT32 vs_copy1_base;
-
- //! Base address or offset to the area reserved for volatile section copy 2. Whether this is an
- //! address or offset depends on the media type, and is an internal detail of those media types'
- //! access functions. See the documentation for vs_copy1_base, but note that not all media
- //! types use double-buffering.
- UINT32 vs_copy2_base;
-
- //! Length in bytes per copy of the area reserved for each volatile section copy. If the target
- //! media uses double buffering to protect against loss, the total space used by the volatile
- //! section is twice this amount. See the documentation for vs_copy1_base and vs_copy1_base.
- UINT32 vs_length_per_copy;
-
- //! Block size for volatile section items. For media with small page sizes (like EEPROM) which
- //! allocate one or more pages per volatile section item, blocks must be a multiple of the media
- //! page size.
- UINT32 vs_block_size;
-
- //! Media page size. This info is needed for managing volatile section contents.
- UINT32 media_page_size;
-} FOUNDATION_CONFIG_ITEM_CONFIG_LAYOUT_t;
-#pragma pack()
-
-//! Enumeration used to specify one of the three sections of config data.
-//! <br><br>
-//! If config data is stored in NVRAM:
-//! <br><br>
-//! Static section is written once during manufacturing, and never again. This section includes
-//! per-device information like crystal trimming information and an assigned address like BD_ADDR
-//! for Bluetooth devices or a MAC address for ethernet or WLAN devices. The static section also
-//! includes key layout information like whether a volatile section is present and if so, where it
-//! is located.
-//! <br><br>
-//! Dynamic section is written during manufacturing. This section might be subject to upgrades in
-//! the field, by the end user. An example of such an upgrade process is USB device firmware
-//! upgrade. If this section is subject to upgrade in the field, then a failsafe config must be
-//! present, which if present would either force the device into an upgrade-only mode, or fall back
-//! to the un-upgraded behavior it would have exhibited when it left the factory.
-//! <br><br>
-//! Volatile section is used to hold information that can change at runtime, for example storing
-//! pairing information for pairing with other devices. The volatile section is implemented as
-//! failsafe as possible for the target media, such that the most recently written "nugget" of
-//! information is subject to loss, but contents that were present before a given write operation
-//! will be preserved.
-//! <br><br>
-//! The "volatile" nomenclature is somewhat misleading because this section is only ever present on
-//! NVRAM (nonvolatile memory). The "volatile" nomenclature is simply used to highlight the fact
-//! that the contents are subject to loss. This is generally a non-issue, but if multiple "nuggets"
-//! of information are interdependent but written independently, then it is possible for one
-//! "nugget" in the interdependent set to be lost, in which case the firmware that uses this
-//! information needs to be ready to recognize that situation and take appropriate action to discard
-//! or if possible repair the rest of the set. If no "nuggets" of volatile information form
-//! interdependent sets then loss of power during a write operation is functionally equivalent to
-//! loss of power immediately before the write operation was initiated.
-//! <br><br>
-//! If config data is stored in RAM (downloaded by the host):
-//! <br><br>
-//! Only the static and dynamic sections are relevant. The distinction between the two halves is
-//! more or less irrelevant, merely being a reflection of the NVRAM organization. Nonetheless, the
-//! location in which certain pieces of information are stored is influenced by the NVRAM
-//! organization. A volatile section should never be specified for RAM config data.
-typedef enum
-{
- //! Configuration data section containing per-device information and key layout information.
- //! The layout information communicates to firmware where to find the rest of the configuration
- //! data. See the documentation for the config_section_id_t enumeration as a whole for more
- //! complete info.
- CONFIG_STATIC,
-
- //! Configuration data section containing per-product or product family information. See the
- //! documentation for the config_section_id_t enumeration as a whole for more complete info.
- CONFIG_DYNAMIC,
-
- //! Configuration data section in NVRAM containing information that can be changed at runtime.
- //! This refers to info that needs to be preserved across resets or power cycles. See the
- //! documentation for the config_section_id_t enumeration as a whole for more complete info,
- //! including where the seemingly contradictory name comes from.
- CONFIG_VOLATILE
-} config_section_id_t;
-
-//! \internal
-//! Structure used internally by the config module to achieve config media abstraction. It stores
-//! layout information for any supported config data media type, as well as media-specific function
-//! pointers for various tasks.
-typedef struct
-{
- //! Access function pointer to read raw data from the media on which config data is stored.
- void (*fp_ReadRaw)(int offset, config_section_id_t which_section, OUT BYTE * buffer, int length);
-
- //! Access function pointer to write raw data to the media on which config data is stored.
- void (*fp_WriteRaw)(int offset, config_section_id_t which_section, IN BYTE * buffer, int length);
-
- //! Address of the static section.
- UINT32 ss_base;
-
- //! Function to handle when the layout config item below has been filled in. It will have been
- //! filled in using content from the static section, then this function will be called.
- void (*fp_ConfigLayoutHasBeenSet)(void);
-
- //! Address of the valid dynamic section (which might be the failsafe copy, or might be the
- //! upgradable copy).
- UINT32 active_ds_base;
-
- //! Access function pointer to read a volatile section item from config data. The function is
- //! presented as being specific to the type of media, but it really reflects the partitioning
- //! scheme used by this media as dictated by its physical page size. The truly media-specific
- //! access function is in fp_ReadRaw.
- UINT16 (*fp_ReadVolatileSectionItem)(UINT16 group_id, UINT16 sub_id_in_group, OUT BYTE * buffer, UINT16 max_length);
-
- //! Access function pointer to write a volatile section item to config data. The function is
- //! presented as being specific to the type of media, but it really reflects the partitioning
- //! scheme used by this media as dictated by its physical page size. The truly media-specific
- //! access function is in fp_WriteRaw.
- void (*fp_WriteVolatileSectionItem)(UINT16 group_id, UINT16 sub_id_in_group, IN BYTE * buffer, UINT16 length);
-
- //! Layout info, retrieved from the static section.
- FOUNDATION_CONFIG_ITEM_CONFIG_LAYOUT_t layout;
-
- //! Checksum/CRC info for validating segment by segment in the dynamic section.
- UINT32 checksum;
- UINT32 crc32;
- BOOL8 valid_crc32;
-
- //! Used to allow faster access to the config if it is memory mapped (not in serial flash for example)
- BOOL8 direct_access;
-
- //! Whether a valid DS section was found or not.
- BOOL8 valid_ds_found;
-} CONFIG_INFO_t;
-
-typedef struct ds_header
-{
- char signature[8];
- uint32_t crc32;
- uint32_t length;
- uint8_t data[0];
-} ds_header_t;
-
-typedef struct upgrade_xs
-{
- ds_header_t ds_header;
- uint32_t crc32;
- uint32_t length;
- uint32_t compressed_data_crc32;
- uint32_t compressed_data_length;
- uint8_t compressed_data[0];
-} upgrade_xs_t;
-
-extern const CONFIG_INFO_t g_config_Info;
-
-static uint32_t upgrade_location_write(uint32_t offset, const uint8_t * data, uint32_t len);
-static bool lzss_decompress(const void * src, size_t n, bool (*data_writer)(uint32_t, int))
- __attribute__((section(".text_in_ram")));
-static bool xs_data_writer(uint32_t data_offset, int c) __attribute__((section(".text_in_ram")));
-static uint32_t calc_crc32(const uint8_t * buf, uint32_t len) __attribute__((section(".text_in_ram")));
-static uint32_t ef_offset(uint32_t offset) __attribute__((section(".text_in_ram")));
-static uint32_t upgrade_ds_location(void);
-
-/******************************************************
- * Function Definitions
- ******************************************************/
-__attribute__((section(".init_code"))) void wiced_firmware_upgrade_bootloader(void)
-{
- const ds_header_t * ds_header = (const ds_header_t *) g_config_Info.active_ds_base;
- const upgrade_xs_t * upgrade_xs = (upgrade_xs_t *) XS_LOCATION_UPGRADE;
-
- /* Check the DS header of the upgrade XS */
- if (memcmp(&upgrade_xs->ds_header, ds_header, sizeof(*ds_header)) != 0)
- {
- return;
- }
-
- /* Erase the active XS */
- if (WICED_SUCCESS != wiced_hal_eflash_erase(ef_offset(XS_LOCATION_ACTIVE), upgrade_xs->length))
- {
- return;
- }
-
- /* Copy the upgrade XS to the active XS */
- if (!lzss_decompress(upgrade_xs->compressed_data, upgrade_xs->compressed_data_length, xs_data_writer))
- {
- goto reset;
- }
-
- /* Verify the active XS */
- if (calc_crc32((void *) XS_LOCATION_ACTIVE, upgrade_xs->length) != upgrade_xs->crc32)
- goto reset;
-
- /* Erase the upgrade XS */
- wiced_hal_eflash_erase(ef_offset(XS_LOCATION_UPGRADE), EF_PAGE_SIZE);
-
- return;
-
-reset:
- wiced_hal_wdog_reset_system();
- while (1)
- ;
-}
-
-bool wiced_firmware_upgrade_prepare(void)
-{
- const uint32_t ds1_length = g_config_Info.layout.upgradable_ds_base - g_config_Info.layout.failsafe_ds_base;
- const uint32_t ds2_length = XS_LOCATION_ACTIVE - g_config_Info.layout.upgradable_ds_base;
-
- printf("Active DS: 0x%08x\n", g_config_Info.active_ds_base);
- printf("Active XS: 0x%08x\n", XS_LOCATION_ACTIVE);
-
- if (upgrade_ds_location() == 0 || ds1_length != ds2_length)
- {
- return false;
- }
-
- printf("Erasing Upgrade DS: 0x%08lx, len: 0x%08lx\n", upgrade_ds_location(), ds1_length);
- if (WICED_SUCCESS != wiced_hal_eflash_erase(ef_offset(upgrade_ds_location()), ds1_length))
- {
- printf("ERROR erase\n");
- return false;
- }
-
- const uint32_t upgrade_xs_length = FLASH_SIZE - ef_offset(XS_LOCATION_UPGRADE);
- printf("Erasing Upgrade XS: 0x%08x, len: 0x%08lx\n", XS_LOCATION_UPGRADE, upgrade_xs_length);
- if (WICED_SUCCESS != wiced_hal_eflash_erase(ef_offset(XS_LOCATION_UPGRADE), upgrade_xs_length))
- {
- printf("ERROR erase\n");
- return false;
- }
-
- return true;
-}
-
-uint32_t wiced_firmware_upgrade_process_block(uint32_t offset, const uint8_t * data, uint32_t len)
-{
- const ds_header_t * ds_header = (const ds_header_t *) upgrade_ds_location();
-
- if (offset == 0)
- {
- ds_header = (const ds_header_t *) data;
- }
- else
- {
- ds_header = (const ds_header_t *) upgrade_ds_location();
- }
-
- const uint32_t ds_length = sizeof(*ds_header) + ds_header->length;
- uint32_t ds_write_length;
- uint32_t xs_write_length;
- if (offset < ds_length)
- {
- if (offset + len <= ds_length)
- {
- ds_write_length = len;
- xs_write_length = 0;
- }
- else
- {
- ds_write_length = ds_length - offset;
- xs_write_length = len - ds_write_length;
- }
- }
- else
- {
- ds_write_length = 0;
- xs_write_length = len;
- }
-
- uint32_t byte_written = 0;
- if (ds_write_length > 0)
- {
- const uint32_t ds_offset = offset + upgrade_ds_location();
- byte_written += upgrade_location_write(ds_offset, data, ds_write_length);
- }
- if (xs_write_length > 0)
- {
- const uint32_t xs_offset = offset + ds_write_length - ds_length + XS_LOCATION_UPGRADE;
- byte_written += upgrade_location_write(xs_offset, data + ds_write_length, xs_write_length);
- }
- return byte_written;
-}
-
-uint32_t upgrade_location_write(uint32_t offset, const uint8_t * data, uint32_t len)
-{
- // reserve first 4 bytes of download to commit when complete, in case of unexpected power loss
- // boot rom checks this signature to validate DS
- uint32_t offset_adjustment;
- if (offset == upgrade_ds_location())
- {
- offset_adjustment = 4;
- }
- else
- {
- offset_adjustment = 0;
- }
- offset += offset_adjustment;
- data += offset_adjustment;
- len -= offset_adjustment;
-
- printf("write: offset: 0x%08lx len: %lu\n", offset, len);
- /* write length should in words */
- if (wiced_hal_eflash_write(ef_offset(offset), (uint8_t *) data, (len + 3) & 0xfffffffc) == WICED_SUCCESS)
- {
- return len + offset_adjustment;
- }
- else
- {
- printf("ERROR write\n");
- return 0;
- }
-}
-
-bool wiced_firmware_upgrade_finalize(void)
-{
- const ds_header_t * ds_header = (ds_header_t *) upgrade_ds_location();
- const upgrade_xs_t * upgrade_xs = (upgrade_xs_t *) XS_LOCATION_UPGRADE;
-
- const uint32_t ds_crc32 = calc_crc32(ds_header->data, ds_header->length);
- const uint32_t cx_crc32 = calc_crc32(upgrade_xs->compressed_data, upgrade_xs->compressed_data_length);
-
- printf("DS: length 0x%08lx, crc32 0x%08lx\n", ds_header->length, ds_crc32);
- printf("XS: length 0x%08lx, crc32 0x%08lx\n", upgrade_xs->length, upgrade_xs->crc32);
- printf("CX: length 0x%08lx, crc32 0x%08lx\n", upgrade_xs->compressed_data_length, cx_crc32);
-
- return ds_header->crc32 == ds_crc32 && upgrade_xs->compressed_data_crc32 == cx_crc32;
-}
-
-bool wiced_firmware_upgrade_apply(void)
-{
- enum
- {
- SIGNATURE = 0x4d435242,
- };
- wiced_result_t result;
- uint32_t signature = SIGNATURE;
-
- printf("Switching DS to 0x%08lx\n", upgrade_ds_location());
-
- // commit reserved first 4 bytes of download to complete
- // this is done last and after crc in case of power loss during download
- // boot rom checks this signature to validate DS, checking DS1 first, then DS2
- wiced_hal_eflash_write(ef_offset(upgrade_ds_location()), (uint8_t *) &signature, 4);
-
- // check that the write completed
- wiced_hal_eflash_read(ef_offset(upgrade_ds_location()), (uint8_t *) &signature, 4);
- if (signature != SIGNATURE)
- {
- return false;
- }
-
- // clear first active DS sector in eflash, so that on next boot, CRC check will fail and ROM code boots from upgraded DS
- result = wiced_hal_eflash_erase(ef_offset(g_config_Info.active_ds_base), EF_PAGE_SIZE);
- printf("wiced_hal_eflash_erase status %d\n", result);
-
- return result == WICED_SUCCESS;
-}
-
-void wiced_firmware_upgrade_abort(void) {}
-
-bool lzss_decompress(const void * src, size_t n, bool (*data_writer)(uint32_t, int))
-{
- enum
- {
- /* size of ring buffer */
- N = 4096,
- /* upper limit for match_length */
- F = 18,
- /*
- * encode string into position and length
- * if match_length is greater than this
- */
- THRESHOLD = 2,
- };
-
- /* ring buffer of size N, with extra F-1 bytes to facilitate string comparison */
- static uint8_t ring_buf[N + F - 1];
-
- int r;
- int c;
- unsigned int flags;
- uint32_t offset = 0;
- const uint8_t * s = src;
- const uint8_t * s_stop = s + n;
-
- memset(ring_buf, 0, N - F);
-
- r = N - F;
- flags = 0;
- while (s != s_stop)
- {
- if (((flags >>= 1) & 0x100) == 0)
- {
- c = *s++;
- flags = c | 0xff00; /* ues higher byte cleverly */
- } /* to count eight */
- if (flags & 1)
- {
- c = *s++;
- ring_buf[r++] = c;
- r &= N - 1;
- if (!data_writer(offset++, c))
- return FALSE;
- }
- else
- {
- int i;
- int patloc = *s++;
- int patlen = *s++;
-
- patloc |= ((patlen & 0xf0) << 4);
- patlen = (patlen & 0x0f) + THRESHOLD;
-
- for (i = 0; i <= patlen; i++)
- {
- c = ring_buf[(patloc + i) & (N - 1)];
- ring_buf[r++] = c;
- r &= N - 1;
- if (!data_writer(offset++, c))
- return FALSE;
- }
- }
- }
- return data_writer(offset, EOF);
-}
-
-bool xs_data_writer(uint32_t data_offset, int c)
-{
- static uint8_t xs_data_buf[EF_PAGE_SIZE];
-
- const uint32_t offset = data_offset % sizeof(xs_data_buf);
-
- if (c != EOF)
- {
- xs_data_buf[offset] = c;
- }
-
- uint32_t write_length = 0;
- if (offset + 1 == sizeof(xs_data_buf))
- {
- write_length = offset + 1;
- }
- else if (c == EOF)
- {
- write_length = offset;
- }
-
- if (write_length > 0)
- {
- const uint32_t write_offset = XS_LOCATION_ACTIVE + data_offset - offset;
- if (WICED_SUCCESS != wiced_hal_eflash_write(ef_offset(write_offset), xs_data_buf, write_length))
- {
- return FALSE;
- }
- }
- return TRUE;
-}
-
-uint32_t calc_crc32(const uint8_t * buf, uint32_t len)
-{
- uint32_t crc32_Update(uint32_t crc, const uint8_t * buf, uint16_t len);
- uint32_t crc32 = 0xffffffff;
- uint32_t i;
-
- for (i = 0; i < len; i += UINT16_MAX)
- {
- crc32 = crc32_Update(crc32, buf + i, MIN(len - i, UINT16_MAX));
- }
-
- return crc32 ^ 0xffffffff;
-}
-
-uint32_t ef_offset(uint32_t offset)
-{
- return offset - FLASH_BASE_ADDRESS;
-}
-
-uint32_t upgrade_ds_location(void)
-{
- if (g_config_Info.active_ds_base == g_config_Info.layout.failsafe_ds_base)
- {
- return g_config_Info.layout.upgradable_ds_base;
- }
- else if (g_config_Info.active_ds_base == g_config_Info.layout.upgradable_ds_base)
- {
- return g_config_Info.layout.failsafe_ds_base;
- }
- else
- {
- return 0;
- }
-}
-
-/* Dummy stub */
-wiced_bool_t wiced_ota_fw_upgrade_init(void * public_key, wiced_ota_firmware_upgrade_status_callback_t * p_status_callback,
- wiced_ota_firmware_upgrade_send_data_callback_t * p_send_data_callback)
-{
- return TRUE;
-}
diff --git a/third_party/infineon/cyw30739_sdk/src/platform_retarget_lock.c b/third_party/infineon/cyw30739_sdk/src/platform_retarget_lock.c
deleted file mode 100644
index 2de5160..0000000
--- a/third_party/infineon/cyw30739_sdk/src/platform_retarget_lock.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright 2016-2021, Cypress Semiconductor Corporation (an Infineon company) or
- * an affiliate of Cypress Semiconductor Corporation. All rights reserved.
- *
- * This software, including source code, documentation and related
- * materials ("Software") is owned by Cypress Semiconductor Corporation
- * or one of its affiliates ("Cypress") and is protected by and subject to
- * worldwide patent protection (United States and foreign),
- * United States copyright laws and international treaty provisions.
- * Therefore, you may use this Software only as provided in the license
- * agreement accompanying the software package from which you
- * obtained this Software ("EULA").
- * If no EULA applies, Cypress hereby grants you a personal, non-exclusive,
- * non-transferable license to copy, modify, and compile the Software
- * source code solely for use in connection with Cypress's
- * integrated circuit products. Any reproduction, modification, translation,
- * compilation, or representation of this Software except as specified
- * above is prohibited without the express written permission of Cypress.
- *
- * Disclaimer: THIS SOFTWARE IS PROVIDED AS-IS, WITH NO WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, NONINFRINGEMENT, IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress
- * reserves the right to make changes to the Software without notice. Cypress
- * does not assume any liability arising out of the application or use of the
- * Software or any product or circuit described in the Software. Cypress does
- * not authorize its products for use in any products where a malfunction or
- * failure of the Cypress product may reasonably be expected to result in
- * significant property damage, injury or death ("High Risk Product"). By
- * including Cypress's product in a High Risk Product, the manufacturer
- * of such system or application assumes all risk of such use and in doing
- * so agrees to indemnify Cypress against all liability.
- */
-
-#include <sys/lock.h>
-#include <wiced_rtos.h>
-
-typedef struct __lock
-{
- wiced_mutex_t * mutex;
-} lock_t;
-
-static void lock_init_recursive(lock_t * lock);
-
-lock_t __lock___sinit_recursive_mutex;
-lock_t __lock___sfp_recursive_mutex;
-lock_t __lock___atexit_recursive_mutex;
-lock_t __lock___malloc_recursive_mutex;
-lock_t __lock___env_recursive_mutex;
-lock_t __lock___tz_mutex;
-
-void platform_retarget_lock_init(void)
-{
- lock_init_recursive(&__lock___sinit_recursive_mutex);
- lock_init_recursive(&__lock___sfp_recursive_mutex);
- lock_init_recursive(&__lock___malloc_recursive_mutex);
-}
-
-void __retarget_lock_init_recursive(lock_t ** lock) {}
-
-void __retarget_lock_close_recursive(lock_t * lock) {}
-
-void __retarget_lock_acquire(lock_t * lock) {}
-
-void __retarget_lock_acquire_recursive(lock_t * lock)
-{
- if (lock != NULL && lock->mutex != NULL)
- {
- wiced_rtos_lock_mutex(lock->mutex);
- }
-}
-
-void __retarget_lock_release(lock_t * lock) {}
-
-void __retarget_lock_release_recursive(lock_t * lock)
-{
- if (lock != NULL && lock->mutex != NULL)
- {
- wiced_rtos_unlock_mutex(lock->mutex);
- }
-}
-
-void lock_init_recursive(lock_t * lock)
-{
- lock->mutex = wiced_rtos_create_mutex();
- if (lock->mutex != NULL)
- {
- wiced_rtos_init_mutex(lock->mutex);
- }
-}
diff --git a/third_party/infineon/cyw30739_sdk/src/wiced_button_manager.c b/third_party/infineon/cyw30739_sdk/src/wiced_button_manager.c
deleted file mode 100644
index c8761c6..0000000
--- a/third_party/infineon/cyw30739_sdk/src/wiced_button_manager.c
+++ /dev/null
@@ -1,714 +0,0 @@
-/*
- * Copyright 2016-2021, Cypress Semiconductor Corporation (an Infineon company) or
- * an affiliate of Cypress Semiconductor Corporation. All rights reserved.
- *
- * This software, including source code, documentation and related
- * materials ("Software") is owned by Cypress Semiconductor Corporation
- * or one of its affiliates ("Cypress") and is protected by and subject to
- * worldwide patent protection (United States and foreign),
- * United States copyright laws and international treaty provisions.
- * Therefore, you may use this Software only as provided in the license
- * agreement accompanying the software package from which you
- * obtained this Software ("EULA").
- * If no EULA applies, Cypress hereby grants you a personal, non-exclusive,
- * non-transferable license to copy, modify, and compile the Software
- * source code solely for use in connection with Cypress's
- * integrated circuit products. Any reproduction, modification, translation,
- * compilation, or representation of this Software except as specified
- * above is prohibited without the express written permission of Cypress.
- *
- * Disclaimer: THIS SOFTWARE IS PROVIDED AS-IS, WITH NO WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, NONINFRINGEMENT, IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress
- * reserves the right to make changes to the Software without notice. Cypress
- * does not assume any liability arising out of the application or use of the
- * Software or any product or circuit described in the Software. Cypress does
- * not authorize its products for use in any products where a malfunction or
- * failure of the Cypress product may reasonably be expected to result in
- * significant property damage, injury or death ("High Risk Product"). By
- * including Cypress's product in a High Risk Product, the manufacturer
- * of such system or application assumes all risk of such use and in doing
- * so agrees to indemnify Cypress against all liability.
- */
-/** @file
- *
- * Button manager implements generic interface for button events and button type configurations.
- * It exposes interface to configure platform button events (like click,long press) with user configurable timing.
- */
-#include "wiced_button_manager.h"
-#include "clock_timer.h"
-#include "platform_button.h"
-#include "string.h"
-#include "wiced_bt_trace.h"
-#ifdef CYW55572
-#include "wiced_memory.h"
-#include "wiced_misc_rtos_utils.h"
-#endif
-#include <wiced_sleep.h>
-
-/******************************************************
- * Macros
- ******************************************************/
-
-#define BUTTON_TIMER_TIMEOUT (100) /*msec*/
-
-/******************************************************
- * Constants
- ******************************************************/
-
-/******************************************************
- * Enumerations
- ******************************************************/
-
-/******************************************************
- * Type Definitions
- ******************************************************/
-#if BTSTACK_VER >= 0x03000001
-#define TIMER_PARAM_TYPE WICED_TIMER_PARAM_TYPE
-#endif
-
-#ifdef CYW55572
-#define BUTTON_EVENT_QUEUE_DEPTH 16
-#endif
-
-/******************************************************
- * Structures
- ******************************************************/
-#ifdef CYW55572
-typedef struct
-{
- button_manager_button_t * p_button;
- button_manager_event_t event;
-} button_event_defer_to_mpaf_t;
-#endif
-
-/******************************************************
- * Function Declarations
- ******************************************************/
-static void button_state_change_callback(platform_button_t id, wiced_bool_t new_state);
-static wiced_result_t button_pressed_event_handler(void * arg);
-static wiced_result_t button_released_event_handler(void * arg);
-static wiced_result_t deferred_button_timer_handler(void * arg);
-
-static wiced_bool_t button_check_event_mask(button_manager_button_t * button, uint16_t new_event);
-static void button_check_for_double_click(button_manager_button_t * button, button_manager_event_t * new_event);
-static button_manager_event_t button_deduce_duration_event(button_manager_button_t * button, uint32_t current_interval);
-static button_manager_button_t * get_button(platform_button_t id);
-#ifdef CYW55572
-static void button_event_defer_to_mpaf(void * arg);
-#endif
-
-/******************************************************
- * Variables Definitions
- ******************************************************/
-static button_manager_t * button_manager;
-#ifdef CYW55572
-static wiced_mutex_t * p_mutex_button_event;
-static wiced_bt_buffer_q_t button_event_queue;
-static wiced_bt_pool_t * p_button_event_pool = NULL;
-#endif
-
-/******************************************************
- * Function Definitions
- ******************************************************/
-
-/*
- * button_long_press_detect_timeout_handler
- *
- * Timeout handler for button long press detect timer.
- *
- * The execution duration of this utility is defined in BUTTON_TIMER_TIMEOUT.
- */
-static void button_long_press_detect_timeout_handler(TIMER_PARAM_TYPE arg)
-{
- button_manager_button_t * p_button = (button_manager_button_t *) arg;
-
- /* Check if button is under debouncing state. */
- if (p_button->debouncing)
- {
- return;
- }
-
- /* Get current button state. */
- p_button->current_state = (button_manager_button_state_t) platform_button_get_value(p_button->configuration->button);
-
- if (p_button->current_state != BUTTON_STATE_HELD)
- {
- WICED_BT_TRACE("Err: Button %d is already released\n", p_button->configuration->button);
-
- if (wiced_is_timer_in_use(&p_button->long_press_timer))
- {
- wiced_stop_timer(&p_button->long_press_timer);
- }
-
- return;
- }
- /* Get current timestatmp. */
- p_button->timer_timestamp = clock_SystemTimeMicroseconds64();
-
- deferred_button_timer_handler((void *) p_button);
-}
-
-/*
- * button_debounce_timeout_handler
- *
- * Timeout handler for button debounce timer.
- */
-static void button_debounce_timeout_handler(TIMER_PARAM_TYPE arg)
-{
- button_manager_button_t * p_button = (button_manager_button_t *) arg;
- wiced_result_t result;
-
- // WICED_BT_TRACE("button_debounce_timeout_handler (%d, %d)\n", p_button->configuration->button, p_button->debounce_counter);
-
- if (p_button->debounce_counter > 0)
- {
- /* Reset the button debounce counter. */
- p_button->debounce_counter = 0;
-
- button_pressed_event_handler((void *) p_button);
- }
- else
- {
- if (wiced_is_timer_in_use(&p_button->long_press_timer))
- {
- wiced_stop_timer(&p_button->long_press_timer);
- }
- }
-
- /* Reset the button debounce state. */
- p_button->debouncing = WICED_FALSE;
-}
-
-/**
- * The application should call this function to Initialize the Button Manager
- */
-wiced_result_t __attribute__((weak))
-wiced_button_manager_init(button_manager_t * manager, const wiced_button_manager_configuration_t * configuration,
- button_manager_button_t * buttons, uint32_t number_of_buttons)
-{
- uint32_t a;
-
- memset(manager, 0, sizeof(*manager));
-
- manager->configuration = configuration;
- manager->buttons = buttons;
- manager->number_of_buttons = number_of_buttons;
-
- button_manager = manager;
-
- for (a = 0; a < number_of_buttons; a++)
- {
- platform_button_init(buttons[a].configuration->button);
- platform_button_enable(buttons[a].configuration->button);
- buttons[a].current_state = BUTTON_STATE_RELEASED;
- buttons[a].repeat = 0;
- buttons[a].debounce_counter = 0;
- buttons[a].debouncing = WICED_FALSE;
- }
-
- platform_button_register_state_change_callback(button_state_change_callback);
-
- /* Initialize the timers used for detecting the long press event. */
- for (a = 0; a < number_of_buttons; a++)
- {
- wiced_init_timer(&buttons[a].long_press_timer, button_long_press_detect_timeout_handler, (TIMER_PARAM_TYPE) &buttons[a],
- WICED_MILLI_SECONDS_PERIODIC_TIMER);
- }
-
- /* Initialize the timers used for de-bounce. */
- for (a = 0; a < number_of_buttons; a++)
- {
- wiced_init_timer(&buttons[a].debounce_timer, button_debounce_timeout_handler, (TIMER_PARAM_TYPE) &buttons[a],
- WICED_MILLI_SECONDS_TIMER);
- }
-
-#ifdef CYW55572
- p_button_event_pool =
- wiced_bt_create_pool("Button Event", sizeof(button_event_defer_to_mpaf_t), BUTTON_EVENT_QUEUE_DEPTH, NULL);
-
- if (!p_button_event_pool)
- {
- WICED_BT_TRACE("%s: Fail to create pool.\n", __FUNCTION__);
- return WICED_ERROR;
- }
-
- wiced_bt_init_q(&button_event_queue, NULL);
- p_mutex_button_event = wiced_rtos_create_mutex();
- if (p_mutex_button_event == NULL)
- {
- WICED_BT_TRACE("%s: Fail to create mutex.\n", __FUNCTION__);
- return WICED_ERROR;
- }
-
- if (wiced_rtos_init_mutex(p_mutex_button_event) != WICED_SUCCESS)
- {
- WICED_BT_TRACE("%s: Fail to init. mutex.\n", __FUNCTION__);
- return WICED_ERROR;
- }
-#endif
-
- return WICED_SUCCESS;
-}
-
-/**
- * The application should call this function to de-Initialize the Button Manager
- *
- * @param manager : Pointer to button manager to de-initialize.
- * @return : result.
- */
-wiced_result_t wiced_button_manager_deinit(button_manager_t * manager)
-{
- uint32_t a;
- for (a = 0; a < manager->number_of_buttons; a++)
- {
- platform_button_disable(manager->buttons[a].configuration->button);
- platform_button_deinit(manager->buttons[a].configuration->button);
- }
-
- for (a = 0; a < manager->number_of_buttons; a++)
- {
- if (WICED_TRUE == wiced_is_timer_in_use(&manager->buttons[a].debounce_timer))
- {
- wiced_stop_timer(&manager->buttons[a].debounce_timer);
- }
-
- wiced_deinit_timer(&manager->buttons[a].debounce_timer);
-
- if (WICED_TRUE == wiced_is_timer_in_use(&manager->buttons[a].long_press_timer))
- {
- wiced_stop_timer(&manager->buttons[a].long_press_timer);
- }
-
- wiced_deinit_timer(&manager->buttons[a].long_press_timer);
- }
-
- button_manager = NULL;
- return WICED_SUCCESS;
-}
-
-/**
- * Deferred Handler initiated from timer handler
- *
- * @param arg : Arguments passed by the timer framework to timer handler
- * @return : result
- */
-static wiced_result_t deferred_button_timer_handler(void * arg)
-{
- button_manager_button_t * p_button = (button_manager_button_t *) arg;
- uint64_t duration; // us
- button_manager_event_t new_held_event = 0;
-
- /* Check current button state. */
- if (p_button->current_state == BUTTON_STATE_RELEASED)
- {
- return WICED_SUCCESS;
- }
-
- /* Calculate the time difference. */
- duration = p_button->timer_timestamp - p_button->pressed_timestamp; // us
- duration = duration / 1000; // ms
-
- /* deduce the event depending on the duration */
- new_held_event = button_deduce_duration_event(p_button, (uint32_t) duration);
-
- /*
- * timers should be mainly interested in duration-specific events;
- * let release_handler only report Click events to the application
- */
- if (new_held_event == BUTTON_CLICK_EVENT)
- {
- return WICED_SUCCESS;
- }
-
- if (button_check_event_mask(p_button, new_held_event))
- {
- if (p_button->last_sent_event != BUTTON_HOLDING_EVENT)
- {
- if (p_button->last_sent_event != new_held_event)
- {
- button_manager->configuration->event_handler(p_button, new_held_event, p_button->current_state);
- p_button->last_sent_event = new_held_event;
- }
- }
- else
- {
- button_manager->configuration->event_handler(p_button, new_held_event, p_button->current_state);
- p_button->last_sent_event = new_held_event;
- }
- }
-
- return WICED_SUCCESS;
-}
-
-static void button_state_change_callback_pressed(button_manager_button_t * p_button)
-{
- /* Check if the button is under de-bounce state. */
- if (p_button->debouncing)
- { // under de-bounce state
- p_button->debounce_counter++;
- }
- else
- {
- /* ignore pressed event for already pressed button*/
- if (p_button->current_state == BUTTON_STATE_HELD)
- {
- return;
- }
-
- /* Get current timestamp for pressed event. */
- p_button->pressed_timestamp = clock_SystemTimeMicroseconds64();
-
- /* Start the button debounce timer. */
- wiced_start_timer(&p_button->debounce_timer, (uint32_t) button_manager->configuration->debounce_duration);
-
- /* Start the long pressed event detect timer. */
- wiced_start_timer(&p_button->long_press_timer, BUTTON_TIMER_TIMEOUT);
-
- /* Update information. */
- p_button->debouncing = WICED_TRUE;
- p_button->debounce_counter = 1;
- }
-}
-
-static void button_state_change_callback_released(button_manager_button_t * p_button)
-{
- wiced_result_t result;
-
- /* Check if the button is under de-bounce state. */
- if (p_button->debouncing)
- { // under de-bounce state
- p_button->debounce_counter--;
- }
- else
- {
- /* ignore released event for already released button */
- if (p_button->current_state == BUTTON_STATE_RELEASED)
- {
- return;
- }
-
- /* Get current timestamp for release event. */
- p_button->released_timestamp = clock_SystemTimeMicroseconds64();
-
- /* Stop the long pressed event detect timer. */
- if (wiced_is_timer_in_use(&p_button->long_press_timer))
- {
- wiced_stop_timer(&p_button->long_press_timer);
- }
-
- button_released_event_handler((void *) p_button);
- }
-}
-
-/**
- * Call back received when button state is changed.
- *
- * @param id : id of the button.
- * @param new_state : new state of the button.
- * @return void : no return value is expected.
- */
-static void button_state_change_callback(platform_button_t id, wiced_bool_t new_state)
-{
- button_manager_button_t * button = get_button(id);
-
-#if 0
- WICED_BT_TRACE("button_state_change_callback (button %d %s, %s, %d, %d)\n",
- id,
- button->current_state == BUTTON_STATE_HELD ? "H" : "R",
- button->debouncing ? "D" : "-",
- new_state,
- button->debounce_counter);
-#endif
-
- /* Check module state.*/
- if (button == NULL || button_manager == NULL)
- {
- WICED_BT_TRACE("button manager not initialized\n");
- return;
- }
-
- if (new_state == WICED_TRUE)
- {
- button_state_change_callback_pressed(button);
- }
- else
- {
- button_state_change_callback_released(button);
- }
-}
-
-/**
- * Event handler for button press event.
- *
- * @param arg : Arguments passed by the event manager
- * @return void : No return value expected.
- */
-static wiced_result_t button_pressed_event_handler(void * arg)
-{
- button_manager_button_t * button = (button_manager_button_t *) arg;
-
- if (button->current_state == BUTTON_STATE_HELD)
- {
- return WICED_SUCCESS;
- }
-
- /** Button is pressed; update the state so that timer-handlers know it */
- button->current_state = BUTTON_STATE_HELD;
-
- return WICED_SUCCESS;
-}
-
-/**
- * Event handler for button release event.
- *
- * @param arg : Arguments passed by the event manager
- * @return void : No return value expected.
- */
-
-static wiced_result_t button_released_event_handler(void * arg)
-{
- button_manager_button_t * button = (button_manager_button_t *) arg;
- button_manager_event_t new_release_event = 0;
- uint64_t duration; // us
-
- if (button->current_state == BUTTON_STATE_RELEASED)
- {
- return WICED_SUCCESS;
- }
-
- button->current_state = BUTTON_STATE_RELEASED;
-
- /* Calculate the time difference. */
- duration = button->released_timestamp - button->pressed_timestamp; // us
- duration = duration / 1000; // ms
-
- /** If release event comes before debounce duration, ignore it */
- if (duration <= button_manager->configuration->debounce_duration)
- {
- return WICED_SUCCESS;
- }
-
- /** deduce the event depending on the duration */
- new_release_event = button_deduce_duration_event(button, (uint32_t) duration);
-
- /** Check if this Release is from 2nd click of a double-click event */
- button_check_for_double_click(button, &new_release_event);
-
- /**
- * As the new state is Release and application has asked for this kind of event,
- * send it irrespective of whether timer-handler
- * had sent it previously
- */
- if (button_check_event_mask(button, new_release_event))
- {
-#ifndef CYW55572
- button_manager->configuration->event_handler(button, new_release_event, button->current_state);
-#else
- /*
- * Button released event is handled by another thread, it needs defer to mpaf thread.
- * Deferred_button_timer_handler(long press) is handled by timer which is in mpaf thread,
- * it does not need defer.
- */
- wiced_result_t result;
-
- wiced_rtos_lock_mutex(p_mutex_button_event);
- button_event_defer_to_mpaf_t * p_data = (button_event_defer_to_mpaf_t *) wiced_bt_get_buffer_from_pool(p_button_event_pool);
-
- if (!p_data)
- {
- wiced_rtos_unlock_mutex(p_mutex_button_event);
- WICED_BT_TRACE("Err: release event_handler no memory \n");
- goto DEFER_MPAF_ERROR;
- }
-
- p_data->p_button = button;
- p_data->event = new_release_event;
- wiced_bt_enqueue(&button_event_queue, (wiced_bt_buffer_t *) p_data);
- wiced_rtos_unlock_mutex(p_mutex_button_event);
- result = wiced_rtos_defer_execution(WICED_RTOS_DEFER_TO_MPAF_THREAD, &button_event_defer_to_mpaf, NULL);
-
- if (result != WICED_SUCCESS)
- {
- wiced_rtos_lock_mutex(p_mutex_button_event);
- button_event_defer_to_mpaf_t * p_buf = (button_event_defer_to_mpaf_t *) wiced_bt_dequeue(&button_event_queue);
- wiced_bt_free_buffer(p_buf);
- wiced_rtos_unlock_mutex(p_mutex_button_event);
- WICED_BT_TRACE("Err: release event_handler wiced_rtos_defer_execution (%d)\n", result);
- goto DEFER_MPAF_ERROR;
- }
-#endif
- }
-
-#ifdef CYW55572
-DEFER_MPAF_ERROR:
-#endif
-
- /** reset the button's last-sent so that a new press/held after this release is handled properly */
- button->last_sent_event = 0;
-
- return WICED_SUCCESS;
-}
-
-/**
- * Checks if the event is a double click event.
- *
- * @param button : button information.
- * @param new_event : new event generated for the button.
- * @return void : no return value is expected.
- */
-static void button_check_for_double_click(button_manager_button_t * button, button_manager_event_t * new_event)
-{
- if (!button_check_event_mask(button, BUTTON_DOUBLE_CLICK_EVENT) || *new_event != BUTTON_CLICK_EVENT)
- {
- return;
- }
- /** figure out the time-difference in two-releases */
- if ((button->released_timestamp - button->last_released_timestamp) <= button_manager->configuration->double_click_interval)
- {
- /** morph it as DOUBLE_CLICK */
- *new_event = BUTTON_DOUBLE_CLICK_EVENT;
- }
-
- button->last_released_timestamp = button->released_timestamp;
-
- return;
-}
-
-/**
- * Checks the event mask for the button
- *
- * @param button : button information.
- * @param new_event : new event generated for the button.
- * @return wiced_bool_t : returns true/false based on the new event.
- */
-static wiced_bool_t button_check_event_mask(button_manager_button_t * button, uint16_t new_event)
-{
- if (!button)
- {
- return WICED_FALSE;
- }
-
- return ((new_event & button->configuration->button_event_mask) ? WICED_TRUE : WICED_FALSE);
-}
-
-/**
- * Checks duration of the event
- *
- * @param button : the button that been triggered
- * @param current_interval : current time interval
- * @return button_manager_event_t : returns button manager event.
- */
-
-static button_manager_event_t button_deduce_duration_event(button_manager_button_t * button, uint32_t current_interval)
-{
- button_manager_event_t new_event = 0;
- uint32_t target_hold_interval;
-
- if (current_interval <= button_manager->configuration->debounce_duration)
- {
- return (button_manager_event_t) 0;
- }
- else if (current_interval > button_manager->configuration->debounce_duration &&
- current_interval <= button_manager->configuration->short_hold_duration)
- {
- return BUTTON_CLICK_EVENT;
- }
- else if (current_interval > button_manager->configuration->short_hold_duration &&
- current_interval <= button_manager->configuration->medium_hold_duration)
- {
- return BUTTON_SHORT_DURATION_EVENT;
- }
- else if (current_interval > button_manager->configuration->medium_hold_duration &&
- current_interval <= button_manager->configuration->long_hold_duration)
- {
- return BUTTON_MEDIUM_DURATION_EVENT;
- }
- else if (current_interval > button_manager->configuration->long_hold_duration &&
- current_interval <= button_manager->configuration->very_long_hold_duration)
- {
- button->repeat = 0;
- return BUTTON_LONG_DURATION_EVENT;
- }
- else
- { // current_interval > button_manager->configuration->very_long_hold_duration
- if (button_manager->configuration->continuous_hold_detect == WICED_FALSE)
- {
- return BUTTON_VERY_LONG_DURATION_EVENT;
- }
- else
- {
- target_hold_interval = (button->repeat + 2) * button_manager->configuration->long_hold_duration;
-
- if (current_interval > target_hold_interval)
- {
- button->repeat++;
-
- return BUTTON_HOLDING_EVENT;
- }
- else
- {
- return (button_manager_event_t) 0;
- }
- }
- }
-}
-
-/**
- * returns button based on the button id
- *
- * @param id : id of the buttonl
- * @return button_manager_button_t : returns button.
- */
-
-static button_manager_button_t * get_button(platform_button_t id)
-{
- uint8_t a;
-
- for (a = 0; a < button_manager->number_of_buttons; a++)
- {
- if (button_manager->buttons[a].configuration->button == id)
- {
- return &button_manager->buttons[a];
- }
- }
-
- return NULL;
-}
-
-/**
- * Checks if there is pending event and then re-send the event.
- *
- * @return void : no return value is expected.
- */
-void wiced_button_manager_pending_event_handle(void)
-{
- uint32_t a;
- if (wiced_sleep_get_boot_mode() == WICED_SLEEP_FAST_BOOT)
- {
- for (a = 0; a < button_manager->number_of_buttons; a++)
- {
- if (platform_button_pending_event_get_and_clear(button_manager->buttons[a].configuration->button))
- {
- button_manager->configuration->event_handler(&button_manager->buttons[a], BUTTON_CLICK_EVENT,
- BUTTON_STATE_RELEASED);
- break;
- }
- }
- }
-}
-
-#ifdef CYW55572
-static void button_event_defer_to_mpaf(void * arg)
-{
- button_event_defer_to_mpaf_t button_event_buf;
-
- wiced_rtos_lock_mutex(p_mutex_button_event);
- button_event_defer_to_mpaf_t * p_buf = (button_event_defer_to_mpaf_t *) wiced_bt_dequeue(&button_event_queue);
- memcpy(&button_event_buf, p_buf, sizeof(button_event_defer_to_mpaf_t));
- wiced_bt_free_buffer(p_buf);
- wiced_rtos_unlock_mutex(p_mutex_button_event);
- button_manager->configuration->event_handler(button_event_buf.p_button, button_event_buf.event,
- button_event_buf.p_button->current_state);
-}
-#endif
diff --git a/third_party/infineon/cyw30739_sdk/src/wiced_led_manager.c b/third_party/infineon/cyw30739_sdk/src/wiced_led_manager.c
deleted file mode 100644
index 7761c92..0000000
--- a/third_party/infineon/cyw30739_sdk/src/wiced_led_manager.c
+++ /dev/null
@@ -1,305 +0,0 @@
-/*
- * Copyright 2016-2021, Cypress Semiconductor Corporation (an Infineon company) or
- * an affiliate of Cypress Semiconductor Corporation. All rights reserved.
- *
- * This software, including source code, documentation and related
- * materials ("Software") is owned by Cypress Semiconductor Corporation
- * or one of its affiliates ("Cypress") and is protected by and subject to
- * worldwide patent protection (United States and foreign),
- * United States copyright laws and international treaty provisions.
- * Therefore, you may use this Software only as provided in the license
- * agreement accompanying the software package from which you
- * obtained this Software ("EULA").
- * If no EULA applies, Cypress hereby grants you a personal, non-exclusive,
- * non-transferable license to copy, modify, and compile the Software
- * source code solely for use in connection with Cypress's
- * integrated circuit products. Any reproduction, modification, translation,
- * compilation, or representation of this Software except as specified
- * above is prohibited without the express written permission of Cypress.
- *
- * Disclaimer: THIS SOFTWARE IS PROVIDED AS-IS, WITH NO WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, NONINFRINGEMENT, IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress
- * reserves the right to make changes to the Software without notice. Cypress
- * does not assume any liability arising out of the application or use of the
- * Software or any product or circuit described in the Software. Cypress does
- * not authorize its products for use in any products where a malfunction or
- * failure of the Cypress product may reasonably be expected to result in
- * significant property damage, injury or death ("High Risk Product"). By
- * including Cypress's product in a High Risk Product, the manufacturer
- * of such system or application assumes all risk of such use and in doing
- * so agrees to indemnify Cypress against all liability.
- */
-/** @file
- *
- * This file provides implementation for the LED Manager library interface.
- * LED Manager library provides API's to enable/disable, blink and set brightness of a LED.
- */
-
-#include "wiced_led_manager.h"
-#include "platform_led.h"
-#include "wiced_bt_dev.h"
-#include "wiced_bt_trace.h"
-#include "wiced_hal_gpio.h"
-#include "wiced_platform.h"
-#include "wiced_rtos.h"
-#include "wiced_timer.h"
-/******************************************************
- * Macros
- ******************************************************/
-#define LED_FREQ (60) /*Hz*/
-
-/******************************************************
- * Constants
- ******************************************************/
-
-/******************************************************
- * Enumerations
- ******************************************************/
-
-/******************************************************
- * Type Definitions
- ******************************************************/
-extern platform_led_config_t platform_led_config[PLATFORM_LED_MAX];
-/******************************************************
- * Structures
- ******************************************************/
-
-/**
- * @brief timer structure for LED manager
- *
- */
-typedef struct
-{
- wiced_led_t led;
- wiced_bool_t led_state;
- uint32_t on_period;
- uint32_t off_period;
- wiced_timer_t timer;
- wiced_bool_t is_init;
-} led_manager_timer;
-
-/**
- * @brief LED timer
- *
- */
-static led_manager_timer led_timer[PLATFORM_LED_MAX] = { 0 };
-
-/******************************************************
- * Function Declarations
- ******************************************************/
-void led_timer_function(uint32_t arg);
-
-/**
- * Function to Initialize the LED Manager
- *
- * @param config : Configuration for the LED.
- * @return : result.
- */
-wiced_result_t wiced_led_manager_init(wiced_led_config_t * config)
-{
- uint32_t i;
- uint16_t bright;
- // WICED_BT_TRACE("%s <<\n",__func__);
- if (config == NULL)
- return WICED_ERROR;
-
- if (config->led >= PLATFORM_LED_MAX)
- {
- WICED_BT_TRACE("Invalid LED for platform\n");
- return WICED_ERROR;
- }
-
- /* check whether initialized */
- if (led_timer[config->led].is_init)
- {
- WICED_BT_TRACE("Error: Init LED(%d) multiple times\n", config->led);
- return WICED_ERROR;
- }
-
- bright = config->bright;
-
- if (bright > 99)
- {
- bright = 99;
- }
-
- if (WICED_SUCCESS != platform_led_init(&platform_led_config[config->led], LED_FREQ, bright))
- return WICED_ERROR;
-
- led_timer[config->led].led = config->led;
-
- /* initialize timer */
- wiced_init_timer(&led_timer[config->led].timer, &led_timer_function, (uint32_t) config->led,
- WICED_MILLI_SECONDS_PERIODIC_TIMER);
-
- led_timer[config->led].is_init = WICED_TRUE;
-
- return WICED_SUCCESS;
-}
-
-/**
- * Function to de-initialize the LED Manager
- *
- * @param void : No arguments.
- * @return : result.
- */
-wiced_result_t wiced_led_manager_deinit()
-{
- uint32_t i;
- /*if any led active we stop all of them*/
- for (i = 0; i < PLATFORM_LED_MAX; i++)
- platform_led_deinit(&platform_led_config[i]);
-
- /* deinit timer */
- for (i = 0; i < PLATFORM_LED_MAX; i++)
- {
- if (led_timer[i].is_init)
- {
- wiced_deinit_timer(&led_timer[i].timer);
- led_timer[i].is_init = WICED_FALSE;
- }
- }
-
- return WICED_SUCCESS;
-}
-
-/**
- * Enables the selected LED
- *
- * @param led : LED to be enabled.
- * @return : result.
- */
-wiced_result_t wiced_led_manager_enable_led(wiced_led_t led)
-{
- wiced_result_t result;
- if (led >= PLATFORM_LED_MAX)
- {
- WICED_BT_TRACE("Invalid LED for platform\n");
- return WICED_ERROR;
- }
-
- result = platform_led_start(&platform_led_config[led]);
-
- return result;
-}
-
-/**
- * Disables the selected LED
- *
- * @param led : LED to be disabled.
- * @return : result.
- */
-wiced_result_t wiced_led_manager_disable_led(wiced_led_t led)
-{
- wiced_result_t result;
- if (led >= PLATFORM_LED_MAX)
- {
- WICED_BT_TRACE("Invalid LED for platform\n");
- return WICED_ERROR;
- }
- if (wiced_is_timer_in_use(&led_timer[led].timer))
- {
- wiced_stop_timer(&led_timer[led].timer);
- // wiced_deinit_timer(&led_timer[led].timer);
- }
-
- result = platform_led_stop(&platform_led_config[led]);
-
- return result;
-}
-
-/**
- * Reconfigures the LED
- *
- * @param config : Configuration for the LED.
- * @return : result.
- */
-wiced_result_t wiced_led_manager_reconfig_led(wiced_led_config_t * config)
-{
- uint16_t bright;
-
- if (config == NULL)
- return WICED_ERROR;
-
- if (config->led >= PLATFORM_LED_MAX)
- {
- WICED_BT_TRACE("Invalid LED for platform\n");
- return WICED_ERROR;
- }
-
- bright = config->bright;
-
- if (bright > 99)
- {
- bright = 99;
- }
-
- return platform_led_reinit(&platform_led_config[config->led], LED_FREQ, bright);
-}
-
-/**
- * LED timer handler
- *
- * @param arg : arguments passed to the handler.
- * @return : no return value expected.
- */
-void led_timer_function(uint32_t arg)
-{
- if (led_timer[arg].led_state == WICED_TRUE)
- {
- // WICED_BT_TRACE("Timer led %d stop\n",led_timer[arg].led);
- platform_led_stop(&platform_led_config[led_timer[arg].led]);
- led_timer[arg].led_state = WICED_FALSE;
- }
- else
- {
- platform_led_start(&platform_led_config[led_timer[arg].led]);
- // WICED_BT_TRACE("Timer led %d start\n",led_timer[arg].led);
- led_timer[arg].led_state = WICED_TRUE;
- }
-
- wiced_stop_timer(&led_timer[arg].timer);
- wiced_start_timer(&led_timer[arg].timer,
- led_timer[arg].led_state == WICED_TRUE ? led_timer[arg].on_period : led_timer[arg].off_period);
-}
-
-/**
- * Function called to blink a LED
- *
- * @param led : LED to be blinked.
- * @param on_period : on period (ms)
- * @param off_period : off period (ms)
- * @return : result.
- */
-
-wiced_result_t wiced_led_manager_blink_led(wiced_led_t led, uint32_t on_period, uint32_t off_period)
-{
- // WICED_BT_TRACE("%s <<\n",__func__);
- if (led >= PLATFORM_LED_MAX)
- {
- WICED_BT_TRACE("Invalid LED for platform\n");
- return WICED_ERROR;
- }
-
- if (led_timer[led].is_init == WICED_FALSE)
- {
- WICED_BT_TRACE("LED(%d) un-init\n", led);
- return WICED_ERROR;
- }
-
- led_timer[led].on_period = on_period;
- led_timer[led].off_period = off_period;
-
- if (WICED_SUCCESS != wiced_led_manager_enable_led(led))
- {
- WICED_BT_TRACE("LED enable failed\n");
- return WICED_ERROR;
- }
-
- led_timer[led].led_state = WICED_TRUE;
- wiced_start_timer(&led_timer[led].timer, on_period);
- // WICED_BT_TRACE("timer started\n");
-
- return WICED_SUCCESS;
-}
diff --git a/third_party/infineon/repos/matter-wpan-sdk b/third_party/infineon/repos/matter-wpan-sdk
new file mode 160000
index 0000000..f6e196c
--- /dev/null
+++ b/third_party/infineon/repos/matter-wpan-sdk
@@ -0,0 +1 @@
+Subproject commit f6e196cbd982cfd4c74ffca6ba4128dba298b8ac
diff --git a/third_party/openthread/ot-ifx b/third_party/openthread/ot-ifx
index 8da150a..2f7a132 160000
--- a/third_party/openthread/ot-ifx
+++ b/third_party/openthread/ot-ifx
@@ -1 +1 @@
-Subproject commit 8da150a2ef425dc06a02e56c5019a3b75ed627d1
+Subproject commit 2f7a13230d26c25b23726cd1a0ee49cc6b2df03c
diff --git a/third_party/openthread/platforms/ifx/BUILD.gn b/third_party/openthread/platforms/ifx/BUILD.gn
index fefabcd..379f50a 100644
--- a/third_party/openthread/platforms/ifx/BUILD.gn
+++ b/third_party/openthread/platforms/ifx/BUILD.gn
@@ -16,42 +16,19 @@
import("//build_overrides/cyw30739_sdk.gni")
import("//build_overrides/openthread.gni")
-openthread_ifx_root = "${chip_root}/third_party/openthread/ot-ifx"
+import("ifx_openthread.gni")
+
openthread_ifx_mcu = "cyw30739"
config("openthread_ifx_config") {
- include_dirs = [
- "${openthread_ifx_root}/src/${openthread_ifx_mcu}",
- "${openthread_ifx_root}/src/${openthread_ifx_mcu}/mbedtls/include",
- ]
+ include_dirs = [ "${openthread_ifx_root}/src/${openthread_ifx_mcu}" ]
}
source_set("openthread_core_config_ifx") {
sources = [ "${openthread_ifx_root}/src/${openthread_ifx_mcu}/openthread-core-cyw30739-config.h" ]
- public_deps = [ "${cyw30739_sdk_build_root}:cyw30739_sdk" ]
-
- public_configs = [ ":openthread_ifx_config" ]
-}
-
-source_set("libopenthread-ifx") {
- sources = [
- "${openthread_ifx_root}/src/${openthread_ifx_mcu}/alarm.c",
- "${openthread_ifx_root}/src/${openthread_ifx_mcu}/entropy.c",
- "${openthread_ifx_root}/src/${openthread_ifx_mcu}/logging.c",
- "${openthread_ifx_root}/src/${openthread_ifx_mcu}/misc.c",
- "${openthread_ifx_root}/src/${openthread_ifx_mcu}/radio.c",
- "${openthread_ifx_root}/src/${openthread_ifx_mcu}/radio_wrapper.cpp",
- "${openthread_ifx_root}/src/${openthread_ifx_mcu}/settings.c",
- "${openthread_ifx_root}/src/${openthread_ifx_mcu}/system.c",
- ]
-
- defines = [ "CHIP_HAVE_CONFIG_H=1" ]
-
- public_deps = [
- ":openthread_core_config_ifx",
- "${openthread_root}/src/core:libopenthread_core_headers",
- "..:libopenthread-platform",
- "..:libopenthread-platform-utils",
+ public_configs = [
+ "${cyw30739_sdk_build_root}:mbedtls_config",
+ ":openthread_ifx_config",
]
}
diff --git a/third_party/openthread/platforms/ifx/ifx_openthread.gni b/third_party/openthread/platforms/ifx/ifx_openthread.gni
new file mode 100644
index 0000000..c6051ef
--- /dev/null
+++ b/third_party/openthread/platforms/ifx/ifx_openthread.gni
@@ -0,0 +1,58 @@
+# Copyright (c) 2024 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.
+
+import("//build_overrides/chip.gni")
+import("//build_overrides/cyw30739_sdk.gni")
+import("//build_overrides/openthread.gni")
+
+openthread_ifx_root = "${chip_root}/third_party/openthread/ot-ifx"
+
+template("ifx_openthread") {
+ forward_variables_from(invoker,
+ [
+ "board",
+ "chip_family",
+ ])
+
+ static_library(target_name) {
+ sources = [
+ "${openthread_ifx_root}/src/${chip_family}/alarm.c",
+ "${openthread_ifx_root}/src/${chip_family}/crypto.c",
+ "${openthread_ifx_root}/src/${chip_family}/entropy.c",
+ "${openthread_ifx_root}/src/${chip_family}/logging.c",
+ "${openthread_ifx_root}/src/${chip_family}/misc.c",
+ "${openthread_ifx_root}/src/${chip_family}/radio.c",
+ "${openthread_ifx_root}/src/${chip_family}/radio_wrapper.cpp",
+ "${openthread_ifx_root}/src/${chip_family}/settings.c",
+ "${openthread_ifx_root}/src/${chip_family}/system.c",
+ ]
+
+ defines = [ "CHIP_HAVE_CONFIG_H=1" ]
+
+ configs +=
+ [ "${matter_wpan_sdk_build_root}:wpan_sdk-${chip_family}-config" ]
+
+ deps = [
+ "${matter_wpan_sdk_build_root}:${board}",
+ "${matter_wpan_sdk_build_root}:wpan_sdk-${board}",
+ ]
+
+ public_deps = [
+ "${chip_root}/third_party/openthread/platforms:libopenthread-platform",
+ "${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils",
+ "${chip_root}/third_party/openthread/platforms/ifx:openthread_core_config_ifx",
+ "${openthread_root}/src/core:libopenthread_core_headers",
+ ]
+ }
+}