diff --git a/.github/.wordlist.txt b/.github/.wordlist.txt index 251fa2fee90749..82e88caf568625 100644 --- a/.github/.wordlist.txt +++ b/.github/.wordlist.txt @@ -564,6 +564,7 @@ FW gbl gcloud GDB +gdbgui gdbserver GeneralCommissioning GeneralDiagnostics @@ -719,6 +720,7 @@ Jupyter jupyterlab KA kAdminister +kbd kBusy kCase Kconfig diff --git a/.github/workflows/darwin.yaml b/.github/workflows/darwin.yaml index 53ea74716dd028..053eb96af69796 100644 --- a/.github/workflows/darwin.yaml +++ b/.github/workflows/darwin.yaml @@ -136,7 +136,7 @@ jobs: run: defaults delete com.apple.dt.xctest.tool continue-on-error: true - name: Run Framework Tests - timeout-minutes: 20 + timeout-minutes: 30 # For now disable unguarded-availability-new warnings because we # internally use APIs that we are annotating as only available on # new enough versions. Maybe we should change out deployment @@ -144,15 +144,18 @@ jobs: run: | mkdir -p /tmp/darwin/framework-tests ../../../out/debug/chip-all-clusters-app --interface-id -1 > >(tee /tmp/darwin/framework-tests/all-cluster-app.log) 2> >(tee /tmp/darwin/framework-tests/all-cluster-app-err.log >&2) & - # Make each ota-requestor is using a different port, discriminator, and KVS from + # Make sure each ota-requestor is using a different port, discriminator, and KVS from # all-clusters-app and from other requestors. # # And a different port from the test harness too; the test harness uses port 5541. ../../../out/debug/chip-ota-requestor-app --interface-id -1 --secured-device-port 5542 --discriminator 1111 --KVS /tmp/chip-ota-requestor-kvs1 --otaDownloadPath /tmp/chip-ota-requestor-downloaded-image1 --autoApplyImage > >(tee /tmp/darwin/framework-tests/ota-requestor-app-1.log) 2> >(tee /tmp/darwin/framework-tests/ota-requestor-app-err-1.log >&2) & ../../../out/debug/chip-ota-requestor-app --interface-id -1 --secured-device-port 5543 --discriminator 1112 --KVS /tmp/chip-ota-requestor-kvs2 --otaDownloadPath /tmp/chip-ota-requestor-downloaded-image2 --autoApplyImage > >(tee /tmp/darwin/framework-tests/ota-requestor-app-2.log) 2> >(tee /tmp/darwin/framework-tests/ota-requestor-app-err-2.log >&2) & - # UndefinedBehaviorSanitizer is enabled in the Xcode scheme, so the code in Matter.framework gets instrumented, + # -enableUndefinedBehaviorSanitizer instruments the code in Matter.framework, # but to instrument the code in the underlying libCHIP we need to pass CHIP_IS_UBSAN=YES - xcodebuild test -target "Matter" -scheme "Matter Framework Tests" -sdk macosx OTHER_CFLAGS='${inherited} -Werror -Wconversion -Wno-incomplete-umbrella -Wno-unguarded-availability-new' CHIP_IS_UBSAN=YES > >(tee /tmp/darwin/framework-tests/darwin-tests.log) 2> >(tee /tmp/darwin/framework-tests/darwin-tests-err.log >&2) + TEST_RUNNER_ASAN_OPTIONS=__CURRENT_VALUE__:detect_stack_use_after_return=1 xcodebuild test -target "Matter" -scheme "Matter Framework Tests" -sdk macosx -enableAddressSanitizer YES -enableUndefinedBehaviorSanitizer YES OTHER_CFLAGS='${inherited} -Werror -Wconversion -Wno-incomplete-umbrella -Wno-unguarded-availability-new' CHIP_IS_UBSAN=YES > >(tee /tmp/darwin/framework-tests/darwin-tests-asan.log) 2> >(tee /tmp/darwin/framework-tests/darwin-tests-asan-err.log >&2) + # -enableThreadSanitizer instruments the code in Matter.framework, + # but to instrument the code in the underlying libCHIP we need to pass CHIP_IS_TSAN=YES + #xcodebuild test -target "Matter" -scheme "Matter Framework Tests" -sdk macosx -enableThreadSanitizer YES OTHER_CFLAGS='${inherited} -Werror -Wconversion -Wno-incomplete-umbrella -Wno-unguarded-availability-new' CHIP_IS_TSAN=YES > >(tee /tmp/darwin/framework-tests/darwin-tests-tsan.log) 2> >(tee /tmp/darwin/framework-tests/darwin-tests-tsan-err.log >&2) working-directory: src/darwin/Framework - name: Uploading log files uses: actions/upload-artifact@v3 diff --git a/.github/workflows/examples-cc13x2x7_26x2x7.yaml b/.github/workflows/examples-cc13x2x7_26x2x7.yaml index f3703f38b85f69..f48b3264f32957 100644 --- a/.github/workflows/examples-cc13x2x7_26x2x7.yaml +++ b/.github/workflows/examples-cc13x2x7_26x2x7.yaml @@ -22,7 +22,6 @@ on: concurrency: group: ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.number) || (github.event_name == 'workflow_dispatch' && github.run_number) || github.sha }} cancel-in-progress: true - env: CHIP_NO_LOG_TIMESTAMPS: true # XXX: Workaround for https://github.com/actions/cache/issues/1141 @@ -40,7 +39,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-ti:0.7.3 + image: connectedhomeip/chip-build-ti:0.7.14 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: @@ -79,5 +78,93 @@ jobs: path: | .environment/gn_out/.ninja_log .environment/pigweed-venv/*.log - + - name: Build examples + timeout-minutes: 100 + run: | + scripts/run_in_build_env.sh "\ + ./scripts/build/build_examples.py \ + --target ti-cc13x2x7_26x2x7-lock-mtd \ + --target ti-cc13x2x7_26x2x7-pump-mtd \ + --target ti-cc13x2x7_26x2x7-lighting \ + --target ti-cc13x2x7_26x2x7-pump-controller-mtd \ + --target ti-cc13x4_26x4-lighting \ + --target ti-cc13x4_26x4-lock-ftd \ + --target ti-cc13x4_26x4-lock-mtd \ + --target ti-cc13x4_26x4-pump-mtd \ + --target ti-cc13x4_26x4-pump-ftd \ + --target ti-cc13x4_26x4-pump-controller-mtd \ + --target ti-cc13x4_26x4-pump-controller-ftd \ + build \ + --copy-artifacts-to out/artifacts \ + " + - name: Get lock MTD size stats + timeout-minutes: 5 + run: | + .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ + cc13x2_26x2 LP_CC2652R7 lock-mtd \ + out/artifacts/ti-cc13x2x7_26x2x7-lock-mtd/chip-LP_CC2652R7-lock-example.out \ + /tmp/bloat_reports/ + - name: Get Pump App size stats + timeout-minutes: 5 + run: | + .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ + cc13x2_26x2 LP_CC2652R7 pump-app \ + out/artifacts/ti-cc13x2x7_26x2x7-pump-mtd/chip-LP_CC2652R7-pump-example.out \ + /tmp/bloat_reports/ + - name: Get Pump Controller App size stats + timeout-minutes: 5 + run: | + .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ + cc13x2_26x2 LP_CC2652R7 pump-controller-app \ + out/artifacts/ti-cc13x2x7_26x2x7-pump-controller-mtd/chip-LP_CC2652R7-pump-controller-example.out \ + /tmp/bloat_reports/ + - name: Get lock FTD size stats + timeout-minutes: 5 + run: | + .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ + cc13x4_26x4 LP_EM_CC1354P10_6 lock-ftd \ + out/artifacts/ti-cc13x4_26x4-lock-ftd/chip-LP_EM_CC1354P10_6-lock-example.out \ + /tmp/bloat_reports/ + - name: Get lock MTD size stats + timeout-minutes: 5 + run: | + .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ + cc13x4_26x4 LP_EM_CC1354P10_6 lock-mtd \ + out/artifacts/ti-cc13x4_26x4-lock-mtd/chip-LP_EM_CC1354P10_6-lock-example.out \ + /tmp/bloat_reports/ + - name: Get Pump App size stats + timeout-minutes: 5 + run: | + .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ + cc13x4_26x4 LP_EM_CC1354P10_6 pump-app \ + out/artifacts/ti-cc13x4_26x4-pump-mtd/chip-LP_EM_CC1354P10_6-pump-example.out \ + /tmp/bloat_reports/ + - name: Get Pump Controller App size stats + timeout-minutes: 5 + run: | + .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ + cc13x4_26x4 LP_EM_CC1354P10_6 pump-controller-app \ + out/artifacts/ti-cc13x4_26x4-pump-controller-mtd/chip-LP_EM_CC1354P10_6-pump-controller-example.out \ + /tmp/bloat_reports/ + - name: Get Lighting App size stats + timeout-minutes: 5 + run: | + .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ + cc13x4_26x4 LP_EM_CC1354P10_6 lighting-app \ + out/artifacts/ti-cc13x4_26x4-lighting/chip-LP_EM_CC1354P10_6-lighting-example.out \ + /tmp/bloat_reports/ + - name: Uploading Size Reports + uses: actions/upload-artifact@v2 + if: ${{ !env.ACT }} + with: + name: Size,cc13x2x7_26x2x7-Examples,${{ env.GH_EVENT_PR }},${{ env.GH_EVENT_HASH }},${{ env.GH_EVENT_PARENT }},${{ github.event_name }} + path: | + /tmp/bloat_reports/ + - name: Uploading Size Reports + uses: actions/upload-artifact@v2 + if: ${{ !env.ACT }} + with: + name: Size,cc13x4_26x4-Examples,${{ env.GH_EVENT_PR }},${{ env.GH_EVENT_HASH }},${{ env.GH_EVENT_PARENT }},${{ github.event_name }} + path: | + /tmp/bloat_reports/ diff --git a/.github/workflows/examples-efr32.yaml b/.github/workflows/examples-efr32.yaml index 17e0b5617b2230..d8961dde06c5a1 100644 --- a/.github/workflows/examples-efr32.yaml +++ b/.github/workflows/examples-efr32.yaml @@ -87,7 +87,7 @@ jobs: - name: Test SLC gen timeout-minutes: 30 run: | - scripts/examples/gn_efr32_example.sh examples/lighting-app/silabs/efr32 ./out/light-app BRD4187C --slc_generate --docker + scripts/examples/gn_silabs_example.sh examples/lighting-app/silabs ./out/light-app BRD4187C --slc_generate --docker rm -rf ./out/ - name: Build some BRD4187C variants timeout-minutes: 90 @@ -120,7 +120,7 @@ jobs: - name: Build example EFR32+WF200 WiFi Lock app for BRD4161A timeout-minutes: 15 run: | - scripts/examples/gn_efr32_example.sh examples/lock-app/silabs/efr32/ out/lock_app_wifi_wf200 BRD4161A is_debug=false chip_logging=false --wifi wf200 --docker + scripts/examples/gn_silabs_example.sh examples/lock-app/silabs out/lock_app_wifi_wf200 BRD4161A is_debug=false chip_logging=false --wifi wf200 --docker .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py efr32 BRD4161A+wf200 lock-app \ out/lock_app_wifi_wf200/BRD4161A/matter-silabs-lock-example.out /tmp/bloat_reports/ - name: Clean out build output @@ -128,7 +128,7 @@ jobs: - name: Build example EFR32+RS9116 WiFi Lighting app for BRD4161A timeout-minutes: 15 run: | - scripts/examples/gn_efr32_example.sh examples/lighting-app/silabs/efr32/ out/lighting_app_wifi_rs9116 BRD4161A --wifi rs9116 --docker + scripts/examples/gn_silabs_example.sh examples/lighting-app/silabs out/lighting_app_wifi_rs9116 BRD4161A --wifi rs9116 --docker .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py efr32 BRD4161A+rs9116 lighting-app \ out/lighting_app_wifi_rs9116/BRD4161A/matter-silabs-lighting-example.out /tmp/bloat_reports/ - name: Clean out build output diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index cf0317c61c190c..8bddf9aa69b81c 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -38,7 +38,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-telink:0.7.3 + image: connectedhomeip/chip-build-telink:0.7.14 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" @@ -144,6 +144,18 @@ jobs: - name: clean out build output run: rm -rf ./out + - name: Build example Telink Lighting App with Shell + run: | + ./scripts/run_in_build_env.sh \ + "./scripts/build/build_examples.py --target 'telink-tlsr9518adk80d-light-shell' build" + .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ + telink tlsr9518adk80d lighting-app-shell \ + out/telink-tlsr9518adk80d-light-shell/zephyr/zephyr.elf \ + /tmp/bloat_reports/ + + - name: clean out build output + run: rm -rf ./out + - name: Build example Telink Lighting App with Factory Data run: | ./scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform linux diff --git a/.github/workflows/java-tests.yaml b/.github/workflows/java-tests.yaml new file mode 100644 index 00000000000000..33d267edb23a95 --- /dev/null +++ b/.github/workflows/java-tests.yaml @@ -0,0 +1,229 @@ +# Copyright (c) 2023 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Java Tests + +on: + push: + pull_request: + merge_group: + workflow_dispatch: + +concurrency: + group: ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == + 'pull_request' && github.event.number) || (github.event_name == + 'workflow_dispatch' && github.run_number) || github.sha }} + cancel-in-progress: true + +env: + CHIP_NO_LOG_TIMESTAMPS: true + # XXX: Workaround for https://github.com/actions/cache/issues/1141 + SEGMENT_DOWNLOAD_TIMEOUT_MINS: 3 + +jobs: + java_tests_linux: + name: Linux + timeout-minutes: 130 + + env: + TSAN_OPTIONS: "halt_on_error=1 suppressions=scripts/tests/chiptest/tsan-linux-suppressions.txt" + JAVA_PATH: /usr/lib/jvm/java-8-openjdk-amd64 + + if: github.actor != 'restyled-io[bot]' + runs-on: ubuntu-latest + + container: + image: connectedhomeip/chip-build-java:0.7.3 + options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 + net.ipv4.conf.all.forwarding=0 net.ipv6.conf.all.forwarding=0" + + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Checkout submodules + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform linux + - name: Try to ensure the directories for core dumping exist and we + can write them. + run: | + mkdir /tmp/cores || true + sysctl -w kernel.core_pattern=/tmp/cores/core.%u.%p.%t || true + mkdir objdir-clone || true + + - name: Bootstrap cache + uses: actions/cache@v3 + timeout-minutes: 10 + with: + key: ${{ runner.os }}-env-${{ hashFiles('scripts/setup/*', 'third_party/pigweed/**') }} + path: | + .environment + build_overrides/pigweed_environment.gni + - name: Bootstrap + timeout-minutes: 10 + run: bash scripts/bootstrap.sh + - name: Uploading bootstrap logs + uses: actions/upload-artifact@v3 + if: ${{ always() && !env.ACT }} + with: + name: bootstrap-logs-linux-${{ matrix.build_variant }}${{ matrix.chip_tool }} + path: | + .environment/gn_out/.ninja_log + .environment/pigweed-venv/*.log + + - name: Build Java Matter Controller and all clusters app + timeout-minutes: 50 + run: | + scripts/run_in_build_env.sh './scripts/build_python.sh --install_wheel build-env' + ./scripts/run_in_build_env.sh \ + "./scripts/build/build_examples.py \ + --target linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test \ + --target linux-x64-java-matter-controller \ + build \ + " + - name: Run Discover Commissionables Test + timeout-minutes: 10 + run: | + scripts/run_in_build_env.sh \ + './scripts/tests/run_java_test.py \ + --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \ + --app-args "--discriminator 3840 --interface-id -1" \ + --tool-path out/linux-x64-java-matter-controller \ + --tool-cluster "discover" \ + --tool-args "commissionables" \ + --factoryreset \ + ' + - name: Run Pairing Onnetwork Test + timeout-minutes: 10 + run: | + scripts/run_in_build_env.sh \ + './scripts/tests/run_java_test.py \ + --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \ + --app-args "--discriminator 3840 --interface-id -1" \ + --tool-path out/linux-x64-java-matter-controller \ + --tool-cluster "pairing" \ + --tool-args "onnetwork-long --nodeid 1 --setup-pin-code 20202021 --discriminator 3840 -t 1000" \ + --factoryreset \ + ' + - name: Run IM Invoke Test + timeout-minutes: 10 + run: | + scripts/run_in_build_env.sh \ + './scripts/tests/run_java_test.py \ + --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \ + --app-args "--discriminator 3840 --interface-id -1" \ + --tool-path out/linux-x64-java-matter-controller \ + --tool-cluster "im" \ + --tool-args "onnetwork-long-im-invoke --nodeid 1 --setup-pin-code 20202021 --discriminator 3840 -t 1000" \ + --factoryreset \ + ' + - name: Run IM Read Test + timeout-minutes: 10 + run: | + scripts/run_in_build_env.sh \ + './scripts/tests/run_java_test.py \ + --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \ + --app-args "--discriminator 3840 --interface-id -1" \ + --tool-path out/linux-x64-java-matter-controller \ + --tool-cluster "im" \ + --tool-args "onnetwork-long-im-read --nodeid 1 --setup-pin-code 20202021 --discriminator 3840 -t 1000" \ + --factoryreset \ + ' + - name: Run IM Write Test + timeout-minutes: 10 + run: | + scripts/run_in_build_env.sh \ + './scripts/tests/run_java_test.py \ + --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \ + --app-args "--discriminator 3840 --interface-id -1" \ + --tool-path out/linux-x64-java-matter-controller \ + --tool-cluster "im" \ + --tool-args "onnetwork-long-im-write --nodeid 1 --setup-pin-code 20202021 --discriminator 3840 -t 1000" \ + --factoryreset \ + ' + - name: Run IM Subscribe Test + timeout-minutes: 10 + run: | + scripts/run_in_build_env.sh \ + './scripts/tests/run_java_test.py \ + --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \ + --app-args "--discriminator 3840 --interface-id -1" \ + --tool-path out/linux-x64-java-matter-controller \ + --tool-cluster "im" \ + --tool-args "onnetwork-long-im-subscribe --nodeid 1 --setup-pin-code 20202021 --discriminator 3840 -t 1000" \ + --factoryreset \ + ' + - name: Run Pairing AlreadyDiscovered Test + timeout-minutes: 10 + run: | + scripts/run_in_build_env.sh \ + './scripts/tests/run_java_test.py \ + --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \ + --app-args "--discriminator 3840 --interface-id -1" \ + --tool-path out/linux-x64-java-matter-controller \ + --tool-cluster "pairing" \ + --tool-args "already-discovered --nodeid 1 --setup-pin-code 20202021 --address ::1 --port 5540 -t 1000" \ + --factoryreset \ + ' + - name: Run Pairing Address-PaseOnly Test + timeout-minutes: 10 + run: | + scripts/run_in_build_env.sh \ + './scripts/tests/run_java_test.py \ + --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \ + --app-args "--discriminator 3840 --interface-id -1" \ + --tool-path out/linux-x64-java-matter-controller \ + --tool-cluster "pairing" \ + --tool-args "address-paseonly --nodeid 1 --setup-pin-code 20202021 --address ::1 --port 5540 -t 1000" \ + --factoryreset \ + ' + - name: Run Pairing SetupQRCode Test + timeout-minutes: 10 + run: | + scripts/run_in_build_env.sh \ + './scripts/tests/run_java_test.py \ + --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \ + --app-args "--discriminator 3840 --interface-id -1" \ + --tool-path out/linux-x64-java-matter-controller \ + --tool-cluster "pairing" \ + --tool-args "code --nodeid 1 --setup-payload MT:-24J0AFN00KA0648G00 --discover-once 1 --use-only-onnetwork-discovery 0 -t 1000" \ + --factoryreset \ + ' + - name: Run Pairing ManualCode Test + timeout-minutes: 10 + run: | + scripts/run_in_build_env.sh \ + './scripts/tests/run_java_test.py \ + --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \ + --app-args "--discriminator 3840 --interface-id -1" \ + --tool-path out/linux-x64-java-matter-controller \ + --tool-cluster "pairing" \ + --tool-args "code --nodeid 1 --setup-payload 34970112332 --discover-once 1 --use-only-onnetwork-discovery 0 -t 1000" \ + --factoryreset \ + ' + - name: Uploading core files + uses: actions/upload-artifact@v3 + if: ${{ failure() && !env.ACT }} + with: + name: crash-core-linux-java-controller + path: /tmp/cores/ + # Cores are big; don't hold on to them too long. + retention-days: 5 + - name: Uploading objdir for debugging + uses: actions/upload-artifact@v3 + if: ${{ failure() && !env.ACT }} + with: + name: crash-objdir-linux-java-controller + path: objdir-clone/ + # objdirs are big; don't hold on to them too long. + retention-days: 5 + diff --git a/.github/workflows/release_artifacts.yaml b/.github/workflows/release_artifacts.yaml index 314600d3e588ff..fc371f695ab25e 100644 --- a/.github/workflows/release_artifacts.yaml +++ b/.github/workflows/release_artifacts.yaml @@ -124,7 +124,7 @@ jobs: .environment/pigweed-venv/*.log - name: Build example EFR32 Lock App - run: scripts/examples/gn_efr32_example.sh examples/lock-app/efr32/ + run: scripts/examples/gn_silabs_example.sh examples/lock-app/efr32/ out/lock_app_debug $SILABS_BOARD - name: Upload artifact diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index dcf34d4ad8b125..70c0fb95d59bde 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -524,201 +524,6 @@ jobs: # objdirs are big; don't hold on to them too long. retention-days: 5 - java_tests_linux: - name: Java Tests - Linux - timeout-minutes: 130 - - env: - TSAN_OPTIONS: "halt_on_error=1 suppressions=scripts/tests/chiptest/tsan-linux-suppressions.txt" - JAVA_PATH: /usr/lib/jvm/java-8-openjdk-amd64 - - if: github.actor != 'restyled-io[bot]' - runs-on: ubuntu-latest - - container: - image: connectedhomeip/chip-build-java:0.7.3 - options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 - net.ipv4.conf.all.forwarding=0 net.ipv6.conf.all.forwarding=0" - - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Checkout submodules - run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform linux - - name: Try to ensure the directories for core dumping exist and we - can write them. - run: | - mkdir /tmp/cores || true - sysctl -w kernel.core_pattern=/tmp/cores/core.%u.%p.%t || true - mkdir objdir-clone || true - - - name: Bootstrap cache - uses: actions/cache@v3 - timeout-minutes: 10 - with: - key: ${{ runner.os }}-env-${{ hashFiles('scripts/setup/*', 'third_party/pigweed/**') }} - path: | - .environment - build_overrides/pigweed_environment.gni - - name: Bootstrap - timeout-minutes: 10 - run: bash scripts/bootstrap.sh - - name: Uploading bootstrap logs - uses: actions/upload-artifact@v3 - if: ${{ always() && !env.ACT }} - with: - name: bootstrap-logs-linux-${{ matrix.build_variant }}${{ matrix.chip_tool }} - path: | - .environment/gn_out/.ninja_log - .environment/pigweed-venv/*.log - - - name: Build Java Matter Controller and all clusters app - timeout-minutes: 50 - run: | - scripts/run_in_build_env.sh './scripts/build_python.sh --install_wheel build-env' - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py \ - --target linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test \ - --target linux-x64-java-matter-controller \ - build \ - " - - name: Run Discover Commissionables Test - timeout-minutes: 10 - run: | - scripts/run_in_build_env.sh \ - './scripts/tests/run_java_test.py \ - --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \ - --app-args "--discriminator 3840 --interface-id -1" \ - --tool-path out/linux-x64-java-matter-controller \ - --tool-cluster "discover" \ - --tool-args "commissionables" \ - --factoryreset \ - ' - - name: Run Pairing Onnetwork Test - timeout-minutes: 10 - run: | - scripts/run_in_build_env.sh \ - './scripts/tests/run_java_test.py \ - --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \ - --app-args "--discriminator 3840 --interface-id -1" \ - --tool-path out/linux-x64-java-matter-controller \ - --tool-cluster "pairing" \ - --tool-args "onnetwork-long --nodeid 1 --setup-pin-code 20202021 --discriminator 3840 -t 1000" \ - --factoryreset \ - ' - - name: Run IM Invoke Test - timeout-minutes: 10 - run: | - scripts/run_in_build_env.sh \ - './scripts/tests/run_java_test.py \ - --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \ - --app-args "--discriminator 3840 --interface-id -1" \ - --tool-path out/linux-x64-java-matter-controller \ - --tool-cluster "im" \ - --tool-args "onnetwork-long-im-invoke --nodeid 1 --setup-pin-code 20202021 --discriminator 3840 -t 1000" \ - --factoryreset \ - ' - - name: Run IM Read Test - timeout-minutes: 10 - run: | - scripts/run_in_build_env.sh \ - './scripts/tests/run_java_test.py \ - --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \ - --app-args "--discriminator 3840 --interface-id -1" \ - --tool-path out/linux-x64-java-matter-controller \ - --tool-cluster "im" \ - --tool-args "onnetwork-long-im-read --nodeid 1 --setup-pin-code 20202021 --discriminator 3840 -t 1000" \ - --factoryreset \ - ' - - name: Run IM Write Test - timeout-minutes: 10 - run: | - scripts/run_in_build_env.sh \ - './scripts/tests/run_java_test.py \ - --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \ - --app-args "--discriminator 3840 --interface-id -1" \ - --tool-path out/linux-x64-java-matter-controller \ - --tool-cluster "im" \ - --tool-args "onnetwork-long-im-write --nodeid 1 --setup-pin-code 20202021 --discriminator 3840 -t 1000" \ - --factoryreset \ - ' - - name: Run IM Subscribe Test - timeout-minutes: 10 - run: | - scripts/run_in_build_env.sh \ - './scripts/tests/run_java_test.py \ - --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \ - --app-args "--discriminator 3840 --interface-id -1" \ - --tool-path out/linux-x64-java-matter-controller \ - --tool-cluster "im" \ - --tool-args "onnetwork-long-im-subscribe --nodeid 1 --setup-pin-code 20202021 --discriminator 3840 -t 1000" \ - --factoryreset \ - ' - - name: Run Pairing AlreadyDiscovered Test - timeout-minutes: 10 - run: | - scripts/run_in_build_env.sh \ - './scripts/tests/run_java_test.py \ - --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \ - --app-args "--discriminator 3840 --interface-id -1" \ - --tool-path out/linux-x64-java-matter-controller \ - --tool-cluster "pairing" \ - --tool-args "already-discovered --nodeid 1 --setup-pin-code 20202021 --address ::1 --port 5540 -t 1000" \ - --factoryreset \ - ' - - name: Run Pairing Address-PaseOnly Test - timeout-minutes: 10 - run: | - scripts/run_in_build_env.sh \ - './scripts/tests/run_java_test.py \ - --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \ - --app-args "--discriminator 3840 --interface-id -1" \ - --tool-path out/linux-x64-java-matter-controller \ - --tool-cluster "pairing" \ - --tool-args "address-paseonly --nodeid 1 --setup-pin-code 20202021 --address ::1 --port 5540 -t 1000" \ - --factoryreset \ - ' - - name: Run Pairing SetupQRCode Test - timeout-minutes: 10 - run: | - scripts/run_in_build_env.sh \ - './scripts/tests/run_java_test.py \ - --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \ - --app-args "--discriminator 3840 --interface-id -1" \ - --tool-path out/linux-x64-java-matter-controller \ - --tool-cluster "pairing" \ - --tool-args "code --nodeid 1 --setup-payload MT:-24J0AFN00KA0648G00 --discover-once 1 --use-only-onnetwork-discovery 0 -t 1000" \ - --factoryreset \ - ' - - name: Run Pairing ManualCode Test - timeout-minutes: 10 - run: | - scripts/run_in_build_env.sh \ - './scripts/tests/run_java_test.py \ - --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \ - --app-args "--discriminator 3840 --interface-id -1" \ - --tool-path out/linux-x64-java-matter-controller \ - --tool-cluster "pairing" \ - --tool-args "code --nodeid 1 --setup-payload 34970112332 --discover-once 1 --use-only-onnetwork-discovery 0 -t 1000" \ - --factoryreset \ - ' - - name: Uploading core files - uses: actions/upload-artifact@v3 - if: ${{ failure() && !env.ACT }} - with: - name: crash-core-linux-java-controller - path: /tmp/cores/ - # Cores are big; don't hold on to them too long. - retention-days: 5 - - name: Uploading objdir for debugging - uses: actions/upload-artifact@v3 - if: ${{ failure() && !env.ACT }} - with: - name: crash-objdir-linux-java-controller - path: objdir-clone/ - # objdirs are big; don't hold on to them too long. - retention-days: 5 - repl_tests_darwin: name: REPL Tests - Darwin timeout-minutes: 120 diff --git a/.vscode/launch.json b/.vscode/launch.json index 83ce3d5fe494bd..ed80ae59c95e23 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -430,8 +430,8 @@ "name": "Debug Open IoT SDK example application", "type": "cortex-debug", "request": "launch", - "cwd": "${workspaceRoot}/examples/${input:openiotsdkApp}/openiotsdk", - "executable": "./build/chip-openiotsdk-${input:openiotsdkApp}-example.elf", + "cwd": "${workspaceRoot}/examples/${input:openiotsdkExample}/openiotsdk", + "executable": "./build/chip-openiotsdk-${input:openiotsdkExample}-example.elf", "armToolchainPath": "${env:PW_ENVIRONMENT_ROOT}/cipd/packages/arm/bin/", "servertype": "external", "gdbTarget": "${input:openiotsdkRemoteHost}:31627", //GDBserver port on FVP @@ -439,7 +439,7 @@ "-enable-pretty-printing", "add-symbol-file ./build/bl2.elf 0x10000000", "add-symbol-file ./build/tfm_s.elf 0x38000400", - "add-symbol-file ./build/chip-openiotsdk-${input:openiotsdkApp}-example_ns.elf 0x28060400", + "add-symbol-file ./build/chip-openiotsdk-${input:openiotsdkExample}-example_ns.elf 0x28060400", "break main_ns.cpp:main" ], "runToEntryPoint": "main", @@ -451,7 +451,7 @@ "type": "cortex-debug", "request": "launch", "cwd": "${workspaceRoot}/src/test_driver/openiotsdk/unit-tests", - "executable": "./build/${input:openiotsdkUnittest}.elf", + "executable": "./build/${input:openiotsdkUnitTest}.elf", "armToolchainPath": "${env:PW_ENVIRONMENT_ROOT}/cipd/packages/arm/bin/", "servertype": "external", "gdbTarget": ":31627", //GDBserver port on FVP @@ -459,7 +459,7 @@ "-enable-pretty-printing", "add-symbol-file ./build/bl2.elf 0x10000000", "add-symbol-file ./build/tfm_s.elf 0x38000400", - "add-symbol-file ./build/${input:openiotsdkUnittest}_ns.elf 0x28060400", + "add-symbol-file ./build/${input:openiotsdkUnitTest}_ns.elf 0x28060400", "break main_ns.cpp:main" ], "runToEntryPoint": "main", @@ -522,11 +522,13 @@ "default": "CY8CPROTO_062_4343W" }, { - "type": "pickString", - "id": "openiotsdkApp", - "description": "What Open IoT SDK example do you want to use?", - "options": ["shell", "lock-app"], - "default": "shell" + "type": "command", + "id": "openiotsdkExample", + "command": "shellCommand.execute", + "args": { + "command": "cat examples/platform/openiotsdk/supported_examples.txt", + "description": "What Open IoT SDK example application do you want to use?" + } }, { "type": "promptString", @@ -535,37 +537,13 @@ "default": "" }, { - "type": "pickString", - "id": "openiotsdkUnittest", - "description": "What Open IoT SDK unit test do you want to use?", - "options": [ - "accesstest", - "AppTests", - "ASN1Tests", - "BDXTests", - "ChipCryptoTests", - "ControllerTests", - "CoreTests", - "CredentialsTest", - "DataModelTests", - "InetLayerTests", - "MdnsTests", - "MessagingLayerTests", - "MinimalMdnsCoreTests", - "MinimalMdnsRecordsTests", - "MinimalMdnsRespondersTests", - "PlatformTests", - "RawTransportTests", - "RetransmitTests", - "SecureChannelTests", - "SetupPayloadTests", - "SupportTests", - "SystemLayerTests", - "TestShell", - "TransportLayerTests", - "UserDirectedCommissioningTests" - ], - "default": "accesstest" + "type": "command", + "id": "openiotsdkUnitTest", + "command": "shellCommand.execute", + "args": { + "command": "cat src/test_driver/openiotsdk/unit-tests/test_components.txt", + "description": "What Open IoT SDK unit test application do you want to use?" + } } ] } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 7d02179af08b53..2fb34adb0e8423 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -243,6 +243,19 @@ "clear": true } }, + { + "label": "Setup Open IoT SDK network", + "type": "shell", + "command": "sudo scripts/setup/openiotsdk/network_setup.sh -n${input:openiotsdkNetworkSetupName} ${input:openiotsdkNetworkSetupCmd}", + "problemMatcher": { + "pattern": { + "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$", + "file": 1, + "line": 2, + "message": 5 + } + } + }, { "label": "Build Open IoT SDK example", "type": "shell", @@ -453,6 +466,19 @@ "options": ["simple", "boot", "upgrade"], "default": "simple" }, + { + "type": "pickString", + "id": "openiotsdkNetworkSetupCmd", + "description": "Which command do you wish to use?", + "options": ["up", "down", "restart"], + "default": "up" + }, + { + "type": "promptString", + "id": "openiotsdkNetworkSetupName", + "description": "Type the network namespace name that you want to use.", + "default": "ARM" + }, { "type": "pickString", "id": "openiotsdkDebugMode", @@ -468,44 +494,22 @@ "default": "false" }, { - "type": "pickString", + "type": "command", "id": "openiotsdkExample", - "description": "What Open IoT SDK example application do you want to use?", - "options": ["shell", "lock-app"], - "default": "shell" + "command": "shellCommand.execute", + "args": { + "command": "cat examples/platform/openiotsdk/supported_examples.txt", + "description": "What Open IoT SDK example application do you want to use?" + } }, { - "type": "pickString", + "type": "command", "id": "openiotsdkUnitTest", - "description": "What unit test do you want to use?", - "options": [ - "accesstest", - "AppTests", - "ASN1Tests", - "BDXTests", - "ChipCryptoTests", - "ControllerTests", - "CoreTests", - "CredentialsTest", - "DataModelTests", - "InetLayerTests", - "MdnsTests", - "MessagingLayerTests", - "MinimalMdnsCoreTests", - "MinimalMdnsRecordsTests", - "MinimalMdnsRespondersTests", - "PlatformTests", - "RawTransportTests", - "RetransmitTests", - "SecureChannelTests", - "SetupPayloadTests", - "SupportTests", - "SystemLayerTests", - "TestShell", - "TransportLayerTests", - "UserDirectedCommissioningTests" - ], - "default": "accesstest" + "command": "shellCommand.execute", + "args": { + "command": "cat src/test_driver/openiotsdk/unit-tests/test_components.txt", + "description": "What Open IoT SDK unit test application do you want to use?" + } }, { "type": "promptString", diff --git a/config/esp32/components/chip/CMakeLists.txt b/config/esp32/components/chip/CMakeLists.txt index 6f30e30e297e34..a5f26e3e46cec3 100644 --- a/config/esp32/components/chip/CMakeLists.txt +++ b/config/esp32/components/chip/CMakeLists.txt @@ -238,6 +238,9 @@ if (CONFIG_SEC_CERT_DAC_PROVIDER) chip_gn_arg_append("chip_use_secure_cert_dac_provider" "true") endif() +if (CONFIG_USE_ESP32_ECDSA_PERIPHERAL) + chip_gn_arg_append("chip_use_esp32_ecdsa_peripheral" "true") +endif() set(args_gn_input "${CMAKE_CURRENT_BINARY_DIR}/args.gn.in") file(GENERATE OUTPUT "${args_gn_input}" CONTENT "${chip_gn_args}") @@ -332,22 +335,17 @@ target_include_directories(${COMPONENT_LIB} INTERFACE "${CHIP_ROOT}/config/esp32/${CONFIG_CHIP_EXTERNAL_PLATFORM_DIR}/../../" ) -idf_component_get_property(esp32_mbedtls_lib esp32_mbedtls COMPONENT_LIB) +idf_component_get_property(mbedtls_lib mbedtls COMPONENT_LIB) + +idf_build_get_property(idf_target IDF_TARGET) +set(target_name "${idf_target}") if(CONFIG_BT_ENABLED) idf_component_get_property(bt_lib bt COMPONENT_LIB) - if("${CONFIG_IDF_TARGET}" STREQUAL "esp32h2") - idf_component_get_property(bt_dir bt COMPONENT_DIR) - list(APPEND chip_libraries $) - list(APPEND chip_libraries ${bt_dir}/controller/lib_esp32h2/esp32h2-bt-lib/libble_app.a) - elseif("${CONFIG_IDF_TARGET}" STREQUAL "esp32c2") + if((target_name STREQUAL "esp32h2") OR (target_name STREQUAL "esp32c2") OR (target_name STREQUAL "esp32c6")) idf_component_get_property(bt_dir bt COMPONENT_DIR) list(APPEND chip_libraries $) - list(APPEND chip_libraries ${bt_dir}/controller/lib_esp32c2/esp32c2-bt-lib/libble_app.a) - elseif("${CONFIG_IDF_TARGET}" STREQUAL "esp32c6") - idf_component_get_property(bt_dir bt COMPONENT_DIR) - list(APPEND chip_libraries $) - list(APPEND chip_libraries ${bt_dir}/controller/lib_esp32c6/esp32c6-bt-lib/libble_app.a) + list(APPEND chip_libraries "${bt_dir}/controller/lib_${target_name}/${target_name}-bt-lib/libble_app.a") else() list(APPEND chip_libraries $ -lbtdm_app) endif() @@ -383,9 +381,65 @@ if (CONFIG_SEC_CERT_DAC_PROVIDER) list(APPEND chip_libraries $) endif() +idf_component_get_property(lwip_lib lwip COMPONENT_LIB) +list(APPEND chip_libraries $) + + +if (CONFIG_ESP_WIFI_ENABLED) + idf_component_get_property(esp_wifi_lib esp_wifi COMPONENT_LIB) + idf_component_get_property(esp_wifi_dir esp_wifi COMPONENT_DIR) + list(APPEND chip_libraries $) + if (CONFIG_IDF_TARGET_ESP32C2) + set(blobs core net80211 pp) + else() + set(blobs core mesh net80211 pp) + endif() + + foreach(blob ${blobs}) + list(APPEND chip_libraries "${esp_wifi_dir}/lib/${target_name}/lib${blob}.a") + endforeach() +endif() + +idf_component_get_property(esp_netif_lib esp_netif COMPONENT_LIB) +list(APPEND chip_libraries $) + +idf_component_get_property(esp_hw_support_lib esp_hw_support COMPONENT_LIB) +list(APPEND chip_libraries $) + +idf_component_get_property(esp_phy_lib esp_phy COMPONENT_LIB) +idf_component_get_property(esp_phy_dir esp_phy COMPONENT_DIR) +list(APPEND chip_libraries $) + +if (CONFIG_IDF_TARGET_ESP32) + set(phy_blobs phy rtc) +elseif (CONFIG_IDF_TARGET_ESP32S2) + set(phy_blobs phy) +else() + set(phy_blobs phy btbb) +endif() +foreach(phy_blob ${phy_blobs}) + list(APPEND chip_libraries "${esp_phy_dir}/lib/${target_name}/lib${phy_blob}.a") +endforeach() + +idf_component_get_property(esp_event_lib esp_event COMPONENT_LIB) +list(APPEND chip_libraries $) + +idf_component_get_property(hal_lib hal COMPONENT_LIB) +list(APPEND chip_libraries $) + +idf_component_get_property(esp_system_lib esp_system COMPONENT_LIB) +list(APPEND chip_libraries $) + +idf_component_get_property(soc_lib soc COMPONENT_LIB) +list(APPEND chip_libraries $) + +idf_component_get_property(efuse_lib efuse COMPONENT_LIB) +list(APPEND chip_libraries $) + target_link_libraries(${COMPONENT_LIB} INTERFACE -Wl,--start-group ${chip_libraries} - $ $ + $ $ + $ -Wl,--end-group) # Make the component dependent on our CHIP build diff --git a/config/esp32/components/chip/Kconfig b/config/esp32/components/chip/Kconfig index dc3b03b07ac555..732f0533a3d708 100644 --- a/config/esp32/components/chip/Kconfig +++ b/config/esp32/components/chip/Kconfig @@ -700,6 +700,19 @@ menu "CHIP Device Layer" Use ESP32 Secure Cert DAC Provider which is ESP32 DeviceAttestationCredentialsProvider implementation which reads attestation information from the esp_secure_cert partition + config USE_ESP32_ECDSA_PERIPHERAL + bool "Use ESP32 ECDSA Peripheral" + depends on SEC_CERT_DAC_PROVIDER && SOC_ECDSA_SUPPORTED + default y + select MBEDTLS_HARDWARE_ECDSA_SIGN + select ENABLE_ESP32_FACTORY_DATA_PROVIDER + select ENABLE_ESP32_DEVICE_INSTANCE_INFO_PROVIDER + help + If DAC is being read from secure cert and SOC supports ECDSA signing using on-chip peripheral + then this option gets enabled. This option also selects few more that are required for commissioning + the device. + Also, please disable ESP_SECURE_CERT_DS_PERIPHERAL from the menuconfig when this option is disabled + endmenu diff --git a/config/esp32/components/chip/idf_component.yml b/config/esp32/components/chip/idf_component.yml index 30d77e8b2eb7c9..b9ce7591b88dd6 100644 --- a/config/esp32/components/chip/idf_component.yml +++ b/config/esp32/components/chip/idf_component.yml @@ -7,6 +7,6 @@ dependencies: - if: "target != esp32h2" espressif/esp_secure_cert_mgr: - version: "^2.2.1" + version: "^2.3.0" rules: - if: "idf_version >=4.3" diff --git a/config/esp32/components/esp32_mbedtls/CMakeLists.txt b/config/esp32/components/esp32_mbedtls/CMakeLists.txt deleted file mode 100644 index 1e5382bbad0e0c..00000000000000 --- a/config/esp32/components/esp32_mbedtls/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -idf_component_register(SRCS hkdf.c - INCLUDE_DIRS . - PRIV_REQUIRES mbedtls) diff --git a/config/esp32/components/esp32_mbedtls/hkdf.c b/config/esp32/components/esp32_mbedtls/hkdf.c deleted file mode 100644 index c480bbf950b203..00000000000000 --- a/config/esp32/components/esp32_mbedtls/hkdf.c +++ /dev/null @@ -1,191 +0,0 @@ -/** - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved - * 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. - * - */ - -/* - * HKDF implementation -- RFC 5869 - * - * This file is part of mbed TLS (https://tls.mbed.org) - */ -#if !defined(MBEDTLS_CONFIG_FILE) -#include "mbedtls/config.h" -#else -#include MBEDTLS_CONFIG_FILE -#endif - -#if defined(MBEDTLS_HKDF_C) - -#include "mbedtls/hkdf.h" -#include "mbedtls/platform_util.h" -#include - -int mbedtls_hkdf(const mbedtls_md_info_t * md, const unsigned char * salt, size_t salt_len, const unsigned char * ikm, - size_t ikm_len, const unsigned char * info, size_t info_len, unsigned char * okm, size_t okm_len) -{ - int ret; - unsigned char prk[MBEDTLS_MD_MAX_SIZE]; - - ret = mbedtls_hkdf_extract(md, salt, salt_len, ikm, ikm_len, prk); - - if (ret == 0) - { - ret = mbedtls_hkdf_expand(md, prk, mbedtls_md_get_size(md), info, info_len, okm, okm_len); - } - - mbedtls_platform_zeroize(prk, sizeof(prk)); - - return (ret); -} - -int mbedtls_hkdf_extract(const mbedtls_md_info_t * md, const unsigned char * salt, size_t salt_len, const unsigned char * ikm, - size_t ikm_len, unsigned char * prk) -{ - unsigned char null_salt[MBEDTLS_MD_MAX_SIZE] = { '\0' }; - - if (salt == NULL) - { - size_t hash_len; - - if (salt_len != 0) - { - return MBEDTLS_ERR_HKDF_BAD_INPUT_DATA; - } - - hash_len = mbedtls_md_get_size(md); - - if (hash_len == 0) - { - return MBEDTLS_ERR_HKDF_BAD_INPUT_DATA; - } - - salt = null_salt; - salt_len = hash_len; - } - - return (mbedtls_md_hmac(md, salt, salt_len, ikm, ikm_len, prk)); -} - -int mbedtls_hkdf_expand(const mbedtls_md_info_t * md, const unsigned char * prk, size_t prk_len, const unsigned char * info, - size_t info_len, unsigned char * okm, size_t okm_len) -{ - size_t hash_len; - size_t where = 0; - size_t n; - size_t t_len = 0; - size_t i; - int ret = 0; - mbedtls_md_context_t ctx; - unsigned char t[MBEDTLS_MD_MAX_SIZE]; - - if (okm == NULL) - { - return (MBEDTLS_ERR_HKDF_BAD_INPUT_DATA); - } - - hash_len = mbedtls_md_get_size(md); - - if (prk_len < hash_len || hash_len == 0) - { - return (MBEDTLS_ERR_HKDF_BAD_INPUT_DATA); - } - - if (info == NULL) - { - info = (const unsigned char *) ""; - info_len = 0; - } - - n = okm_len / hash_len; - - if ((okm_len % hash_len) != 0) - { - n++; - } - - /* - * Per RFC 5869 Section 2.3, okm_len must not exceed - * 255 times the hash length - */ - if (n > 255) - { - return (MBEDTLS_ERR_HKDF_BAD_INPUT_DATA); - } - - mbedtls_md_init(&ctx); - - if ((ret = mbedtls_md_setup(&ctx, md, 1)) != 0) - { - goto exit; - } - - /* - * Compute T = T(1) | T(2) | T(3) | ... | T(N) - * Where T(N) is defined in RFC 5869 Section 2.3 - */ - for (i = 1; i <= n; i++) - { - size_t num_to_copy; - unsigned char c = i & 0xff; - - ret = mbedtls_md_hmac_starts(&ctx, prk, prk_len); - if (ret != 0) - { - goto exit; - } - - ret = mbedtls_md_hmac_update(&ctx, t, t_len); - if (ret != 0) - { - goto exit; - } - - ret = mbedtls_md_hmac_update(&ctx, info, info_len); - if (ret != 0) - { - goto exit; - } - - /* The constant concatenated to the end of each T(n) is a single octet. - * */ - ret = mbedtls_md_hmac_update(&ctx, &c, 1); - if (ret != 0) - { - goto exit; - } - - ret = mbedtls_md_hmac_finish(&ctx, t); - if (ret != 0) - { - goto exit; - } - - num_to_copy = i != n ? hash_len : okm_len - where; - memcpy(okm + where, t, num_to_copy); - where += hash_len; - t_len = hash_len; - } - -exit: - mbedtls_md_free(&ctx); - mbedtls_platform_zeroize(t, sizeof(t)); - - return (ret); -} - -#endif /* MBEDTLS_HKDF_C */ diff --git a/config/esp32/components/esp32_mbedtls/mbedtls/esp_config.h b/config/esp32/components/esp32_mbedtls/mbedtls/esp_config.h deleted file mode 100644 index aca884cdc9fbf6..00000000000000 --- a/config/esp32/components/esp32_mbedtls/mbedtls/esp_config.h +++ /dev/null @@ -1,2345 +0,0 @@ -/** - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved - * 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. - * - */ - -/** - * - * \brief Default mbedTLS configuration options for esp-idf - * - * This set of compile-time options may be used to enable - * or disable features selectively, and reduce the global - * memory footprint. - * - * This file is part of mbed TLS (https://tls.mbed.org) - */ - -#ifndef ESP_CONFIG_H -#define ESP_CONFIG_H - -#include "esp_idf_version.h" -#include "sdkconfig.h" -// For ESP32H2, we use idf v5.0. Its "mbedtls/config.h" was replaced by "mbedtls/build_info.h" -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) -#include "mbedtls/build_info.h" -#else -#include "mbedtls/config.h" -#endif -/** - * \name SECTION: System support - * - * This section sets system specific settings. - * \{ - */ - -/** - * \def MBEDTLS_HAVE_TIME - * - * System has time.h and time(). - * The time does not need to be correct, only time differences are used, - * by contrast with MBEDTLS_HAVE_TIME_DATE - * - * Comment if your system does not support time functions - */ -#ifdef CONFIG_MBEDTLS_HAVE_TIME -#define MBEDTLS_HAVE_TIME -#else -#undef MBEDTLS_HAVE_TIME -#endif - -/** - * \def MBEDTLS_HAVE_TIME_DATE - * - * System has time.h and time(), gmtime() and the clock is correct. - * The time needs to be correct (not necesarily very accurate, but at least - * the date should be correct). This is used to verify the validity period of - * X.509 certificates. - * - * Comment if your system does not have a correct clock. - */ -#ifdef CONFIG_MBEDTLS_HAVE_TIME_DATE -#define MBEDTLS_HAVE_TIME_DATE -#else -#undef MBEDTLS_HAVE_TIME_DATE -#endif - -/** - * \def MBEDTLS_PLATFORM_MEMORY - * - * Enable the memory allocation layer. - * - * By default mbed TLS uses the system-provided calloc() and free(). - * This allows different allocators (self-implemented or provided) to be - * provided to the platform abstraction layer. - * - * Enabling MBEDTLS_PLATFORM_MEMORY without the - * MBEDTLS_PLATFORM_{FREE,CALLOC}_MACROs will provide - * "mbedtls_platform_set_calloc_free()" allowing you to set an alternative calloc() and - * free() function pointer at runtime. - * - * Enabling MBEDTLS_PLATFORM_MEMORY and specifying - * MBEDTLS_PLATFORM_{CALLOC,FREE}_MACROs will allow you to specify the - * alternate function at compile time. - * - * Requires: MBEDTLS_PLATFORM_C - * - * Enable this layer to allow use of alternative memory allocators. - */ -#define MBEDTLS_PLATFORM_MEMORY - -/** Override calloc(), free() except for case where memory allocation scheme is not set to custom */ -#ifndef CONFIG_MBEDTLS_CUSTOM_MEM_ALLOC -#include "esp_mem.h" -#define MBEDTLS_PLATFORM_STD_CALLOC esp_mbedtls_mem_calloc -#define MBEDTLS_PLATFORM_STD_FREE esp_mbedtls_mem_free -#endif - -/* \} name SECTION: System support */ - -/** - * \name SECTION: mbed TLS feature support - * - * This section sets support for features that are or are not needed - * within the modules that are enabled. - * \{ - */ - -/* The following units have ESP32 hardware support, - uncommenting each _ALT macro will use the - hardware-accelerated implementation. */ -#ifdef CONFIG_MBEDTLS_HARDWARE_AES -#define MBEDTLS_AES_ALT -#else -#undef MBEDTLS_AES_ALT -#endif - -/* MBEDTLS_SHAxx_ALT to enable hardware SHA support - with software fallback. -*/ -#ifdef CONFIG_MBEDTLS_HARDWARE_SHA -#define MBEDTLS_SHA1_ALT -#define MBEDTLS_SHA256_ALT -#define MBEDTLS_SHA512_ALT -#else -#undef MBEDTLS_SHA1_ALT -#undef MBEDTLS_SHA256_ALT -#undef MBEDTLS_SHA512_ALT -#endif - -/* The following MPI (bignum) functions have ESP32 hardware support, - Uncommenting these macros will use the hardware-accelerated - implementations. -*/ -#ifdef CONFIG_MBEDTLS_HARDWARE_MPI -#define MBEDTLS_MPI_EXP_MOD_ALT -#define MBEDTLS_MPI_MUL_MPI_ALT -#else -#undef MBEDTLS_MPI_EXP_MOD_ALT -#undef MBEDTLS_MPI_MUL_MPI_ALT -#endif - -/** - * \def MBEDTLS_ENTROPY_HARDWARE_ALT - * - * Uncomment this macro to let mbed TLS use your own implementation of a - * hardware entropy collector. - * - * Your function must be called \c mbedtls_hardware_poll(), have the same - * prototype as declared in entropy_poll.h, and accept NULL as first argument. - * - * Uncomment to use your own hardware entropy collector. - */ -#define MBEDTLS_ENTROPY_HARDWARE_ALT - -/** - * \def MBEDTLS_AES_ROM_TABLES - * - * Store the AES tables in ROM. - * - * Uncomment this macro to store the AES tables in ROM. - */ -#define MBEDTLS_AES_ROM_TABLES - -/** - * \def MBEDTLS_CIPHER_MODE_CBC - * - * Enable Cipher Block Chaining mode (CBC) for symmetric ciphers. - */ -#define MBEDTLS_CIPHER_MODE_CBC - -/** - * \def MBEDTLS_CIPHER_MODE_CFB - * - * Enable Cipher Feedback mode (CFB) for symmetric ciphers. - */ -#define MBEDTLS_CIPHER_MODE_CFB - -/** - * \def MBEDTLS_CIPHER_MODE_CTR - * - * Enable Counter Block Cipher mode (CTR) for symmetric ciphers. - */ -#define MBEDTLS_CIPHER_MODE_CTR - -/** - * \def MBEDTLS_CIPHER_MODE_OFB - * - * Enable Output Feedback mode (OFB) for symmetric ciphers. - */ -#define MBEDTLS_CIPHER_MODE_OFB - -/** - * \def MBEDTLS_CIPHER_MODE_XTS - * - * Enable Xor-encrypt-xor with ciphertext stealing mode (XTS) for AES. - */ -#define MBEDTLS_CIPHER_MODE_XTS - -/** - * \def MBEDTLS_CIPHER_PADDING_PKCS7 - * - * MBEDTLS_CIPHER_PADDING_XXX: Uncomment or comment macros to add support for - * specific padding modes in the cipher layer with cipher modes that support - * padding (e.g. CBC) - * - * If you disable all padding modes, only full blocks can be used with CBC. - * - * Enable padding modes in the cipher layer. - */ -#define MBEDTLS_CIPHER_PADDING_PKCS7 -#define MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS -#define MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN -#define MBEDTLS_CIPHER_PADDING_ZEROS - -/** - * \def MBEDTLS_REMOVE_ARC4_CIPHERSUITES & MBEDTLS_ARC4_C - * - * MBEDTLS_ARC4_C - * Enable the ARCFOUR stream cipher. - * - * This module enables/disables the following ciphersuites - * MBEDTLS_TLS_ECDH_ECDSA_WITH_RC4_128_SHA - * MBEDTLS_TLS_ECDH_RSA_WITH_RC4_128_SHA - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA - * MBEDTLS_TLS_ECDHE_RSA_WITH_RC4_128_SHA - * MBEDTLS_TLS_ECDHE_PSK_WITH_RC4_128_SHA - * MBEDTLS_TLS_DHE_PSK_WITH_RC4_128_SHA - * MBEDTLS_TLS_RSA_WITH_RC4_128_SHA - * MBEDTLS_TLS_RSA_WITH_RC4_128_MD5 - * MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA - * MBEDTLS_TLS_PSK_WITH_RC4_128_SHA - * - * MBEDTLS_REMOVE_ARC4_CIPHERSUITES - * This flag removes the ciphersuites based on RC4 from the default list as - * returned by mbedtls_ssl_list_ciphersuites(). However, it is still possible to - * enable (some of) them with mbedtls_ssl_conf_ciphersuites() by including them - * explicitly. - * - * Uncomment this macro to remove RC4 ciphersuites by default. - */ -#ifdef CONFIG_MBEDTLS_RC4_ENABLED -#define MBEDTLS_ARC4_C -#undef MBEDTLS_REMOVE_ARC4_CIPHERSUITES -#elif defined CONFIG_MBEDTLS_RC4_ENABLED_NO_DEFAULT -#define MBEDTLS_ARC4_C -#define MBEDTLS_REMOVE_ARC4_CIPHERSUITES -#else -#undef MBEDTLS_ARC4_C -#define MBEDTLS_REMOVE_ARC4_CIPHERSUITES -#endif - -/** - * \def MBEDTLS_ECP_RESTARTABLE - * - * Enable "non-blocking" ECC operations that can return early and be resumed. - * - * This allows various functions to pause by returning - * #MBEDTLS_ERR_ECP_IN_PROGRESS (or, for functions in the SSL module, - * #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS) and then be called later again in - * order to further progress and eventually complete their operation. This is - * controlled through mbedtls_ecp_set_max_ops() which limits the maximum - * number of ECC operations a function may perform before pausing; see - * mbedtls_ecp_set_max_ops() for more information. - * - * This is useful in non-threaded environments if you want to avoid blocking - * for too long on ECC (and, hence, X.509 or SSL/TLS) operations. - * - * Uncomment this macro to enable restartable ECC computations. - * - * \note This option only works with the default software implementation of - * elliptic curve functionality. It is incompatible with - * MBEDTLS_ECP_ALT, MBEDTLS_ECDH_XXX_ALT and MBEDTLS_ECDSA_XXX_ALT. - */ -#ifdef CONFIG_MBEDTLS_ECP_RESTARTABLE -#define MBEDTLS_ECP_RESTARTABLE -#endif - -/** - * \def MBEDTLS_CMAC_C - * - * Enable the CMAC (Cipher-based Message Authentication Code) mode for block - * ciphers. - * - * Module: library/cmac.c - * - * Requires: MBEDTLS_AES_C or MBEDTLS_DES_C - * - */ -#ifdef CONFIG_MBEDTLS_CMAC_C -#define MBEDTLS_CMAC_C -#endif - -/** - * \def MBEDTLS_ECP_DP_SECP192R1_ENABLED - * - * MBEDTLS_ECP_XXXX_ENABLED: Enables specific curves within the Elliptic Curve - * module. By default all supported curves are enabled. - * - * Comment macros to disable the curve and functions for it - */ -#ifdef CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED -#define MBEDTLS_ECP_DP_SECP192R1_ENABLED -#else -#undef MBEDTLS_ECP_DP_SECP192R1_ENABLED -#endif -#ifdef CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED -#define MBEDTLS_ECP_DP_SECP224R1_ENABLED -#else -#undef MBEDTLS_ECP_DP_SECP224R1_ENABLED -#endif -#ifdef CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED -#define MBEDTLS_ECP_DP_SECP256R1_ENABLED -#else -#undef MBEDTLS_ECP_DP_SECP256R1_ENABLED -#endif -#ifdef CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED -#define MBEDTLS_ECP_DP_SECP384R1_ENABLED -#else -#undef MBEDTLS_ECP_DP_SECP384R1_ENABLED -#endif -#ifdef CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED -#define MBEDTLS_ECP_DP_SECP521R1_ENABLED -#else -#undef MBEDTLS_ECP_DP_SECP521R1_ENABLED -#endif -#ifdef CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED -#define MBEDTLS_ECP_DP_SECP192K1_ENABLED -#else -#undef MBEDTLS_ECP_DP_SECP192K1_ENABLED -#endif -#ifdef CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED -#define MBEDTLS_ECP_DP_SECP224K1_ENABLED -#else -#undef MBEDTLS_ECP_DP_SECP224K1_ENABLED -#endif -#ifdef CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED -#define MBEDTLS_ECP_DP_SECP256K1_ENABLED -#else -#undef MBEDTLS_ECP_DP_SECP256K1_ENABLED -#endif -#ifdef CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED -#define MBEDTLS_ECP_DP_BP256R1_ENABLED -#else -#undef MBEDTLS_ECP_DP_BP256R1_ENABLED -#endif -#ifdef CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED -#define MBEDTLS_ECP_DP_BP384R1_ENABLED -#else -#undef MBEDTLS_ECP_DP_BP384R1_ENABLED -#endif -#ifdef CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED -#define MBEDTLS_ECP_DP_BP512R1_ENABLED -#else -#undef MBEDTLS_ECP_DP_BP512R1_ENABLED -#endif -#ifdef CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED -#define MBEDTLS_ECP_DP_CURVE25519_ENABLED -#else -#undef MBEDTLS_ECP_DP_CURVE25519_ENABLED -#endif - -#ifdef MBEDTLS_ECP_DP_CURVE448_ENABLED -#undef MBEDTLS_ECP_DP_CURVE448_ENABLED -#endif - -/** - * \def MBEDTLS_ECP_NIST_OPTIM - * - * Enable specific 'modulo p' routines for each NIST prime. - * Depending on the prime and architecture, makes operations 4 to 8 times - * faster on the corresponding curve. - * - * Comment this macro to disable NIST curves optimisation. - */ -#ifdef CONFIG_MBEDTLS_ECP_NIST_OPTIM -#define MBEDTLS_ECP_NIST_OPTIM -#else -#undef MBEDTLS_ECP_NIST_OPTIM -#endif - -/** - * \def MBEDTLS_ECDSA_DETERMINISTIC - * - * Enable deterministic ECDSA (RFC 6979). - * Standard ECDSA is "fragile" in the sense that lack of entropy when signing - * may result in a compromise of the long-term signing key. This is avoided by - * the deterministic variant. - * - * Requires: MBEDTLS_HMAC_DRBG_C - * - * Comment this macro to disable deterministic ECDSA. - */ -#define MBEDTLS_ECDSA_DETERMINISTIC - -/** - * \def MBEDTLS_KEY_EXCHANGE_PSK_ENABLED - * - * Enable the PSK based ciphersuite modes in SSL / TLS. - * - * This enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_PSK_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_PSK_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_PSK_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_PSK_WITH_RC4_128_SHA - */ -#ifdef CONFIG_MBEDTLS_KEY_EXCHANGE_PSK -#define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED -#else -#undef MBEDTLS_KEY_EXCHANGE_PSK_ENABLED -#endif - -/** - * \def MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED - * - * Enable the DHE-PSK based ciphersuite modes in SSL / TLS. - * - * Requires: MBEDTLS_DHM_C - * - * This enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_DHE_PSK_WITH_RC4_128_SHA - */ -#ifdef CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_PSK -#define MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED -#else -#undef MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED -#endif - -/** - * \def MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED - * - * Enable the ECDHE-PSK based ciphersuite modes in SSL / TLS. - * - * Requires: MBEDTLS_ECDH_C - * - * This enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_ECDHE_PSK_WITH_RC4_128_SHA - */ -#ifdef CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK -#define MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED -#else -#undef MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED -#endif - -/** - * \def MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED - * - * Enable the RSA-PSK based ciphersuite modes in SSL / TLS. - * - * Requires: MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, - * MBEDTLS_X509_CRT_PARSE_C - * - * This enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA - */ -#ifdef CONFIG_MBEDTLS_KEY_EXCHANGE_RSA_PSK -#define MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED -#else -#undef MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED -#endif - -/** - * \def MBEDTLS_KEY_EXCHANGE_RSA_ENABLED - * - * Enable the RSA-only based ciphersuite modes in SSL / TLS. - * - * Requires: MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, - * MBEDTLS_X509_CRT_PARSE_C - * - * This enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256 - * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 - * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA - * MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA - * MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_RSA_WITH_RC4_128_SHA - * MBEDTLS_TLS_RSA_WITH_RC4_128_MD5 - */ -#ifdef CONFIG_MBEDTLS_KEY_EXCHANGE_RSA -#define MBEDTLS_KEY_EXCHANGE_RSA_ENABLED -#else -#undef MBEDTLS_KEY_EXCHANGE_RSA_ENABLED -#endif - -/** - * \def MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED - * - * Enable the DHE-RSA based ciphersuite modes in SSL / TLS. - * - * Requires: MBEDTLS_DHM_C, MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, - * MBEDTLS_X509_CRT_PARSE_C - * - * This enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 - * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 - * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA - * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA - * MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA - */ -#ifdef CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA -#define MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED -#else -#undef MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED -#endif - -/** - * \def MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED - * - * Enable the ECDHE-RSA based ciphersuite modes in SSL / TLS. - * - * Requires: MBEDTLS_ECDH_C, MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, - * MBEDTLS_X509_CRT_PARSE_C - * - * This enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_ECDHE_RSA_WITH_RC4_128_SHA - */ -#ifdef CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA -#define MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED -#else -#undef MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED -#endif - -/** - * \def MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED - * - * Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS. - * - * Requires: MBEDTLS_ECDH_C, MBEDTLS_ECDSA_C, MBEDTLS_X509_CRT_PARSE_C, - * - * This enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA - */ -#ifdef CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA -#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED -#else -#undef MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED -#endif - -/** - * \def MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED - * - * Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS. - * - * Requires: MBEDTLS_ECDH_C, MBEDTLS_X509_CRT_PARSE_C - * - * This enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_ECDH_ECDSA_WITH_RC4_128_SHA - * MBEDTLS_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 - */ -#ifdef CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA -#define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED -#else -#undef MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED -#endif - -/** - * \def MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED - * - * Enable the ECDH-RSA based ciphersuite modes in SSL / TLS. - * - * Requires: MBEDTLS_ECDH_C, MBEDTLS_X509_CRT_PARSE_C - * - * This enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_ECDH_RSA_WITH_RC4_128_SHA - * MBEDTLS_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 - */ -#ifdef CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA -#define MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED -#else -#undef MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED -#endif - -/** - * \def MBEDTLS_PK_PARSE_EC_EXTENDED - * - * Enhance support for reading EC keys using variants of SEC1 not allowed by - * RFC 5915 and RFC 5480. - * - * Currently this means parsing the SpecifiedECDomain choice of EC - * parameters (only known groups are supported, not arbitrary domains, to - * avoid validation issues). - * - * Disable if you only need to support RFC 5915 + 5480 key formats. - */ -#define MBEDTLS_PK_PARSE_EC_EXTENDED - -/** - * \def MBEDTLS_ERROR_STRERROR_DUMMY - * - * Enable a dummy error function to make use of mbedtls_strerror() in - * third party libraries easier when MBEDTLS_ERROR_C is disabled - * (no effect when MBEDTLS_ERROR_C is enabled). - * - * You can safely disable this if MBEDTLS_ERROR_C is enabled, or if you're - * not using mbedtls_strerror() or error_strerror() in your application. - * - * Disable if you run into name conflicts and want to really remove the - * mbedtls_strerror() - */ -#define MBEDTLS_ERROR_STRERROR_DUMMY - -/** - * \def MBEDTLS_GENPRIME - * - * Enable the prime-number generation code. - * - * Requires: MBEDTLS_BIGNUM_C - */ -#define MBEDTLS_GENPRIME - -/** - * \def MBEDTLS_FS_IO - * - * Enable functions that use the filesystem. - */ -#define MBEDTLS_FS_IO - -/** - * \def MBEDTLS_NO_PLATFORM_ENTROPY - * - * Do not use built-in platform entropy functions. - * This is useful if your platform does not support - * standards like the /dev/urandom or Windows CryptoAPI. - * - * Uncomment this macro to disable the built-in platform entropy functions. - */ -#define MBEDTLS_NO_PLATFORM_ENTROPY - -/** - * \def MBEDTLS_PK_RSA_ALT_SUPPORT - * - * Support external private RSA keys (eg from a HSM) in the PK layer. - * - * Comment this macro to disable support for external private RSA keys. - */ -#define MBEDTLS_PK_RSA_ALT_SUPPORT - -/** - * \def MBEDTLS_PKCS1_V15 - * - * Enable support for PKCS#1 v1.5 encoding. - * - * Requires: MBEDTLS_RSA_C - * - * This enables support for PKCS#1 v1.5 operations. - */ -#define MBEDTLS_PKCS1_V15 - -/** - * \def MBEDTLS_PKCS1_V21 - * - * Enable support for PKCS#1 v2.1 encoding. - * - * Requires: MBEDTLS_MD_C, MBEDTLS_RSA_C - * - * This enables support for RSAES-OAEP and RSASSA-PSS operations. - */ -#define MBEDTLS_PKCS1_V21 - -/** - * \def MBEDTLS_SELF_TEST - * - * Enable the checkup functions (*_self_test). - */ -#define MBEDTLS_SELF_TEST - -/** - * \def MBEDTLS_SSL_ALL_ALERT_MESSAGES - * - * Enable sending of alert messages in case of encountered errors as per RFC. - * If you choose not to send the alert messages, mbed TLS can still communicate - * with other servers, only debugging of failures is harder. - * - * The advantage of not sending alert messages, is that no information is given - * about reasons for failures thus preventing adversaries of gaining intel. - * - * Enable sending of all alert messages - */ -#define MBEDTLS_SSL_ALL_ALERT_MESSAGES - -/** \def MBEDTLS_SSL_ENCRYPT_THEN_MAC - * - * Enable support for Encrypt-then-MAC, RFC 7366. - * - * This allows peers that both support it to use a more robust protection for - * ciphersuites using CBC, providing deep resistance against timing attacks - * on the padding or underlying cipher. - * - * This only affects CBC ciphersuites, and is useless if none is defined. - * - * Requires: MBEDTLS_SSL_PROTO_TLS1 or - * MBEDTLS_SSL_PROTO_TLS1_1 or - * MBEDTLS_SSL_PROTO_TLS1_2 - * - * Comment this macro to disable support for Encrypt-then-MAC - */ -#ifdef CONFIG_MBEDTLS_TLS_ENABLED -#define MBEDTLS_SSL_ENCRYPT_THEN_MAC -#else -#undef MBEDTLS_SSL_ENCRYPT_THEN_MAC -#endif - -/** \def MBEDTLS_SSL_EXTENDED_MASTER_SECRET - * - * Enable support for Extended Master Secret, aka Session Hash - * (draft-ietf-tls-session-hash-02). - * - * This was introduced as "the proper fix" to the Triple Handshake familiy of - * attacks, but it is recommended to always use it (even if you disable - * renegotiation), since it actually fixes a more fundamental issue in the - * original SSL/TLS design, and has implications beyond Triple Handshake. - * - * Requires: MBEDTLS_SSL_PROTO_TLS1 or - * MBEDTLS_SSL_PROTO_TLS1_1 or - * MBEDTLS_SSL_PROTO_TLS1_2 - * - * Comment this macro to disable support for Extended Master Secret. - */ -#ifdef CONFIG_MBEDTLS_TLS_ENABLED -#define MBEDTLS_SSL_EXTENDED_MASTER_SECRET -#else -#undef MBEDTLS_SSL_EXTENDED_MASTER_SECRET -#endif - -/** - * \def MBEDTLS_SSL_FALLBACK_SCSV - * - * Enable support for FALLBACK_SCSV (draft-ietf-tls-downgrade-scsv-00). - * - * For servers, it is recommended to always enable this, unless you support - * only one version of TLS, or know for sure that none of your clients - * implements a fallback strategy. - * - * For clients, you only need this if you're using a fallback strategy, which - * is not recommended in the first place, unless you absolutely need it to - * interoperate with buggy (version-intolerant) servers. - * - * Comment this macro to disable support for FALLBACK_SCSV - */ -#define MBEDTLS_SSL_FALLBACK_SCSV - -/** - * \def MBEDTLS_SSL_PROTO_TLS1 - * - * Enable support for TLS 1.0. - * - * Requires: MBEDTLS_MD5_C - * MBEDTLS_SHA1_C - * - * Comment this macro to disable support for TLS 1.0 - */ -#ifdef CONFIG_MBEDTLS_SSL_PROTO_TLS1 -#define MBEDTLS_SSL_PROTO_TLS1 -#else -#undef MBEDTLS_SSL_PROTO_TLS1 -#endif - -/** - * \def MBEDTLS_SSL_PROTO_SSL3 - * - * Enable support for SSL 3.0. - * - * Requires: MBEDTLS_MD5_C - * MBEDTLS_SHA1_C - * - * Comment this macro to disable support for SSL 3.0 - */ -#ifdef CONFIG_MBEDTLS_SSL_PROTO_SSL3 -#define MBEDTLS_SSL_PROTO_SSL3 -#else -#undef MBEDTLS_SSL_PROTO_SSL3 -#endif - -/** - * \def MBEDTLS_SSL_CBC_RECORD_SPLITTING - * - * Enable 1/n-1 record splitting for CBC mode in SSLv3 and TLS 1.0. - * - * This is a countermeasure to the BEAST attack, which also minimizes the risk - * of interoperability issues compared to sending 0-length records. - * - * Comment this macro to disable 1/n-1 record splitting. - */ -#if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) -#define MBEDTLS_SSL_CBC_RECORD_SPLITTING -#else -#undef MBEDTLS_SSL_CBC_RECORD_SPLITTING -#endif - -/** - * \def MBEDTLS_SSL_RENEGOTIATION - * - * Disable support for TLS renegotiation. - * - * The two main uses of renegotiation are (1) refresh keys on long-lived - * connections and (2) client authentication after the initial handshake. - * If you don't need renegotiation, it's probably better to disable it, since - * it has been associated with security issues in the past and is easy to - * misuse/misunderstand. - * - * Comment this to disable support for renegotiation. - */ -#ifdef CONFIG_MBEDTLS_SSL_RENEGOTIATION -#define MBEDTLS_SSL_RENEGOTIATION -#else -#undef MBEDTLS_SSL_RENEGOTIATION -#endif - -/** - * \def MBEDTLS_SSL_MAX_FRAGMENT_LENGTH - * - * Enable support for RFC 6066 max_fragment_length extension in SSL. - * - * Comment this macro to disable support for the max_fragment_length extension - */ -#define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH - -/** - * \def MBEDTLS_SSL_PROTO_TLS1_1 - * - * Enable support for TLS 1.1 (and DTLS 1.0 if DTLS is enabled). - * - * Requires: MBEDTLS_MD5_C - * MBEDTLS_SHA1_C - * - * Comment this macro to disable support for TLS 1.1 / DTLS 1.0 - */ -#ifdef CONFIG_MBEDTLS_SSL_PROTO_TLS1_1 -#define MBEDTLS_SSL_PROTO_TLS1_1 -#endif - -/** - * \def MBEDTLS_SSL_PROTO_TLS1_2 - * - * Enable support for TLS 1.2 (and DTLS 1.2 if DTLS is enabled). - * - * Requires: MBEDTLS_SHA1_C or MBEDTLS_SHA256_C or MBEDTLS_SHA512_C - * (Depends on ciphersuites) - * - * Comment this macro to disable support for TLS 1.2 / DTLS 1.2 - */ -#ifdef CONFIG_MBEDTLS_SSL_PROTO_TLS1_2 -#define MBEDTLS_SSL_PROTO_TLS1_2 -#else -#undef MBEDTLS_SSL_PROTO_TLS1_2 -#endif - -/** - * \def MBEDTLS_SSL_PROTO_DTLS - * - * Enable support for DTLS (all available versions). - * - * Enable this and MBEDTLS_SSL_PROTO_TLS1_1 to enable DTLS 1.0, - * and/or this and MBEDTLS_SSL_PROTO_TLS1_2 to enable DTLS 1.2. - * - * Requires: MBEDTLS_SSL_PROTO_TLS1_1 - * or MBEDTLS_SSL_PROTO_TLS1_2 - * - * Comment this macro to disable support for DTLS - */ -#ifdef CONFIG_MBEDTLS_SSL_PROTO_DTLS -#define MBEDTLS_SSL_PROTO_DTLS -#else -#undef MBEDTLS_SSL_PROTO_DTLS -#endif - -/** - * \def MBEDTLS_SSL_ALPN - * - * Enable support for RFC 7301 Application Layer Protocol Negotiation. - * - * Comment this macro to disable support for ALPN. - */ -#ifdef CONFIG_MBEDTLS_SSL_ALPN -#define MBEDTLS_SSL_ALPN -#else -#undef MBEDTLS_SSL_ALPN -#endif - -/** - * \def MBEDTLS_SSL_DTLS_ANTI_REPLAY - * - * Enable support for the anti-replay mechanism in DTLS. - * - * Requires: MBEDTLS_SSL_TLS_C - * MBEDTLS_SSL_PROTO_DTLS - * - * \warning Disabling this is often a security risk! - * See mbedtls_ssl_conf_dtls_anti_replay() for details. - * - * Comment this to disable anti-replay in DTLS. - */ -#ifdef CONFIG_MBEDTLS_SSL_PROTO_DTLS -#define MBEDTLS_SSL_DTLS_ANTI_REPLAY -#else -#undef MBEDTLS_SSL_DTLS_ANTI_REPLAY -#endif - -/** - * \def MBEDTLS_SSL_DTLS_HELLO_VERIFY - * - * Enable support for HelloVerifyRequest on DTLS servers. - * - * This feature is highly recommended to prevent DTLS servers being used as - * amplifiers in DoS attacks against other hosts. It should always be enabled - * unless you know for sure amplification cannot be a problem in the - * environment in which your server operates. - * - * \warning Disabling this can ba a security risk! (see above) - * - * Requires: MBEDTLS_SSL_PROTO_DTLS - * - * Comment this to disable support for HelloVerifyRequest. - */ -#ifdef CONFIG_MBEDTLS_SSL_PROTO_DTLS -#define MBEDTLS_SSL_DTLS_HELLO_VERIFY -#else -#undef MBEDTLS_SSL_DTLS_HELLO_VERIFY -#endif - -/** - * \def MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE - * - * Enable server-side support for clients that reconnect from the same port. - * - * Some clients unexpectedly close the connection and try to reconnect using the - * same source port. This needs special support from the server to handle the - * new connection securely, as described in section 4.2.8 of RFC 6347. This - * flag enables that support. - * - * Requires: MBEDTLS_SSL_DTLS_HELLO_VERIFY - * - * Comment this to disable support for clients reusing the source port. - */ -#ifdef CONFIG_MBEDTLS_SSL_PROTO_DTLS -#define MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE -#else -#undef MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE -#endif - -/** - * \def MBEDTLS_SSL_DTLS_BADMAC_LIMIT - * - * Enable support for a limit of records with bad MAC. - * - * See mbedtls_ssl_conf_dtls_badmac_limit(). - * - * Requires: MBEDTLS_SSL_PROTO_DTLS - */ -#ifdef CONFIG_MBEDTLS_SSL_PROTO_DTLS -#define MBEDTLS_SSL_DTLS_BADMAC_LIMIT -#else -#undef MBEDTLS_SSL_DTLS_BADMAC_LIMIT -#endif - -/** - * \def MBEDTLS_SSL_SESSION_TICKETS - * - * Enable support for RFC 5077 session tickets in SSL. - * Client-side, provides full support for session tickets (maintainance of a - * session store remains the responsibility of the application, though). - * Server-side, you also need to provide callbacks for writing and parsing - * tickets, including authenticated encryption and key management. Example - * callbacks are provided by MBEDTLS_SSL_TICKET_C. - * - * Comment this macro to disable support for SSL session tickets - */ -#ifdef CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS -#define MBEDTLS_SSL_SESSION_TICKETS -#else -#undef MBEDTLS_SSL_SESSION_TICKETS -#endif - -/** - * \def MBEDTLS_SSL_EXPORT_KEYS - * - * Enable support for exporting key block and master secret. - * This is required for certain users of TLS, e.g. EAP-TLS. - * - * Comment this macro to disable support for key export - */ -#define MBEDTLS_SSL_EXPORT_KEYS - -/** - * \def MBEDTLS_SSL_SERVER_NAME_INDICATION - * - * Enable support for RFC 6066 server name indication (SNI) in SSL. - * - * Requires: MBEDTLS_X509_CRT_PARSE_C - * - * Comment this macro to disable support for server name indication in SSL - */ -#define MBEDTLS_SSL_SERVER_NAME_INDICATION - -/** - * \def MBEDTLS_SSL_TRUNCATED_HMAC - * - * Enable support for RFC 6066 truncated HMAC in SSL. - * - * Comment this macro to disable support for truncated HMAC in SSL - */ -#define MBEDTLS_SSL_TRUNCATED_HMAC - -/** - * \def MBEDTLS_VERSION_FEATURES - * - * Allow run-time checking of compile-time enabled features. Thus allowing users - * to check at run-time if the library is for instance compiled with threading - * support via mbedtls_version_check_feature(). - * - * Requires: MBEDTLS_VERSION_C - * - * Comment this to disable run-time checking and save ROM space - */ -#define MBEDTLS_VERSION_FEATURES - -/** - * \def MBEDTLS_X509_CHECK_KEY_USAGE - * - * Enable verification of the keyUsage extension (CA and leaf certificates). - * - * Disabling this avoids problems with mis-issued and/or misused - * (intermediate) CA and leaf certificates. - * - * \warning Depending on your PKI use, disabling this can be a security risk! - * - * Comment to skip keyUsage checking for both CA and leaf certificates. - */ -#define MBEDTLS_X509_CHECK_KEY_USAGE - -/** - * \def MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE - * - * Enable verification of the extendedKeyUsage extension (leaf certificates). - * - * Disabling this avoids problems with mis-issued and/or misused certificates. - * - * \warning Depending on your PKI use, disabling this can be a security risk! - * - * Comment to skip extendedKeyUsage checking for certificates. - */ -#define MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE - -/** - * \def MBEDTLS_X509_RSASSA_PSS_SUPPORT - * - * Enable parsing and verification of X.509 certificates, CRLs and CSRS - * signed with RSASSA-PSS (aka PKCS#1 v2.1). - * - * Comment this macro to disallow using RSASSA-PSS in certificates. - */ -#define MBEDTLS_X509_RSASSA_PSS_SUPPORT - -/* \} name SECTION: mbed TLS feature support */ - -/** - * \name SECTION: mbed TLS modules - * - * This section enables or disables entire modules in mbed TLS - * \{ - */ - -/** - * \def MBEDTLS_AESNI_C - * - * Enable AES-NI support on x86-64. - * - * Module: library/aesni.c - * Caller: library/aes.c - * - * Requires: MBEDTLS_HAVE_ASM - * - * This modules adds support for the AES-NI instructions on x86-64 - */ -#define MBEDTLS_AESNI_C - -/** - * \def MBEDTLS_AES_C - * - * Enable the AES block cipher. - * - * Module: library/aes.c - * Caller: library/ssl_tls.c - * library/pem.c - * library/ctr_drbg.c - * - * This module enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256 - * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA - * MBEDTLS_TLS_PSK_WITH_AES_256_GCM_SHA384 - * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA384 - * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA - * MBEDTLS_TLS_PSK_WITH_AES_128_GCM_SHA256 - * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256 - * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA - * - * PEM_PARSE uses AES for decrypting encrypted keys. - */ -#ifdef CONFIG_MBEDTLS_AES_C -#define MBEDTLS_AES_C -#else -#undef MBEDTLS_AES_C -#endif - -/** - * \def MBEDTLS_ASN1_PARSE_C - * - * Enable the generic ASN1 parser. - * - * Module: library/asn1.c - * Caller: library/x509.c - * library/dhm.c - * library/pkcs12.c - * library/pkcs5.c - * library/pkparse.c - */ -#define MBEDTLS_ASN1_PARSE_C - -/** - * \def MBEDTLS_ASN1_WRITE_C - * - * Enable the generic ASN1 writer. - * - * Module: library/asn1write.c - * Caller: library/ecdsa.c - * library/pkwrite.c - * library/x509_create.c - * library/x509write_crt.c - * library/mbedtls_x509write_csr.c - */ -#define MBEDTLS_ASN1_WRITE_C - -/** - * \def MBEDTLS_BASE64_C - * - * Enable the Base64 module. - * - * Module: library/base64.c - * Caller: library/pem.c - * - * This module is required for PEM support (required by X.509). - */ -#define MBEDTLS_BASE64_C - -/** - * \def MBEDTLS_BIGNUM_C - * - * Enable the multi-precision integer library. - * - * Module: library/bignum.c - * Caller: library/dhm.c - * library/ecp.c - * library/ecdsa.c - * library/rsa.c - * library/ssl_tls.c - * - * This module is required for RSA, DHM and ECC (ECDH, ECDSA) support. - */ -#define MBEDTLS_BIGNUM_C - -/** - * \def MBEDTLS_BLOWFISH_C - * - * Enable the Blowfish block cipher. - * - * Module: library/blowfish.c - */ -#ifdef CONFIG_MBEDTLS_BLOWFISH_C -#define MBEDTLS_BLOWFISH_C -#else -#undef MBEDTLS_BLOWFISH_C -#endif - -/** - * \def MBEDTLS_CAMELLIA_C - * - * Enable the Camellia block cipher. - * - * Module: library/camellia.c - * Caller: library/ssl_tls.c - * - * This module enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 - * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA - * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 - * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA - * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA - * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 - * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 - * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 - */ -#ifdef CONFIG_MBEDTLS_CAMELLIA_C -#define MBEDTLS_CAMELLIA_C -#else -#undef MBEDTLS_CAMELLIA_C -#endif - -/** - * \def MBEDTLS_CCM_C - * - * Enable the Counter with CBC-MAC (CCM) mode for 128-bit block cipher. - * - * Module: library/ccm.c - * - * Requires: MBEDTLS_AES_C or MBEDTLS_CAMELLIA_C - * - * This module enables the AES-CCM ciphersuites, if other requisites are - * enabled as well. - */ -#ifdef CONFIG_MBEDTLS_CCM_C -#define MBEDTLS_CCM_C -#else -#undef MBEDTLS_CCM_C -#endif - -/** - * \def MBEDTLS_CERTS_C - * - * Enable the test certificates. - * - * Module: library/certs.c - * Caller: - * - * This module is used for testing (ssl_client/server). - */ -#define MBEDTLS_CERTS_C - -/** - * \def MBEDTLS_CHACHA20_C - * - * Disable the ChaCha20 stream cipher. - * - * Module: library/chacha20.c - */ -#ifdef MBEDTLS_CHACHA20_C -#undef MBEDTLS_CHACHA20_C -#endif - -/** - * \def MBEDTLS_CHACHAPOLY_C - * - * Disable the ChaCha20-Poly1305 AEAD algorithm. - * - * Module: library/chachapoly.c - * - * This module requires: MBEDTLS_CHACHA20_C, MBEDTLS_POLY1305_C - */ -#ifdef MBEDTLS_CHACHAPOLY_C -#undef MBEDTLS_CHACHAPOLY_C -#endif - -/** - * \def MBEDTLS_CIPHER_C - * - * Enable the generic cipher layer. - * - * Module: library/cipher.c - * Caller: library/ssl_tls.c - * - * Uncomment to enable generic cipher wrappers. - */ -#define MBEDTLS_CIPHER_C - -/** - * \def MBEDTLS_CTR_DRBG_C - * - * Enable the CTR_DRBG AES-256-based random generator. - * - * Module: library/ctr_drbg.c - * Caller: - * - * Requires: MBEDTLS_AES_C - * - * This module provides the CTR_DRBG AES-256 random number generator. - */ -#define MBEDTLS_CTR_DRBG_C - -/** - * \def MBEDTLS_DEBUG_C - * - * Enable the debug functions. - * - * Module: library/debug.c - * Caller: library/ssl_cli.c - * library/ssl_srv.c - * library/ssl_tls.c - * - * This module provides debugging functions. - */ -#if CONFIG_MBEDTLS_DEBUG -#define MBEDTLS_DEBUG_C -#else -#undef MBEDTLS_DEBUG_C -#endif - -/** - * \def MBEDTLS_DES_C - * - * Enable the DES block cipher. - * - * Module: library/des.c - * Caller: library/pem.c - * library/ssl_tls.c - * - * This module enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_PSK_WITH_3DES_EDE_CBC_SHA - * - * PEM_PARSE uses DES/3DES for decrypting encrypted keys. - */ -#ifdef CONFIG_MBEDTLS_DES_C -#define MBEDTLS_DES_C -#else -#undef MBEDTLS_DES_C -#endif - -/** - * \def MBEDTLS_DHM_C - * - * Enable the Diffie-Hellman-Merkle module. - * - * Module: library/dhm.c - * Caller: library/ssl_cli.c - * library/ssl_srv.c - * - * This module is used by the following key exchanges: - * DHE-RSA, DHE-PSK - */ -#define MBEDTLS_DHM_C - -/** - * \def MBEDTLS_ECDH_C - * - * Enable the elliptic curve Diffie-Hellman library. - * - * Module: library/ecdh.c - * Caller: library/ssl_cli.c - * library/ssl_srv.c - * - * This module is used by the following key exchanges: - * ECDHE-ECDSA, ECDHE-RSA, DHE-PSK - * - * Requires: MBEDTLS_ECP_C - */ -#ifdef CONFIG_MBEDTLS_ECDH_C -#define MBEDTLS_ECDH_C -#else -#undef MBEDTLS_ECDH_C -#endif - -/** - * \def MBEDTLS_ECDSA_C - * - * Enable the elliptic curve DSA library. - * - * Module: library/ecdsa.c - * Caller: - * - * This module is used by the following key exchanges: - * ECDHE-ECDSA - * - * Requires: MBEDTLS_ECP_C, MBEDTLS_ASN1_WRITE_C, MBEDTLS_ASN1_PARSE_C - */ -#ifdef CONFIG_MBEDTLS_ECDSA_C -#define MBEDTLS_ECDSA_C -#else -#undef MBEDTLS_ECDSA_C -#endif - -/** - * \def MBEDTLS_ECJPAKE_C - * - * Enable the elliptic curve J-PAKE library. - * - * \warning This is currently experimental. EC J-PAKE support is based on the - * Thread v1.0.0 specification; incompatible changes to the specification - * might still happen. For this reason, this is disabled by default. - * - * Module: library/ecjpake.c - * Caller: - * - * This module is used by the following key exchanges: - * ECJPAKE - * - * Requires: MBEDTLS_ECP_C, MBEDTLS_MD_C - */ -//#define MBEDTLS_ECJPAKE_C - -/** - * \def MBEDTLS_ECP_C - * - * Enable the elliptic curve over GF(p) library. - * - * Module: library/ecp.c - * Caller: library/ecdh.c - * library/ecdsa.c - * library/ecjpake.c - * - * Requires: MBEDTLS_BIGNUM_C and at least one MBEDTLS_ECP_DP_XXX_ENABLED - */ -#ifdef CONFIG_MBEDTLS_ECP_C -#define MBEDTLS_ECP_C -#else -#undef MBEDTLS_ECP_C -#endif - -/** - * \def MBEDTLS_ENTROPY_C - * - * Enable the platform-specific entropy code. - * - * Module: library/entropy.c - * Caller: - * - * Requires: MBEDTLS_SHA512_C or MBEDTLS_SHA256_C - * - * This module provides a generic entropy pool - */ -#define MBEDTLS_ENTROPY_C - -/** - * \def MBEDTLS_ERROR_C - * - * Enable error code to error string conversion. - * - * Module: library/error.c - * Caller: - * - * This module enables mbedtls_strerror(). - */ -#define MBEDTLS_ERROR_C - -/** - * \def MBEDTLS_GCM_C - * - * Enable the Galois/Counter Mode (GCM) for AES. - * - * Module: library/gcm.c - * - * Requires: MBEDTLS_AES_C or MBEDTLS_CAMELLIA_C - * - * This module enables the AES-GCM and CAMELLIA-GCM ciphersuites, if other - * requisites are enabled as well. - */ -#ifdef CONFIG_MBEDTLS_GCM_C -#define MBEDTLS_GCM_C -#else -#undef MBEDTLS_GCM_C -#endif - -/** - * \def MBEDTLS_HKDF_C - * - * Enable the HKDF algorithm (RFC 5869). - * - * Module: library/hkdf.c - * Caller: - * - * Requires: MBEDTLS_MD_C - * - * This module adds support for the Hashed Message Authentication Code - * (HMAC)-based key derivation function (HKDF). - */ -#ifndef MBEDTLS_HKDF_C -#define MBEDTLS_HKDF_C -#endif - -/** - * \def MBEDTLS_HMAC_DRBG_C - * - * Enable the HMAC_DRBG random generator. - * - * Module: library/hmac_drbg.c - * Caller: - * - * Requires: MBEDTLS_MD_C - * - * Uncomment to enable the HMAC_DRBG random number geerator. - */ -#define MBEDTLS_HMAC_DRBG_C - -/** - * \def MBEDTLS_MD_C - * - * Enable the generic message digest layer. - * - * Module: library/mbedtls_md.c - * Caller: - * - * Uncomment to enable generic message digest wrappers. - */ -#define MBEDTLS_MD_C - -/** - * \def MBEDTLS_MD5_C - * - * Enable the MD5 hash algorithm. - * - * Module: library/mbedtls_md5.c - * Caller: library/mbedtls_md.c - * library/pem.c - * library/ssl_tls.c - * - * This module is required for SSL/TLS and X.509. - * PEM_PARSE uses MD5 for decrypting encrypted keys. - */ -#define MBEDTLS_MD5_C - -/** - * \def MBEDTLS_NET_C - * - * Enable the TCP/IP networking routines. - * - * Module: library/net.c - * - * This module provides TCP/IP networking routines. - */ -#ifdef MBEDTLS_NET_C -#undef MBEDTLS_NET_C -#endif - -/** - * \def MBEDTLS_OID_C - * - * Enable the OID database. - * - * Module: library/oid.c - * Caller: library/asn1write.c - * library/pkcs5.c - * library/pkparse.c - * library/pkwrite.c - * library/rsa.c - * library/x509.c - * library/x509_create.c - * library/mbedtls_x509_crl.c - * library/mbedtls_x509_crt.c - * library/mbedtls_x509_csr.c - * library/x509write_crt.c - * library/mbedtls_x509write_csr.c - * - * This modules translates between OIDs and internal values. - */ -#define MBEDTLS_OID_C - -/** - * \def MBEDTLS_PADLOCK_C - * - * Enable VIA Padlock support on x86. - * - * Module: library/padlock.c - * Caller: library/aes.c - * - * Requires: MBEDTLS_HAVE_ASM - * - * This modules adds support for the VIA PadLock on x86. - */ -#define MBEDTLS_PADLOCK_C - -/** - * \def MBEDTLS_PEM_PARSE_C - * - * Enable PEM decoding / parsing. - * - * Module: library/pem.c - * Caller: library/dhm.c - * library/pkparse.c - * library/mbedtls_x509_crl.c - * library/mbedtls_x509_crt.c - * library/mbedtls_x509_csr.c - * - * Requires: MBEDTLS_BASE64_C - * - * This modules adds support for decoding / parsing PEM files. - */ -#ifdef CONFIG_MBEDTLS_PEM_PARSE_C -#define MBEDTLS_PEM_PARSE_C -#else -#undef MBEDTLS_PEM_PARSE_C -#endif - -/** - * \def MBEDTLS_PEM_WRITE_C - * - * Enable PEM encoding / writing. - * - * Module: library/pem.c - * Caller: library/pkwrite.c - * library/x509write_crt.c - * library/mbedtls_x509write_csr.c - * - * Requires: MBEDTLS_BASE64_C - * - * This modules adds support for encoding / writing PEM files. - */ -#ifdef CONFIG_MBEDTLS_PEM_WRITE_C -#define MBEDTLS_PEM_WRITE_C -#else -#undef MBEDTLS_PEM_WRITE_C -#endif - -/** - * \def MBEDTLS_PK_C - * - * Enable the generic public (asymetric) key layer. - * - * Module: library/pk.c - * Caller: library/ssl_tls.c - * library/ssl_cli.c - * library/ssl_srv.c - * - * Requires: MBEDTLS_RSA_C or MBEDTLS_ECP_C - * - * Uncomment to enable generic public key wrappers. - */ -#define MBEDTLS_PK_C - -/** - * \def MBEDTLS_PK_PARSE_C - * - * Enable the generic public (asymetric) key parser. - * - * Module: library/pkparse.c - * Caller: library/mbedtls_x509_crt.c - * library/mbedtls_x509_csr.c - * - * Requires: MBEDTLS_PK_C - * - * Uncomment to enable generic public key parse functions. - */ -#define MBEDTLS_PK_PARSE_C - -/** - * \def MBEDTLS_PK_WRITE_C - * - * Enable the generic public (asymetric) key writer. - * - * Module: library/pkwrite.c - * Caller: library/x509write.c - * - * Requires: MBEDTLS_PK_C - * - * Uncomment to enable generic public key write functions. - */ -#define MBEDTLS_PK_WRITE_C - -/** - * \def MBEDTLS_PKCS5_C - * - * Enable PKCS#5 functions. - * - * Module: library/pkcs5.c - * - * Requires: MBEDTLS_MD_C - * - * This module adds support for the PKCS#5 functions. - */ -#define MBEDTLS_PKCS5_C - -/** - * \def MBEDTLS_PKCS12_C - * - * Enable PKCS#12 PBE functions. - * Adds algorithms for parsing PKCS#8 encrypted private keys - * - * Module: library/pkcs12.c - * Caller: library/pkparse.c - * - * Requires: MBEDTLS_ASN1_PARSE_C, MBEDTLS_CIPHER_C, MBEDTLS_MD_C - * Can use: MBEDTLS_ARC4_C - * - * This module enables PKCS#12 functions. - */ -#define MBEDTLS_PKCS12_C - -/** - * \def MBEDTLS_PLATFORM_C - * - * Enable the platform abstraction layer that allows you to re-assign - * functions like calloc(), free(), snprintf(), printf(), fprintf(), exit(). - * - * Enabling MBEDTLS_PLATFORM_C enables to use of MBEDTLS_PLATFORM_XXX_ALT - * or MBEDTLS_PLATFORM_XXX_MACRO directives, allowing the functions mentioned - * above to be specified at runtime or compile time respectively. - * - * \note This abstraction layer must be enabled on Windows (including MSYS2) - * as other module rely on it for a fixed snprintf implementation. - * - * Module: library/platform.c - * Caller: Most other .c files - * - * This module enables abstraction of common (libc) functions. - */ -#define MBEDTLS_PLATFORM_C - -/** - * \def MBEDTLS_POLY1305_C - * - * Disable the Poly1305 MAC algorithm. - * - * Module: library/poly1305.c - * Caller: library/chachapoly.c - */ -#ifdef MBEDTLS_POLY1305_C -#undef MBEDTLS_POLY1305_C -#endif - -/** - * \def MBEDTLS_RIPEMD160_C - * - * Enable the RIPEMD-160 hash algorithm. - * - * Module: library/mbedtls_ripemd160.c - * Caller: library/mbedtls_md.c - * - */ -#ifdef CONFIG_MBEDTLS_RIPEMD160_C -#define MBEDTLS_RIPEMD160_C -#else -#undef MBEDTLS_RIPEMD160_C -#endif - -/** - * \def MBEDTLS_RSA_C - * - * Enable the RSA public-key cryptosystem. - * - * Module: library/rsa.c - * Caller: library/ssl_cli.c - * library/ssl_srv.c - * library/ssl_tls.c - * library/x509.c - * - * This module is used by the following key exchanges: - * RSA, DHE-RSA, ECDHE-RSA, RSA-PSK - * - * Requires: MBEDTLS_BIGNUM_C, MBEDTLS_OID_C - */ -#define MBEDTLS_RSA_C - -/** - * \def MBEDTLS_SHA1_C - * - * Enable the SHA1 cryptographic hash algorithm. - * - * Module: library/mbedtls_sha1.c - * Caller: library/mbedtls_md.c - * library/ssl_cli.c - * library/ssl_srv.c - * library/ssl_tls.c - * library/x509write_crt.c - * - * This module is required for SSL/TLS and SHA1-signed certificates. - */ -#define MBEDTLS_SHA1_C - -/** - * \def MBEDTLS_SHA256_C - * - * Enable the SHA-224 and SHA-256 cryptographic hash algorithms. - * - * Module: library/mbedtls_sha256.c - * Caller: library/entropy.c - * library/mbedtls_md.c - * library/ssl_cli.c - * library/ssl_srv.c - * library/ssl_tls.c - * - * This module adds support for SHA-224 and SHA-256. - * This module is required for the SSL/TLS 1.2 PRF function. - */ -#define MBEDTLS_SHA256_C - -/** - * \def MBEDTLS_SHA512_C - * - * Enable the SHA-384 and SHA-512 cryptographic hash algorithms. - * - * Module: library/mbedtls_sha512.c - * Caller: library/entropy.c - * library/mbedtls_md.c - * library/ssl_cli.c - * library/ssl_srv.c - * - * This module adds support for SHA-384 and SHA-512. - */ -#define MBEDTLS_SHA512_C - -/** - * \def MBEDTLS_SSL_CACHE_C - * - * Enable simple SSL cache implementation. - * - * Module: library/ssl_cache.c - * Caller: - * - * Requires: MBEDTLS_SSL_CACHE_C - */ -#define MBEDTLS_SSL_CACHE_C - -/** - * \def MBEDTLS_SSL_COOKIE_C - * - * Enable basic implementation of DTLS cookies for hello verification. - * - * Module: library/ssl_cookie.c - * Caller: - */ -#define MBEDTLS_SSL_COOKIE_C - -/** - * \def MBEDTLS_SSL_TICKET_C - * - * Enable an implementation of TLS server-side callbacks for session tickets. - * - * Module: library/ssl_ticket.c - * Caller: - * - * Requires: MBEDTLS_CIPHER_C - */ -#ifdef CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS -#define MBEDTLS_SSL_TICKET_C -#else -#undef MBEDTLS_SSL_TICKET_C -#endif - -/** - * \def MBEDTLS_SSL_CLI_C - * - * Enable the SSL/TLS client code. - * - * Module: library/ssl_cli.c - * Caller: - * - * Requires: MBEDTLS_SSL_TLS_C - * - * This module is required for SSL/TLS client support. - */ -#ifdef CONFIG_MBEDTLS_TLS_CLIENT -#define MBEDTLS_SSL_CLI_C -#else -#undef MBEDTLS_SSL_CLI_C -#endif - -/** - * \def MBEDTLS_SSL_SRV_C - * - * Enable the SSL/TLS server code. - * - * Module: library/ssl_srv.c - * Caller: - * - * Requires: MBEDTLS_SSL_TLS_C - * - * This module is required for SSL/TLS server support. - */ -#ifdef CONFIG_MBEDTLS_TLS_SERVER -#define MBEDTLS_SSL_SRV_C -#else -#undef MBEDTLS_SSL_SRV_C -#endif - -/** - * \def MBEDTLS_SSL_TLS_C - * - * Enable the generic SSL/TLS code. - * - * Module: library/ssl_tls.c - * Caller: library/ssl_cli.c - * library/ssl_srv.c - * - * Requires: MBEDTLS_CIPHER_C, MBEDTLS_MD_C - * and at least one of the MBEDTLS_SSL_PROTO_XXX defines - * - * This module is required for SSL/TLS. - */ -#ifdef CONFIG_MBEDTLS_TLS_ENABLED -#define MBEDTLS_SSL_TLS_C -#else -#undef MBEDTLS_SSL_TLS_C -#endif - -/** - * \def MBEDTLS_TIMING_C - * - * Enable the semi-portable timing interface. - * - * \note The provided implementation only works on POSIX/Unix (including Linux, - * BSD and OS X) and Windows. On other platforms, you can either disable that - * module and provide your own implementations of the callbacks needed by - * \c mbedtls_ssl_set_timer_cb() for DTLS, or leave it enabled and provide - * your own implementation of the whole module by setting - * \c MBEDTLS_TIMING_ALT in the current file. - * - * \note See also our Knowledge Base article about porting to a new - * environment: - * https://tls.mbed.org/kb/how-to/how-do-i-port-mbed-tls-to-a-new-environment-OS - * - * Module: library/timing.c - * Caller: library/havege.c - * - * This module is used by the HAVEGE random number generator. - */ -#ifdef MBEDTLS_TIMING_C -#undef MBEDTLS_TIMING_C -#endif - -/** - * \def MBEDTLS_VERSION_C - * - * Enable run-time version information. - * - * Module: library/version.c - * - * This module provides run-time version information. - */ -#define MBEDTLS_VERSION_C - -/** - * \def MBEDTLS_X509_USE_C - * - * Enable X.509 core for using certificates. - * - * Module: library/x509.c - * Caller: library/mbedtls_x509_crl.c - * library/mbedtls_x509_crt.c - * library/mbedtls_x509_csr.c - * - * Requires: MBEDTLS_ASN1_PARSE_C, MBEDTLS_BIGNUM_C, MBEDTLS_OID_C, - * MBEDTLS_PK_PARSE_C - * - * This module is required for the X.509 parsing modules. - */ -#define MBEDTLS_X509_USE_C - -/** - * \def MBEDTLS_X509_CRT_PARSE_C - * - * Enable X.509 certificate parsing. - * - * Module: library/mbedtls_x509_crt.c - * Caller: library/ssl_cli.c - * library/ssl_srv.c - * library/ssl_tls.c - * - * Requires: MBEDTLS_X509_USE_C - * - * This module is required for X.509 certificate parsing. - */ -#define MBEDTLS_X509_CRT_PARSE_C - -/** - * \def MBEDTLS_X509_CRL_PARSE_C - * - * Enable X.509 CRL parsing. - * - * Module: library/mbedtls_x509_crl.c - * Caller: library/mbedtls_x509_crt.c - * - * Requires: MBEDTLS_X509_USE_C - * - * This module is required for X.509 CRL parsing. - */ -#ifdef CONFIG_MBEDTLS_X509_CRL_PARSE_C -#define MBEDTLS_X509_CRL_PARSE_C -#else -#undef MBEDTLS_X509_CRL_PARSE_C -#endif - -/** - * \def MBEDTLS_X509_CSR_PARSE_C - * - * Enable X.509 Certificate Signing Request (CSR) parsing. - * - * Module: library/mbedtls_x509_csr.c - * Caller: library/x509_crt_write.c - * - * Requires: MBEDTLS_X509_USE_C - * - * This module is used for reading X.509 certificate request. - */ -#ifdef CONFIG_MBEDTLS_X509_CSR_PARSE_C -#define MBEDTLS_X509_CSR_PARSE_C -#else -#undef MBEDTLS_X509_CSR_PARSE_C -#endif - -/** - * \def MBEDTLS_X509_CREATE_C - * - * Enable X.509 core for creating certificates. - * - * Module: library/x509_create.c - * - * Requires: MBEDTLS_BIGNUM_C, MBEDTLS_OID_C, MBEDTLS_PK_WRITE_C - * - * This module is the basis for creating X.509 certificates and CSRs. - */ -#define MBEDTLS_X509_CREATE_C - -/** - * \def MBEDTLS_X509_CRT_WRITE_C - * - * Enable creating X.509 certificates. - * - * Module: library/x509_crt_write.c - * - * Requires: MBEDTLS_X509_CREATE_C - * - * This module is required for X.509 certificate creation. - */ -#define MBEDTLS_X509_CRT_WRITE_C - -/** - * \def MBEDTLS_X509_CSR_WRITE_C - * - * Enable creating X.509 Certificate Signing Requests (CSR). - * - * Module: library/x509_csr_write.c - * - * Requires: MBEDTLS_X509_CREATE_C - * - * This module is required for X.509 certificate request writing. - */ -#define MBEDTLS_X509_CSR_WRITE_C - -/** - * \def MBEDTLS_XTEA_C - * - * Enable the XTEA block cipher. - * - * Module: library/xtea.c - * Caller: - */ -#ifdef CONFIG_MBEDTLS_XTEA_C -#define MBEDTLS_XTEA_C -#else -#undef MBEDTLS_XTEA_C -#endif - -/* \} name SECTION: mbed TLS modules */ - -/** - * \name SECTION: Module configuration options - * - * This section allows for the setting of module specific sizes and - * configuration options. The default values are already present in the - * relevant header files and should suffice for the regular use cases. - * - * Our advice is to enable options and change their values here - * only if you have a good reason and know the consequences. - * - * Please check the respective header file for documentation on these - * parameters (to prevent duplicate documentation). - * \{ - */ - -/* SSL options */ -#ifndef CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN - -#define MBEDTLS_SSL_MAX_CONTENT_LEN \ - CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN /**< Maxium fragment length in bytes, determines the size of each of the two internal I/O \ - buffers */ - -#else - -/** \def MBEDTLS_SSL_IN_CONTENT_LEN - * - * Maximum incoming fragment length in bytes. - * - * Uncomment to set the size of the inward TLS buffer independently of the - * outward buffer. - */ -#define MBEDTLS_SSL_IN_CONTENT_LEN CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN - -/** \def MBEDTLS_SSL_OUT_CONTENT_LEN - * - * Maximum outgoing fragment length in bytes. - * - * Uncomment to set the size of the outward TLS buffer independently of the - * inward buffer. - * - * It is possible to save RAM by setting a smaller outward buffer, while keeping - * the default inward 16384 byte buffer to conform to the TLS specification. - * - * The minimum required outward buffer size is determined by the handshake - * protocol's usage. Handshaking will fail if the outward buffer is too small. - * The specific size requirement depends on the configured ciphers and any - * certificate data which is sent during the handshake. - * - * For absolute minimum RAM usage, it's best to enable - * MBEDTLS_SSL_MAX_FRAGMENT_LENGTH and reduce MBEDTLS_SSL_MAX_CONTENT_LEN. This - * reduces both incoming and outgoing buffer sizes. However this is only - * guaranteed if the other end of the connection also supports the TLS - * max_fragment_len extension. Otherwise the connection may fail. - */ -#define MBEDTLS_SSL_OUT_CONTENT_LEN CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN - -#endif /* !CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN */ - -/** - * Allow SHA-1 in the default TLS configuration for TLS 1.2 handshake - * signature and ciphersuite selection. Without this build-time option, SHA-1 - * support must be activated explicitly through mbedtls_ssl_conf_sig_hashes. - * The use of SHA-1 in TLS <= 1.1 and in HMAC-SHA-1 is always allowed by - * default. At the time of writing, there is no practical attack on the use - * of SHA-1 in handshake signatures, hence this option is turned on by default - * for compatibility with existing peers. - */ -#define MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE - -/* \} name SECTION: Module configuration options */ - -#if defined(TARGET_LIKE_MBED) -#include "mbedtls/target_config.h" -#endif - -/* - * Allow user to override any previous default. - * - * Use two macro names for that, as: - * - with yotta the prefix YOTTA_CFG_ is forced - * - without yotta is looks weird to have a YOTTA prefix. - */ -#if defined(YOTTA_CFG_MBEDTLS_USER_CONFIG_FILE) -#include YOTTA_CFG_MBEDTLS_USER_CONFIG_FILE -#elif defined(MBEDTLS_USER_CONFIG_FILE) -#include MBEDTLS_USER_CONFIG_FILE -#endif - -#include "mbedtls/check_config.h" - -#endif /* ESP_CONFIG_H */ diff --git a/config/openiotsdk/cmake/sdk.cmake b/config/openiotsdk/cmake/sdk.cmake index 7fbc7efa9561bc..61cd704a030041 100644 --- a/config/openiotsdk/cmake/sdk.cmake +++ b/config/openiotsdk/cmake/sdk.cmake @@ -194,11 +194,11 @@ if(TARGET mcu-driver-hal) DOMAIN_NS=$,1,0> ) - # Fixing the optimization issue for mcu-driver-hal target in the no-debug build. - # The default -Og optimization causes performance issues for the application. + # Fixing the optimization issue for mcu-driver-hal target in the release build. + # The default -Os optimization causes performance issues for the application. # We need to replace it with -O2 which is suitable for performance. # This fix can be removed in the future when the issue will be fixed in SDK directly. - if (NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug") + if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release") target_compile_options(mcu-driver-hal INTERFACE $<$:-O2>) target_compile_options(mcu-driver-hal INTERFACE $<$:-O2>) endif() diff --git a/config/telink/app/enable-gnu-std.cmake b/config/telink/app/enable-gnu-std.cmake index e46c87199aad2d..a8a63cf63c95f0 100644 --- a/config/telink/app/enable-gnu-std.cmake +++ b/config/telink/app/enable-gnu-std.cmake @@ -15,5 +15,5 @@ # add_library(gnu17 INTERFACE) -target_compile_options(gnu17 INTERFACE $<$:-std=gnu++17> -D_SYS__PTHREADTYPES_H_) -target_link_libraries(app PRIVATE gnu17) \ No newline at end of file +target_compile_options(gnu17 INTERFACE $<$:-std=gnu++17> -Wno-register -D_DEFAULT_SOURCE) +target_link_libraries(app PRIVATE gnu17) diff --git a/config/telink/app/zephyr.conf b/config/telink/app/zephyr.conf index a8a4c0af92b8a7..680c6b4634fbe0 100644 --- a/config/telink/app/zephyr.conf +++ b/config/telink/app/zephyr.conf @@ -126,3 +126,20 @@ CONFIG_SHELL=n # BLE MAC address CONFIG_B91_BLE_CTRL_MAC_FLASH_ADDR=0x1FE000 + +# getopt version +CONFIG_GETOPT_LONG=y + +# flash stream functionality +CONFIG_STREAM_FLASH=y + +# In current config/zephyr/Kconfig +# next deprecated values are selected +# warning: Deprecated symbol CPLUSPLUS is enabled. +# warning: Deprecated symbol LIB_CPLUSPLUS is enabled. +# new one are: +# CONFIG_CPP +# CONFIG_LIBCPP_IMPLEMENTATION +# See https://docs.zephyrproject.org/latest/releases/release-notes-3.3.html +# Since not only Telink is using Zephyr just suppress warnings +CONFIG_WARN_DEPRECATED=n diff --git a/config/telink/chip-module/CMakeLists.txt b/config/telink/chip-module/CMakeLists.txt index e1953b324d3c07..8ff944fd1bfba2 100644 --- a/config/telink/chip-module/CMakeLists.txt +++ b/config/telink/chip-module/CMakeLists.txt @@ -48,7 +48,7 @@ include(${COMMON_CMAKE_SOURCE_DIR}/chip_gn.cmake) # Prepare compiler flags if (CONFIG_POSIX_API) - matter_add_flags(-D_SYS__PTHREADTYPES_H_) + matter_add_flags(-D_DEFAULT_SOURCE) matter_add_flags(-isystem${ZEPHYR_BASE}/include/zephyr/posix) endif() diff --git a/config/telink/chip-module/Kconfig b/config/telink/chip-module/Kconfig index bce258355feff8..97f42e01932c5d 100644 --- a/config/telink/chip-module/Kconfig +++ b/config/telink/chip-module/Kconfig @@ -60,6 +60,14 @@ config CHIP_OTA_IMAGE_BUILD bool default y if CHIP_OTA_REQUESTOR +config CHIP_ROTATING_DEVICE_ID + bool "Generate rotating device ID" + default y + help + Enables the rotating device identifier that provides a non-trackable + identifier. The identifier is unique per device and rotates at pre-defined + moments. + config CHIP_EXAMPLE_DEVICE_INFO_PROVIDER bool "Include default device information provider build" default y @@ -179,3 +187,23 @@ config CHIP_OPENTHREAD_TX_POWER config SHELL_BACKEND_SERIAL_RX_RING_BUFFER_SIZE int default 255 if SHELL_BACKEND_SERIAL + +config CHIP_ICD_SUBSCRIPTION_HANDLING + bool "Enables platform specific handling of ICD subscriptions" + default PM + help + Enables platform specific implementation that handles ICD subscription requests + and selects subscription report interval value considering maximum interval preferred + by the publisher. + +config CHIP_MAX_PREFERRED_SUBSCRIPTION_REPORT_INTERVAL + int "Maximum preferred interval of sending subscription reports (s)" + default 60 + help + Provides maximum preferred interval to be used by a publisher for negotiation + of the final maximum subscription report interval, after receiving a subscription + request from the initiator. This value should be selected as a compromise between + keeping the power consumption low due to not sending reports too often, and allowing + the initiator device to detect the publisher absence reasonably fast due to not sending + the reports too rarely. The current algorithm is to select bigger value from the one + requested by the initiator and the one preferred by the publisher. diff --git a/docs/examples/index.md b/docs/examples/index.md index 6890ff955ec866..46482fcbe8934e 100644 --- a/docs/examples/index.md +++ b/docs/examples/index.md @@ -134,15 +134,6 @@ log-source-app/**/README minimal-mdns/README ``` -## Open IoT SDK examples - -```{toctree} -:glob: -:maxdepth: 1 - -openiotsdk_examples -``` - ## OTA Provider example ```{toctree} diff --git a/docs/examples/openiotsdk_examples.md b/docs/examples/openiotsdk_examples.md deleted file mode 100644 index 91bb27ffa9f13c..00000000000000 --- a/docs/examples/openiotsdk_examples.md +++ /dev/null @@ -1,303 +0,0 @@ -# Matter Open IoT SDK Example Application - -These examples are built using -[Open IoT SDK](https://gitlab.arm.com/iot/open-iot-sdk) and runs inside an -emulated target through the -[Arm FVP model for the Corstone-300 MPS3](https://developer.arm.com/downloads/-/arm-ecosystem-fvps). - -You can use these example as a reference for creating your own applications. - -## Environment setup - -Before building the examples, check out the Matter repository and sync -submodules using the following command: - -``` -$ git submodule update --init -``` - -The VSCode devcontainer has all dependencies pre-installed. Using the VSCode -devcontainer is the recommended way to interact with Open IoT SDK port of the -Matter Project. Please read this [README.md](../VSCODE_DEVELOPMENT.md) for more -information. - -### Networking setup - -Running ARM Fast Model with TAP/TUN device networking mode requires setup proper -network interfaces. Special scripts were designed to make setup easy. In -`scripts/setup/openiotsdk` directory you can find: - -- **network_setup.sh** - script to create the specific network namespace and - Virtual Ethernet interface to connect with host network. Both host and - namespace sides have linked IP addresses. Inside the network namespace the - TAP device interface is created and bridged with Virtual Ethernet peer. - There is also option to enable Internet connection in namespace by - forwarding traffic to host default interface. - - To enable Open IoT SDK networking environment: - - ``` - ${MATTER_ROOT}/scripts/setup/openiotsdk/network_setup.sh up - ``` - - To disable Open IoT SDK networking environment: - - ``` - ${MATTER_ROOT}/scripts/setup/openiotsdk/network_setup.sh down - ``` - - Use `--help` to get more information about the script options. - -- **connect_if.sh** - script that connects specified network interfaces with - the default route interface. It creates a bridge and links all interfaces to - it. The bridge becomes the default interface. - - Example: - - ``` - ${MATTER_ROOT}/scripts/setup/openiotsdk/connect_if.sh ARMhveth - ``` - - Use `--help` to get more information about the script options. - -Open IoT SDK network setup scripts contain commands that require root -permissions. Use `sudo` to run the scripts in user account with root privileges. - -After setting up the Open IoT SDK network environment the user will be able to -run Matter examples on `FVP` in an isolated network namespace in TAP device -mode. - -To execute a command in a specific network namespace use the helper script -`scripts/run_in_ns.sh`. - -Example: - -``` -${MATTER_ROOT}/scripts/run_in_ns.sh ARMns -``` - -Use `--help` to get more information about the script options. - -**NOTE** - -For Docker environment users it's recommended to use the -[default bridge network](https://docs.docker.com/network/bridge/#use-the-default-bridge-network) -for a running container. This guarantees full isolation of the Open IoT SDK -network from host settings. - -### Debugging setup - -Debugging Matter application running on `FVP` model requires GDB Remote -Connection Plugin for Fast Model. More details -[GDBRemoteConnection](https://developer.arm.com/documentation/100964/1116/Plug-ins-for-Fast-Models/GDBRemoteConnection). - -The Third-Party IP add-on package can be downloaded from ARM developer website -[Fast models](https://developer.arm.com/downloads/-/fast-models). Currently -required version is `11.16`. - -To install Fast Model Third-Party IP package: - -- unpack the installation package in a temporary location -- execute the command `./setup.bin` (Linux) or `Setup.exe` (Windows), and - follow the installation instructions. - -After installation the GDB Remote Connection Plugin should be visible in -`FastModelsPortfolio_11.16/plugins` directory. - -Then add the GDB plugin to your development environment: - -- host environment - add GDB plugin path to environment variable as - FAST_MODEL_PLUGINS_PATH. - - Example - - ``` - export FAST_MODEL_PLUGINS_PATH=/opt/FastModelsPortfolio_11.16/plugins/Linux64_GCC-9.3 - ``` - -- Docker container environment - mount the Fast Model Third-Party IP directory - into the `/opt/FastModelsPortfolio_11.16` directory in container. - - The Vscode devcontainer users should add a volume bound to this directory - [Add local file mount](https://code.visualstudio.com/remote/advancedcontainers/add-local-file-mount). - - You can edit the `.devcontainer/devcontainer.json` file, for example: - - ``` - ... - "mounts": [ - ... - "source=/opt/FastModelsPortfolio_11.16,target=/opt/FastModelsPortfolio_11.16,type=bind,consistency=cached" - ... - ], - ... - ``` - - In this case, the FAST MODEL PLUGINS PATH environment variable is already - created. - - If you launch the Docker container directly from CLI, use the above - arguments with `docker run` command. Remember add GDB plugin path to - environment variable as FAST_MODEL_PLUGINS_PATH inside container. - -## Configuration - -### Trusted Firmware-M - -To add [TF-M](https://tf-m-user-guide.trustedfirmware.org) support to Matter -example you need to set `TFM_SUPPORT` variable inside main application -`CMakeLists.txt` file. - -``` -set(TFM_SUPPORT YES) -``` - -This causes the Matter example to be built as non-secure application in -Non-secure Processing Environment (`NSPE`). The bootloader and the secure part -are also built from `TF-M` sources. All components are merged into a single -executable file at the end of the building process. - -You can also provide the own version of Matter example by setting -`TFM_NS_APP_VERSION` variable. - -``` -set(TFM_NS_APP_VERSION "0.0.1") -``` - -### Trusted Firmware-M Protected Storage - -There is an option to add -[TF-M Protected Storage Service](https://tf-m-user-guide.trustedfirmware.org/integration_guide/services/tfm_ps_integration_guide.html) -support for `key-value` storage component in Matter examples. You need to set -`CONFIG_CHIP_OPEN_IOT_SDK_USE_PSA_PS` variable inside main application -`CMakeLists.txt` fi - -``` -set(CONFIG_CHIP_OPEN_IOT_SDK_USE_PSA_PS YES) -``` - -This option causes `key-value` objects will be stored in a secure part of flash -memory and the Protected Storage Service takes care of their encryption and -authentication. - -**NOTE** - -The `TF-M Protected Storage` option requires enabling -[TF-M](#trusted-firmware-m) support. - -## Building - -You build using a vscode task or call the script directly from the command line. - -### Building using vscode task - -``` -Command Palette (F1) => Run Task... => Build Open IoT SDK example => (debug on/off) => -``` - -This will call the scripts with the selected parameters. - -### Building using CLI - -You can call the script directly yourself. - -``` -${MATTER_ROOT}/scripts/examples/openiotsdk_example.sh -``` - -Use `--help` to get more information about the script options. - -## Running - -The application runs in the background and opens a telnet session. The script -will open telnet for you and connect to the port used by the `FVP`. When the -telnet process is terminated it will also terminate the `FVP` instance. - -You can run the application script from a vscode task or call the script -directly. - -### Running using vscode task - -``` -Command Palette (F1) => Run Task... => Run Open IoT SDK example => (network namespace) => (network interface) => -``` - -This will call the scripts with the selected example name. - -### Running using CLI - -You can call the script directly yourself. - -``` -${MATTER_ROOT}/scripts/examples/openiotsdk_example.sh -C run -``` - -Run example in specific network namespace with TAP device mode: - -``` -${MATTER_ROOT}/scripts/run_in_ns.sh ARMns ${MATTER_ROOT}/scripts/examples/openiotsdk_example.sh -C run -n ARMtap -``` - -### Commissioning - -Once booted the application can be commissioned, please refer to -[docs/guides/openiotsdk_commissioning.md](../guides/openiotsdk_commissioning.md) -for further instructions. - -## Testing - -Run the Pytest integration test for specific application. - -The test result can be found in -`src/test_driver/openiotsdk/integration-tests//test_report.json` -file. - -You run testing using a vscode task or call the script directly from the command -line. - -### Testing using vscode task - -``` -Command Palette (F1) => Run Task... => Test Open IoT SDK example => (network namespace) => (network interface) => -``` - -This will call the scripts with the selected example name. - -### Testing using CLI - -You can call the script directly yourself. - -``` -${MATTER_ROOT}/scripts/examples/openiotsdk_example.sh -C test -``` - -Test example in specific network namespace with TAP device mode: - -``` -${MATTER_ROOT}/scripts/run_in_ns.sh ARMns ${MATTER_ROOT}/scripts/examples/openiotsdk_example.sh -C test -n ARMtap -``` - -## Debugging - -Debugging can be started using a VS code launch task: - -``` -Run and Debug (Ctrl+Shift+D) => Debug Open IoT SDK example application => Start -Debugging (F5) => => (GDB target address) => (network namespace) => (network interface) => -``` - -For debugging remote targets (i.e. run in other network namespaces) you need to -pass hostname/IP address of external GDB target that you want to connect to -(_GDB target address_). In case of using the -[Open IoT SDK network environment](#networking-setup) the GDB server runs inside -a namespace and has the same IP address as bridge interface. - -``` -${MATTER_ROOT}/scripts/run_in_ns.sh ifconfig -``` - -**NOTE** - -As you can see above, you will need to select the name of the example twice. -This is because the debug task needs to launch the run task and currently VS -code has no way of passing parameters between tasks. diff --git a/docs/guides/README.md b/docs/guides/README.md index 67bb8b66001830..451a2c6d2fdff7 100644 --- a/docs/guides/README.md +++ b/docs/guides/README.md @@ -22,6 +22,10 @@ - [Silicon Labs - Building](./silabs_efr32_building.md) - [Silicon Labs - Software Update](./silabs_efr32_software_update.md) - [TI - Platform Overview](./ti_platform_overview.md) +- [Open IoT SDK - Platform Overview](./openiotsdk_platform_overview.md) +- [Open IoT SDK - Examples](./openiotsdk_examples.md) +- [Open IoT SDK - Unit Tests](./openiotsdk_unit_tests.md) +- [Open IoT SDK - Commissioning](./openiotsdk_commissioning.md) ## Development Guides diff --git a/docs/guides/access-control-guide.md b/docs/guides/access-control-guide.md index 6aa20e032825d5..46878ab1cfca09 100644 --- a/docs/guides/access-control-guide.md +++ b/docs/guides/access-control-guide.md @@ -552,13 +552,13 @@ await devCtrl.WriteAttribute(1, [ (0, Clusters.AccessControl.Attributes.Acl( [ authMode = Clusters.AccessControl.Enums.AccessControlEntryAuthModeEnum.kGroup, subjects = [ 123, 456 ], targets = [ - Clusters.AccessControl.Structs.Target( + Clusters.AccessControl.Structs.AccessControlTargetStruct( cluster = Clusters.OnOff.id, ), - Clusters.AccessControl.Structs.Target( + Clusters.AccessControl.Structs.AccessControlTargetStruct( endpoint = 1, ), - Clusters.AccessControl.Structs.Target( + Clusters.AccessControl.Structs.AccessControlTargetStruct( cluster = Clusters.LevelControl.id, endpoint = 2, ), diff --git a/docs/guides/darwin.md b/docs/guides/darwin.md index 131feaf7f3971d..197023c3c99580 100644 --- a/docs/guides/darwin.md +++ b/docs/guides/darwin.md @@ -252,7 +252,7 @@ Example: ##### Guides - [Bouffalo Lab](/examples/lighting-app/bouffalolab/README.md) -- [EFR32 Window Covering](/examples/window-app/silabs/efr32/README.md) +- [EFR32 Window Covering](/examples/window-app/silabs/README.md) - [ESP32 All Clusters](/examples/all-clusters-app/esp32/README.md) - [ESP32 Lighting](/examples/lighting-app/esp32/README.md) - [ESP32 Temperature Sensor](/examples/temperature-measurement-app/esp32/README.md) @@ -268,7 +268,7 @@ Example: - [Simulated Linux](./simulated_device_linux.md) - [Telink](/examples/lighting-app/telink/README.md) - [TI Platform](./ti_platform_overview.md) -- [TI All Clusters](/examples/all-clusters-app/cc13x2x7_26x2x7/README.md) +- [TI All Clusters](/examples/all-clusters-app/cc13x4_26x4/README.md) - [Tizen](/examples/lighting-app/tizen/README.md) ## Providing Feedback to Apple @@ -306,8 +306,17 @@ Example: - Please refer to the iOS/iPadOS 16.1 [Release Notes](https://developer.apple.com/documentation/ios-ipados-release-notes/ios-16_1-release-notes) for currently known issues. -- Please refer to the iOS/iPadOS 16.2 beta 3 - [Release Notes](https://developer.apple.com/documentation/ios-ipados-release-notes/ios-ipados-16-release-notes) +- Please refer to the iOS/iPadOS 16.2 + [Release Notes](https://developer.apple.com/documentation/ios-ipados-release-notes/ios-ipados-16_2-release-notes) + for currently known issues +- Please refer to the iOS & iPadOS 16.3 + [Release Notes](https://developer.apple.com/documentation/ios-ipados-release-notes/ios-ipados-16_3-release-notes) + for currently known issues +- Please refer to the iOS & iPadOS 16.4 + [Release Notes](https://developer.apple.com/documentation/ios-ipados-release-notes/ios-ipados-16_4-release-notes) + for currently known issues +- Please refer to the iOS & iPadOS 16.5 + [Release Notes](https://developer.apple.com/documentation/ios-ipados-release-notes/ios-ipados-16_5-release-notes) for currently known issues - An issues related to Apple Home integration should be reported [feedback](#providing-feedback-to-apple) as described in this section diff --git a/docs/guides/esp32/setup_idf_chip.md b/docs/guides/esp32/setup_idf_chip.md index 13feaee221ca4e..2196109bea077e 100644 --- a/docs/guides/esp32/setup_idf_chip.md +++ b/docs/guides/esp32/setup_idf_chip.md @@ -73,9 +73,12 @@ For MacOS, `gdbgui` python package will not be installed using `bootstrap.sh` script as it is restricted only for x64 Linux platforms. It is restricted because, building wheels for `gevent` (dependency of `gdbgui`) fails on MacOS. -Please run the below commands after every bootstrapping. +For ARM-based Mac, no further installation steps are necessary if Python3 +version is greater than or equal to 3.11. -Workaround is to install `gdbgui` wheels as binary: +If Python3 version is less than 3.11 or you are using x86(Intel-based) Mac then +please run the below commands after every bootstrapping to install gdbgui wheels +as binary ``` python3 -m pip install -c scripts/setup/constraints.txt --no-cache --prefer-binary gdbgui==0.13.2.0 diff --git a/docs/guides/openiotsdk_commissioning.md b/docs/guides/openiotsdk_commissioning.md index 596184fd27a961..520cff033d611d 100644 --- a/docs/guides/openiotsdk_commissioning.md +++ b/docs/guides/openiotsdk_commissioning.md @@ -7,41 +7,82 @@ the device becomes available on the Matter network. Open IoT SDK Matter devices, due to the connectivity setup, start already connected to the IP network and do not require credentials provisioning. -## Building and installing the Python Device Controller +## Building Matter controller -To make provisioning possible and to control the Matter device with a Python -application, you can build and run the Python controller application. Please -read the guide -[Python Device Controller guide](python_chip_controller_building.md) for further -instructions. +The [Matter controller](../../src/controller/README.md) is a client application +that allows commission and control of the Matter node. + +The [POSIX CLI chip-tool](../../examples/chip-tool/README.md) is the recommended +Matter controller to use with Open IoT SDK devices. + +To build `chip-tool` execute command: + +``` +scripts/examples/gn_build_example.sh examples/chip-tool out/chip-tool +``` ## Device commissioning -Run chip-device-ctrl and use the interactive prompt to commission the device. +Open IoT SDK examples require to setup a specific +[network environment](./openiotsdk_examples.md#networking-setup): + +``` +export TEST_NETWORK_NAME=OIStest +sudo ${MATTER_ROOT}/scripts/setup/openiotsdk/network_setup.sh -n $TEST_NETWORK_NAME restart +``` + +Both the device application and the controller should be started in a separate +terminal sessions and inside the created network namespace. Use the +`{MATTER_ROOT}/scripts/examples/scripts/run_in_ns.sh` helper script to execute +the specific shell command inside the network namespace. + +Run the application in `device terminal` and use the network namespace: + +``` +${MATTER_ROOT}/scripts/examples/scripts/run_in_ns.sh ${TEST_NETWORK_NAME}ns +${MATTER_ROOT}/scripts/examples/openiotsdk_example.sh -C run -n ${TEST_NETWORK_NAME}tap + +``` After the device boots, it's in ready for commissioning mode and starts the mDNS -advertisement. This can be discovered by the controller using: +advertisement. + +To commission the node in `client terminal` run Matter controller in the same +network namespace with pairing command: + +``` +${MATTER_ROOT}/scripts/run_in_ns.sh ${TEST_NETWORK_NAME}ns ./out/chip-tool/chip-tool pairing onnetwork-long +``` + +The `node_id` is chosen by the user. `pin_code` and `discriminator` are node +parameters printed when running the application in the `device terminal`. + +Example: ``` -discover -all +${MATTER_ROOT}/scripts/run_in_ns.sh ${TEST_NETWORK_NAME}ns ./out/chip-tool/chip-tool pairing onnetwork-long 123 20202021 3840 ``` -This will list the devices and their addresses. To commission the device use: +The application output a trace when commissioning succeeds. This trace is +displayed in the `device terminal`: ``` -connect -ip
[] +[INF] [SVR] Commissioning completed successfully ``` -The setup pin code is printed in the log of the device. The `` can be -chosen by the user, if left blank it will be automatically picked. +## Sending ZCL cluster commands -## Sending ZCL commands +Before sending cluster commands [commission](#device-commissioning) the device. -If the commissioning process was successful, it is possible to send a ZCL -command to the device which initiates a certain action. +To perform cluster action, run the Matter controller in the `client terminal` +and use the same network namespace: -`zcl [arguments]` +``` +${MATTER_ROOT}/scripts/run_in_ns.sh ${TEST_NETWORK_NAME}ns ./out/chip-tool/chip-tool [param1 param2 ...] +``` Example: - chip-device-ctrl > zcl LevelControl MoveWithOnOff 12344321 1 0 moveMode=1 rate=2 +``` +${MATTER_ROOT}/scripts/run_in_ns.sh ${TEST_NETWORK_NAME}ns ./out/chip-tool/chip-tool basicinformation read vendor-id 123 0 +``` diff --git a/docs/guides/openiotsdk_examples.md b/docs/guides/openiotsdk_examples.md new file mode 100644 index 00000000000000..2de1915f3ecf43 --- /dev/null +++ b/docs/guides/openiotsdk_examples.md @@ -0,0 +1,766 @@ +# Matter Open IoT SDK Example Application + +These examples are built using +[Open IoT SDK](https://gitlab.arm.com/iot/open-iot-sdk) and runs inside an +emulated target through the +[Arm FVP model for the Corstone-300 MPS3](https://developer.arm.com/downloads/-/arm-ecosystem-fvps). + +The list of currently supported Matter examples: + +``` +shell +lock-app +``` + +You can use these examples as a reference for creating your own applications. + +## Environment setup + +The VSCode devcontainer has all the dependencies pre-installed. It is the +recommended way to build, run and develop with the Open IoT SDK port of the +Matter Project. Please read this +[VSCode development guide](../VSCODE_DEVELOPMENT.md) for more information. + +Before building the examples, check out the Matter repository and sync Open IoT +SDK submodules using the following command: + +``` +scripts/checkout_submodules.py --shallow --recursive --platform openiotsdk +``` + +Next, bootstrap the source tree to install Pigweed (CIPD and Python packages) +components inside your environment (only once). + +To bootstrap: + +**using CLI** + +``` +$ bash scripts/bootstrap.sh +``` + +**using VSCode tasks** + +- Open the Command Palette: F1 +- Select `Tasks: Run Task` +- Select `Bootstrap` + +### Networking setup + +Running ARM Fast Model with the TAP/TUN device networking mode requires the +setting up of proper network interfaces. Special scripts were designed to make +the setup easy. In the `scripts/setup/openiotsdk` directory you can find: + +- **network_setup.sh** - script to create the specific network namespace and + Virtual Ethernet interface to connect with the host network. Both host and + namespace sides have linked IP addresses. Inside the network namespace the + TAP device interface is created and bridged with a Virtual Ethernet peer. + There is also an option to enable an Internet connection in the namespace by + forwarding traffic to the host default interface. + + To enable the Open IoT SDK networking environment: + + ``` + ${MATTER_ROOT}/scripts/setup/openiotsdk/network_setup.sh up + ``` + + To disable the Open IoT SDK networking environment: + + ``` + ${MATTER_ROOT}/scripts/setup/openiotsdk/network_setup.sh down + ``` + + To restart the Open IoT SDK networking environment: + + ``` + ${MATTER_ROOT}/scripts/setup/openiotsdk/network_setup.sh restart + ``` + + The default scripts settings are: + + - `ARM` - network base name + - `current session user` - network namespace user + - `fe00::1` - host side IPv6 address + - `fe00::2` - namespace side IPv6 address + - `10.200.1.1` - host side IPv4 address + - `10.200.1.2` - namespace side IPv4 address + - no Internet connection support to network namespace + + Example of the `OIS` network environment settings: + + ``` + ARMns namespace configuration + ARMbr: flags=4163 mtu 1500 + inet 10.200.1.2 netmask 255.255.255.0 broadcast 0.0.0.0 + inet6 fe00::2 prefixlen 64 scopeid 0x0 + inet6 fe80::1809:17ff:fe6c:f566 prefixlen 64 scopeid 0x20 + ether 1a:09:17:6c:f5:66 txqueuelen 1000 (Ethernet) + RX packets 1 bytes 72 (72.0 B) + RX errors 0 dropped 0 overruns 0 frame 0 + TX packets 0 bytes 0 (0.0 B) + TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 + + ARMnveth: flags=4163 mtu 1500 + ether 46:66:29:a6:91:4b txqueuelen 1000 (Ethernet) + RX packets 2 bytes 216 (216.0 B) + RX errors 0 dropped 0 overruns 0 frame 0 + TX packets 3 bytes 270 (270.0 B) + TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 + + ARMtap: flags=4419 mtu 1500 + ether 1a:09:17:6c:f5:66 txqueuelen 1000 (Ethernet) + RX packets 0 bytes 0 (0.0 B) + RX errors 0 dropped 0 overruns 0 frame 0 + TX packets 0 bytes 0 (0.0 B) + TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 + + lo: flags=73 mtu 65536 + inet 127.0.0.1 netmask 255.0.0.0 + inet6 ::1 prefixlen 128 scopeid 0x10 + loop txqueuelen 1000 (Local Loopback) + RX packets 0 bytes 0 (0.0 B) + RX errors 0 dropped 0 overruns 0 frame 0 + TX packets 0 bytes 0 (0.0 B) + TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 + + Host configuration + ARMhveth: flags=4163 mtu 1500 + inet 10.200.1.1 netmask 255.255.255.0 broadcast 0.0.0.0 + inet6 fe80::147c:c9ff:fe4a:c6d2 prefixlen 64 scopeid 0x20 + inet6 fe00::1 prefixlen 64 scopeid 0x0 + ether 16:7c:c9:4a:c6:d2 txqueuelen 1000 (Ethernet) + RX packets 3 bytes 270 (270.0 B) + RX errors 0 dropped 0 overruns 0 frame 0 + TX packets 2 bytes 216 (216.0 B) + TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 + ``` + + Use `--help` to get more information about the script options. + + Open IoT SDK network setup is also supported via `VScode tasks`: + + - Open the Command Palette: F1 + - Select `Tasks: Run Task` + - Select `Setup Open IoT SDK network` + - Enter the network namespace name + - Choose command + + The VSCode task invokes `network_setup.sh` with the selected parameters. + +- **connect_if.sh** - script that connects specified network interfaces with + the default route interface. It creates a bridge and links all interfaces to + it. The bridge becomes the default interface. + + Example: + + ``` + ${MATTER_ROOT}/scripts/setup/openiotsdk/connect_if.sh ARMhveth + ``` + + Use `--help` to get more information about the script options. + +Open IoT SDK network setup scripts contain commands that require root +permissions. Use `sudo` to run the scripts in a user account with root +privileges. + +After setting up the Open IoT SDK network environment the user will be able to +run Matter examples on `FVP` in an isolated network namespace in TAP device +mode. + +To execute a command in a specific network namespace use the helper script +`scripts/run_in_ns.sh`. + +Example: + +``` +${MATTER_ROOT}/scripts/run_in_ns.sh ARMns +``` + +Use `--help` to get more information about the script options. + +> 💡 **Notes**: +> +> For Docker environment users it's recommended to use the +> [default bridge network](https://docs.docker.com/network/bridge/>#use-the-default-bridge-network) +> for a running container. This guarantees full isolation of the Open IoT SDK +> network from host settings. + +### Debugging setup + +Debugging the Matter application running on `FVP` model requires GDB Remote +Connection Plugin for Fast Model. More details +[GDBRemoteConnection](https://developer.arm.com/documentation/100964/1116/Plug-ins-for-Fast-Models/GDBRemoteConnection). + +The `Fast Models FVP` add-on package can be downloaded from the ARM developer +website [Fast models](https://developer.arm.com/downloads/-/fast-models). After +login in to the `ARM developer` platform search for `Fast Models`, choose +`Fast Models (FM000A)` on the list of results, then choose the revision +`r11p16-16rel0` and download the +`Third Party Add-ons for Fast Models 11.16 (Linux)` package. Then unpack the +package in the selected location on the host machine. + +Now you should add the GDB Remote Connection Plugin to your development +environment: + +- Linux host environment: + + - install Fast Model Extension package by executing the command + `./setup.bin`, and follow the installation instructions. After + installation, the GDB Remote Connection Plugin should be visible in + `/FastModelsPortfolio_11.16/plugins/Linux64_GCC-9.3` + directory. + - add GDB plugin path to environment variable as + `FAST_MODEL_PLUGINS_PATH`. + + Example: + + ``` + export FAST_MODEL_PLUGINS_PATH=/FastModelsPortfolio_11.16/plugins/Linux64_GCC-9.3 + ``` + +- Docker container environment: + + - pass the Fast Model Extension package to Docker container development + environment by mounting it into the + `/opt/FastModels_ThirdParty_IP_11-16_b16_Linux64` directory in the + container. Add a volume bound to this directory + [Add local file mount](https://code.visualstudio.com/remote/advancedcontainers/add-local-file-mount). + + You can edit the `.devcontainer/devcontainer.json` file, for example: + + ``` + ... + "mounts": [ ... + "source=/opt/FastModels_ThirdParty_IP_11-16_b16_Linux64,target=/opt/FastModels_ThirdParty_IP_11-16_b16_Linux64,type=bind,consistency=cached" + ... ], + ... + ``` + + Or if you launch the Docker container directly from CLI, use the above + arguments with `docker run` command: + + ``` + docker run ... --mount type=bind,source=/opt/FastModels_ThirdParty_IP_11-16_b16_Linux64,target=/opt/FastModels_ThirdParty_IP_11-16_b16_Linux64 ... + ``` + + - install the Fast Model Extension package via setup script inside Docker + container: + + ``` + ${MATTER_ROOT}/scripts/setup/openiotsdk/debugging_setup.sh + ``` + + - the GDB Remote Connection Plugin should be visible in + `/opt/FastModelsPortfolio_11.16/plugins/Linux64_GCC-9.3` directory. + - For `VScode devcontainer` use the environment variable + `FAST_MODEL_PLUGINS_PATH` to point to the correct directory. + - If the Docker container is directly launched remember to add the GDB + Remote Connection Plugin path to the environment variable + `FAST_MODEL_PLUGINS_PATH` inside the container: + ``` + export FAST_MODEL_PLUGINS_PATH=/opt/FastModelsPortfolio_11.16/plugins/Linux64_GCC-9.3 + ``` + +### Testing setup + +The Matter Python packages are required for the integration test suite. They are +not provided as part of the VSCode devcontainer. To install these run the +following command from the CLI: + +``` +${MATTER_ROOT}/scripts/run_in_build_env.sh './scripts/build_python.sh --install_wheel +build-env' +``` + +More information about the Python tools you can find +[here](../../src/controller/python/README.md). + +## Configuration + +### Trusted Firmware-M + +To add [TF-M](https://tf-m-user-guide.trustedfirmware.org) support to Matter +example you need to set `TFM_SUPPORT` variable inside main application +`CMakeLists.txt` file. + +``` +set(TFM_SUPPORT YES) +``` + +This causes the Matter example to be built as non-secure application in +Non-secure Processing Environment (`NSPE`). The bootloader and the secure part +are also built from `TF-M` sources. All components are merged into a single +executable file at the end of the building process. + +You can also provide the own version of Matter example by setting +`TFM_NS_APP_VERSION` variable. + +``` +set(TFM_NS_APP_VERSION "0.0.1") +``` + +### Trusted Firmware-M Protected Storage + +By default, the +[Block Device storage](./openiotsdk_platform_overview.md#storage) is used for +storing Matter key-value data. + +There is an option to add +[TF-M Protected Storage Service](https://tf-m-user-guide.trustedfirmware.org/integration_guide/services/tfm_ps_integration_guide.html) +support for `key-value` storage component in the Matter examples. Set the +variable `CONFIG_CHIP_OPEN_IOT_SDK_USE_PSA_PS` to `YES` to add +`TF-M Protected Storage` support to your application. You can put it inside the +main application `CMakeLists.txt` file: + +``` +set(CONFIG_CHIP_OPEN_IOT_SDK_USE_PSA_PS YES) +``` + +or add as a Cmake command-line parameter: + +``` +cmake -G <...> -DCONFIG_CHIP_OPEN_IOT_SDK_USE_PSA_PS=YES <...> +``` + +This option causes `key-value` objects will be stored in a secure part of flash +memory and the Protected Storage Service takes care of their encryption and +authentication. + +> 💡 **Notes**: +> +> The `TF-M Protected Storage` option requires enabling +> [TF-M](#trusted-firmware-m) support. +> +> The `-k/--kvsstore` option in +> [Open IoT SDK build script](../../scripts/examples/openiotsdk_example.sh) +> selects key-value storage implementation for the Matter's examples. It +> demonstrates how to use the `CONFIG_CHIP_OPEN_IOT_SDK_USE_PSA_PS` variable. + +### Storing persistent memory block in external files + +The persistent storage is required to store key-value data of the Matter +examples. + +Two storage types are supported: + +- Block device storage: The memory partition is located in `non-secure SRAM` +- `TF-M` protected storage: The memory partition is located in + `secure QSPI_RAM` + +Fast models offers option to load and dump memory content. More details are +available +[here](./openiotsdk_platform_overview.md#fast-model-persistent-memory-via-files). +Depending on the storage implementation, different flags are used in the `FVP` +options. + +For block device storage use: + +``` +--dump mps3_board.sram=@0:0x0,0x100000 +--data mps3_board.sram=@0:0x0 +``` + +For `TF-M` protected storage use: + +``` +--dump mps3_board.qspi_sram=@0:0x660000,0x12000 +--data mps3_board.qspi_sram=@0:0x660000 +``` + +> 💡 **Notes**: +> +> The `file-path` must exist to use the `--data` option. + +[Open IoT SDK build script](../../scripts/examples/openiotsdk_example.sh) +provides the `-K,--kvsfile` option to use the persistence options listed above. + +## Building + +You can build examples using the dedicated VSCode task or by calling directly +the build script from the command line. + +### Building using the VSCode task + +- Open the Command Palette: F1 +- Select `Tasks: Run Task` +- Select `Build Open IoT SDK example` +- Decide on debug mode support +- Decide on LwIP debug logs support +- Choose example name + +This will call the script with the selected parameters. + +### Building using CLI + +You can call the script directly yourself. + +``` +${MATTER_ROOT}/scripts/examples/openiotsdk_example.sh +``` + +Use `--help` to get more information about the script options. + +## Running + +The application runs in the background and opens a telnet session. The telnet +client connects to the port used by the `FVP`. When the telnet process is +terminated it also terminates the `FVP` instance. + +To exit the telnet session, type CTRL + ]. This changes the command +prompt to show as: + +``` +telnet> +``` + +Back in the terminal, type in the word 'close' to terminate the session. + +``` +telnet> close +``` + +You can run an example by using a VSCode task or by calling the run script +directly from the command line. + +### Running using the VSCode task + +- Open the Command Palette: F1 +- Select `Tasks: Run Task` +- Select `Run Open IoT SDK example` +- Enter network namespace +- Enter network interface +- Choose example name + +This will call the script with the selected example name. + +### Running using CLI + +You can call the script directly yourself. + +``` +${MATTER_ROOT}/scripts/examples/openiotsdk_example.sh -C run +``` + +Run example in specific network namespace with TAP device mode: + +``` +${MATTER_ROOT}/scripts/run_in_ns.sh ARMns ${MATTER_ROOT}/scripts/examples/openiotsdk_example.sh -C run -n ARMtap +``` + +## Testing + +Run the Pytest integration test for the specific application. + +The test result can be found in the +`src/test_driver/openiotsdk/integration-tests//test_report.json` +file. + +You can test an example by using a VSCode task or by calling the test script +directly from the command line. + +### Testing using the VSCode task + +- Open the Command Palette: F1 +- Select `Tasks: Run Task` +- Select `Test Open IoT SDK example` +- Enter network namespace +- Enter network interface +- Choose example name + +This will call the scripts with the selected example name. + +### Testing using CLI + +You can call the script directly yourself. + +``` +${MATTER_ROOT}/scripts/examples/openiotsdk_example.sh -C test +``` + +Testing an example in a specific network namespace with TAP device mode: + +``` +${MATTER_ROOT}/scripts/run_in_ns.sh ARMns ${MATTER_ROOT}/scripts/examples/openiotsdk_example.sh -C test -n ARMtap +``` + +## Debugging + +Before debugging ensure the following: + +1. The debug environment is correctly setup: + [debugging setup](#debugging-setup). + +2. The example is compiled with debug symbols enabled: + + For CLI: + + ``` + ${MATTER_ROOT}/scripts/examples/openiotsdk_example.sh -d true + ``` + + For the VSCode task: + + ``` + => Use debug mode (true) + ``` + +3. The test network is correctly setup (if required): see + [networking setup](#networking-setup). + +### General instructions + +- Click `Run and Debug` from the primary side menu or press + Ctrl+Shift+D +- Select `Debug Open IoT SDK example application` from the drop down list +- Click `Start Debugging`(green triangle) or press F5 +- Choose example name +- Enter GDB target address +- Enter network namespace +- Enter network interface +- Choose example name + +As soon as a debugging session starts, the `DEBUG CONSOLE` panel is displayed +and shows the debugging output. Use debug controls to debug the current +application. + +For debugging remote targets (i.e. run in other network namespaces) you need to +pass the hostname/IP address of the external GDB target that you want to connect +to (_GDB target address_). + +In the case of using the [Open IoT SDK network environment](#networking-setup) +the GDB server runs inside a namespace and has the same IP address as the bridge +interface. + +``` +${MATTER_ROOT}/scripts/run_in_ns.sh ifconfig +``` + +The network namespace name and TAP interface name are also required then. + +The application with GDB Remote Connection Plugin runs in the background and +opens a telnet session in terminal. The telnet client connects to the port used +by the `FVP`. When the telnet process is terminated it will also terminate the +`FVP` instance. + +To exit the telnet session, type CTRL + ]. This changes the command +prompt to show as: + +``` +telnet> +``` + +Back in the terminal, type in the word 'close' to terminate the session. + +``` +telnet> close +``` + +> 💡 **Notes**: +> +> As you can see above, you will need to select the name of the example twice. +> This is because the debug task needs to launch the run task and currently VS +> code has no way of passing parameters between tasks. +> +> There are issues with debugging examples when the Docker container use the +> [network host](https://docs.docker.com/network/host/) and VPN connection is +> established. Changing routing negatively affects debugging process. It is +> recommended not to use VPN connections while debugging. + +## Specific examples + +### Build lock-app example and run it in the network namespace + +**Using CLI** + +``` +${MATTER_ROOT}/scripts/examples/openiotsdk_example.sh lock-app + +export TEST_NETWORK_NAME=OIStest + +sudo ${MATTER_ROOT}/scripts/setup/openiotsdk/network_setup.sh -n $TEST_NETWORK_NAME restart + +${MATTER_ROOT}/scripts/examples/scripts/run_in_ns.sh ${TEST_NETWORK_NAME}ns +${MATTER_ROOT}/scripts/examples/openiotsdk_example.sh -C run -n ${TEST_NETWORK_NAME}tap +lock-app +``` + +**Using the VSCode task** + +Build example: + +- Open the Command Palette: F1 +- Select `Tasks: Run Task` +- Select `Build Open IoT SDK example` +- Deny debug mode support `false` +- Deny LwIP debug logs support `false` +- Choose example name `lock-app` + +Setup network environment: + +- Open the Command Palette: F1 +- Select `Tasks: Run Task` +- Select `Setup Open IoT SDK network` +- Enter the network namespace name `OIStest` +- Choose command `restart` + +Run example: + +- Open the Command Palette: F1 +- Select `Tasks: Run Task` +- Select `Run Open IoT SDK example` +- Enter network namespace `OIStestns` +- Enter network interface `OIStesttap` +- Choose example name `lock-app` + +The example output should be seen in the terminal window. + +### Build lock-app example and execute its test in the network namespace + +**Using CLI** + +``` +${MATTER_ROOT}/scripts/examples/openiotsdk_example.sh lock-app + +export TEST_NETWORK_NAME=OIStest + +sudo ${MATTER_ROOT}/scripts/setup/openiotsdk/network_setup.sh -n $TEST_NETWORK_NAME restart + +${MATTER_ROOT}/scripts/examples/scripts/run_in_ns.sh ${TEST_NETWORK_NAME}ns +${MATTER_ROOT}/scripts/examples/openiotsdk_example.sh -C test -n ${TEST_NETWORK_NAME}tap +lock-app +``` + +**Using the VSCode task** + +Build example: + +- Open the Command Palette: F1 +- Select `Tasks: Run Task` +- Select `Build Open IoT SDK example` +- Deny debug mode support `false` +- Deny LwIP debug logs support `false` +- Choose example name `lock-app` + +Setup network environment: + +- Open the Command Palette: F1 +- Select `Tasks: Run Task` +- Select `Setup Open IoT SDK network` +- Enter the network namespace name `OIStest` +- Choose command `restart` + +Test example: + +- Open the Command Palette: F1 +- Select `Tasks: Run Task` +- Select `Test Open IoT SDK example` +- Enter network namespace `OIStestns` +- Enter network interface `OIStesttap` +- Choose example name `lock-app` + +### Build lock-app example in debug mode and debug it in the network namespace using the VSCode task + +Build example: + +- Open the Command Palette: F1 +- Select `Tasks: Run Task` +- Select `Build Open IoT SDK example` +- Confirm debug mode support `true` +- Deny LwIP debug logs support `false` +- Choose example name `lock-app` + +Setup network environment: + +- Open the Command Palette: F1 +- Select `Tasks: Run Task` +- Select `Setup Open IoT SDK network` +- Enter the network namespace name `OIStest` +- Choose command `restart` + +Debug example: + +- Click `Run and Debug` from the primary side menu or press + Ctrl+Shift+D +- Select `Debug Open IoT SDK example application` from the drop down list +- Click `Start Debugging`(green triangle) or press F5 +- Choose example name `lock-app` +- Enter GDB target address `10.200.1.2` +- Enter network namespace `OIStestns` +- Enter network interface `OIStesttap` +- Choose example name `lock-app` + +Use debug controls to debug the application. + +## Add new example + +This chapter describes how to add a new Matter example based on Open IoT SDK +platform. + +In the description below we use the placeholder `example_name` as the name of +the example to create. Replace it with the name of your example. + +> 💡 **Notes**: +> +> Remember to update the list of currently supported Matter examples at the top +> of this document. + +### Files structure + +A new example should be put into `examples//openiotsdk` directory. +It should contain: + +- application source files and headers in the `main` sub-directory +- application `CMakeLists.txt` file +- `.gitignore` file with with all sources to skip +- `README.md` file with example description +- additional directories with required configuration for used components. Use + `component_name-config` pattern, e.g `freertos-config` + +### Target name + +A new application target name should be created with +`chip-openiotsdk--example(_ns)` pattern. The `_ns` suffix is +required for [TF-M applications](#trusted-firmware-m). + +Example: + +``` +set(APP_TARGET chip-openiotsdk-new-example-example_ns) +``` + +### Example tools + +Add a new example name to the list in the +`examples/platform/openiotsdk/supported_examples.txt` file. After that the new +example is available in all necessary tools such as helper script +`scripts/examples/openiotsdk_example.sh` or VSCode tasks. + +Example: + +``` +... +example_name +... +``` + +### CI + +To add a new example to the Matter CI edit the +`.github/workflows/examples-openiotsdk.yaml` file and add the next step for +`openiotsdk` job step that build this example. + +Example: + +``` +... +- name: Build new-example example + id: build_new_example + timeout-minutes: 10 + run: | + scripts/examples/openiotsdk_example.sh new-example + .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ + openiotsdk release new-example \ + examples/new-example/openiotsdk/build/chip-openiotsdk-new-example-example.elf \ + /tmp/bloat_reports/ +... +``` diff --git a/docs/guides/openiotsdk_platform_overview.md b/docs/guides/openiotsdk_platform_overview.md index 211cd1af852179..f52d18b4e65aa0 100644 --- a/docs/guides/openiotsdk_platform_overview.md +++ b/docs/guides/openiotsdk_platform_overview.md @@ -68,17 +68,42 @@ Configuration of Mbed TLS is in Storage in Open IoT SDK is provided by [TDBStore](https://gitlab.arm.com/iot/open-iot-sdk/storage) which is a simple -Key-Value Storage over a block device. +key-value storage over a block device. + +If the application uses +[Trusted Firmware-M](https://tf-m-user-guide.trustedfirmware.org) then +[TF-M Protected Storage Service](https://tf-m-user-guide.trustedfirmware.org/integration_guide/services/tfm_ps_integration_guide.html) +can be used as an alternative for persistence in secure memory. --- **NOTE** -On the Corstone targets this currently is implemented as a RAM memory region -emulating a Flash device. This does not offer persistence between launches. +On `FVP` Corstone targets, memory content is lost after the program exits. To +achieve persistence memory regions used for the key-value storage must be saved +when the execution ends. --- +### Fast model persistent memory via files + +Two command lines options can be used to achieve persistence of a specific +memory regions: + +- `--dump` store the content of a memory region into a file when the model + ends its execution +- `--data` load the content of a file into a specific memory region at startup + +Use the `--list-memory` flag to see the list of instances and memory spaces for +your `FVP` model. + +Visit the +[FVP command line documentation](https://developer.arm.com/documentation/100966/1116/Getting-Started-with-Fixed-Virtual-Platforms/FVP-command-line-options) +for more details about these flags. + +Depending on your application, choose the right memory instance, memory space, +address and size. + ## Clocks Open IoT SDK does not currently offer an RTC. Matter configuration has been set diff --git a/docs/guides/openiotsdk_unit_tests.md b/docs/guides/openiotsdk_unit_tests.md new file mode 100644 index 00000000000000..7b9bba56707870 --- /dev/null +++ b/docs/guides/openiotsdk_unit_tests.md @@ -0,0 +1,249 @@ +# Matter Open IoT SDK unit tests + +The unit testing approach is to create a separate application with Matter test +library dependence. Each Matter project component implements the set of unit +tests that are located in the `test` directory, e.g. `src/inet/tests`. Those +sources are built as a static library that can be linked to the unit test +application separately or as a monolithic test library. The common Matter test +library collects all test cases and provides the engine based on +[Nest Labs Unit Test](https://github.com/nestlabs/nlunit-test) to run them in +the application. + +The Open IoT SDK unit tests implementation are located in the +`src/test_driver/openiotsdk/unit-tests` directory. This project builds a +separate application for each Matter component that is tested. It's built using +[Open IoT SDK](https://gitlab.arm.com/iot/open-iot-sdk) and run inside an +emulated target through the +[Arm FVP model for the Corstone-300 MPS3](https://developer.arm.com/downloads/-/arm-ecosystem-fvps). + +The list of currently supported Matter's component tests: + +``` +accesstest +AppTests +ASN1Tests +BDXTests +ChipCryptoTests +CoreTests +CredentialsTest +DataModelTests +InetLayerTests +MdnsTests +MessagingLayerTests +MinimalMdnsCoreTests +MinimalMdnsRecordsTests +MinimalMdnsRespondersTests +PlatformTests +RawTransportTests +RetransmitTests +SecureChannelTests +SetupPayloadTests +SupportTests +SystemLayerTests +TestShell +TransportLayerTests +UserDirectedCommissioningTests +``` + +Each application links the specific Matter test library, executes registered +tests and prints the result which is the number of tests that failed. + +## Environment setup + +The required environment is the same as for the Matter examples. For information +on how to set it up see +[Open IoT SDK examples environment](./openiotsdk_examples.md#environment-setup). + +## Configuration + +The configuration options are the same as for the Matter examples. For +information on how to configure unit-tests applications see +[Open IoT SDK examples configuration](./openiotsdk_examples.md#configuration). + +## Building + +The build process means creating a separate executable file for each Matter +tested component. It assumes the use of all supported test libraries and +creating independent applications from them. + +You can build unit tests by using a VSCode task or by calling the build script +directly from the command line. + +### Building using the VSCode task + +- Open the Command Palette: F1 +- Select `Tasks: Run Task` +- Select `Build Open IoT SDK unit-tests` +- Decide on debug mode support +- Decide on LwIP debug logs support +- Choose crypto algorithm +- Choose socket API + +This will call the script with the selected parameters. + +### Building using CLI + +You can call the script directly yourself. + +``` +${MATTER_ROOT}/scripts/examples/openiotsdk_example.sh unit-tests +``` + +Use `--help` to get more information about the script options. + +## Running + +Unit-tests applications are run independently. It runs in the background and +opens a telnet session. The telnet client connects to the port used by the +`FVP`. When the telnet process is terminated it will also terminate the `FVP` +instance. + +To exit the telnet session, type CTRL + ]. This changes the command +prompt to show as: + +``` +telnet> +``` + +Back in the terminal, type in the word 'close' to terminate the session. + +``` +telnet> close +``` + +You can run specific unit test by using a VSCode task or by calling the run +script directly from the command line. + +### Running using the VSCode task + +- Open the Command Palette: F1 +- Select `Tasks: Run Task` +- Select `Run Open IoT SDK unit-tests` +- Choose unit test name + +This will call the script with the selected example name. + +### Running using CLI + +You can call the script directly yourself. + +``` +${MATTER_ROOT}/scripts/examples/openiotsdk_example.sh -C run unit-tests +``` + +## Testing + +Run the Pytest integration test for the specific unit test application. + +The test result can be found in the +`src/test_driver/openiotsdk/integration-tests/unit-tests/test_report_.json` +file. + +You can execute the integration test for specific unit test by using a VSCode +task or by calling the run script directly from the command line. + +### Testing using the VSCode task + +- Open the Command Palette: F1 +- Select `Tasks: Run Task` +- Select `Test Open IoT SDK unit-tests` +- Choose unit test name + +This will call the scripts with the selected example name. + +### Testing using CLI + +You can call the script directly yourself. + +``` +${MATTER_ROOT}/scripts/examples/openiotsdk_example.sh -C test unit-tests +``` + +> 💡 **Notes**: +> +> Use `test` command without a specific test name, runs all supported unit +> tests: +> +> `${MATTER_ROOT}/scripts/examples/openiotsdk_example.sh -C test unit-tests` + +## Debugging + +Before debugging ensure the following: + +1. The debug environment is correctly setup: + [debugging setup](./openiotsdk_examples.md#debugging-setup). + +2. The unit tests are compiled with debug symbols enabled: + + For CLI: + + ``` + ${MATTER_ROOT}/scripts/examples/openiotsdk_example.sh -d true unit-tests + ``` + + For the VSCode task: + + ``` + => Use debug mode (true) + ``` + +You can debug the specific unit test by using a VSCode launch task: + +- Click `Run and Debug` from the primary side menu or press + Ctrl+Shift+D +- Select `Debug Open IoT SDK unit-tests application` from the drop down list +- Click `Start Debugging`(green triangle) or press F5 +- Choose unit test name twice + +As soon as a debugging session starts, the `DEBUG CONSOLE` panel is displayed +and shows the debugging output. Use debug controls to debug the current +application. + +The application with GDB Remote Connection Plugin runs in the background and +opens a telnet session in terminal. The telnet client connects to the port used +by the `FVP`. When the telnet process is terminated it will also terminate the +`FVP` instance. + +To exit the telnet session, type CTRL + ]. This changes the command +prompt to show as: + +``` +telnet> +``` + +Back in the terminal, type in the word 'close' to terminate the session. + +``` +telnet> close +``` + +> 💡 **Notes**: +> +> As you can see above, you will need to select the name of the unit test twice. +> This is because the debug task needs to launch the run task and currently VS +> code has no way of passing parameters between tasks. + +## Add existing Matter's component test + +To to add an existing Matter's component test to unit tests project, extend the +list in the `src/test_driver/openiotsdk/unit-tests/test_components.txt` file +with a test name (`test_name`). After that, the new test is built and available +in all necessary tools such as helper script +`scripts/examples/openiotsdk_example.sh` or VSCode tasks. + +Example: + +``` +... +test_name +... +``` + +> 💡 **Notes**: +> +> The existing Matter's component tests are built as a separate libraries. The +> `src/BUILD.gn` GN project collects them in the target group. Make sure that +> the test you want to add is not skipped for the Open IoT SDK platform. +> +> Remember to update the list of supported Matter's component tests at the top +> of this document. diff --git a/docs/guides/repl/Matter_Access_Control.ipynb b/docs/guides/repl/Matter_Access_Control.ipynb index 8bc0c44a72a5ac..4d0d1853af206e 100644 --- a/docs/guides/repl/Matter_Access_Control.ipynb +++ b/docs/guides/repl/Matter_Access_Control.ipynb @@ -733,7 +733,7 @@ " fabricIndex = 1,\n", " privilege = Clusters.AccessControl.Enums.AccessControlEntryPrivilegeEnum.kOperate,\n", " authMode = Clusters.AccessControl.Enums.AccessControlEntryAuthModeEnum.kCase,\n", - " targets = [ Clusters.AccessControl.Structs.Target(\n", + " targets = [ Clusters.AccessControl.Structs.AccessControlTargetStruct(\n", " endpoint = 1,\n", " ) ] ) )\n", "acl" diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter index 453ccbeb43063e..4d25f93d11f4d4 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter @@ -63,7 +63,11 @@ server cluster Groups = 4 { kGroupNames = 0x1; } - readonly attribute bitmap8 nameSupport = 0; + bitmap NameSupportBitmap : BITMAP8 { + kGroupNames = 0x80; + } + + readonly attribute NameSupportBitmap nameSupport = 0; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -565,7 +569,7 @@ server cluster AccessControl = 31 { kRemoved = 2; } - struct Target { + struct AccessControlTargetStruct { nullable cluster_id cluster = 0; nullable endpoint_no endpoint = 1; nullable devtype_id deviceType = 2; @@ -575,7 +579,7 @@ server cluster AccessControl = 31 { fabric_sensitive AccessControlEntryPrivilegeEnum privilege = 1; fabric_sensitive AccessControlEntryAuthModeEnum authMode = 2; nullable fabric_sensitive int64u subjects[] = 3; - nullable fabric_sensitive Target targets[] = 4; + nullable fabric_sensitive AccessControlTargetStruct targets[] = 4; fabric_idx fabricIndex = 254; } @@ -1256,7 +1260,7 @@ server cluster PowerSource = 47 { /** This cluster is used to manage global aspects of the Commissioning flow. */ server cluster GeneralCommissioning = 48 { - enum CommissioningError : ENUM8 { + enum CommissioningErrorEnum : ENUM8 { kOk = 0; kValueOutsideRange = 1; kInvalidAuthentication = 2; @@ -1264,7 +1268,7 @@ server cluster GeneralCommissioning = 48 { kBusyWithOtherAdmin = 4; } - enum RegulatoryLocationType : ENUM8 { + enum RegulatoryLocationTypeEnum : ENUM8 { kIndoor = 0; kOutdoor = 1; kIndoorOutdoor = 2; @@ -1277,8 +1281,8 @@ server cluster GeneralCommissioning = 48 { attribute access(write: administer) int64u breadcrumb = 0; readonly attribute BasicCommissioningInfo basicCommissioningInfo = 1; - readonly attribute RegulatoryLocationType regulatoryConfig = 2; - readonly attribute RegulatoryLocationType locationCapability = 3; + readonly attribute RegulatoryLocationTypeEnum regulatoryConfig = 2; + readonly attribute RegulatoryLocationTypeEnum locationCapability = 3; readonly attribute boolean supportsConcurrentConnection = 4; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; @@ -1293,23 +1297,23 @@ server cluster GeneralCommissioning = 48 { } request struct SetRegulatoryConfigRequest { - RegulatoryLocationType newRegulatoryConfig = 0; + RegulatoryLocationTypeEnum newRegulatoryConfig = 0; CHAR_STRING countryCode = 1; INT64U breadcrumb = 2; } response struct ArmFailSafeResponse = 1 { - CommissioningError errorCode = 0; + CommissioningErrorEnum errorCode = 0; CHAR_STRING debugText = 1; } response struct SetRegulatoryConfigResponse = 3 { - CommissioningError errorCode = 0; + CommissioningErrorEnum errorCode = 0; CHAR_STRING debugText = 1; } response struct CommissioningCompleteResponse = 5 { - CommissioningError errorCode = 0; + CommissioningErrorEnum errorCode = 0; CHAR_STRING debugText = 1; } @@ -1342,6 +1346,7 @@ server cluster NetworkCommissioning = 49 { k5g = 2; k6g = 3; k60g = 4; + k1g = 5; } bitmap Feature : BITMAP32 { @@ -1826,6 +1831,7 @@ server cluster WiFiNetworkDiagnostics = 54 { kN = 3; kAc = 4; kAx = 5; + kAh = 6; } bitmap Feature : BITMAP32 { @@ -3203,6 +3209,7 @@ server cluster Thermostat = 513 { kScheduleConfiguration = 0x8; kSetback = 0x10; kAutoMode = 0x20; + kLocalTemperatureNotExposed = 0x40; } bitmap ModeForSequence : BITMAP8 { @@ -5292,14 +5299,14 @@ endpoint 1 { } server cluster ColorControl { - ram attribute currentHue default = 0x00; - ram attribute currentSaturation default = 0x00; + persist attribute currentHue default = 0x00; + persist attribute currentSaturation default = 0x00; ram attribute remainingTime default = 0x0000; - ram attribute currentX default = 0x616B; - ram attribute currentY default = 0x607D; + persist attribute currentX default = 0x616B; + persist attribute currentY default = 0x607D; ram attribute driftCompensation; ram attribute compensationText; - ram attribute colorTemperatureMireds default = 0x00FA; + persist attribute colorTemperatureMireds default = 0x00FA; ram attribute colorMode default = 0x01; ram attribute options default = 0x00; ram attribute numberOfPrimaries; @@ -5332,18 +5339,18 @@ endpoint 1 { ram attribute colorPointBX; ram attribute colorPointBY; ram attribute colorPointBIntensity; - ram attribute enhancedCurrentHue default = 0x0000; - ram attribute enhancedColorMode default = 0x01; - ram attribute colorLoopActive default = 0x00; - ram attribute colorLoopDirection default = 0x00; - ram attribute colorLoopTime default = 0x0019; + persist attribute enhancedCurrentHue default = 0x0000; + persist attribute enhancedColorMode default = 0x01; + persist attribute colorLoopActive default = 0x00; + persist attribute colorLoopDirection default = 0x00; + persist attribute colorLoopTime default = 0x0019; ram attribute colorLoopStartEnhancedHue default = 0x2300; ram attribute colorLoopStoredEnhancedHue default = 0x0000; ram attribute colorCapabilities default = 0x1F; ram attribute colorTempPhysicalMinMireds default = 0x0000; ram attribute colorTempPhysicalMaxMireds default = 0xFEFF; ram attribute coupleColorTempToLevelMinMireds; - ram attribute startUpColorTemperatureMireds; + persist attribute startUpColorTemperatureMireds; ram attribute featureMap default = 0x1F; ram attribute clusterRevision default = 5; } diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index 518a2fedd0f0a6..5fe59d98097a7b 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -279,7 +279,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "bitmap8", + "type": "NameSupportBitmap", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -2967,7 +2967,7 @@ "code": 2, "mfgCode": null, "side": "server", - "type": "RegulatoryLocationType", + "type": "RegulatoryLocationTypeEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -2983,7 +2983,7 @@ "code": 3, "mfgCode": null, "side": "server", - "type": "RegulatoryLocationType", + "type": "RegulatoryLocationTypeEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -9265,7 +9265,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "bitmap8", + "type": "NameSupportBitmap", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -16083,7 +16083,7 @@ "side": "server", "type": "int8u", "included": 1, - "storageOption": "RAM", + "storageOption": "NVM", "singleton": 0, "bounded": 0, "defaultValue": "0x00", @@ -16099,7 +16099,7 @@ "side": "server", "type": "int8u", "included": 1, - "storageOption": "RAM", + "storageOption": "NVM", "singleton": 0, "bounded": 0, "defaultValue": "0x00", @@ -16131,7 +16131,7 @@ "side": "server", "type": "int16u", "included": 1, - "storageOption": "RAM", + "storageOption": "NVM", "singleton": 0, "bounded": 0, "defaultValue": "0x616B", @@ -16147,7 +16147,7 @@ "side": "server", "type": "int16u", "included": 1, - "storageOption": "RAM", + "storageOption": "NVM", "singleton": 0, "bounded": 0, "defaultValue": "0x607D", @@ -16195,7 +16195,7 @@ "side": "server", "type": "int16u", "included": 1, - "storageOption": "RAM", + "storageOption": "NVM", "singleton": 0, "bounded": 0, "defaultValue": "0x00FA", @@ -16723,7 +16723,7 @@ "side": "server", "type": "int16u", "included": 1, - "storageOption": "RAM", + "storageOption": "NVM", "singleton": 0, "bounded": 0, "defaultValue": "0x0000", @@ -16739,7 +16739,7 @@ "side": "server", "type": "enum8", "included": 1, - "storageOption": "RAM", + "storageOption": "NVM", "singleton": 0, "bounded": 0, "defaultValue": "0x01", @@ -16755,7 +16755,7 @@ "side": "server", "type": "int8u", "included": 1, - "storageOption": "RAM", + "storageOption": "NVM", "singleton": 0, "bounded": 0, "defaultValue": "0x00", @@ -16771,7 +16771,7 @@ "side": "server", "type": "int8u", "included": 1, - "storageOption": "RAM", + "storageOption": "NVM", "singleton": 0, "bounded": 0, "defaultValue": "0x00", @@ -16787,7 +16787,7 @@ "side": "server", "type": "int16u", "included": 1, - "storageOption": "RAM", + "storageOption": "NVM", "singleton": 0, "bounded": 0, "defaultValue": "0x0019", @@ -16899,7 +16899,7 @@ "side": "server", "type": "int16u", "included": 1, - "storageOption": "RAM", + "storageOption": "NVM", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -21815,7 +21815,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "bitmap8", + "type": "NameSupportBitmap", "included": 1, "storageOption": "RAM", "singleton": 0, diff --git a/examples/all-clusters-app/cc13x2x7_26x2x7/README.md b/examples/all-clusters-app/cc13x2x7_26x2x7/README.md index d34c57c36d6587..f965d3dd9abbcf 100644 --- a/examples/all-clusters-app/cc13x2x7_26x2x7/README.md +++ b/examples/all-clusters-app/cc13x2x7_26x2x7/README.md @@ -63,9 +63,8 @@ Some initial setup is necessary for preparing the build environment. This section will need to be done when migrating to new versions of the SDK. This guide assumes that the environment is linux based, and recommends Ubuntu 20.04. -- Download and install [SysConfig][sysconfig] ([recommended - version][sysconfig_recommended]). This can be done simply with the following - commands. +- Download and install [SysConfig][sysconfig]. This can be done simply with + the following commands. ``` $ cd ~ @@ -236,8 +235,6 @@ Additionally, we welcome any feedback. [matter-e2e-faq]: https://e2e.ti.com/support/wireless-connectivity/zigbee-thread-group/zigbee-and-thread/f/zigbee-thread-forum/1082428/faq-cc2652r7-matter----getting-started-guide [sysconfig]: https://www.ti.com/tool/SYSCONFIG -[sysconfig_recommended]: - https://software-dl.ti.com/ccs/esd/sysconfig/sysconfig-1.11.0_2225-setup.run [ti_thread_dnd]: https://www.ti.com/wireless-connectivity/thread/design-development.html [ot_border_router_setup]: https://openthread.io/guides/border-router/build diff --git a/examples/lighting-app/silabs/SiWx917/args.gni b/examples/all-clusters-app/cc13x4_26x4/.gn similarity index 63% rename from examples/lighting-app/silabs/SiWx917/args.gni rename to examples/all-clusters-app/cc13x4_26x4/.gn index 7157754d68f864..3d48789e30ab3d 100644 --- a/examples/lighting-app/silabs/SiWx917/args.gni +++ b/examples/all-clusters-app/cc13x4_26x4/.gn @@ -11,11 +11,18 @@ # 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") -silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain") -import("${chip_root}/src/platform/silabs/args.gni") +import("//build_overrides/build.gni") -app_data_model = "${chip_root}/examples/lighting-app/silabs/SiWx917/data_model:silabs-lighting" -chip_enable_ota_requestor = true +# 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 = "freertos" + + import("//args.gni") +} diff --git a/examples/all-clusters-app/cc13x4_26x4/BUILD.gn b/examples/all-clusters-app/cc13x4_26x4/BUILD.gn new file mode 100644 index 00000000000000..259fbdfa960eeb --- /dev/null +++ b/examples/all-clusters-app/cc13x4_26x4/BUILD.gn @@ -0,0 +1,125 @@ +# 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/openthread.gni") +import("//build_overrides/ti_simplelink_sdk.gni") + +import("${build_root}/config/defaults.gni") + +import("${chip_root}/src/platform/device.gni") + +import("${ti_simplelink_sdk_build_root}/ti_simplelink_executable.gni") +import("${ti_simplelink_sdk_build_root}/ti_simplelink_sdk.gni") + +assert(current_os == "freertos") + +project_dir = "${chip_root}/examples/all-clusters-app/cc13x4_26x4" + +ti_simplelink_sdk("sdk") { + include_dirs = [ "${project_dir}/main/include" ] + public_configs = [ ":all-clusters-app_config" ] +} + +ti_sysconfig("sysconfig") { + sources = [ "${project_dir}/chip.syscfg" ] + + outputs = [ + "ti_devices_config.c", + "ti_radio_config.c", + "ti_radio_config.h", + "ti_drivers_config.c", + "ti_drivers_config.h", + "ti_ble_config.c", + "ti_ble_config.h", + "ti_dmm_application_policy.c", + "ti_dmm_application_policy.h", + + # disabled until upstream generation is aligned + #"tiop_config.h", + #"tiop_config.c", + + # not traditional source files + #"ti_utils_build_linker.cmd.genlibs", + #"syscfg_c.rov.xs", + #"ti_utils_runtime_model.gv", + #"ti_utils_runtime_Makefile", + #"ti_ble_app_config.opt", + #"ti_build_config.opt", + ] + + public_configs = [ ":sdk_dmm_config" ] + + cflags = [ + "-Wno-comment", + "@" + rebase_path("${target_gen_dir}/sysconfig/ti_ble_app_config.opt", + root_build_dir), + "@" + rebase_path("${target_gen_dir}/sysconfig/ti_build_config.opt", + root_build_dir), + ] +} + +ti_simplelink_executable("all-clusters-app") { + output_name = "chip-${ti_simplelink_board}-all-clusters-example.out" + + sources = [ + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/binding-handler.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp", + "${chip_root}/examples/providers/DeviceInfoProviderImpl.cpp", + "${project_dir}/main/AppTask.cpp", + "${project_dir}/main/ClusterManager.cpp", + "${project_dir}/main/Globals.cpp", + "${project_dir}/main/ZclCallbacks.cpp", + "${project_dir}/main/main.cpp", + ] + + deps = [ + ":sdk", + ":sysconfig", + "${chip_root}/examples/all-clusters-app/all-clusters-common", + "${chip_root}/examples/platform/cc13x4_26x4:cc13x4_26x4-attestation-credentials", + "${chip_root}/src/lib", + ] + + if (chip_openthread_ftd) { + deps += [ "${chip_root}/third_party/openthread/repo:libopenthread-ftd" ] + } else { + deps += [ "${chip_root}/third_party/openthread/repo:libopenthread-mtd" ] + } + + include_dirs = [ + "${project_dir}", + "${project_dir}/main", + "${chip_root}/examples/all-clusters-app/all-clusters-common/include", + "${chip_root}/examples/providers/", + ] + + cflags = [ + "-Wno-implicit-fallthrough", + "-Wno-sign-compare", + "-Wconversion", + ] + + output_dir = root_out_dir +} + +group("cc13x4_26x4") { + deps = [ ":all-clusters-app" ] +} + +group("default") { + deps = [ ":cc13x4_26x4" ] +} diff --git a/examples/all-clusters-app/cc13x4_26x4/README.md b/examples/all-clusters-app/cc13x4_26x4/README.md new file mode 100644 index 00000000000000..3415f19f1a4c21 --- /dev/null +++ b/examples/all-clusters-app/cc13x4_26x4/README.md @@ -0,0 +1,306 @@ +# Matter All-clusters Example Application + +An example application showing the use of [Matter][matter] on the Texas +Instruments CC13XX_26XX family of Wireless MCUs. + +--- + +- [Matter All Clusters Example Application](#matter-all-clusters-example-application) + - [Introduction](#introduction) + - [Device UI](#device-ui) + - [Building](#building) + - [Preparation](#preparation) + - [Compilation](#compilation) + - [Programming](#programming) + - [Code Composer Studio](#code-composer-studio) + - [UniFlash](#uniflash) + - [Running the Example](#running-the-example) + - [Provisioning](#provisioning) + - [Bluetooth LE Advertising](#bluetooth-le-advertising) + - [Bluetooth LE Rendezvous](#bluetooth-le-rendezvous) + - [TI Support](#ti-support) + +--- + +## Introduction + +The CC13XX_26XX all clusters example application provides the basis to query and +run commands for all currently implemented Matter clusters. This uses the +open-source Matter implementation and the Texas Instruments SimpleLink™ CC13XX +and CC26XX software development kit. + +This example is enabled to build for CC1354P10 devices. + +The all-clusters example is intended to serve both as a means to explore the +workings of Matter, as well as a template for creating real products based on +the Texas Instruments devices. + +## Device UI + +| Action | Functionality | +| ------------------------------------------------ | --------------------------------------------- | +| Left Button (`BTN-1`) Press (more than 1000 ms) | Factory Reset | +| Right Button (`BTN-2`) Press (more than 1000 ms) | BLE Advertisement (Enable/Disable) | +| Red LED Solid Blinking State | Identify Trigger Effect in progress (`EP0/1`) | +| Red LED Off State | No Identify Trigger Effect in progress | +| Green LED Blinking State | Identify Trigger Effect in progress (`EP2`) | +| Green LED Off State | No Identify Trigger Effect in progress | + +## Building + +### Preparation + +Some initial setup is necessary for preparing the build environment. This +section will need to be done when migrating to new versions of the SDK. This +guide assumes that the environment is linux based, and recommends Ubuntu 20.04. + +- Download and install [SysConfig][sysconfig]. This can be done simply with + the following commands. + + ``` + $ cd ~ + $ `wget https://dr-download.ti.com/software-development/ide-configuration-compiler-or-debugger/MD-nsUM6f7Vvb/1.15.0.2826/sysconfig-1.15.0_2826-setup.run` + $ chmod +x sysconfig-1.15.0_2826-setup.run + $ ./sysconfig-1.15.0_2826-setup.run + ``` + +- Run the bootstrap script to setup the build environment. + + ``` + $ cd ~/connectedhomeip + $ source ./scripts/bootstrap.sh + + ``` + +### Compilation + +It is necessary to activate the environment in every new shell. Then run GN and +Ninja to build the executable. + +- Activate the build environment with the repository activate script. + + ``` + $ cd ~/connectedhomeip + $ source ./scripts/activate.sh + + ``` + +- Run the build to produce a default executable. By default on Linux both the + TI SimpleLink SDK and Sysconfig are located in a `ti` folder in the user's + home directory, and you must provide the absolute path to them. For example + `/home/username/ti/sysconfig_1.15.0`. On Windows the default directory is + `C:\ti`. Take note of this install path, as it will be used in the next + step. + + ``` + $ cd ~/connectedhomeip/examples/all-clusters-app/cc13x2x7_26x2x7 + OR + $ cd ~/connectedhomeip/examples/all-clusters-minimal-app/cc13x4_26x4 + $ gn gen out/debug --args="ti_sysconfig_root=\"$HOME/ti/sysconfig_1.15.0\"" + $ ninja -C out/debug + + ``` + + If you would like to define arguments on the command line you may add them + to the GN call. + + ``` + gn gen out/debug --args="ti_sysconfig_root=\"$HOME/ti/sysconfig_1.15.0\" target_defines=[\"CC13X4_26X4_ATTESTATION_CREDENTIALS=1\"]" + ``` + +## Programming + +Loading the built image onto a LaunchPad is supported through two methods; +Uniflash and Code Composer Studio (CCS). UniFlash can be used to load the image. +Code Composer Studio can be used to load the image and debug the source code. + +### Code Composer Studio + +Programming with CCS will allow for a full debug environment within the IDE. +This is accomplished by creating a target connection to the XDS110 debugger and +starting a project-less debug session. The CCS IDE will attempt to find the +source files on the local machine based on the debug information embedded within +the ELF. CCS may prompt you to find the source code if the image was built on +another machine or the source code is located in a different location than is +recorded within the ELF. + +Download and install [Code Composer Studio][ccs]. + +First open CCS and create a new workspace. + +Create a target connection (sometimes called the CCXML) for your target SoC and +debugger as described in the [Manual Method][ccs_manual_method] section of the +CCS User's Guide. + +Next initiate a project-less debug session as described in the [Manual +Launch][ccs_manual_launch] section of the CCS User's Guide. + +CCS should switch to the debug view described in the [After +Launch][ccs_after_launch] section of the User's Guide. The SoC core will likely +be disconnected and symbols will not be loaded. Connect to the core as described +in the [Debug View][ccs_debug_view] section of the User's Guide. Once the core +is connected, use the `Load` button on the toolbar to load the ELF image. + +Note that the default configuration of the CCXML uses 2-wire cJTAG instead of +the full 4-wire JTAG connection to match the default jumper configuration of the +LaunchPad. + +### UniFlash + +Uniflash is Texas Instrument's uniform programming tool for embedded processors. +This will allow you to erase, flash, and inspect the SoC without setting up a +debugging environment. + +Download and install [UniFlash][uniflash]. + +First open UniFlash. Debug probes connected to the computer will usually be +displayed under the Detected Devices due to the automatic device detection +feature. If your device does not show up in this view it my be disconnected, or +you may have to create a New Configuration. If you already have a CCXML for your +SoC and debug connection you can use that in the section at the bottom. Once +your device is selected, click the `Start` button within the section to launch +the session. + +Select the ELF image to load on the device with the `Browse` button. This file +is placed in the `out/debug` folder by this guide and ends with the `*.out` file +extension. For OTA enabled applications, the standalone image will instead end +with the `*-bim.hex` file extension. This this is a combined image with +application and and `BIM` included. The flag to enable or disable the OTA +feature is determined by "chip_enable_ota_requestor" in the application's +args.gni file. + +Finally click the `Load Image` button to load the executable image onto the +device. You should be able to see the log output over the XDS110 User UART. + +Note that programming the device through JTAG sets the Halt-in-Boot flag and may +cause issues when performing a software reset. This flag can be reset by +power-cycling the LaunchPad. + +## Running the Example + +By default the log output will be sent to the Application/User UART. Open a +terminal emulator to that port to see the output with the following options: + +| Parameter | Value | +| ------------ | -------- | +| Speed (baud) | `115200` | +| Data bits | `8` | +| Stop bits | `1` | +| Parity | `None` | +| Flow control | `None` | + +## Running the Example + +Once a device has been flashed with this example, it can now join and operate in +an existing Matter network. The following sections assume that a Matter network +is already active, and has at least one [OpenThread Border +Router][ot_border_router_setup]. + +For insight into what other components are needed to run this example, please +refer to our [Matter Getting Started Guide][matter-e2e-faq]. + +The steps below should be followed to commission the device onto the network and +control it once it has been commissioned. + +**Step 0** + +Set up the CHIP tool by following the instructions outlined in our [Matter +Getting Started Guide][matter-e2e-faq]. + +**Step 1** + +Commission the device onto the Matter network. Run the following command on the +CHIP tool: + +``` + +./chip-tool pairing ble-thread hex: 20202021 3840 + +``` + +Interacting with the application begins by enabling BLE advertisements and then +pairing the device into a Thread network. To provision this example onto a +Matter network, the device must be discoverable over Bluetooth LE. + +On the LaunchPad, press and hold the right button, labeled `BTN-2`, for more +than 1 second. Upon release, the Bluetooth LE advertising will begin. Once the +device is fully provisioned, BLE advertising will stop. + +Once the device has been successfully commissioned, you will see the following +message on the CHIP tool output: + +``` + +[1677648218.370754][39785:39790] CHIP:CTL: Received CommissioningComplete response, errorCode=0 +[1677648218.370821][39785:39790] CHIP:CTL: Successfully finished commissioning step 'SendComplete' + +``` + +An accompanying message will be seen from the device: + +``` + +Commissioning complete, notify platform driver to persist network credentials. + +``` + +**Step 2** + +Send commands to the all-cluster-app. Here are some example commands: + +Basic + +``` +./chip-tool basic read e.g. ./chip-tool basic read product-id 1 0 +``` + +Identify + +``` +./chip-tool identify identify e.g. ./chip-tool identify identify 100 1 1 +``` + +### Provisioning + +Interacting with the application begins by enabling BLE advertisements and then +pairing the device into a Thread network. + +#### Bluetooth LE Advertising + +To provision this example onto a Thread network, the device must be discoverable +over Bluetooth LE. BLE advertising is started by long pressing the right button +(greater than 1000ms), labeled `BTN-2` on the silkscreen. Once the device is +fully provisioned, BLE advertising will stop. + +#### Bluetooth LE Rendezvous + +Pairing this application with `ble-thread` can be done with any of the enabled +[CHIP Controller](../../../src/controller/README.md) applications. Use the +information printed on the console to aide in pairing the device. The controller +application can also be used to control the example app with the cluster +commands. + +## TI Support + +For technical support, please consider creating a post on TI's [E2E forum][e2e]. +Additionally, we welcome any feedback. + +[matter]: https://csa-iot.org/all-solutions/matter/ +[ccs]: https://www.ti.com/tool/CCSTUDIO +[ccs_after_launch]: + https://software-dl.ti.com/ccs/esd/documents/users_guide/ccs_debug-main.html?configuration#after-launch +[ccs_debug_view]: + https://software-dl.ti.com/ccs/esd/documents/users_guide/ccs_debug-main.html?configuration#debug-view +[ccs_manual_launch]: + https://software-dl.ti.com/ccs/esd/documents/users_guide/ccs_debug-main.html?configuration#manual-launch +[ccs_manual_method]: + https://software-dl.ti.com/ccs/esd/documents/users_guide/ccs_debug-main.html?configuration#manual-method +[e2e]: + https://e2e.ti.com/support/wireless-connectivity/zigbee-thread-group/zigbee-and-thread/f/zigbee-thread-forum +[matter-e2e-faq]: + https://e2e.ti.com/support/wireless-connectivity/zigbee-thread-group/zigbee-and-thread/f/zigbee-thread-forum/1082428/faq-cc2652r7-matter----getting-started-guide +[sysconfig]: https://www.ti.com/tool/SYSCONFIG +[ti_thread_dnd]: + https://www.ti.com/wireless-connectivity/thread/design-development.html +[ot_border_router_setup]: https://openthread.io/guides/border-router/build +[uniflash]: https://www.ti.com/tool/download/UNIFLASH diff --git a/examples/all-clusters-app/cc13x4_26x4/args.gni b/examples/all-clusters-app/cc13x4_26x4/args.gni new file mode 100644 index 00000000000000..a524bf977b9a23 --- /dev/null +++ b/examples/all-clusters-app/cc13x4_26x4/args.gni @@ -0,0 +1,50 @@ +# 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}/examples/platform/cc13x4_26x4/args.gni") + +ti_simplelink_sdk_target = get_label_info(":sdk", "label_no_toolchain") +ti_simplelink_sysconfig_target = + get_label_info(":sysconfig", "label_no_toolchain") + +ti_simplelink_board = "LP_EM_CC1354P10_6" + +# Size Optimizations +# use -Os instead of -Og, LWIP release build +optimize_debug_level = "s" +lwip_debug = false + +chip_enable_ota_requestor = false + +openthread_external_platform = "${chip_root}/third_party/openthread/platforms/cc13x4_26x4:libopenthread-cc13x4_cc26x4" + +# Disable CHIP Logging +#chip_progress_logging = false + +# Disable verbose logs for all-clusters app to save Flash +#chip_detail_logging = false +#chip_automation_logging = false + +# BLE options +chip_config_network_layer_ble = true + +# Disable lock tracking, since our FreeRTOS configuration does not set +# INCLUDE_xSemaphoreGetMutexHolder +chip_stack_lock_tracking = "none" + +matter_device_vid = "0xFFF1" +matter_device_pid = "0x8006" +matter_software_ver = "0x0001" +matter_software_ver_str = "1.0d1" diff --git a/examples/chef/efr32/build_overrides b/examples/all-clusters-app/cc13x4_26x4/build_overrides similarity index 100% rename from examples/chef/efr32/build_overrides rename to examples/all-clusters-app/cc13x4_26x4/build_overrides diff --git a/examples/all-clusters-app/cc13x4_26x4/chip.syscfg b/examples/all-clusters-app/cc13x4_26x4/chip.syscfg new file mode 100644 index 00000000000000..e9cb55c3e22f07 --- /dev/null +++ b/examples/all-clusters-app/cc13x4_26x4/chip.syscfg @@ -0,0 +1,242 @@ +/* + * + * Copyright (c) 2020 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. + */ + + +/* Modules */ +var AESCCM = scripting.addModule("/ti/drivers/AESCCM"); +var AESECB = scripting.addModule("/ti/drivers/AESECB"); +var Button = scripting.addModule("/ti/drivers/apps/Button"); +var LED = scripting.addModule("/ti/drivers/apps/LED"); +var NVS = scripting.addModule("/ti/drivers/NVS"); +var RF = scripting.addModule("/ti/drivers/RF"); +var RFDesign = scripting.addModule("ti/devices/radioconfig/rfdesign"); +var RFCustom = scripting.addModule("/ti/devices/radioconfig/custom"); +var TRNG = scripting.addModule("/ti/drivers/TRNG"); +var SHA2 = scripting.addModule("/ti/drivers/SHA2"); +var UART2 = scripting.addModule("/ti/drivers/UART2"); +var ble = scripting.addModule("/ti/ble5stack/ble"); +var dmm = scripting.addModule("/ti/dmm/dmm"); +var AESCTRDRBG = scripting.addModule("/ti/drivers/AESCTRDRBG"); +var ECDH = scripting.addModule("/ti/drivers/ECDH"); + +/* Instances */ +var AESCCM1 = AESCCM.addInstance(); +var AESECB1 = AESECB.addInstance(); +var AESECB2 = AESECB.addInstance(); +var Button1 = Button.addInstance(); +var Button2 = Button.addInstance(); +var NVS1 = NVS.addInstance(); +var NVS2 = NVS.addInstance(); +var SHA21 = SHA2.addInstance(); +var LED1 = LED.addInstance(); +var LED2 = LED.addInstance(); +var TRNG1 = TRNG.addInstance(); +var TRNG2 = TRNG.addInstance(); +var TRNG3 = TRNG.addInstance(); +var UART2 = UART2.addInstance(); +var AESCTRDRBG1 = AESCTRDRBG.addInstance(); +var ECDH1 = ECDH.addInstance(); + +AESCTRDRBG1.$name = "CONFIG_AESCTRDRBG_0"; + +AESCCM1.$name = "CONFIG_AESCCM0"; + +AESECB1.$name = "CONFIG_AESECB0"; +AESECB2.$name = "CONFIG_AESECB_1"; + +ECDH1.$name = "CONFIG_ECDH0"; + +/* Left Button */ +Button1.$name = "CONFIG_BTN_LEFT"; +Button1.$hardware = system.deviceData.board.components["BTN-1"]; +Button1.gpioPin.$name = "CONFIG_GPIO_BTN1"; +Button1.gpioPin.pull = "Pull Up"; +Button1.gpioPin.interruptTrigger = "Falling Edge"; + +/* Left Button */ +Button2.$name = "CONFIG_BTN_RIGHT"; +Button2.$hardware = system.deviceData.board.components["BTN-2"]; +Button2.gpioPin.$name = "CONFIG_GPIO_BTN2"; +Button2.gpioPin.pull = "Pull Up"; +Button2.gpioPin.interruptTrigger = "Falling Edge"; + +/* ======== CCFG ======== */ +var CCFG = scripting.addModule("/ti/devices/CCFG"); +const ccfgSettings = system.getScript("/ti/common/lprf_ccfg_settings.js").ccfgSettings; +for(var setting in ccfgSettings) +{ + CCFG[setting] = ccfgSettings[setting]; +} + +CCFG.enableCodeGeneration = true; + + +/* NVS */ +NVS1.$name = "CONFIG_NVSINTERNAL"; +NVS1.internalFlash.regionBase = 0xFB800; +NVS1.internalFlash.regionSize = 0x2800; + + +NVS2.$name = "CONFIG_NVSEXTERNAL"; +NVS2.nvsType = "External"; // NVS Region Type +NVS2.$hardware = system.deviceData.board.components.MX25R8035F; + +/* RF */ +/* if an antenna component exists, assign it to the rf instance */ +if (system.deviceData.board && system.deviceData.board.components.RF) { + RF.$hardware = system.deviceData.board.components.RF; +} + +const rfDesignSettings = system.getScript("/ti/common/lprf_rf_design_settings.js").rfDesignSettings; +for(var setting in rfDesignSettings) +{ + RFDesign[setting] = rfDesignSettings[setting]; +} + + + +/* Handling for RF frontend characterization */ +if(RFDesign.rfDesign.match(/LP_CC2652PSIP/)) +{ + RFCustom.ieee = ["ieee154p10"]; + var rfCodeExportConfig = RFCustom.radioConfigieee154p10.codeExportConfig +} +else +{ + RFCustom.ieee = ["ieee154"]; + var rfCodeExportConfig = RFCustom.radioConfigieee154.codeExportConfig +} + +var cmdList = [ + "cmdIeeeTx", + "cmdIeeeRx", + "cmdIeeeCsma", + "cmdIeeeEdScan", + "cmdIeeeRxAck", + "cmdTxTest" +]; + +rfCodeExportConfig.useConst = true; +rfCodeExportConfig.useMulti = true; +rfCodeExportConfig.symGenMethod = "Custom"; + +const deviceId = system.deviceData.deviceId; + +// Add high PA options if present +if(deviceId.match(/CC(265[12]R|2674R|1352R1|1354R)/)) +{ + cmdList.push("cmdRadioSetup"); + rfCodeExportConfig.cmdRadioSetup = "RF_cmdIeeeRadioSetup"; +} +else if(deviceId.match(/CC(265[12]P|2674P|1352P)/)) +{ + cmdList.push("cmdRadioSetupPa"); + rfCodeExportConfig.cmdRadioSetupPa = "RF_cmdIeeeRadioSetup"; + rfCodeExportConfig.paExport = "combined"; +} +else if(deviceId.match(/CC(265[34]|1354)P/)) +{ + cmdList.push("cmdRadioSetupPa"); + rfCodeExportConfig.cmdRadioSetupPa = "RF_cmdIeeeRadioSetup"; + // currently not characterized for high PA +} +else +{ + throw new Error("Could not match platform to any known platform types"); +} + +rfCodeExportConfig.cmdList_ieee_15_4 = cmdList; + +/* Red LED */ +LED1.$name = "CONFIG_LED_RED"; +LED1.$hardware = system.deviceData.board.components.LED_RED; +LED1.gpioPin.$name = "CONFIG_GPIO_RLED"; +LED1.gpioPin.mode = "Output"; +LED1.gpioPin.callbackFunction = ""; + +/* Green LED */ +LED2.$name = "CONFIG_LED_GREEN"; +LED2.$hardware = system.deviceData.board.components.LED_GREEN; +LED2.gpioPin.$name = "CONFIG_GPIO_GLED"; +LED2.gpioPin.mode = "Output"; +LED2.gpioPin.callbackFunction = ""; + +/* Debug UART */ +UART2.$hardware = system.deviceData.board.components.XDS110UART; +UART2.$name = "CONFIG_UART2_DEBUG"; + +/* TRNG */ +TRNG1.$name = "CONFIG_TRNG_0"; +TRNG2.$name = "CONFIG_TRNG_THREAD"; +TRNG3.$name = "CONFIG_TRNG_APP"; + +/* BLE */ +ble.addressMode = "ADDRMODE_RP_WITH_PUBLIC_ID"; +ble.maxConnNum = 1; +ble.numOfAdvSets = 1; +ble.lockProject = true; +ble.oneLibSizeOpt = true; +ble.maxPDUSize = 255; +ble.radioConfig.codeExportConfig.$name = "ti_devices_radioconfig_code_export_param1"; +ble.connUpdateParamsPeripheral.$name = "ti_ble5stack_general_ble_conn_update_params0"; +ble.connUpdateParamsPeripheral.reqMinConnInt = 30; +ble.connUpdateParamsPeripheral.reqMaxConnInt = 50; + +ble.advSet1.$name = "ti_ble5stack_broadcaster_advertisement_set0"; +ble.advSet1.advParam1.$name = "ti_ble5stack_broadcaster_advertisement_params0"; + +ble.rfDesign = "LP_EM_CC1354P10_6"; + +ble.thorPg = 2; +/* DMM */ +dmm.project = "ti_thread_thermostat_remote_display"; +dmm.stackRoles = ["blePeripheral","threadFTD"]; +dmm.lockStackRoles = true; +dmm.numApplicationStates = 10; +dmm.applicationState0 = "ANY"; +dmm.applicationState1 = "DMMPOLICY_BLE_IDLE"; +dmm.applicationState2 = "DMMPOLICY_BLE_ADV"; +dmm.applicationState3 = "DMMPOLICY_BLE_CONNECTING"; +dmm.applicationState4 = "DMMPOLICY_BLE_HIGH_BANDWIDTH"; +dmm.applicationState5 = "DMMPOLICY_BLE_CONNECTED"; +dmm.applicationState6 = "DMMPOLICY_BLE_OAD"; +dmm.applicationState7 = "DMMPOLICY_THREAD_IDLE"; +dmm.applicationState8 = "DMMPOLICY_THREAD_LINK_EST"; +dmm.applicationState9 = "DMMPOLICY_THREAD_DATA"; +dmm.policyArray.create(4); +dmm.policyArray[0].$name = "ti_dmm_policy_dmm_policy0"; +dmm.policyArray[0].blePeripheral.$name = "ti_dmm_policy_stack_dmm_stack_ble0"; +dmm.policyArray[0].blePeripheral.applicationStates = ["applicationState6"]; +dmm.policyArray[0].threadFTD.$name = "ti_dmm_policy_stack_dmm_stack_thread0"; +dmm.policyArray[0].threadFTD.pause = "DMMPOLICY_PAUSED"; +dmm.policyArray[1].$name = "ti_dmm_policy_dmm_policy1"; +dmm.policyArray[1].blePeripheral.$name = "ti_dmm_policy_stack_dmm_stack_ble1"; +dmm.policyArray[1].blePeripheral.applicationStates = ["applicationState3","applicationState4"]; +dmm.policyArray[1].blePeripheral.weight = 25; +dmm.policyArray[1].blePeripheral.appliedActivity = ["DMMPOLICY_APPLIED_ACTIVITY_BLE_CONNECTION"]; +dmm.policyArray[1].threadFTD.$name = "ti_dmm_policy_stack_dmm_stack_thread1"; +dmm.policyArray[2].$name = "ti_dmm_policy_dmm_policy2"; +dmm.policyArray[2].blePeripheral.$name = "ti_dmm_policy_stack_dmm_stack_ble2"; +dmm.policyArray[2].threadFTD.$name = "ti_dmm_policy_stack_dmm_stack_thread2"; +dmm.policyArray[2].threadFTD.weight = 30; +dmm.policyArray[2].threadFTD.applicationStates = ["applicationState8"]; +dmm.policyArray[2].threadFTD.appliedActivity = ["DMMPOLICY_APPLIED_ACTIVITY_ALL"]; +dmm.policyArray[3].$name = "ti_dmm_policy_dmm_policy3"; +dmm.policyArray[3].blePeripheral.$name = "ti_dmm_policy_stack_dmm_stack_ble3"; +dmm.policyArray[3].threadFTD.$name = "ti_dmm_policy_stack_dmm_stack_thread3"; +dmm.policyArray[3].threadFTD.weight = 1; diff --git a/examples/all-clusters-app/cc13x4_26x4/main/AppTask.cpp b/examples/all-clusters-app/cc13x4_26x4/main/AppTask.cpp new file mode 100644 index 00000000000000..b8fa3a21a4f9d8 --- /dev/null +++ b/examples/all-clusters-app/cc13x4_26x4/main/AppTask.cpp @@ -0,0 +1,402 @@ +/* + * + * Copyright (c) 2020 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 "AppConfig.h" +#include "AppEvent.h" +#include +#include + +#include "FreeRTOS.h" +#include "Globals.h" +#include +#include + +#include +#include + +#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR +#include +#include +#include +#include +#include +#endif +#include +#include + +#ifdef AUTO_PRINT_METRICS +#include +#endif +#include + +#include +#include + +/* syscfg */ +#include + +#define APP_TASK_STACK_SIZE (5000) +#define APP_TASK_PRIORITY 4 +#define APP_EVENT_QUEUE_SIZE 10 + +using namespace ::chip; +using namespace ::chip::Credentials; +using namespace ::chip::DeviceLayer; + +static TaskHandle_t sAppTaskHandle; +static QueueHandle_t sAppEventQueue; + +static Button_Handle sAppLeftHandle; +static Button_Handle sAppRightHandle; +static DeviceInfoProviderImpl sExampleDeviceInfoProvider; + +AppTask AppTask::sAppTask; + +constexpr EndpointId kNetworkCommissioningEndpointSecondary = 0xFFFE; + +#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR +static DefaultOTARequestor sRequestorCore; +static DefaultOTARequestorStorage sRequestorStorage; +static DefaultOTARequestorDriver sRequestorUser; +static BDXDownloader sDownloader; +static OTAImageProcessorImpl sImageProcessor; + +void InitializeOTARequestor(void) +{ + // Initialize and interconnect the Requestor and Image Processor objects + SetRequestorInstance(&sRequestorCore); + + sRequestorStorage.Init(Server::GetInstance().GetPersistentStorage()); + sRequestorCore.Init(Server::GetInstance(), sRequestorStorage, sRequestorUser, sDownloader); + sImageProcessor.SetOTADownloader(&sDownloader); + sDownloader.SetImageProcessorDelegate(&sImageProcessor); + sRequestorUser.Init(&sRequestorCore, &sImageProcessor); +} +#endif + +#ifdef AUTO_PRINT_METRICS +static void printMetrics(void) +{ + chip::DeviceLayer::ThreadMetrics *threadMetricsOut, *currThread; + uint64_t heapFree, heapUsed; + + DiagnosticDataProviderImpl::GetDefaultInstance().GetCurrentHeapUsed(heapUsed); + DiagnosticDataProviderImpl::GetDefaultInstance().GetCurrentHeapFree(heapFree); + DiagnosticDataProviderImpl::GetDefaultInstance().GetThreadMetrics(&threadMetricsOut); + + PLAT_LOG("Heap Metrics\n Heap Free: %d Heap Used: %d", (uint32_t) heapFree, (uint32_t) heapUsed); + + PLAT_LOG("Thread Metrics\n"); + + currThread = threadMetricsOut; + while (currThread) + { + PLAT_LOG("Task Name: %s ID: %d Stack Free Min: %d", currThread->name, (uint32_t) currThread->id, + (uint32_t) currThread->stackFreeMinimum); + + currThread = currThread->Next; + } + + DiagnosticDataProviderImpl::GetDefaultInstance().ReleaseThreadMetrics(threadMetricsOut); +} +#endif + +void DeviceEventCallback(const ChipDeviceEvent * event, intptr_t arg) +{ + switch (event->Type) + { + case DeviceEventType::kCHIPoBLEConnectionEstablished: + PLAT_LOG("CHIPoBLE connection established"); + break; + + case DeviceEventType::kCHIPoBLEConnectionClosed: + PLAT_LOG("CHIPoBLE disconnected"); + break; + + case DeviceEventType::kCommissioningComplete: + PLAT_LOG("Commissioning complete"); + break; + } + +#ifdef AUTO_PRINT_METRICS + printMetrics(); +#endif +} + +int AppTask::StartAppTask() +{ + int ret = 0; + + sAppEventQueue = xQueueCreate(APP_EVENT_QUEUE_SIZE, sizeof(AppEvent)); + if (sAppEventQueue == NULL) + { + PLAT_LOG("Failed to allocate app event queue"); + while (1) + ; + } + + // Start App task. + if (xTaskCreate(AppTaskMain, "APP", APP_TASK_STACK_SIZE / sizeof(StackType_t), NULL, APP_TASK_PRIORITY, &sAppTaskHandle) != + pdPASS) + { + PLAT_LOG("Failed to create app task"); + while (1) + ; + } + return ret; +} + +int AppTask::Init() +{ + LED_Params ledParams; + Button_Params buttonParams; + + cc13xx_26xxLogInit(); + + // Initialize LEDs + PLAT_LOG("Initialize LEDs"); + LED_init(); + + LED_Params_init(&ledParams); // default PWM LED + sAppRedHandle = LED_open(CONFIG_LED_RED, &ledParams); + LED_setOff(sAppRedHandle); + + LED_Params_init(&ledParams); // default PWM LED + sAppGreenHandle = LED_open(CONFIG_LED_GREEN, &ledParams); + LED_setOff(sAppGreenHandle); + + // Initialize buttons + PLAT_LOG("Initialize buttons"); + Button_init(); + + Button_Params_init(&buttonParams); + buttonParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGCLICKED; + buttonParams.longPressDuration = 1000U; // ms + sAppLeftHandle = Button_open(CONFIG_BTN_LEFT, &buttonParams); + Button_setCallback(sAppLeftHandle, ButtonLeftEventHandler); + + Button_Params_init(&buttonParams); + buttonParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGCLICKED; + buttonParams.longPressDuration = 1000U; // ms + sAppRightHandle = Button_open(CONFIG_BTN_RIGHT, &buttonParams); + Button_setCallback(sAppRightHandle, ButtonRightEventHandler); + + // Init Chip memory management before the stack + Platform::MemoryInit(); + + CHIP_ERROR ret = PlatformMgr().InitChipStack(); + if (ret != CHIP_NO_ERROR) + { + PLAT_LOG("PlatformMgr().InitChipStack() failed"); + while (1) + ; + } + + ret = ThreadStackMgr().InitThreadStack(); + if (ret != CHIP_NO_ERROR) + { + PLAT_LOG("ThreadStackMgr().InitThreadStack() failed"); + while (1) + ; + } + +#ifdef CONFIG_OPENTHREAD_MTD_SED + ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice); +#elif CONFIG_OPENTHREAD_MTD + ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice); +#else + ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router); +#endif + + if (ret != CHIP_NO_ERROR) + { + PLAT_LOG("ConnectivityMgr().SetThreadDeviceType() failed"); + while (1) + ; + } + + ret = PlatformMgr().StartEventLoopTask(); + if (ret != CHIP_NO_ERROR) + { + PLAT_LOG("PlatformMgr().StartEventLoopTask() failed"); + while (1) + ; + } + + ret = ThreadStackMgrImpl().StartThreadTask(); + if (ret != CHIP_NO_ERROR) + { + PLAT_LOG("ThreadStackMgr().StartThreadTask() failed"); + while (1) + ; + } + + // Init ZCL Data Model and start server + PLAT_LOG("Initialize Server"); + static chip::CommonCaseDeviceServerInitParams initParams; + (void) initParams.InitializeStaticResourcesBeforeServerInit(); + + // Initialize info provider + sExampleDeviceInfoProvider.SetStorageDelegate(initParams.persistentStorageDelegate); + SetDeviceInfoProvider(&sExampleDeviceInfoProvider); + + chip::Server::GetInstance().Init(initParams); + + ConfigurationMgr().LogDeviceConfig(); + + // Initialize device attestation config +#ifdef CC13X4_26X4_ATTESTATION_CREDENTIALS + SetDeviceAttestationCredentialsProvider(CC13X4_26X4::GetCC13X4_26X4DacProvider()); +#else + SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); +#endif + + // We only have network commissioning on endpoint 0. + emberAfEndpointEnableDisable(kNetworkCommissioningEndpointSecondary, false); + + // Register a function to receive events from the CHIP device layer. Note that calls to + // this function will happen on the CHIP event loop thread, not the app_main thread. + PlatformMgr().AddEventHandler(DeviceEventCallback, reinterpret_cast(nullptr)); + +#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR + InitializeOTARequestor(); +#endif + // QR code will be used with CHIP Tool + PrintOnboardingCodes(RendezvousInformationFlags(RendezvousInformationFlag::kBLE)); + + return 0; +} + +void AppTask::AppTaskMain(void * pvParameter) +{ + AppEvent event; + + sAppTask.Init(); + + while (1) + { + /* Task pend until we have stuff to do */ + if (xQueueReceive(sAppEventQueue, &event, portMAX_DELAY) == pdTRUE) + { + sAppTask.DispatchEvent(&event); + } + } +} + +void AppTask::PostEvent(const AppEvent * aEvent) +{ + if (xQueueSend(sAppEventQueue, aEvent, 0) != pdPASS) + { + /* Failed to post the message */ + } +} + +void AppTask::ButtonLeftEventHandler(Button_Handle handle, Button_EventMask events) +{ + AppEvent event; + event.Type = AppEvent::kEventType_ButtonLeft; + + if (events & Button_EV_CLICKED) + { + event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked; + } + else if (events & Button_EV_LONGCLICKED) + { + event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongClicked; + } + // button callbacks are in ISR context + if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS) + { + /* Failed to post the message */ + } +} + +void AppTask::ButtonRightEventHandler(Button_Handle handle, Button_EventMask events) +{ + AppEvent event; + event.Type = AppEvent::kEventType_ButtonRight; + + if (events & Button_EV_CLICKED) + { + event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked; + } + else if (events & Button_EV_LONGCLICKED) + { + event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongClicked; + } + // button callbacks are in ISR context + if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS) + { + /* Failed to post the message */ + } +} + +void AppTask::DispatchEvent(AppEvent * aEvent) +{ + switch (aEvent->Type) + { + case AppEvent::kEventType_ButtonLeft: + if (AppEvent::kAppEventButtonType_Clicked == aEvent->ButtonEvent.Type) + { + } + else if (AppEvent::kAppEventButtonType_LongClicked == aEvent->ButtonEvent.Type) + { + chip::Server::GetInstance().ScheduleFactoryReset(); + } + break; + + case AppEvent::kEventType_ButtonRight: + if (AppEvent::kAppEventButtonType_Clicked == aEvent->ButtonEvent.Type) + { + } + else if (AppEvent::kAppEventButtonType_LongClicked == aEvent->ButtonEvent.Type) + { + // Enable BLE advertisements + if (!ConnectivityMgr().IsBLEAdvertisingEnabled()) + { + if (Server::GetInstance().GetCommissioningWindowManager().OpenBasicCommissioningWindow() == CHIP_NO_ERROR) + { + PLAT_LOG("Enabled BLE Advertisements"); + } + else + { + PLAT_LOG("OpenBasicCommissioningWindow() failed"); + } + } + else + { + // Disable BLE advertisements + ConnectivityMgr().SetBLEAdvertisingEnabled(false); + PLAT_LOG("Disabled BLE Advertisements"); + } + } + break; + + case AppEvent::kEventType_AppEvent: + if (NULL != aEvent->Handler) + { + aEvent->Handler(aEvent); + } + break; + + case AppEvent::kEventType_None: + default: + break; + } +} diff --git a/examples/all-clusters-app/cc13x4_26x4/main/ClusterManager.cpp b/examples/all-clusters-app/cc13x4_26x4/main/ClusterManager.cpp new file mode 100644 index 00000000000000..7e6173a5a5b6a1 --- /dev/null +++ b/examples/all-clusters-app/cc13x4_26x4/main/ClusterManager.cpp @@ -0,0 +1,176 @@ +/* + * + * 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 "ClusterManager.h" +#include "Globals.h" +#include +#include +#include +#include +#include + +#ifdef AUTO_PRINT_METRICS +#include +#endif + +using namespace ::chip; +using namespace ::chip::Inet; +using namespace ::chip::System; +using namespace ::chip::DeviceLayer; + +constexpr uint32_t kIdentifyTimerDelayMS = 250; +constexpr uint32_t kIdentifyTimerDelayPerSec = 4; +ClusterManager ClusterManager::sCluster; + +#define ENDPOINT_ID_0 (0) +#define ENDPOINT_ID_1 (1) +#define ENDPOINT_ID_2 (2) + +void OnIdentifyTriggerEffect(Identify * identify) +{ + switch (identify->mCurrentEffectIdentifier) + { + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK: + PLAT_LOG("EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK"); + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE: + PLAT_LOG("EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE"); + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY: + PLAT_LOG("EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY"); + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE: + PLAT_LOG("EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE"); + break; + default: + PLAT_LOG("No identifier effect"); + break; + } + return; +} + +Identify gIdentify0 = { + chip::EndpointId{ 0 }, + [](Identify *) { PLAT_LOG("onIdentifyStart"); }, + [](Identify *) { PLAT_LOG("onIdentifyStop"); }, + EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED, + OnIdentifyTriggerEffect, +}; + +Identify gIdentify1 = { + chip::EndpointId{ 1 }, + [](Identify *) { PLAT_LOG("onIdentifyStart"); }, + [](Identify *) { PLAT_LOG("onIdentifyStop"); }, + EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED, + OnIdentifyTriggerEffect, +}; + +void ClusterManager::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) +{ + using namespace app::Clusters::OnOff::Attributes; + VerifyOrExit(attributeId == OnOff::Id, PLAT_LOG("Unhandled Attribute ID: '0x%04x", attributeId)); + VerifyOrExit(endpointId == ENDPOINT_ID_1 || endpointId == ENDPOINT_ID_2, + PLAT_LOG("Unexpected EndPoint ID: `0x%02x'", endpointId)); + + // At this point we can assume that value points to a bool value. + mEndpointOnOffState[endpointId - 1] = *value; + endpointId == ENDPOINT_ID_1 ? LED_write(sAppGreenHandle, *value) : LED_write(sAppRedHandle, *value); + +exit: + return; +} + +void ClusterManager::OnLevelControlAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) +{ + using namespace app::Clusters::LevelControl::Attributes; + bool onOffState = mEndpointOnOffState[endpointId - 1]; + uint8_t brightness = onOffState ? *value : 0; + + VerifyOrExit(brightness > 0, PLAT_LOG("Brightness set to 0, ignoring")); + VerifyOrExit(attributeId == CurrentLevel::Id, PLAT_LOG("Unhandled Attribute ID: '0x%04x", attributeId)); + VerifyOrExit(endpointId == ENDPOINT_ID_1 || endpointId == ENDPOINT_ID_2, + PLAT_LOG("Unexpected EndPoint ID: `0x%02x'", endpointId)); + + if (brightness > LED_BRIGHTNESS_MAX) + { + brightness = LED_BRIGHTNESS_MAX; + } + + endpointId == ENDPOINT_ID_1 ? LED_setOn(sAppGreenHandle, brightness) : LED_setOn(sAppRedHandle, brightness); + +exit: + return; +} + +void ClusterManager::OnColorControlAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) +{ + using namespace app::Clusters::ColorControl::Attributes; + + VerifyOrExit(attributeId == CurrentHue::Id || attributeId == CurrentSaturation::Id, + PLAT_LOG("Unhandled AttributeId ID: '0x%04x", attributeId)); + VerifyOrExit(endpointId == ENDPOINT_ID_1 || endpointId == ENDPOINT_ID_2, + PLAT_LOG("Unexpected EndPoint ID: `0x%02x'", endpointId)); + + if (endpointId == ENDPOINT_ID_1) + { + uint8_t hue, saturation; + if (attributeId == CurrentHue::Id) + { + hue = *value; + /* Read Current Saturation value when Attribute change callback for HUE Attribute */ + CurrentSaturation::Get(endpointId, &saturation); + } + else + { + saturation = *value; + /* Read Current Hue value when Attribute change callback for SATURATION Attribute */ + CurrentHue::Get(endpointId, &hue); + } + PLAT_LOG("Color Control triggered: Hue: %d Saturation: %d", hue, saturation); + } +exit: + return; +} + +void ClusterManager::OnIdentifyPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint16_t size, + uint8_t * value) +{ + if (attributeId == app::Clusters::Identify::Attributes::IdentifyTime::Id && size == 2) + { + uint16_t identifyTime; + memcpy(&identifyTime, value, size); + if (identifyTime) + { + // Currently we have no separate indicator LEDs on each endpoints. + // We are using LED1 for endpoint 0,1 and LED2 for endpoint 2 + if (endpointId == ENDPOINT_ID_2) + { + LED_startBlinking(sAppGreenHandle, kIdentifyTimerDelayMS, identifyTime * kIdentifyTimerDelayPerSec); + } + else + { + LED_startBlinking(sAppRedHandle, kIdentifyTimerDelayMS, identifyTime * kIdentifyTimerDelayPerSec); + } + } + else + { + bool onOffState; + endpointId == ENDPOINT_ID_0 ? onOffState = mEndpointOnOffState[0] : onOffState = mEndpointOnOffState[endpointId - 1]; + endpointId == ENDPOINT_ID_2 ? LED_write(sAppRedHandle, onOffState) : LED_write(sAppGreenHandle, onOffState); + } + } +} diff --git a/examples/all-clusters-app/cc13x4_26x4/main/Globals.cpp b/examples/all-clusters-app/cc13x4_26x4/main/Globals.cpp new file mode 100644 index 00000000000000..01a945e1a33d12 --- /dev/null +++ b/examples/all-clusters-app/cc13x4_26x4/main/Globals.cpp @@ -0,0 +1,22 @@ +/* + * + * 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 "Globals.h" + +LED_Handle sAppRedHandle; +LED_Handle sAppGreenHandle; diff --git a/examples/all-clusters-app/cc13x4_26x4/main/ZclCallbacks.cpp b/examples/all-clusters-app/cc13x4_26x4/main/ZclCallbacks.cpp new file mode 100644 index 00000000000000..09505504315cad --- /dev/null +++ b/examples/all-clusters-app/cc13x4_26x4/main/ZclCallbacks.cpp @@ -0,0 +1,82 @@ +/* + * + * Copyright (c) 2021 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. + */ + +/** + * @file + * This file implements the handler for data model messages. + */ + +#include "AppConfig.h" +#include "Globals.h" +#include + +#include "ClusterManager.h" + +#include +#include +#include +#include +#include +#include + +using namespace ::chip; +using namespace ::chip::app::Clusters; + +void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size, + uint8_t * value) +{ + EndpointId endpoint = attributePath.mEndpointId; + ClusterId clusterId = attributePath.mClusterId; + AttributeId attributeId = attributePath.mAttributeId; + PLAT_LOG("MatterPostAttributeChangeCallback - Cluster ID: " ChipLogFormatMEI + ", EndPoint ID: '0x%02x', Attribute ID: " ChipLogFormatMEI, + ChipLogValueMEI(clusterId), endpoint, ChipLogValueMEI(attributeId)); + + switch (clusterId) + { + case OnOff::Id: + ClusterMgr().OnOnOffPostAttributeChangeCallback(endpoint, attributeId, value); + break; + + case Identify::Id: + ClusterMgr().OnIdentifyPostAttributeChangeCallback(endpoint, attributeId, size, value); + break; + + case LevelControl::Id: + ClusterMgr().OnLevelControlAttributeChangeCallback(endpoint, attributeId, value); + break; + + case ColorControl::Id: + ClusterMgr().OnColorControlAttributeChangeCallback(endpoint, attributeId, value); + break; + default: + PLAT_LOG("Unhandled cluster ID: " ChipLogFormatMEI, ChipLogValueMEI(clusterId)); + break; + } +} +/** @brief OnOff Cluster Init + * + * This function is called when a specific cluster is initialized. It gives the + * application an opportunity to take care of cluster initialization procedures. + * It is called exactly once for each endpoint where cluster is present. + * + * @param endpoint Ver.: always + */ +void emberAfOnOffClusterInitCallback(EndpointId endpoint) +{ + // TODO: implement any additional Cluster Server init actions +} diff --git a/examples/all-clusters-app/cc13x4_26x4/main/include/AppConfig.h b/examples/all-clusters-app/cc13x4_26x4/main/include/AppConfig.h new file mode 100644 index 00000000000000..7f6ce19a384bdc --- /dev/null +++ b/examples/all-clusters-app/cc13x4_26x4/main/include/AppConfig.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2020 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. + */ + +#ifndef APP_CONFIG_H +#define APP_CONFIG_H + +#endif // APP_CONFIG_H diff --git a/examples/all-clusters-app/cc13x4_26x4/main/include/AppEvent.h b/examples/all-clusters-app/cc13x4_26x4/main/include/AppEvent.h new file mode 100644 index 00000000000000..1d1efd369495b6 --- /dev/null +++ b/examples/all-clusters-app/cc13x4_26x4/main/include/AppEvent.h @@ -0,0 +1,60 @@ +/* + * + * 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. + */ + +#ifndef APP_EVENT_H +#define APP_EVENT_H + +struct AppEvent; +typedef void (*EventHandler)(AppEvent *); + +struct AppEvent +{ + enum AppEventType + { + kEventType_None = 0, + kEventType_ButtonLeft, + kEventType_ButtonRight, + kEventType_AppEvent, + }; + + enum AppEventButtonType + { + kAppEventButtonType_None = 0, + kAppEventButtonType_Clicked, + kAppEventButtonType_LongClicked, + }; + + enum AppEventType Type; + + union + { + struct + { + enum AppEventButtonType Type; + } ButtonEvent; + + struct + { + void * Context; + } BoltLockEvent; + }; + + EventHandler Handler; +}; + +#endif // APP_EVENT_H diff --git a/examples/all-clusters-app/cc13x4_26x4/main/include/AppTask.h b/examples/all-clusters-app/cc13x4_26x4/main/include/AppTask.h new file mode 100644 index 00000000000000..002e1b3f70557c --- /dev/null +++ b/examples/all-clusters-app/cc13x4_26x4/main/include/AppTask.h @@ -0,0 +1,72 @@ +/* + * 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. + */ + +#ifndef APP_TASK_H +#define APP_TASK_H + +#include +#include + +#include "FreeRTOS.h" +#include "semphr.h" +#include "task.h" + +#include "AppEvent.h" + +#include + +class AppTask +{ +public: + int StartAppTask(); + static void AppTaskMain(void * pvParameter); + + void PostEvent(const AppEvent * event); + +private: + friend AppTask & GetAppTask(void); + + int Init(); + + void DispatchEvent(AppEvent * event); + + static void ButtonLeftEventHandler(Button_Handle handle, Button_EventMask events); + static void ButtonRightEventHandler(Button_Handle handle, Button_EventMask events); + static void TimerEventHandler(void * p_context); + + enum Function_t + { + kFunction_NoneSelected = 0, + kFunction_SoftwareUpdate = 0, + kFunction_FactoryReset, + + kFunction_Invalid + } Function; + + Function_t mFunction; + bool mFunctionTimerActive; + + static AppTask sAppTask; +}; + +inline AppTask & GetAppTask(void) +{ + return AppTask::sAppTask; +} + +#endif // APP_TASK_H diff --git a/examples/all-clusters-app/cc13x4_26x4/main/include/CHIPProjectConfig.h b/examples/all-clusters-app/cc13x4_26x4/main/include/CHIPProjectConfig.h new file mode 100644 index 00000000000000..939f01d93b8e6c --- /dev/null +++ b/examples/all-clusters-app/cc13x4_26x4/main/include/CHIPProjectConfig.h @@ -0,0 +1,132 @@ +/* + * 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. + * + */ + +#ifndef CHIP_PROJECT_CONFIG_H +#define CHIP_PROJECT_CONFIG_H + +#if BUILD_RELEASE // release build +// Note: Default Pairing/PIN/Serial Numbers being used. These should not be enabled for production builds +#endif // BUILD_RELEASE + +// Use a default pairing code if one hasn't been provisioned in flash. +#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 +#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 + +// Use a default pairing code if one hasn't been provisioned in flash. +#define CHIP_DEVICE_CONFIG_USE_TEST_PAIRING_CODE "CHIPUS" + +/** + * CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER + * + * Enables the use of a hard-coded default serial number if none + * is found in CHIP NV storage. + */ +#define CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER "TEST_SN" + +/** + * CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION + * + * The hardware version number assigned to device or product by the device vendor. This + * number is scoped to the device product id, and typically corresponds to a revision of the + * physical device, a change to its packaging, and/or a change to its marketing presentation. + * This value is generally *not* incremented for device software versions. + */ +#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1 + +/** + * Values set by args.gni: + * CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID + * CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID + * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING + * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION + */ + +/** + * CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE + * + * Enable support for CHIP-over-BLE (CHIPOBLE). + */ +#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE 1 + +/** + * CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC + * + * Enables synchronizing the device's real time clock with a remote CHIP Time service + * using the CHIP Time Sync protocol. + */ +// #define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1 + +/** + * CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE + * + * A size, in bytes, of the individual debug event logging buffer. + */ +#define CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE (512) + +#define MATTER_CC13XX_26XX_PLATFORM_LOG_ENABLED 1 + +/** + * CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + * + * Enable the OpenThread SRP client to allow for CHIP device discovery. + */ +#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT 1 + +/** + * CHIP_CONFIG_EVENT_LOGGING_DEFAULT_IMPORTANCE + * + * For a development build, set the default importance of events to be logged as Debug. + * Since debug is the lowest importance level, this means all standard, critical, info and + * debug importance level vi events get logged. + */ +#if BUILD_RELEASE +#define CHIP_CONFIG_EVENT_LOGGING_DEFAULT_IMPORTANCE chip::Profiles::DataManagement::Production +#else +#define CHIP_CONFIG_EVENT_LOGGING_DEFAULT_IMPORTANCE chip::Profiles::DataManagement::Debug +#endif // BUILD_RELEASE + +#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1 + +/** + * @def CHIP_IM_MAX_NUM_COMMAND_HANDLER + * + * @brief Defines the maximum number of CommandHandler, limits the number of active commands transactions on server. + */ +#define CHIP_IM_MAX_NUM_COMMAND_HANDLER 1 + +/** + * @def CHIP_IM_MAX_NUM_WRITE_HANDLER + * + * @brief Defines the maximum number of WriteHandler, limits the number of active write transactions on server. + */ +#define CHIP_IM_MAX_NUM_WRITE_HANDLER 1 + +// All clusters app has 3 group endpoints. This needs to defined here so that +// CHIP_CONFIG_MAX_GROUPS_PER_FABRIC is properly configured. +#define CHIP_CONFIG_MAX_GROUP_ENDPOINTS_PER_FABRIC 3 + +#endif // CHIP_PROJECT_CONFIG_H diff --git a/examples/all-clusters-app/cc13x4_26x4/main/include/ClusterManager.h b/examples/all-clusters-app/cc13x4_26x4/main/include/ClusterManager.h new file mode 100644 index 00000000000000..7a9a363980ca6f --- /dev/null +++ b/examples/all-clusters-app/cc13x4_26x4/main/include/ClusterManager.h @@ -0,0 +1,50 @@ +/* + * + * 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. + */ + +/** + * @file ClusterManager.h + * + * Declarations for the ClusterManager callbacks for this application + * + **/ + +#pragma once + +#include +#include +#include + +class ClusterManager +{ +public: + void OnOnOffPostAttributeChangeCallback(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value); + void OnLevelControlAttributeChangeCallback(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value); + void OnColorControlAttributeChangeCallback(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value); + void OnIdentifyPostAttributeChangeCallback(chip::EndpointId endpointId, chip::AttributeId attributeId, uint16_t size, + uint8_t * value); + +private: + friend ClusterManager & ClusterMgr(void); + bool mEndpointOnOffState[2]; + static ClusterManager sCluster; +}; + +inline ClusterManager & ClusterMgr(void) +{ + return ClusterManager::sCluster; +} diff --git a/examples/all-clusters-app/cc13x4_26x4/main/include/Globals.h b/examples/all-clusters-app/cc13x4_26x4/main/include/Globals.h new file mode 100644 index 00000000000000..4cdc0b69174d60 --- /dev/null +++ b/examples/all-clusters-app/cc13x4_26x4/main/include/Globals.h @@ -0,0 +1,35 @@ +/* + * + * Copyright (c) 2020 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 +// Logging +#ifdef __cplusplus +extern "C" { +#endif + +int cc13xx_26xxLogInit(void); +void cc13xx_26xxLog(const char * aFormat, ...); +#define PLAT_LOG(...) cc13xx_26xxLog(__VA_ARGS__); + +#ifdef __cplusplus +} +#endif +extern LED_Handle sAppRedHandle; +extern LED_Handle sAppGreenHandle; diff --git a/examples/all-clusters-app/cc13x4_26x4/main/include/OpenThreadConfig.h b/examples/all-clusters-app/cc13x4_26x4/main/include/OpenThreadConfig.h new file mode 100644 index 00000000000000..7d227258b1eaae --- /dev/null +++ b/examples/all-clusters-app/cc13x4_26x4/main/include/OpenThreadConfig.h @@ -0,0 +1,29 @@ +/* + * + * 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 + * Overrides to default OpenThread configuration. + * + */ + +#pragma once + +// Use the TI-supplied default platform configuration for remainder +#include "openthread-core-cc13x4_26x4-config.h" diff --git a/examples/all-clusters-app/cc13x4_26x4/main/main.cpp b/examples/all-clusters-app/cc13x4_26x4/main/main.cpp new file mode 100644 index 00000000000000..5a7f6a6b8df072 --- /dev/null +++ b/examples/all-clusters-app/cc13x4_26x4/main/main.cpp @@ -0,0 +1,104 @@ +/* + * + * 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. + */ + +#include +#include + +#include + +#include +#include + +#include + +/* Driver Header files */ +#include +#include +#include + +#include +#include +#include +#include + +#include +#define TOTAL_ICALL_HEAP_SIZE (0xd000) + +using namespace ::chip; +using namespace ::chip::Inet; +using namespace ::chip::DeviceLayer; + +__attribute__((section(".heap"))) uint8_t GlobalHeapZoneBuffer[TOTAL_ICALL_HEAP_SIZE]; +uint32_t heapSize = TOTAL_ICALL_HEAP_SIZE; + +// ================================================================================ +// FreeRTOS Callbacks +// ================================================================================ +extern "C" void vApplicationStackOverflowHook(void) +{ + while (1) + { + ; + } +} + +/* Wrapper functions for using the queue registry regardless of whether it is enabled or disabled */ +extern "C" void vQueueAddToRegistryWrapper(QueueHandle_t xQueue, const char * pcQueueName) +{ + /* This function is intentionally left empty as the Queue Registry is disabled */ +} + +extern "C" void vQueueUnregisterQueueWrapper(QueueHandle_t xQueue) +{ + /* This function is intentionally left empty as the Queue Registry is disabled */ +} + +// ================================================================================ +// Main Code +// ================================================================================ +int main(void) +{ + Board_init(); + bpool((void *) GlobalHeapZoneBuffer, TOTAL_ICALL_HEAP_SIZE); + + GPIO_init(); + + NVS_init(); + + ECDH_init(); + + ECDSA_init(); + + AESECB_init(); + + SHA2_init(); + + int ret = GetAppTask().StartAppTask(); + if (ret != 0) + { + // can't log until the kernel is started + // PLAT_LOG("GetAppTask().StartAppTask() failed"); + while (1) + ; + } + + vTaskStartScheduler(); + + // Should never get here. + while (1) + ; +} diff --git a/examples/chef/efr32/third_party/connectedhomeip b/examples/all-clusters-app/cc13x4_26x4/third_party/connectedhomeip similarity index 100% rename from examples/chef/efr32/third_party/connectedhomeip rename to examples/all-clusters-app/cc13x4_26x4/third_party/connectedhomeip diff --git a/examples/all-clusters-app/esp32/README.md b/examples/all-clusters-app/esp32/README.md index 6cb3f9093da13b..d7817027369adf 100644 --- a/examples/all-clusters-app/esp32/README.md +++ b/examples/all-clusters-app/esp32/README.md @@ -1,4 +1,4 @@ -# CHIP ESP32 All Clusters Example +# Matter ESP32 All Clusters Example A prototype application that demonstrates device commissioning and cluster control. diff --git a/examples/all-clusters-app/esp32/main/main.cpp b/examples/all-clusters-app/esp32/main/main.cpp index 94bf4afcc2e5e2..6d9c4e2c488af4 100644 --- a/examples/all-clusters-app/esp32/main/main.cpp +++ b/examples/all-clusters-app/esp32/main/main.cpp @@ -111,8 +111,10 @@ static void InitServer(intptr_t context) { Esp32AppServer::Init(&sCallbacks); // Init ZCL Data Model and CHIP App Server AND Initialize device attestation config +#if !(CHIP_DEVICE_CONFIG_ENABLE_WIFI && CHIP_DEVICE_CONFIG_ENABLE_THREAD) // We only have network commissioning on endpoint 0. emberAfEndpointEnableDisable(kNetworkCommissioningEndpointSecondary, false); +#endif CHIP_ERROR err = GetAppTask().LockInit(); if (err != CHIP_NO_ERROR) diff --git a/examples/all-clusters-app/esp32/partitions.csv b/examples/all-clusters-app/esp32/partitions.csv index efe7f6e9caf0e4..2211b30fa01a74 100644 --- a/examples/all-clusters-app/esp32/partitions.csv +++ b/examples/all-clusters-app/esp32/partitions.csv @@ -3,6 +3,6 @@ nvs, data, nvs, , 0x6000, otadata, data, ota, , 0x2000, phy_init, data, phy, , 0x1000, -ota_0, app, ota_0, , 1700K, -ota_1, app, ota_1, , 1700K, +ota_0, app, ota_0, , 1900K, +ota_1, app, ota_1, , 1900K, ot_storage, data, 0x3a, , 0x2000, diff --git a/examples/all-clusters-app/esp32/sdkconfig.defaults b/examples/all-clusters-app/esp32/sdkconfig.defaults index 42d30f4d170b8d..d824c990600f65 100644 --- a/examples/all-clusters-app/esp32/sdkconfig.defaults +++ b/examples/all-clusters-app/esp32/sdkconfig.defaults @@ -60,6 +60,9 @@ CONFIG_ESPTOOLPY_FLASHSIZE="4MB" # Disable softap support by default CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n +# Enable HKDF in mbedtls +CONFIG_MBEDTLS_HKDF_C=y + # This example uses the older version of RMT driver to work with both # idf-v4.4.3 and idf-v5.0, so supressing the warnings by setting below option CONFIG_RMT_SUPPRESS_DEPRECATE_WARN=y diff --git a/examples/all-clusters-app/esp32/sdkconfig_c3devkit.defaults b/examples/all-clusters-app/esp32/sdkconfig_c3devkit.defaults index 737935b166f98f..24d4fe754ebdc8 100644 --- a/examples/all-clusters-app/esp32/sdkconfig_c3devkit.defaults +++ b/examples/all-clusters-app/esp32/sdkconfig_c3devkit.defaults @@ -47,3 +47,6 @@ CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y # Serial Flasher config CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y CONFIG_ESPTOOLPY_FLASHSIZE="4MB" + +# Enable HKDF in mbedtls +CONFIG_MBEDTLS_HKDF_C=y diff --git a/examples/all-clusters-app/esp32/sdkconfig_m5stack.defaults b/examples/all-clusters-app/esp32/sdkconfig_m5stack.defaults index 6b3de5e5cfea51..d8d54e5eea03a8 100644 --- a/examples/all-clusters-app/esp32/sdkconfig_m5stack.defaults +++ b/examples/all-clusters-app/esp32/sdkconfig_m5stack.defaults @@ -63,4 +63,7 @@ CONFIG_ESPTOOLPY_FLASHSIZE="4MB" #enable it may cause GPIO ISR triggers continuously CONFIG_BTDM_CTRL_MODEM_SLEEP=n CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_ORIG=n -CONFIG_BTDM_CTRL_LPCLK_SEL_MAIN_XTAL=n \ No newline at end of file +CONFIG_BTDM_CTRL_LPCLK_SEL_MAIN_XTAL=n + +# Enable HKDF in mbedtls +CONFIG_MBEDTLS_HKDF_C=y diff --git a/examples/all-clusters-app/esp32/sdkconfig_m5stack_rpc.defaults b/examples/all-clusters-app/esp32/sdkconfig_m5stack_rpc.defaults index 5ffdd6672f1205..35fd87ed9f690c 100644 --- a/examples/all-clusters-app/esp32/sdkconfig_m5stack_rpc.defaults +++ b/examples/all-clusters-app/esp32/sdkconfig_m5stack_rpc.defaults @@ -67,4 +67,7 @@ CONFIG_ESPTOOLPY_FLASHSIZE="4MB" #enable it may cause GPIO ISR triggers continuously CONFIG_BTDM_CTRL_MODEM_SLEEP=n CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_ORIG=n -CONFIG_BTDM_CTRL_LPCLK_SEL_MAIN_XTAL=n \ No newline at end of file +CONFIG_BTDM_CTRL_LPCLK_SEL_MAIN_XTAL=n + +# Enable HKDF in mbedtls +CONFIG_MBEDTLS_HKDF_C=y diff --git a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter index e2d103ea7bd982..7570f498ab177a 100644 --- a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter +++ b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter @@ -57,7 +57,11 @@ server cluster Groups = 4 { kGroupNames = 0x1; } - readonly attribute bitmap8 nameSupport = 0; + bitmap NameSupportBitmap : BITMAP8 { + kGroupNames = 0x80; + } + + readonly attribute NameSupportBitmap nameSupport = 0; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -437,7 +441,7 @@ server cluster AccessControl = 31 { kRemoved = 2; } - struct Target { + struct AccessControlTargetStruct { nullable cluster_id cluster = 0; nullable endpoint_no endpoint = 1; nullable devtype_id deviceType = 2; @@ -447,7 +451,7 @@ server cluster AccessControl = 31 { fabric_sensitive AccessControlEntryPrivilegeEnum privilege = 1; fabric_sensitive AccessControlEntryAuthModeEnum authMode = 2; nullable fabric_sensitive int64u subjects[] = 3; - nullable fabric_sensitive Target targets[] = 4; + nullable fabric_sensitive AccessControlTargetStruct targets[] = 4; fabric_idx fabricIndex = 254; } @@ -1112,7 +1116,7 @@ server cluster PowerSource = 47 { /** This cluster is used to manage global aspects of the Commissioning flow. */ server cluster GeneralCommissioning = 48 { - enum CommissioningError : ENUM8 { + enum CommissioningErrorEnum : ENUM8 { kOk = 0; kValueOutsideRange = 1; kInvalidAuthentication = 2; @@ -1120,7 +1124,7 @@ server cluster GeneralCommissioning = 48 { kBusyWithOtherAdmin = 4; } - enum RegulatoryLocationType : ENUM8 { + enum RegulatoryLocationTypeEnum : ENUM8 { kIndoor = 0; kOutdoor = 1; kIndoorOutdoor = 2; @@ -1133,8 +1137,8 @@ server cluster GeneralCommissioning = 48 { attribute access(write: administer) int64u breadcrumb = 0; readonly attribute BasicCommissioningInfo basicCommissioningInfo = 1; - readonly attribute RegulatoryLocationType regulatoryConfig = 2; - readonly attribute RegulatoryLocationType locationCapability = 3; + readonly attribute RegulatoryLocationTypeEnum regulatoryConfig = 2; + readonly attribute RegulatoryLocationTypeEnum locationCapability = 3; readonly attribute boolean supportsConcurrentConnection = 4; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; @@ -1149,23 +1153,23 @@ server cluster GeneralCommissioning = 48 { } request struct SetRegulatoryConfigRequest { - RegulatoryLocationType newRegulatoryConfig = 0; + RegulatoryLocationTypeEnum newRegulatoryConfig = 0; CHAR_STRING countryCode = 1; INT64U breadcrumb = 2; } response struct ArmFailSafeResponse = 1 { - CommissioningError errorCode = 0; + CommissioningErrorEnum errorCode = 0; CHAR_STRING debugText = 1; } response struct SetRegulatoryConfigResponse = 3 { - CommissioningError errorCode = 0; + CommissioningErrorEnum errorCode = 0; CHAR_STRING debugText = 1; } response struct CommissioningCompleteResponse = 5 { - CommissioningError errorCode = 0; + CommissioningErrorEnum errorCode = 0; CHAR_STRING debugText = 1; } @@ -1198,6 +1202,7 @@ server cluster NetworkCommissioning = 49 { k5g = 2; k6g = 3; k60g = 4; + k1g = 5; } bitmap Feature : BITMAP32 { @@ -1622,6 +1627,7 @@ server cluster WiFiNetworkDiagnostics = 54 { kN = 3; kAc = 4; kAx = 5; + kAh = 6; } bitmap Feature : BITMAP32 { @@ -2725,6 +2731,7 @@ server cluster Thermostat = 513 { kScheduleConfiguration = 0x8; kSetback = 0x10; kAutoMode = 0x20; + kLocalTemperatureNotExposed = 0x40; } bitmap ModeForSequence : BITMAP8 { diff --git a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.zap b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.zap index 8ccacaf941e931..8bb9653d973323 100644 --- a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.zap +++ b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.zap @@ -1,5 +1,5 @@ { - "featureLevel": 92, + "featureLevel": 96, "creator": "zap", "keyValuePairs": [ { @@ -279,7 +279,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "bitmap8", + "type": "NameSupportBitmap", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -2930,7 +2930,7 @@ "code": 2, "mfgCode": null, "side": "server", - "type": "RegulatoryLocationType", + "type": "RegulatoryLocationTypeEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -2946,7 +2946,7 @@ "code": 3, "mfgCode": null, "side": "server", - "type": "RegulatoryLocationType", + "type": "RegulatoryLocationTypeEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -8736,7 +8736,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "bitmap8", + "type": "NameSupportBitmap", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -21187,7 +21187,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "bitmap8", + "type": "NameSupportBitmap", "included": 1, "storageOption": "RAM", "singleton": 0, diff --git a/examples/all-clusters-minimal-app/esp32/sdkconfig.defaults b/examples/all-clusters-minimal-app/esp32/sdkconfig.defaults index 42d30f4d170b8d..dcceac3858cd3e 100644 --- a/examples/all-clusters-minimal-app/esp32/sdkconfig.defaults +++ b/examples/all-clusters-minimal-app/esp32/sdkconfig.defaults @@ -63,3 +63,6 @@ CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n # This example uses the older version of RMT driver to work with both # idf-v4.4.3 and idf-v5.0, so supressing the warnings by setting below option CONFIG_RMT_SUPPRESS_DEPRECATE_WARN=y + +# Enable HKDF in mbedtls +CONFIG_MBEDTLS_HKDF_C=y diff --git a/examples/all-clusters-minimal-app/esp32/sdkconfig_c3devkit.defaults b/examples/all-clusters-minimal-app/esp32/sdkconfig_c3devkit.defaults index 737935b166f98f..24d4fe754ebdc8 100644 --- a/examples/all-clusters-minimal-app/esp32/sdkconfig_c3devkit.defaults +++ b/examples/all-clusters-minimal-app/esp32/sdkconfig_c3devkit.defaults @@ -47,3 +47,6 @@ CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y # Serial Flasher config CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y CONFIG_ESPTOOLPY_FLASHSIZE="4MB" + +# Enable HKDF in mbedtls +CONFIG_MBEDTLS_HKDF_C=y diff --git a/examples/all-clusters-minimal-app/esp32/sdkconfig_m5stack.defaults b/examples/all-clusters-minimal-app/esp32/sdkconfig_m5stack.defaults index 6b3de5e5cfea51..d8d54e5eea03a8 100644 --- a/examples/all-clusters-minimal-app/esp32/sdkconfig_m5stack.defaults +++ b/examples/all-clusters-minimal-app/esp32/sdkconfig_m5stack.defaults @@ -63,4 +63,7 @@ CONFIG_ESPTOOLPY_FLASHSIZE="4MB" #enable it may cause GPIO ISR triggers continuously CONFIG_BTDM_CTRL_MODEM_SLEEP=n CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_ORIG=n -CONFIG_BTDM_CTRL_LPCLK_SEL_MAIN_XTAL=n \ No newline at end of file +CONFIG_BTDM_CTRL_LPCLK_SEL_MAIN_XTAL=n + +# Enable HKDF in mbedtls +CONFIG_MBEDTLS_HKDF_C=y diff --git a/examples/all-clusters-minimal-app/esp32/sdkconfig_m5stack_rpc.defaults b/examples/all-clusters-minimal-app/esp32/sdkconfig_m5stack_rpc.defaults index 5ffdd6672f1205..35fd87ed9f690c 100644 --- a/examples/all-clusters-minimal-app/esp32/sdkconfig_m5stack_rpc.defaults +++ b/examples/all-clusters-minimal-app/esp32/sdkconfig_m5stack_rpc.defaults @@ -67,4 +67,7 @@ CONFIG_ESPTOOLPY_FLASHSIZE="4MB" #enable it may cause GPIO ISR triggers continuously CONFIG_BTDM_CTRL_MODEM_SLEEP=n CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_ORIG=n -CONFIG_BTDM_CTRL_LPCLK_SEL_MAIN_XTAL=n \ No newline at end of file +CONFIG_BTDM_CTRL_LPCLK_SEL_MAIN_XTAL=n + +# Enable HKDF in mbedtls +CONFIG_MBEDTLS_HKDF_C=y diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/BasicClientFragment.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/BasicClientFragment.kt index fcb88262a3d161..3f1692f6720795 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/BasicClientFragment.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/BasicClientFragment.kt @@ -137,7 +137,7 @@ class BasicClientFragment : Fragment() { showMessage("[Read Success] $attributeName: $value") } - }, devicePtr, listOf(ChipAttributePath.newInstance(endpointId.toLong(), clusterId, attributeId)), null, false, 0 /* imTimeoutMs */) + }, devicePtr, listOf(ChipAttributePath.newInstance(endpointId, clusterId, attributeId)), null, false, 0 /* imTimeoutMs */) } private fun makeAttributeList() { @@ -160,7 +160,7 @@ class BasicClientFragment : Fragment() { showMessage("Write ${attribute.name} success") } - }, devicePtr, listOf(AttributeWriteRequest.newInstance(addressUpdateFragment.endpointId.toLong(), clusterId, attribute.id, tlv, Optional.empty())), 0, 0) + }, devicePtr, listOf(AttributeWriteRequest.newInstance(addressUpdateFragment.endpointId, clusterId, attribute.id, tlv, Optional.empty())), 0, 0) } private fun showMessage(msg: String) { diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/MultiAdminClientFragment.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/MultiAdminClientFragment.kt index ffff2139f7d2d9..ed7ba6f4f692f0 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/MultiAdminClientFragment.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/MultiAdminClientFragment.kt @@ -8,10 +8,14 @@ import android.view.ViewGroup import androidx.fragment.app.Fragment import androidx.lifecycle.lifecycleScope import chip.devicecontroller.ChipDeviceController -import chip.devicecontroller.ClusterIDMapping +import chip.devicecontroller.ClusterIDMapping.AdministratorCommissioning import chip.devicecontroller.InvokeCallback import chip.devicecontroller.OpenCommissioningCallback +import chip.devicecontroller.ReportCallback +import chip.devicecontroller.model.ChipAttributePath +import chip.devicecontroller.model.ChipEventPath import chip.devicecontroller.model.InvokeElement +import chip.devicecontroller.model.NodeState import chip.tlv.AnonymousTag import chip.tlv.TlvWriter import com.google.chip.chiptool.ChipClient @@ -47,6 +51,9 @@ class MultiAdminClientFragment : Fragment() { binding.basicCommissioningMethodBtn.setOnClickListener { scope.launch { sendBasicCommissioningCommandClick() } } binding.enhancedCommissioningMethodBtn.setOnClickListener { scope.launch { sendEnhancedCommissioningCommandClick() } } binding.revokeBtn.setOnClickListener { scope.launch { sendRevokeCommandClick() } } + binding.readWindowStatusBtn.setOnClickListener { scope.launch { readAdministratorCommissioningClusterAttributeClick(AdministratorCommissioning.Attribute.WindowStatus) } } + binding.readAdminFabricIndexBtn.setOnClickListener { scope.launch { readAdministratorCommissioningClusterAttributeClick(AdministratorCommissioning.Attribute.AdminFabricIndex) } } + binding.readAdminVendorIdBtn.setOnClickListener { scope.launch { readAdministratorCommissioningClusterAttributeClick(AdministratorCommissioning.Attribute.AdminVendorId) } } return binding.root } @@ -137,9 +144,9 @@ class MultiAdminClientFragment : Fragment() { val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() - val invokeElement = InvokeElement.newInstance(0 - , ClusterIDMapping.AdministratorCommissioning.ID - , ClusterIDMapping.AdministratorCommissioning.Command.RevokeCommissioning.id + val invokeElement = InvokeElement.newInstance(ADMINISTRATOR_COMMISSIONING_CLUSTER_ENDPOINT_ID + , AdministratorCommissioning.ID + , AdministratorCommissioning.Command.RevokeCommissioning.id , tlvWriter.getEncoded(), null) deviceController.invoke(object: InvokeCallback { @@ -156,6 +163,25 @@ class MultiAdminClientFragment : Fragment() { }, getConnectedDevicePointer(), invokeElement, timedInvokeTimeout, 0) } + private suspend fun readAdministratorCommissioningClusterAttributeClick(attribute: AdministratorCommissioning.Attribute) { + val endpointId = ADMINISTRATOR_COMMISSIONING_CLUSTER_ENDPOINT_ID + val clusterId = AdministratorCommissioning.ID + val attributeId = attribute.id + val attributeName = attribute.name + val attributePath = ChipAttributePath.newInstance(endpointId, clusterId, attributeId) + deviceController.readAttributePath(object: ReportCallback { + override fun onReport(nodeState: NodeState?) { + val value = nodeState?.getEndpointState(endpointId)?.getClusterState(clusterId)?.getAttributeState(attributeId)?.value ?: "null" + Log.i(TAG,"read $attributeName: $value") + showMessage("read $attributeName: $value") + } + + override fun onError(attributePath: ChipAttributePath?, eventPath: ChipEventPath?, e: Exception) { + showMessage("read $attributeName - error : ${e?.message}") + } + }, getConnectedDevicePointer(), listOf(attributePath), 0) + } + private suspend fun getConnectedDevicePointer(): Long { return ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) } @@ -168,6 +194,7 @@ class MultiAdminClientFragment : Fragment() { companion object { private const val TAG = "MultiAdminClientFragment" + private const val ADMINISTRATOR_COMMISSIONING_CLUSTER_ENDPOINT_ID = 0 fun newInstance(): MultiAdminClientFragment = MultiAdminClientFragment() } } diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OnOffClientFragment.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OnOffClientFragment.kt index 9afb3aef436fa0..5088cd05036d76 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OnOffClientFragment.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OnOffClientFragment.kt @@ -98,7 +98,7 @@ class OnOffClientFragment : Fragment() { val clusterId = OnOff.ID val attributeId = OnOff.Attribute.OnOff.id - val attributePath = ChipAttributePath.newInstance(endpointId.toLong(), clusterId, attributeId) + val attributePath = ChipAttributePath.newInstance(endpointId, clusterId, attributeId) ChipClient.getDeviceController(requireContext()).readPath(object: ReportCallback { override fun onError(attributePath: ChipAttributePath?, eventPath: ChipEventPath?, ex: java.lang.Exception) { @@ -140,7 +140,7 @@ class OnOffClientFragment : Fragment() { val clusterId = OnOff.ID val attributeId = OnOff.Attribute.OnOff.id - val attributePath = ChipAttributePath.newInstance(endpointId.toLong(), clusterId, attributeId) + val attributePath = ChipAttributePath.newInstance(endpointId, clusterId, attributeId) val subscriptionEstablishedCallback = SubscriptionEstablishedCallback { @@ -209,13 +209,13 @@ class OnOffClientFragment : Fragment() { // TODO : Need to be implement poj-to-tlv val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) - tlvWriter.put(ContextSpecificTag(0), binding.levelBar.progress.toUInt()) - tlvWriter.put(ContextSpecificTag(1), 0u) - tlvWriter.put(ContextSpecificTag(2), 0u) - tlvWriter.put(ContextSpecificTag(3), 0u) + tlvWriter.put(ContextSpecificTag(LevelControl.MoveToLevelCommandField.Level.id), binding.levelBar.progress.toUInt()) + tlvWriter.put(ContextSpecificTag(LevelControl.MoveToLevelCommandField.OptionsMask.id), 0u) + tlvWriter.put(ContextSpecificTag(LevelControl.MoveToLevelCommandField.OptionsOverride.id), 0u) + tlvWriter.put(ContextSpecificTag(LevelControl.MoveToLevelCommandField.TransitionTime.id), 0u) tlvWriter.endStructure() - val invokeElement = InvokeElement.newInstance(addressUpdateFragment.endpointId.toLong() + val invokeElement = InvokeElement.newInstance(addressUpdateFragment.endpointId , LevelControl.ID , LevelControl.Command.MoveToLevel.id , tlvWriter.getEncoded(), null) @@ -239,7 +239,7 @@ class OnOffClientFragment : Fragment() { val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() - val invokeElement = InvokeElement.newInstance(addressUpdateFragment.endpointId.toLong() + val invokeElement = InvokeElement.newInstance(addressUpdateFragment.endpointId , OnOff.ID , commandId.id , tlvWriter.getEncoded(), null) diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OpCredClientFragment.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OpCredClientFragment.kt index bf8e929472833f..02dc9912c5597f 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OpCredClientFragment.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OpCredClientFragment.kt @@ -15,11 +15,16 @@ import com.google.chip.chiptool.databinding.OpCredClientFragmentBinding import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch -import chip.devicecontroller.ClusterIDMapping.* +import chip.devicecontroller.ClusterIDMapping.OperationalCredentials +import chip.devicecontroller.InvokeCallback import chip.devicecontroller.ReportCallback import chip.devicecontroller.model.ChipAttributePath import chip.devicecontroller.model.ChipEventPath +import chip.devicecontroller.model.InvokeElement import chip.devicecontroller.model.NodeState +import chip.tlv.AnonymousTag +import chip.tlv.ContextSpecificTag +import chip.tlv.TlvWriter class OpCredClientFragment : Fragment() { private val deviceController: ChipDeviceController @@ -47,6 +52,8 @@ class OpCredClientFragment : Fragment() { binding.readSupportedFabricBtn.setOnClickListener { scope.launch { readClusterAttribute(OperationalCredentials.Attribute.SupportedFabrics) } } binding.readCommissionedFabricBtn.setOnClickListener { scope.launch { readClusterAttribute(OperationalCredentials.Attribute.CommissionedFabrics) } } + binding.readFabricsBtn.setOnClickListener { scope.launch { readClusterAttribute(OperationalCredentials.Attribute.Fabrics) } } + binding.removeFabricsBtn.setOnClickListener { scope.launch { sendRemoveFabricsBtnClick(binding.fabricIndexEd.text.toString().toUInt()) } } return binding.root } @@ -96,7 +103,33 @@ class OpCredClientFragment : Fragment() { showMessage("OpCred $attributeName value: $value") } - }, devicePtr, listOf(ChipAttributePath.newInstance(endpointId.toLong(), clusterId, attributeId)), null, false, 0 /* imTimeoutMs */) + }, devicePtr, listOf(ChipAttributePath.newInstance(endpointId, clusterId, attributeId)), null, false, 0 /* imTimeoutMs */) + } + + private suspend fun sendRemoveFabricsBtnClick(fabricIndex: UInt) { + val devicePtr = ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + // TODO : Need to be implement poj-to-tlv + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + tlvWriter.put(ContextSpecificTag(OperationalCredentials.RemoveFabricCommandField.FabricIndex.id), fabricIndex) + tlvWriter.endStructure() + val invokeElement = InvokeElement.newInstance(addressUpdateFragment.endpointId + , OperationalCredentials.ID + , OperationalCredentials.Command.RemoveFabric.id + , tlvWriter.getEncoded(), null) + + deviceController.invoke(object: InvokeCallback { + override fun onError(ex: Exception?) { + showMessage("RemoveFabric failure $ex") + Log.e(TAG, "RemoveFabric failure", ex) + } + + override fun onResponse(invokeElement: InvokeElement?, successCode: Long) { + Log.e(TAG, "onResponse : $invokeElement, Code : $successCode") + showMessage("RemoveFabric success") + } + + }, devicePtr, invokeElement, 0, 0) } private fun showMessage(msg: String) { diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/SensorClientFragment.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/SensorClientFragment.kt index 8ccb2591e45e8f..8abe61329a9727 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/SensorClientFragment.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/SensorClientFragment.kt @@ -153,7 +153,7 @@ class SensorClientFragment : Fragment() { val device = ChipClient.getConnectedDevicePointer(requireContext(), deviceId) val callback = makeReadCallback(clusterName, false) - deviceController.readAttributePath(callback, device, listOf(ChipAttributePath.newInstance(endpointId.toLong(), clusterId, attributeId)), 0) + deviceController.readAttributePath(callback, device, listOf(ChipAttributePath.newInstance(endpointId, clusterId, attributeId)), 0) } catch (ex: Exception) { Log.d(TAG, "Failed to read the sensor : ", ex) showMessage(R.string.sensor_client_read_error_text, ex.toString()) @@ -170,7 +170,7 @@ class SensorClientFragment : Fragment() { val device = ChipClient.getConnectedDevicePointer(requireContext(), deviceId) val callback = makeReadCallback(clusterName, true) - deviceController.subscribeToAttributePath({ Log.d(TAG, "onSubscriptionEstablished") }, callback, device, listOf(ChipAttributePath.newInstance(endpointId.toLong(), clusterId, attributeId)), MIN_REFRESH_PERIOD_S, MAX_REFRESH_PERIOD_S, 0) + deviceController.subscribeToAttributePath({ Log.d(TAG, "onSubscriptionEstablished") }, callback, device, listOf(ChipAttributePath.newInstance(endpointId, clusterId, attributeId)), MIN_REFRESH_PERIOD_S, MAX_REFRESH_PERIOD_S, 0) subscribedDevicePtr = device } catch (ex: Exception) { Log.d(TAG, "Failed to subscribe", ex) diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/util/TlvParseUtil.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/util/TlvParseUtil.kt index 7ed17a0a8068bd..efe14a9f100ebb 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/util/TlvParseUtil.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/util/TlvParseUtil.kt @@ -56,8 +56,7 @@ object TlvParseUtil { fun encode(input: ByteArray): ByteArray { val tlvWriter = TlvWriter() - val inputByteStringValue = ByteString.copyFrom(input); - tlvWriter.put(AnonymousTag, inputByteStringValue) + tlvWriter.put(AnonymousTag, input) return tlvWriter.getEncoded(); } diff --git a/examples/android/CHIPTool/app/src/main/res/layout/multi_admin_client_fragment.xml b/examples/android/CHIPTool/app/src/main/res/layout/multi_admin_client_fragment.xml index 95e5458f8164b0..7066cf892626f7 100644 --- a/examples/android/CHIPTool/app/src/main/res/layout/multi_admin_client_fragment.xml +++ b/examples/android/CHIPTool/app/src/main/res/layout/multi_admin_client_fragment.xml @@ -80,12 +80,45 @@ app:layout_constraintEnd_toEndOf="parent" android:text="@string/revoke_btn_text" /> +