From 464ddb6fe2d8fb0ace8a965ad83fbd1f24a262f9 Mon Sep 17 00:00:00 2001 From: Sid Hsu Date: Tue, 7 May 2024 21:23:39 +0800 Subject: [PATCH] [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. --- .github/workflows/examples-infineon.yaml | 82 +- .gitmodules | 26 +- examples/build_overrides/cyw30739_sdk.gni | 7 +- .../infineon/cyw30739/BUILD.gn | 75 +- .../infineon/cyw30739/README.md | 133 +++- .../infineon/cyw30739/args.gni | 18 +- .../infineon/cyw30739/include/AppTask.h | 25 + .../cyw30739/include/CHIPProjectConfig.h | 28 +- .../infineon/cyw30739/include/LightSwitch.h | 2 - .../cyw30739/src/AppShellCommands.cpp | 13 +- .../infineon/cyw30739/src/AppTask.cpp | 203 +++++ .../infineon/cyw30739/src/ButtonHandler.cpp | 12 +- .../infineon/cyw30739/src/LightSwitch.cpp | 4 +- .../infineon/cyw30739/src/LightingManager.cpp | 97 --- .../infineon/cyw30739/src/main.cpp | 328 -------- .../lighting-app/infineon/cyw30739/BUILD.gn | 72 +- .../lighting-app/infineon/cyw30739/README.md | 134 +++- .../lighting-app/infineon/cyw30739/args.gni | 20 +- .../infineon/cyw30739/include/AppTask.h} | 8 +- .../cyw30739/include/CHIPProjectConfig.h | 26 +- .../cyw30739/include/LightingManager.h | 2 +- .../infineon/cyw30739/src/AppTask.cpp | 106 +++ .../infineon/cyw30739/src/ButtonHandler.cpp | 48 +- .../infineon/cyw30739/src/LightingManager.cpp | 7 - examples/lock-app/infineon/cyw30739/BUILD.gn | 72 +- examples/lock-app/infineon/cyw30739/README.md | 138 +++- examples/lock-app/infineon/cyw30739/args.gni | 18 +- .../infineon/cyw30739/include/AppTask.h} | 6 +- .../cyw30739/include/CHIPProjectConfig.h | 26 +- .../infineon/cyw30739/src/AppTask.cpp | 218 ++++++ .../infineon/cyw30739/src/ButtonHandler.cpp | 51 +- .../lock-app/infineon/cyw30739/src/main.cpp | 356 --------- .../ota-requestor-app/infineon/cyw30739/.gn | 28 - .../infineon/cyw30739/BUILD.gn | 73 -- .../infineon/cyw30739/README.md | 139 ---- .../infineon/cyw30739/args.gni | 24 - .../infineon/cyw30739/build_overrides | 1 - .../cyw30739/include/CHIPProjectConfig.h | 61 -- .../infineon/cyw30739/src/main.cpp | 136 ---- .../cyw30739/third_party/connectedhomeip | 1 - .../Matter-Development-DAC-1388-0001.p12 | Bin 0 -> 1584 bytes .../Matter-Development-DAC-1388-0002.p12 | Bin 0 -> 1584 bytes .../Matter-Development-DAC-1388-0005.p12 | Bin 0 -> 1584 bytes .../Matter-Development-DAC-1388-0006.p12 | Bin 0 -> 1584 bytes .../Matter-Development-CD-1388-0001-0008.der | Bin 0 -> 248 bytes .../infineon/cyw30739}/AppShellCommands.h | 0 examples/platform/infineon/cyw30739/BUILD.gn | 20 + .../platform/infineon/cyw30739/LEDWidget.cpp | 65 ++ .../infineon/cyw30739/LEDWidget.h} | 22 +- examples/platform/infineon/cyw30739/args.gni | 4 + .../infineon/cyw30739/cyw30739_example.gni | 46 ++ examples/platform/infineon/cyw30739/main.cpp | 29 + .../infineon/cyw30739/matter_config.cpp} | 247 +++--- .../infineon/cyw30739/matter_config.h | 33 + scripts/build/build/targets.py | 7 +- scripts/build/builders/cyw30739.py | 53 +- .../build/testdata/all_targets_linux_x64.txt | 2 +- scripts/flashing/cyw30739_firmware_utils.py | 60 +- src/lib/shell/streamer_cyw30739.cpp | 2 +- src/platform/Infineon/CYW30739/BUILD.gn | 29 +- .../Infineon/CYW30739/CYW30739Config.cpp | 10 +- .../Infineon/CYW30739/CYW30739Config.h | 33 +- src/platform/Infineon/CYW30739/EventFlags.cpp | 9 +- .../Infineon/CYW30739/FactoryDataProvider.cpp | 132 ++++ .../Infineon/CYW30739/FactoryDataProvider.h | 29 +- .../CYW30739/KeyValueStoreManagerImpl.cpp | 3 +- .../CYW30739/KeyValueStoreManagerImpl.h | 2 +- .../Infineon/CYW30739/PlatformManagerImpl.cpp | 5 +- .../CYW30739/ThreadStackManagerImpl.cpp | 5 +- src/platform/Infineon/CYW30739/args.gni | 13 +- .../CYW30739/cyw30739-chip-mbedtls-config.h | 13 + .../Infineon/CYW30739/cyw30739_platform.gni | 57 ++ third_party/infineon/cyw30739_sdk/BUILD.gn | 56 -- .../bsp_design_modus/cycfg_notices.h | 41 - .../bsp_design_modus/cycfg_pins.c | 163 ---- .../bsp_design_modus/cycfg_pins.h | 91 --- .../bsp_design_modus/cycfg_routing.h | 71 -- .../infineon/cyw30739_sdk/btp_reader.py | 77 -- .../cyw30739_sdk/compress_cgs_data.py | 237 ------ .../infineon/cyw30739_sdk/cyw30739_arm.gni | 17 - .../cyw30739_sdk/cyw30739_executable.gni | 83 -- .../infineon/cyw30739_sdk/cyw30739_sdk.gni | 599 --------------- third_party/infineon/cyw30739_sdk/flash.btp | 53 -- .../infineon/cyw30739_sdk/gen_ota_image.py | 211 ------ .../cyw30739_sdk/include/auto_flags.h | 7 - .../cyw30739_sdk/include/ota_fw_upgrade.h | 52 -- .../include/wiced_button_manager.h | 241 ------ .../cyw30739_sdk/include/wiced_led_manager.h | 135 ---- .../infineon/cyw30739_sdk/merge_hex.py | 143 ---- .../infineon/cyw30739_sdk/repos/30739A0 | 1 - .../cyw30739_sdk/repos/CYW930739M2EVB-01 | 1 - .../infineon/cyw30739_sdk/repos/btsdk-include | 1 - .../infineon/cyw30739_sdk/repos/btsdk-tools | 1 - .../cyw30739_sdk/scripts/gen_ss_cgs.py | 128 ---- .../cyw30739_sdk/scripts/wiced-gen-ld.pl | 549 -------------- .../cyw30739_sdk/src/ota_fw_upgrade.c | 569 -------------- .../cyw30739_sdk/src/platform_retarget_lock.c | 89 --- .../cyw30739_sdk/src/wiced_button_manager.c | 714 ------------------ .../cyw30739_sdk/src/wiced_led_manager.c | 305 -------- third_party/infineon/repos/matter-wpan-sdk | 1 + third_party/openthread/ot-ifx | 2 +- third_party/openthread/platforms/ifx/BUILD.gn | 35 +- .../platforms/ifx/ifx_openthread.gni | 58 ++ 103 files changed, 1919 insertions(+), 6566 deletions(-) create mode 100644 examples/light-switch-app/infineon/cyw30739/include/AppTask.h create mode 100644 examples/light-switch-app/infineon/cyw30739/src/AppTask.cpp delete mode 100644 examples/light-switch-app/infineon/cyw30739/src/LightingManager.cpp delete mode 100644 examples/light-switch-app/infineon/cyw30739/src/main.cpp rename examples/{lock-app/infineon/cyw30739/include/AppShellCommands.h => lighting-app/infineon/cyw30739/include/AppTask.h} (74%) create mode 100644 examples/lighting-app/infineon/cyw30739/src/AppTask.cpp rename examples/{light-switch-app/infineon/cyw30739/include/AppShellCommands.h => lock-app/infineon/cyw30739/include/AppTask.h} (86%) create mode 100644 examples/lock-app/infineon/cyw30739/src/AppTask.cpp delete mode 100644 examples/lock-app/infineon/cyw30739/src/main.cpp delete mode 100644 examples/ota-requestor-app/infineon/cyw30739/.gn delete mode 100644 examples/ota-requestor-app/infineon/cyw30739/BUILD.gn delete mode 100644 examples/ota-requestor-app/infineon/cyw30739/README.md delete mode 100644 examples/ota-requestor-app/infineon/cyw30739/args.gni delete mode 120000 examples/ota-requestor-app/infineon/cyw30739/build_overrides delete mode 100644 examples/ota-requestor-app/infineon/cyw30739/include/CHIPProjectConfig.h delete mode 100644 examples/ota-requestor-app/infineon/cyw30739/src/main.cpp delete mode 120000 examples/ota-requestor-app/infineon/cyw30739/third_party/connectedhomeip create mode 100644 examples/platform/infineon/credentials/development/attestation/Matter-Development-DAC-1388-0001.p12 create mode 100644 examples/platform/infineon/credentials/development/attestation/Matter-Development-DAC-1388-0002.p12 create mode 100644 examples/platform/infineon/credentials/development/attestation/Matter-Development-DAC-1388-0005.p12 create mode 100644 examples/platform/infineon/credentials/development/attestation/Matter-Development-DAC-1388-0006.p12 create mode 100644 examples/platform/infineon/credentials/development/certification-declaration/Matter-Development-CD-1388-0001-0008.der rename examples/{lighting-app/infineon/cyw30739/include => platform/infineon/cyw30739}/AppShellCommands.h (100%) create mode 100644 examples/platform/infineon/cyw30739/LEDWidget.cpp rename examples/{light-switch-app/infineon/cyw30739/include/LightingManager.h => platform/infineon/cyw30739/LEDWidget.h} (71%) create mode 100644 examples/platform/infineon/cyw30739/cyw30739_example.gni create mode 100644 examples/platform/infineon/cyw30739/main.cpp rename examples/{lighting-app/infineon/cyw30739/src/main.cpp => platform/infineon/cyw30739/matter_config.cpp} (51%) create mode 100644 examples/platform/infineon/cyw30739/matter_config.h create mode 100644 src/platform/Infineon/CYW30739/cyw30739_platform.gni delete mode 100644 third_party/infineon/cyw30739_sdk/BUILD.gn delete mode 100644 third_party/infineon/cyw30739_sdk/bsp_design_modus/cycfg_notices.h delete mode 100644 third_party/infineon/cyw30739_sdk/bsp_design_modus/cycfg_pins.c delete mode 100644 third_party/infineon/cyw30739_sdk/bsp_design_modus/cycfg_pins.h delete mode 100644 third_party/infineon/cyw30739_sdk/bsp_design_modus/cycfg_routing.h delete mode 100644 third_party/infineon/cyw30739_sdk/btp_reader.py delete mode 100644 third_party/infineon/cyw30739_sdk/compress_cgs_data.py delete mode 100644 third_party/infineon/cyw30739_sdk/cyw30739_arm.gni delete mode 100644 third_party/infineon/cyw30739_sdk/cyw30739_executable.gni delete mode 100644 third_party/infineon/cyw30739_sdk/cyw30739_sdk.gni delete mode 100644 third_party/infineon/cyw30739_sdk/flash.btp delete mode 100644 third_party/infineon/cyw30739_sdk/gen_ota_image.py delete mode 100644 third_party/infineon/cyw30739_sdk/include/auto_flags.h delete mode 100644 third_party/infineon/cyw30739_sdk/include/ota_fw_upgrade.h delete mode 100644 third_party/infineon/cyw30739_sdk/include/wiced_button_manager.h delete mode 100644 third_party/infineon/cyw30739_sdk/include/wiced_led_manager.h delete mode 100644 third_party/infineon/cyw30739_sdk/merge_hex.py delete mode 160000 third_party/infineon/cyw30739_sdk/repos/30739A0 delete mode 160000 third_party/infineon/cyw30739_sdk/repos/CYW930739M2EVB-01 delete mode 160000 third_party/infineon/cyw30739_sdk/repos/btsdk-include delete mode 160000 third_party/infineon/cyw30739_sdk/repos/btsdk-tools delete mode 100644 third_party/infineon/cyw30739_sdk/scripts/gen_ss_cgs.py delete mode 100644 third_party/infineon/cyw30739_sdk/scripts/wiced-gen-ld.pl delete mode 100644 third_party/infineon/cyw30739_sdk/src/ota_fw_upgrade.c delete mode 100644 third_party/infineon/cyw30739_sdk/src/platform_retarget_lock.c delete mode 100644 third_party/infineon/cyw30739_sdk/src/wiced_button_manager.c delete mode 100644 third_party/infineon/cyw30739_sdk/src/wiced_led_manager.c create mode 160000 third_party/infineon/repos/matter-wpan-sdk create mode 100644 third_party/openthread/platforms/ifx/ifx_openthread.gni diff --git a/.github/workflows/examples-infineon.yaml b/.github/workflows/examples-infineon.yaml index 3de5c1d124528d..071905d62f0417 100644 --- a/.github/workflows/examples-infineon.yaml +++ b/.github/workflows/examples-infineon.yaml @@ -107,41 +107,89 @@ jobs: 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/ - - 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-03 light \ + out/artifacts/cyw30739-cyw30739b2_p5_evk_03-light/lighting_app-CYW30739B2-P5-EVK-03.elf \ /tmp/bloat_reports/ - - name: Get ota-requestor size stats + .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 cyw930739m2evb_01 ota-requestor \ - out/artifacts/cyw30739-cyw930739m2evb_01-ota-requestor/chip-cyw30739-ota-requestor-example.elf \ + 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/ - - name: Get switch size stats + .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 CYW30739B2-P5-EVK-01 lock \ + out/artifacts/cyw30739-cyw30739b2_p5_evk_01-lock/lock_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 lock \ + out/artifacts/cyw30739-cyw30739b2_p5_evk_02-lock/lock_app-CYW30739B2-P5-EVK-02.elf \ + /tmp/bloat_reports/ .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 c372f58f4402b6..26fff510eebfb5 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 d98ac9866b0a4f..5c4fa9ebe4df63 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 0a594386bc9206..a096888849634b 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" - - sources = [ - "src/AppShellCommands.cpp", - "src/BindingHandler.cpp", - "src/ButtonHandler.cpp", - "src/LightSwitch.cpp", - "src/LightingManager.cpp", - "src/ZclCallbacks.cpp", - "src/main.cpp", - ] +template("matter_wpan_app") { + forward_variables_from(invoker, [ "board" ]) - 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", - ] + import("${matter_wpan_sdk_build_root}/boards/${board}/args.gni") - include_dirs = [ "include" ] + matter_wpan_executable(target_name) { + sources = [ + "src/AppShellCommands.cpp", + "src/AppTask.cpp", + "src/BindingHandler.cpp", + "src/ButtonHandler.cpp", + "src/LightSwitch.cpp", + "src/ZclCallbacks.cpp", + ] - if (chip_enable_ota_requestor) { - sources += [ - "${examples_plat_dir}/OTAConfig.cpp", - "${examples_plat_dir}/OTAConfig.h", + 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 fc45a42a42f9f4..530cfde2501498 100644 --- a/examples/light-switch-app/infineon/cyw30739/README.md +++ b/examples/light-switch-app/infineon/cyw30739/README.md @@ -9,14 +9,22 @@ An example showing the use of Matter on the Infineon CYW30739 platform. - [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 @@ 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. +## 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 ``` -- To delete generated executable, libraries and object files use: +- OR use GN/Ninja directly ```bash $ cd ~/connectedhomeip - $ rm -rf ./out/ + $ 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] ``` -- OR use GN/Ninja directly +- To delete generated executable, libraries and object files use: ```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 + $ rm -rf out/cyw30739-light-switch ``` -- To delete generated executable, libraries and object files use: +## 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 - $ rm -rf out/ + $ 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=="' ``` -## Building Options +### 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 + $ 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"' + ``` ### 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 @@ Put the CYW30739 in to the recovery mode before running the flash script. - 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 ``` ## 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 0f3c578940d0ce..20db27e3613083 100644 --- a/examples/light-switch-app/infineon/cyw30739/args.gni +++ b/examples/light-switch-app/infineon/cyw30739/args.gni @@ -16,14 +16,18 @@ 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") +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/AppTask.h b/examples/light-switch-app/infineon/cyw30739/include/AppTask.h new file mode 100644 index 00000000000000..77eddf979ac5ed --- /dev/null +++ b/examples/light-switch-app/infineon/cyw30739/include/AppTask.h @@ -0,0 +1,25 @@ +/* + * + * 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. + */ + +#pragma once + +#include +#include + +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 82ea3f0e71d7a4..6cac0a980816fc 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 244c1bcb7b6452..ac62bf40ef4ac6 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 -#include - 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 5a63cea5d543d6..9be05feafe4ea6 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 #include #include +#include #include -#include +#include #include #include #include @@ -80,7 +81,7 @@ static CHIP_ERROR AppCommandHandler(int argc, char ** argv) 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 OnCommandHandler(int argc, char ** argv) 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 OffCommandHandler(int argc, char ** argv) 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 00000000000000..1bb443c74bb0ec --- /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 +#include +#include +#include +#include +#include +#include + +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 5be809bf53e88e..90dc68aa3d67ca 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 +#include #include -#include #include +#include #include #include #include @@ -53,7 +54,7 @@ wiced_result_t app_button_init(void) 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 @@ wiced_result_t app_button_init(void) 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 10c68ffc098030..848c665bea6e32 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 - #include +#include #include #include +#include #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 497efd24900daf..00000000000000 --- 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 - -#include - -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 483a475b51cee0..00000000000000 --- 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 - -#include -#include -#include -#include -#include -#include -#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -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(&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 be63607b0bf97b..8fce49a0792afc 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" - - sources = [ - "src/AppShellCommands.cpp", - "src/ButtonHandler.cpp", - "src/LightingManager.cpp", - "src/ZclCallbacks.cpp", - "src/main.cpp", - ] +template("matter_wpan_app") { + forward_variables_from(invoker, [ "board" ]) - 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", - ] + import("${matter_wpan_sdk_build_root}/boards/${board}/args.gni") - include_dirs = [ "include" ] + matter_wpan_executable(target_name) { + sources = [ + "src/AppShellCommands.cpp", + "src/AppTask.cpp", + "src/ButtonHandler.cpp", + "src/LightingManager.cpp", + "src/ZclCallbacks.cpp", + ] - if (chip_enable_ota_requestor) { - sources += [ - "${examples_plat_dir}/OTAConfig.cpp", - "${examples_plat_dir}/OTAConfig.h", + 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 f085272b1c00d6..9dbfc23fe9e52f 100644 --- a/examples/lighting-app/infineon/cyw30739/README.md +++ b/examples/lighting-app/infineon/cyw30739/README.md @@ -7,9 +7,20 @@ An example showing the use of Matter on the Infineon CYW30739 platform. ## 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 @@ 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. +## 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 ``` -- To delete generated executable, libraries and object files use: +- OR use GN/Ninja directly ```bash $ cd ~/connectedhomeip - $ rm -rf ./out/ + $ source scripts/activate.sh + $ gn gen --root=examples/lighting-app/infineon/cyw30739 out/cyw30739-light + $ ninja -C out/cyw30739-light [lighting_app-BOARD_NAME] ``` -- OR use GN/Ninja directly +- To delete generated executable, libraries and object files use: ```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 + $ rm -rf out/cyw30739-light ``` -- To delete generated executable, libraries and object files use: +## 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 - $ rm -rf out/ + $ 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=="' ``` -## Building Options +### 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 + $ 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"' + ``` ### 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 @@ Put the CYW30739 in to the recovery mode before running the flash script. - 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 ``` ## Running the Complete Example diff --git a/examples/lighting-app/infineon/cyw30739/args.gni b/examples/lighting-app/infineon/cyw30739/args.gni index 770d2675cd9176..0dfb938cb3e235 100644 --- a/examples/lighting-app/infineon/cyw30739/args.gni +++ b/examples/lighting-app/infineon/cyw30739/args.gni @@ -16,14 +16,18 @@ 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 +app_data_model = "${chip_root}/examples/lighting-app/lighting-common" +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/lock-app/infineon/cyw30739/include/AppShellCommands.h b/examples/lighting-app/infineon/cyw30739/include/AppTask.h similarity index 74% rename from examples/lock-app/infineon/cyw30739/include/AppShellCommands.h rename to examples/lighting-app/infineon/cyw30739/include/AppTask.h index 575d6c24a3e2d0..8fc6b14d3a9044 100644 --- a/examples/lock-app/infineon/cyw30739/include/AppShellCommands.h +++ b/examples/lighting-app/infineon/cyw30739/include/AppTask.h @@ -1,7 +1,6 @@ /* * - * Copyright (c) 2021 Project CHIP Authors - * Copyright (c) 2019 Google LLC. + * Copyright (c) 2022 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,4 +18,7 @@ #pragma once -void RegisterAppShellCommands(); +#include + +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 26d7e65bcca57e..f22fdc5307b9a6 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 917bb37c023c63..5da05576ab4847 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 +#include class LightingManager { @@ -47,7 +48,6 @@ class LightingManager 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 00000000000000..620fd4620de61c --- /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 +#include +#include +#include +#include +#include + +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 ebb6b74fc903d0..965606aa22c488 100644 --- a/examples/lighting-app/infineon/cyw30739/src/ButtonHandler.cpp +++ b/examples/lighting-app/infineon/cyw30739/src/ButtonHandler.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -59,9 +60,10 @@ wiced_result_t app_button_init(void) 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 @@ void app_button_event_handler(const button_manager_button_t * button_mgr, button button_manager_button_state_t state) { chip::BitMask 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 (event == BUTTON_HOLDING_EVENT) + { + printf("Button Performing factory reset ...\r\n"); + chip::DeviceLayer::ConfigurationMgr().InitiateFactoryReset(); } - } - 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); } } diff --git a/examples/lighting-app/infineon/cyw30739/src/LightingManager.cpp b/examples/lighting-app/infineon/cyw30739/src/LightingManager.cpp index a121801134a24c..eb707676b59d4d 100644 --- a/examples/lighting-app/infineon/cyw30739/src/LightingManager.cpp +++ b/examples/lighting-app/infineon/cyw30739/src/LightingManager.cpp @@ -28,13 +28,6 @@ using namespace chip::app::Clusters; 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/lock-app/infineon/cyw30739/BUILD.gn b/examples/lock-app/infineon/cyw30739/BUILD.gn index 8d0cc6333d32d9..7ce4c26c03f4cc 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" - - sources = [ - "src/AppShellCommands.cpp", - "src/ButtonHandler.cpp", - "src/LockManager.cpp", - "src/ZclCallbacks.cpp", - "src/main.cpp", - ] +template("matter_wpan_app") { + forward_variables_from(invoker, [ "board" ]) - 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", - ] + import("${matter_wpan_sdk_build_root}/boards/${board}/args.gni") - include_dirs = [ "include" ] + matter_wpan_executable(target_name) { + sources = [ + "src/AppShellCommands.cpp", + "src/AppTask.cpp", + "src/ButtonHandler.cpp", + "src/LockManager.cpp", + "src/ZclCallbacks.cpp", + ] - if (chip_enable_ota_requestor) { - sources += [ - "${examples_plat_dir}/OTAConfig.cpp", - "${examples_plat_dir}/OTAConfig.h", + 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 b91f4b9157e155..6623f77c88c1c4 100644 --- a/examples/lock-app/infineon/cyw30739/README.md +++ b/examples/lock-app/infineon/cyw30739/README.md @@ -7,17 +7,28 @@ An example showing the use of Matter on the Infineon CYW30739 platform. ## 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 @@ 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. +## 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 ``` -- To delete generated executable, libraries and object files use: +- OR use GN/Ninja directly ```bash $ cd ~/connectedhomeip - $ rm -rf ./out/ + $ source scripts/activate.sh + $ gn gen --root=examples/lock-app/infineon/cyw30739 out/cyw30739-lock + $ ninja -C out/cyw30739-lock [lock_app-BOARD_NAME] ``` -- OR use GN/Ninja directly +- To delete generated executable, libraries and object files use: ```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 + $ rm -rf out/cyw30739-lock ``` -- To delete generated executable, libraries and object files use: +## 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 - $ rm -rf out/ + $ 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=="' ``` -## Building Options +### 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 + $ 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"' + ``` ### 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 @@ Put the CYW30739 in to the recovery mode before running the flash script. - 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 ``` ## Running the Complete Example diff --git a/examples/lock-app/infineon/cyw30739/args.gni b/examples/lock-app/infineon/cyw30739/args.gni index 770d2675cd9176..8b4b4d6c2d6708 100644 --- a/examples/lock-app/infineon/cyw30739/args.gni +++ b/examples/lock-app/infineon/cyw30739/args.gni @@ -16,14 +16,18 @@ 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") +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 86% rename from examples/light-switch-app/infineon/cyw30739/include/AppShellCommands.h rename to examples/lock-app/infineon/cyw30739/include/AppTask.h index a139b9fb293003..078484a2e35ebe 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 + +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 ffe889f725d909..f22fdc5307b9a6 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 00000000000000..2277049316d803 --- /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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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 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(nullptr)); + syncClusterToButtonAction = false; + } +} diff --git a/examples/lock-app/infineon/cyw30739/src/ButtonHandler.cpp b/examples/lock-app/infineon/cyw30739/src/ButtonHandler.cpp index 40233323890c96..37451eb0247208 100644 --- a/examples/lock-app/infineon/cyw30739/src/ButtonHandler.cpp +++ b/examples/lock-app/infineon/cyw30739/src/ButtonHandler.cpp @@ -20,7 +20,8 @@ #include #include -#include +#include +#include #include #include #include @@ -55,9 +56,10 @@ wiced_result_t app_button_init(void) 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 @@ void app_button_event_handler(const button_manager_button_t * button_mgr, button 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) - { - action = (LockMgr().NextState() == true) ? LockManager::LOCK_ACTION : LockManager::UNLOCK_ACTION; - } - else if (event == BUTTON_LONG_DURATION_EVENT) - { - action = LockManager::LOCK_JAMMED; - } - else + if (button_mgr[0].configuration->gpio == PLATFORM_BUTTON_USER) { - 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 c82cc894bae5af..00000000000000 --- 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 - -#include -#include -#include -#include -#include -#include -#include -#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -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(&nativeParams); - chip::Server::GetInstance().Init(initParams); - - SetDeviceAttestationCredentialsProvider(&sFactoryDataProvider); - - // Initial lock state - chip::app::DataModel::Nullable 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(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 90115e4209947e..00000000000000 --- 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 3701330b0f7113..00000000000000 --- 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 629418c395d552..00000000000000 --- 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 - ``` - - - 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 6f4645ad4beb71..00000000000000 --- 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 ee19c065d619a2..00000000000000 --- 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 82a889907606bd..00000000000000 --- 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 14ce58809f68dc..00000000000000 --- 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 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -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(&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 3efed95be5dbe9..00000000000000 --- 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 0000000000000000000000000000000000000000..fb8f0e9f53ed59052d9137ecec4aa16331f0661f GIT binary patch literal 1584 zcmai!X*84z9LBxlow3Z2JvT-nOB%eRt7KnmQrVhBlcg9U#6`KX&5L1dSBaE6mS)H@ zcEXh`*OHVe89Fyva#4%(+M2|gM2n< zA^Sb2Z^`v;D2&eT&FH{0mlxV)v~Lm&ID~$Cr`Qi_#MTG58RPeTUhc5B9i5ZTOcXZ0 zPJ3ds&W^&6bMqa@>Zx&I=L%qPJN0%7N}dBq&dOIBv1=A_9L%s5iE2QUtq@Saazsrn zTd~%aN!f139sMO){BAT&gHC{Ox_reCU2rhv?TV zlgHEMHM^#fJ3P&o*GuTEXu~tOLlf+?P==WZQ93GM6-iB+6|t<5LR`(5W$JlUF!X2C5{ z(kB8AW!l|NlGiJus7#@+z2^^4ogOl0cuj?72G_c$Bi~y+w4H3#``ly-Xqsp*437o4!%K4EtI=|3>%mTTqpVV^yR*>v&qDrp@G>2%_iL%RbGV zm{~B<$(`cPS6p&URc#_6xi?|m6=Qn+qfvZ0Svrb!kM!CeDyY7&f2?pex2Lh{7W&;T zD+x6pqdji(-qc}|EjFvZ)0854B`o(#%-4#=6r9~rA8595LqaCf?g{rPDMBS=CgbH0 zO;LD&&gmc=$Vmu`UqwghM30=U{#~|&e?&Xb-?7L9lj%|Aw#W(9uNfd_vK}S26rYiw zKlz?q@QJq)SO>EQz)~#p?r`3%kKbGjmkwBi^j$=5zmnk{@$$g)y3vCS^ZAeVIcZAH zr)J)^*RIzch9v8|2yvs?d1mlkrzA=&j96KJH|FRyNz}4JPIu1OsNr_$b|Jj8R z1`zp_IfydzGaQW{glohlQO-ZbQ6$t()kRHo`?_|rKuS70zxqg;R3x#vmOVTf zn8Q!13y%>h_Q2scKe#joN(IYSa=(K6@whZrOWXt!P;v#&mH6aQ|&zOIj9?s zy)&Dz!mbLE-pNJBko$dY_C^-8JlQqX9dX8`tf$=H{%~{JU5)h29A5c>1}{2S!E?zg zDWCV*)pwxBOpG@}IqFB&@k3akq*qfKKr~(jQr=!iNE$B#O6g}`J+S=Ff6X<(tx~Vf zKqr`dj0c%Pct~WMwFm&o2kyZ}hW2cD7Ts!(zQGmPxYO|9`4jkK$kmjwmS1g6PkJnX Qg6c*ii@nU#o8OoE7e(31=l}o! literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..cf8bc38fa23fcdf4eec31b346ee38653c80f3e59 GIT binary patch literal 1584 zcmai!dpOez9LBf#ZN@enk%Z8wHl?3yB{_)PYVJucX>ym#3E9yRi@8LGvc=I@N)#y# zBi)$G$z|uT%r)em5LsE`=sD-npZ)QD-sgSaKfcfN{_z3Hh`lhV2uOyHBE;|%OUh>q zR1{i3hIavEc;`m^8YBbc9~Gj23|!cVLSazIhWP(zprFg9fnz{x5ck8PK}7(WahRJ$AT&zWC`t&S-^p+>0h%DHdz_3EVOi|adP>8?Ttif=h_3r$7V zux^FGK5EaXH_LJxKlN@x*<3A09M0f;ikEsh5o0XFy_9DfxXjYYGQ$L|oQW#;rgplT zlWbS5+BM`%-BP*hbEL9?s5ETo5+FmYW<(QNnQOMm9*Bj5H#Hv2#R$yy>~+U0sdEfg zqB)75Rnk|~`+t8_@eFl6c6t0uIE$E&`gG~Cfql?DgLF?puRm*rC?r5Q{Ls=G?Gh3V zoc(LKp+(mqLeF`UtI=*vxkdU`HsXacibg9K)_Gu*DLX zihvu2CFB}Kh(GnR(|tw?t%I8uCm zRWXv~{)g4<;%A-3dk0z_aCcWRY5b5{N1Xzm)E?-t;3F>eab z+N$`d+lB`e!A+Og9#b|C7dmAaHkytttlU~J?b!TG#;f5;%Y|1e#(fge7wZki_HpR& zbAm_*mAgF%!=?57=h?B=QPK;?vI4zx75CWJQ`zC?ye++OM)%SaifM+CCsILXL*kPH z@l`XfoSfNY7CEN}9f-SituU@+{N|w*ovk<8v`Nt}XU{CPd#IS!t0^QF>$RnxDEwQi zIhlb%TI`^Wde1x4v4gtW5)w@M-J1E9N1ina<#sd7F}8Mooy(Cbi}^Ip?bFc8x{CH@ z$K3V`VaJ43_Y;G1dLXQFXxxz1Lht=EI)O%#xOq)6o6T*(Xw5^D$Z@-Xm$# zvK6;Hai*9;{X!?5xDQkXG#&1nUF~`)X(+jCK$2WM(NBpC;^a{;+#Bx;zFHH4omRjN zVd-}GI_#I#ehUCu?xcQPy2`>&89Fpm*3ng{1d^d9n>_grD5y3-hH7ra_>J3zK>g1y zv^W%25I+yb&;ATY`N6Kr`!jd<{TxTG2XENFqFxhRl++dAFt34lYI~@1_q%uY&ip@p z7X8IgDD?7nqRAE73!r0J-$AvVkB|ApEwDQt{AjEGgb1&iX+pp`@>2@WiAPAFh#_{Q zCR$Zu*Hoaj31VlN+vVIwQRvrV_?ZeW(y!-mKL;U6R4qMee5I{VCqfYmX%V{_T zt7OeI3jNz5g2Q?lx2vaTilitOYDQ;U8M-7bbr8F`j+m_0RzT(ezwdm2LiJQY#-zNQ z#z0HmsEZe90&0PnP1eGoa0sBn+qEX#MpIa;w9W=^NFJ8^ZQT_&9zmOyT~ALY*t9$Y QkkX@`3EEWy556z;F9%J=761SM literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..b9145561204ddc649e8a60410a3492df35c5b679 GIT binary patch literal 1584 zcmai!X*84z9LBxlov}0|OC!ULO!n%vG^LVc2-i-ME_cR~h|y-qGG>OMBFklzbeVJ# zCfPzvW7oBlNum_4EMrTyjOM!Ta`dqe|MQ&Zc|QElc|QCg8bSvK2tzdZC_+pt)*^OQ z0uTY1G&mQe!Miu(c8CVjzE=n)4ZOM;1;GHJO}X&B0iZKm1}*_vL7Lw!5>f<3`_QGs zxCqTI7)(?MLLx-}`vwz(3qeW9Xo-Mz~0R@-HAk}58= z3Z@MM!Y^-(acdzUzb!R5tLxUU#)thzW!CoPRUjwS2jiB*N@E790*3-$f+i{w2W?4{ z?t8CH^PG{F2*%xeI4B=Z0lU;`Z6LZvZl*KXL&TirkI9-&jAr+WOzYuXq)zku7X<;P zU6mrrAlX{67?3)sM9T?f6Z_AgQmX+$qSMC*jVzB`%Qu4*++G+ebL1+)CZ{Up#Y3`~ zZ)*MObkE|SJM!W5wU2gB#uGf7tSw4}vUd#@*%*co|3|dLnn3P1s<8n-E zTF!z}{`XYAH7AOUhsS?Q86SI!;JoLFIv89G3%Q%8sq-jCeW2Z69;f_D&pj!C&!9FW z)ZX(O&k`OayOd0i$d2`x9SVmc7#$f;clrztttu#Ml`G=8yB<&LyUi68=}~9vts@ay&ZhED#eOi`5cLKa`0XD?%Y$JiQE`dEsMpoPSx`Hz_rM1>A}Oc!N&_~HKObl z-A3=6n;7ZvE;Yz)k+1Yu=ODMqk0k(1-KCfYbPYV{o|s&{^VQbgqR9=~oUd^nk4CQ!Q5Q`kJCtmIu*>hsqE|{laJ4^XPk&^60?~=^n zsz!S;%;paenW#W6)H1)Lf59NK`D;?!vCosu3wY`E9zjqBDM{j1Yi&Q*SjwbAOXD=B z{z;12D9K*(wRI&!aWx|q()X-EDzde!bPS6zVI?L-Vx4tzSg#4y`YQGGeKBntp@t{v z-HmEDY>d?$>CC9n4~@Q49dPEIb;8v3T>ImfoJI%*yhsaj1A4z9fF=9oQvkgu~bf~f_YeG4>jERt#m_EG@pAQqd2acW7GQ4 z@%mMCTAuGORg<01e6gl!Zq43q@lz^V^f7s(?rj<@K?LB*p}b}jiFvMX_;HdbjE%~( zSR?WZX_r0jrn7%`O1Krei?4tBbz(6gJAICIK1%LLT77-XDZX^$hZMTGQ`1e+FjMX0 zBbX_kiii4a^YolH_ITV^!xHU2!R&#mNxxw#SJkOW(k>mpmU*PV4by3R1xJU<7QNcP zt(QAD89jL6j2ia$7Eb7O-k`|*^)_EZz<3Zf+{YLqK5PvsKtvk4Vh8+O$*8U?>FuCR-8?vK9$>xjwe?gV9}#_MkIEw4XoZ7bH$ zdHcH6ezgj5EF%2I@c#2Djtb?!a-*oXgl&htDU{^vX&eh?Y1!w(2RWY{Y2ZdhmXP23Y zh%4~(3-LiBaH0Rc@grb-kOCax6=w-x1VBI=+}><`1^OJnz_}4#Y52^KX&X%j`JCwk z^n&c>)*`%yJ{+Ay@i(+1PQSbxCVOy62+8ow+MrD}kDN-5W{O+{igkDzgcap|Dlg zi&Dj2QPf!JAG_0s)M%O!`m64%^h$W(q^U2DV8KYOevHjXxv4e4Udu1xgb(Z&%F2%@ zjp#XY|C#*m(1d)(8{4*~=G&w8lHEINZtS~kng_03cT`q>H{sgjfK}<>TJ4jPYt#v; z%11etlFsxLEDm`xFQMZqGwd4V8d9iCUSUlr?^WUBspA;zm)R5%neAyU`Ue_5l++|x zPpDZ+WF`lHuk)K=oQ$4WvTBg1pQa`;gGg0<1I3zh%tIm5My^OqqkMlUrkpd*D*VeL zVVlBI%H&m}+__@mH6e?!cGE#ZV%u|y^O63~yUli$xuiZbzq&O1%Iw$_Zv3?s{4}bF zZrg`wyB4rFg*e-Kd(DKP5y>@8RMy2mtsSCCd}%S4>`cQ(7Q6uU;E3{qPRh6XmyS;K z2}s<~wf|yS*s24G$@(c;Ayzv$)*d^e?H=~f-?IY=m8*X071mTn&a|(Eo7^$O71^bS znLf423W-M_(zQSCOA;54_OITVdgsU2=hykJ{ES#Or?vnDA%VfM+QwS;oX+9Ghv(z) z)`P@M*|<(bNt?o=vm++|YLwX^u^KslDztTfEJOy5ZSmw6pa6Z44Crmf+MA~V7yh4J zBHIA|oS1J=%-o-FG!-T|CEQjH{t-uax7)20E8eQXk%Gi7D_v9rW2nA6_2nWO?V>~) zI+x^NRrUw=Nz&72SO*Q>*lA@ut6(ceitAoP3Y3_LmJyez2hpRd5?18M+2bn347N;A ze6keiCRu5|*1VxQa*IJC2n>`3v#8Pn_*Hmi&@l)FiEgo$AAs?J$|LnQv+Pr73OknaUV)wBZdl_dD-GnIy5w#fJl1FL R4hq?5g(-=c`qO?b^)J;d$<_b> literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..35a115805cc50fcca14957bcd64afd505923dc6b GIT binary patch literal 248 zcmXqL{L03u)#lOmotKfFX+h(2gT^OJjLe3-2Hb3%32h#Xsmv@)j0S-SMT`qvSe!&v z7#LLKTb#V=IcF{F7wy@Am0|FIR z1{F326?R4y4h9LsT7zn!MGYcJznY9A*Zf*J%}(Z*2-n@OET0P#P%Y8^ literal 0 HcmV?d00001 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 8390dd680d1004..0673c55c351de3 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 00000000000000..cfea4d695ab981 --- /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 +#include + +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 71% rename from examples/light-switch-app/infineon/cyw30739/include/LightingManager.h rename to examples/platform/infineon/cyw30739/LEDWidget.h index 21a3b3871b05d1..67f4d564f5a04b 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 #include -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 4c1695e32252e1..3659eb4d9e8c88 100644 --- a/examples/platform/infineon/cyw30739/args.gni +++ b/examples/platform/infineon/cyw30739/args.gni @@ -17,3 +17,7 @@ chip_device_project_config_include = "" chip_project_config_include = "" chip_inet_project_config_include = "" chip_system_project_config_include = "" + +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 00000000000000..df8e50ee68bf2f --- /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/platform/infineon/cyw30739/main.cpp b/examples/platform/infineon/cyw30739/main.cpp new file mode 100644 index 00000000000000..71689caf97cba8 --- /dev/null +++ b/examples/platform/infineon/cyw30739/main.cpp @@ -0,0 +1,29 @@ +/* + * + * 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 +#include +#include + +APPLICATION_START() +{ + printf("\nApp starting\n"); + + if (CYW30739MatterConfig::InitMatter() != CHIP_NO_ERROR) + printf("\nERROR InitMatter\n"); +} diff --git a/examples/lighting-app/infineon/cyw30739/src/main.cpp b/examples/platform/infineon/cyw30739/matter_config.cpp similarity index 51% rename from examples/lighting-app/infineon/cyw30739/src/main.cpp rename to examples/platform/infineon/cyw30739/matter_config.cpp index f851e2e8819664..6b0b56730edecd 100644 --- a/examples/lighting-app/infineon/cyw30739/src/main.cpp +++ b/examples/platform/infineon/cyw30739/matter_config.cpp @@ -16,18 +16,25 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include +#include "matter_config.h" +#include "AppTask.h" +#ifdef BOARD_ENABLE_DISPLAY +#include "GUI.h" +#endif +#include "cy_serial_flash.h" #include -#include #include #include -#include +#include +#include +#include #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR #include #endif -#include -#include +#ifdef BOARD_ENABLE_I2C +#include "wiced_hal_i2c.h" +#endif #include #include #include @@ -36,144 +43,78 @@ #include #include #include +#include #include +#include #include -#include -#include -#include -#include -#include +#ifdef BOARD_ENABLE_OPTIGA +#include "wiced_optiga.h" +#endif +#include +using namespace ::chip; +using namespace ::chip::Inet; using namespace ::chip::Credentials; using namespace ::chip::DeviceLayer; using namespace ::chip::Shell; using namespace ::chip::app; -static chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; +static DeviceInfoProviderImpl sExampleDeviceInfoProvider; 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) +void __attribute__((weak)) AppChipEventHandler(const chip::DeviceLayer::ChipDeviceEvent * aEvent, intptr_t arg) { - 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; + (void) aEvent; + (void) arg; } -static Identify gIdentify = { - chip::EndpointId{ 1 }, - [](Identify *) { ChipLogProgress(Zcl, "onIdentifyStart"); }, - [](Identify *) { ChipLogProgress(Zcl, "onIdentifyStop"); }, - Clusters::Identify::IdentifyTypeEnum::kNone, - OnIdentifyTriggerEffect, -}; +void __attribute__((weak)) RegisterAppShellCommands(); -APPLICATION_START() +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD +void LockOpenThreadTask(void) { - 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); - } + ThreadStackMgr().LockThreadStack(); +} - /* 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); +void UnlockOpenThreadTask(void) +{ + ThreadStackMgr().UnlockThreadStack(); +} - printf("Initializing CHIP\n"); - err = PlatformMgr().InitChipStack(); - if (err != CHIP_NO_ERROR) - { - printf("ERROR InitChipStack %ld\n", err.AsInteger()); - } +CHIP_ERROR CYW30739MatterConfig::InitOpenThread(void) +{ + CHIP_ERROR err; -#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 + ReturnLogErrorOnFailure(ThreadStackMgr().InitThreadStack()); #if CHIP_DEVICE_CONFIG_THREAD_FTD err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router); #else // !CHIP_DEVICE_CONFIG_THREAD_FTD -#if CHIP_DEVICE_CONFIG_ENABLE_SED +#if CHIP_CONFIG_ENABLE_ICD_SERVER err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice); -#else /* !CHIP_DEVICE_CONFIG_ENABLE_SED */ +#else /* !CHIP_CONFIG_ENABLE_ICD_SERVER */ err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice); -#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ +#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 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 + ReturnLogErrorOnFailure(ThreadStackMgr().StartThreadTask()); - PlatformMgr().ScheduleWork(InitApp, 0); + return err; +} +#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD +void CYW30739MatterConfig::InitShell(void) +{ const int ret = Engine::Root().Init(); if (!chip::ChipError::IsSuccess(ret)) { @@ -181,12 +122,68 @@ APPLICATION_START() } 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 InitApp(intptr_t args) +void CYW30739MatterConfig::InitApp(void) { + LogAppInit(); ConfigurationMgr().LogDeviceConfig(); // Print QR Code URL @@ -196,45 +193,35 @@ void InitApp(intptr_t args) 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; - gExampleDeviceInfoProvider.SetStorageDelegate(initParams.persistentStorageDelegate); - chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); + 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 = chip::DeviceLayer::ThreadStackMgrImpl().OTInstance(); + nativeParams.openThreadInstancePtr = ThreadStackMgrImpl().OTInstance(); initParams.endpointNativeParams = static_cast(&nativeParams); - chip::Server::GetInstance().Init(initParams); - - SetDeviceAttestationCredentialsProvider(&sFactoryDataProvider); +#endif - LightMgr().Init(); - LightMgr().SetCallbacks(LightManagerCallback, nullptr); - LightMgr().WriteClusterLevel(254); + // Init Matter Server + chip::Server::GetInstance().Init(initParams); #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR OTAConfig::Init(); #endif } -void LightManagerCallback(LightingManager::Actor_t actor, LightingManager::Action_t action, uint8_t level) +void CYW30739MatterConfig::LogAppInit(void) { - 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) + char productName[ConfigurationManager::kMaxProductNameLength + 1]; + if (CHIP_NO_ERROR == GetDeviceInstanceInfoProvider()->GetProductName(productName, sizeof(productName))) { - 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); + printf("Initializing %s\n", productName); } } diff --git a/examples/platform/infineon/cyw30739/matter_config.h b/examples/platform/infineon/cyw30739/matter_config.h new file mode 100644 index 00000000000000..a8df27415648e7 --- /dev/null +++ b/examples/platform/infineon/cyw30739/matter_config.h @@ -0,0 +1,33 @@ +/* + * + * 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. + */ +#pragma once + +#include +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 9eb2ebfb704e23..ece157dc7718ff 100755 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -537,15 +537,18 @@ def BuildCyw30739Target(): 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 722a07578fa0b1..41bfecc10fd789 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 @@ def __init__( 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 @@ def __init__( 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 GnBuildArgs(self): 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 a1d6a46755e938..4bd269b22b07eb 100644 --- a/scripts/build/testdata/all_targets_linux_x64.txt +++ b/scripts/build/testdata/all_targets_linux_x64.txt @@ -4,7 +4,7 @@ android-{arm,arm64,x86,x64,androidstudio-arm,androidstudio-arm64,androidstudio-x 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 0b671bffd76c86..b741c2568b6ef5 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 @@ def flash(self): """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 6c8e5aca412114..f2b3db1d7b4a87 100644 --- a/src/lib/shell/streamer_cyw30739.cpp +++ b/src/lib/shell/streamer_cyw30739.cpp @@ -18,8 +18,8 @@ #include #include #include +#include #include -#include namespace chip { namespace Shell { diff --git a/src/platform/Infineon/CYW30739/BUILD.gn b/src/platform/Infineon/CYW30739/BUILD.gn index 7da725e63034be..7613847e0f134c 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 @@ if (chip_enable_openthread) { 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 @@ static_library("CYW30739") { 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 15438ceb18e446..1b50c56d383ae5 100644 --- a/src/platform/Infineon/CYW30739/CYW30739Config.cpp +++ b/src/platform/Infineon/CYW30739/CYW30739Config.cpp @@ -45,7 +45,14 @@ CHIP_ERROR CYW30739Config::ReadConfigValue(Key key, T & val) 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 @@ CHIP_ERROR CYW30739Config::ReadConfigValueBin(Key key, void * buf, size_t bufSiz } 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 80f0895e10687e..f5e56f0fee42cc 100644 --- a/src/platform/Infineon/CYW30739/CYW30739Config.h +++ b/src/platform/Infineon/CYW30739/CYW30739Config.h @@ -54,21 +54,23 @@ class CYW30739Config // 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 @@ class CYW30739Config 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 4a299843cf6a39..4b6b5d88c7f12c 100644 --- a/src/platform/Infineon/CYW30739/EventFlags.cpp +++ b/src/platform/Infineon/CYW30739/EventFlags.cpp @@ -44,15 +44,12 @@ CHIP_ERROR EventFlags::Init(void) 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 0c33a279756f16..0ece03d3c19c83 100644 --- a/src/platform/Infineon/CYW30739/FactoryDataProvider.cpp +++ b/src/platform/Infineon/CYW30739/FactoryDataProvider.cpp @@ -25,6 +25,54 @@ namespace DeviceLayer { 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 @@ CHIP_ERROR FactoryDataProvider::SignWithDeviceAttestationKey(const ByteSpan & me 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 6fc22b9c96e20e..def69734e1dc22 100644 --- a/src/platform/Infineon/CYW30739/FactoryDataProvider.h +++ b/src/platform/Infineon/CYW30739/FactoryDataProvider.h @@ -19,13 +19,26 @@ #include #include +#include +#include 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 @@ class FactoryDataProvider : public chip::Credentials::DeviceAttestationCredentia 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 f78d6397823317..079acbe90682d6 100644 --- a/src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.cpp +++ b/src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.cpp @@ -121,8 +121,7 @@ CHIP_ERROR KeyValueStoreManagerImpl::_Put(const char * key, const void * value, 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 9d16dd4ce1e6cd..9f51a3e324110f 100644 --- a/src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.h +++ b/src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.h @@ -55,7 +55,7 @@ class KeyValueStoreManagerImpl final : public KeyValueStoreManager 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 643cecc44d9fdb..c6c2698f7961fa 100644 --- a/src/platform/Infineon/CYW30739/PlatformManagerImpl.cpp +++ b/src/platform/Infineon/CYW30739/PlatformManagerImpl.cpp @@ -29,7 +29,7 @@ #include #include -#include +#include namespace chip { namespace DeviceLayer { @@ -218,12 +218,11 @@ void PlatformManagerImpl::TimerCallback(WICED_TIMER_PARAM_TYPE params) 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(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 21297d75cf5252..58e905a84004b6 100644 --- a/src/platform/Infineon/CYW30739/ThreadStackManagerImpl.cpp +++ b/src/platform/Infineon/CYW30739/ThreadStackManagerImpl.cpp @@ -28,7 +28,6 @@ #include #include -#include namespace chip { namespace DeviceLayer { @@ -73,7 +72,7 @@ void ThreadStackManagerImpl::SignalThreadActivityPending() mEventFlags.Set(kActivityPendingEventFlag); } -void ThreadStackManagerImpl::SignalThreadActivityPendingFromISR() +__attribute__((section(".text_in_ram"))) void ThreadStackManagerImpl::SignalThreadActivityPendingFromISR() { mEventFlags.Set(kActivityPendingFromISREventFlag); } @@ -150,7 +149,7 @@ extern "C" void otTaskletsSignalPending(otInstance * p_instance) 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 252c5e6716e59e..11bfab9379ff68 100644 --- a/src/platform/Infineon/CYW30739/args.gni +++ b/src/platform/Infineon/CYW30739/args.gni @@ -41,9 +41,13 @@ chip_with_lwip = false 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_external_mbedtls = mbedtls_target 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_ip6_slaac_enable = true 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 1dda5aa93cf4ff..1446a2d3d7b3a9 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 00000000000000..367727207e506b --- /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 46ca83b4eae8e4..00000000000000 --- 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=", - "MBEDTLS_USER_CONFIG_FILE=", - ] - - 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 3d64d129352038..00000000000000 --- 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 ec8bc6af4af752..00000000000000 --- 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 d8e3c8ab28fc58..00000000000000 --- 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 b4e1a38b050feb..00000000000000 --- 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 69ee21956329d7..00000000000000 --- 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 803415316db4e7..00000000000000 --- 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(''): - 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('')] - - 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 44b76f74c502a3..00000000000000 --- 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 0251a1d5805fce..00000000000000 --- 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 8bb9a47e53d727..00000000000000 --- 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 e57581ecb82493..00000000000000 --- 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 edd51c6bef7b4a..00000000000000 --- 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(" -#include - -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 65091250a0d809..00000000000000 --- 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 c23f3672a2c9e5..00000000000000 --- 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 ed9c034c4c8020..00000000000000 --- 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 f951c7d3d3c37e..00000000000000 --- 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 d3e46e83a248fd..00000000000000 --- 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 b9a1aac342f239..00000000000000 --- 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 0943e94ccca9ed..00000000000000 --- 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 aaf1ef4f7f410e..00000000000000 --- 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 - {{ - -""") - - 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 28c3cff862cdd1..00000000000000 --- 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 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 a741a1ac42dc40..00000000000000 --- 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 -#include -#include -#include -#include - -#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. -//!

-//! If config data is stored in NVRAM: -//!

-//! 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. -//!

-//! 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. -//!

-//! 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. -//!

-//! 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. -//!

-//! If config data is stored in RAM (downloaded by the host): -//!

-//! 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 2de5160261a8c6..00000000000000 --- 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 -#include - -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 c8761c6e354023..00000000000000 --- 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 - -/****************************************************** - * 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 7761c92f8fcbfa..00000000000000 --- 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 00000000000000..f6e196cbd982cf --- /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 8da150a2ef425d..2f7a13230d26c2 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 fefabcd3562fef..379f50ad81be5b 100644 --- a/third_party/openthread/platforms/ifx/BUILD.gn +++ b/third_party/openthread/platforms/ifx/BUILD.gn @@ -16,42 +16,19 @@ 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" +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 00000000000000..c6051efebdc14f --- /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", + ] + } +}