From b85c5ec60a1f9b35bcbe37b5b18c04e1d695db1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20Kr=C3=B3lik?= <66667989+Damian-Nordic@users.noreply.github.com> Date: Mon, 22 Aug 2022 16:40:44 +0200 Subject: [PATCH 01/15] [nrfconnect] Fix Light Switch Example build (#22036) The example was not built in CI, so we missed the build breakage. Signed-off-by: Damian Krolik Signed-off-by: Damian Krolik --- .github/workflows/examples-nrfconnect.yaml | 54 +++++++++---------- .../nrfconnect/CMakeLists.txt | 2 +- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/.github/workflows/examples-nrfconnect.yaml b/.github/workflows/examples-nrfconnect.yaml index 3c110ce1ccece7..5da513c70de6ba 100644 --- a/.github/workflows/examples-nrfconnect.yaml +++ b/.github/workflows/examples-nrfconnect.yaml @@ -95,15 +95,6 @@ jobs: nrfconnect nrf52840dk_nrf52840 lock-app \ examples/lock-app/nrfconnect/build/zephyr/zephyr.elf \ /tmp/bloat_reports/ - - name: Build example nRF Connect SDK Lighting App on nRF52840 DK - if: github.event_name == 'push' || steps.changed_paths.outputs.nrfconnect == 'true' - timeout-minutes: 15 - run: | - scripts/examples/nrfconnect_example.sh lighting-app nrf52840dk_nrf52840 - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - nrfconnect nrf52840dk_nrf52840 lighting-app \ - examples/lighting-app/nrfconnect/build/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - name: Build example nRF Connect SDK Lighting App on nRF52840 Dongle if: github.event_name == 'push' || steps.changed_paths.outputs.nrfconnect == 'true' timeout-minutes: 15 @@ -122,6 +113,15 @@ jobs: nrfconnect nrf52840dk_nrf52840+rpc lighting-app \ examples/lighting-app/nrfconnect/build/zephyr/zephyr.elf \ /tmp/bloat_reports/ + - name: Build example nRF Connect SDK Light Switch App on nRF52840 DK + if: github.event_name == 'push' || steps.changed_paths.outputs.nrfconnect == 'true' + timeout-minutes: 15 + run: | + scripts/examples/nrfconnect_example.sh light-switch-app nrf52840dk_nrf52840 + .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ + nrfconnect nrf52840dk_nrf52840 light-switch-app \ + examples/light-switch-app/nrfconnect/build/zephyr/zephyr.elf \ + /tmp/bloat_reports/ - name: Build example nRF Connect SDK Shell on nRF52840 DK if: github.event_name == 'push' || steps.changed_paths.outputs.shell == 'true' timeout-minutes: 15 @@ -140,24 +140,6 @@ jobs: nrfconnect nrf52840dk_nrf52840 pigweed-app \ examples/pigweed-app/nrfconnect/build/zephyr/zephyr.elf \ /tmp/bloat_reports/ - - name: Build example nRF Connect SDK Lock App on nRF5340 DK - if: github.event_name == 'push' || steps.changed_paths.outputs.nrfconnect == 'true' - timeout-minutes: 15 - run: | - scripts/examples/nrfconnect_example.sh lock-app nrf5340dk_nrf5340_cpuapp - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - nrfconnect nrf5340dk_nrf5340_cpuapp lock-app \ - examples/lock-app/nrfconnect/build/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - name: Build example nRF Connect SDK Lighting App on nRF5340 DK - if: github.event_name == 'push' || steps.changed_paths.outputs.nrfconnect == 'true' - timeout-minutes: 15 - run: | - scripts/examples/nrfconnect_example.sh lighting-app nrf5340dk_nrf5340_cpuapp - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - nrfconnect nrf5340dk_nrf5340_cpuapp lighting-app \ - examples/lighting-app/nrfconnect/build/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - name: Build example nRF Connect SDK Pump App on nRF52840 DK if: github.event_name == 'push' || steps.changed_paths.outputs.nrfconnect == 'true' timeout-minutes: 15 @@ -192,6 +174,24 @@ jobs: nrfconnect nrf52840dk_nrf52840 all-clusters-minimal-app \ examples/all-clusters-minimal-app/nrfconnect/build/zephyr/zephyr.elf \ /tmp/bloat_reports/ + - name: Build example nRF Connect SDK Lock App on nRF5340 DK + if: github.event_name == 'push' || steps.changed_paths.outputs.nrfconnect == 'true' + timeout-minutes: 15 + run: | + scripts/examples/nrfconnect_example.sh lock-app nrf5340dk_nrf5340_cpuapp + .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ + nrfconnect nrf5340dk_nrf5340_cpuapp lock-app \ + examples/lock-app/nrfconnect/build/zephyr/zephyr.elf \ + /tmp/bloat_reports/ + - name: Build example nRF Connect SDK Lighting App on nRF5340 DK + if: github.event_name == 'push' || steps.changed_paths.outputs.nrfconnect == 'true' + timeout-minutes: 15 + run: | + scripts/examples/nrfconnect_example.sh lighting-app nrf5340dk_nrf5340_cpuapp + .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ + nrfconnect nrf5340dk_nrf5340_cpuapp lighting-app \ + examples/lighting-app/nrfconnect/build/zephyr/zephyr.elf \ + /tmp/bloat_reports/ - name: Run unit tests for Zephyr native_posix_64 platform if: github.event_name == 'push' || steps.changed_paths.outputs.tests == 'true' timeout-minutes: 15 diff --git a/examples/light-switch-app/nrfconnect/CMakeLists.txt b/examples/light-switch-app/nrfconnect/CMakeLists.txt index 865b8262749bb9..3a0084efa79c42 100644 --- a/examples/light-switch-app/nrfconnect/CMakeLists.txt +++ b/examples/light-switch-app/nrfconnect/CMakeLists.txt @@ -60,7 +60,7 @@ target_sources(app PRIVATE main/BindingHandler.cpp ${GEN_DIR}/light-switch-app/zap-generated/callback-stub.cpp ${GEN_DIR}/light-switch-app/zap-generated/IMClusterCommandHandler.cpp - ${NRFCONNECT_COMMON}/util/LEDWidget.cpp + ${NRFCONNECT_COMMON}/util/LEDWidget.cpp) if(CONFIG_CHIP_OTA_REQUESTOR) From e2c28dfd077f411342a5781abe71377cd98f9874 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Mon, 22 Aug 2022 13:11:51 -0400 Subject: [PATCH 02/15] Restrict esp32 build dependencies to x64 linux. Mac seems to fail on gevent which is brought by gdbgui (#22071) --- scripts/requirements.esp32.txt | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/scripts/requirements.esp32.txt b/scripts/requirements.esp32.txt index c870b03a23cd56..4bf5479986c5a2 100644 --- a/scripts/requirements.esp32.txt +++ b/scripts/requirements.esp32.txt @@ -1,12 +1,12 @@ -click>=7.0 -future>=0.15.2 -pyparsing>=2.0.3,<2.4.0 -idf-component-manager>=0.2.99-beta -gdbgui==0.13.2.0 -pygdbmi<=0.9.0.2 -reedsolo>=1.5.3,<=1.5.4 -bitstring>=3.1.6 -ecdsa>=0.16.0 -kconfiglib==13.7.1 -construct==2.10.54 -python-socketio<5 +click>=7.0 ; platform_machine != 'aarch64' and sys_platform == 'linux' +future>=0.15.2 ; platform_machine != 'aarch64' and sys_platform == 'linux' +pyparsing>=2.0.3,<2.4.0 ; platform_machine != 'aarch64' and sys_platform == 'linux' +idf-component-manager>=0.2.99-beta ; platform_machine != 'aarch64' and sys_platform == 'linux' +gdbgui==0.13.2.0 ; platform_machine != 'aarch64' and sys_platform == 'linux' +pygdbmi<=0.9.0.2 ; platform_machine != 'aarch64' and sys_platform == 'linux' +reedsolo>=1.5.3,<=1.5.4 ; platform_machine != 'aarch64' and sys_platform == 'linux' +bitstring>=3.1.6 ; platform_machine != 'aarch64' and sys_platform == 'linux' +ecdsa>=0.16.0 ; platform_machine != 'aarch64' and sys_platform == 'linux' +kconfiglib==13.7.1 ; platform_machine != 'aarch64' and sys_platform == 'linux' +construct==2.10.54 ; platform_machine != 'aarch64' and sys_platform == 'linux' +python-socketio<5 ; platform_machine != 'aarch64' and sys_platform == 'linux' From 585a53a96f51e3e593316fba85bb8d49e0d8bb7c Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Mon, 22 Aug 2022 13:17:19 -0400 Subject: [PATCH 03/15] Disable imx docker CI check step because it always fails with no space left on device (#22050) --- .github/workflows/docker_img.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker_img.yaml b/.github/workflows/docker_img.yaml index b706dbcac39e42..73c45ee303a756 100644 --- a/.github/workflows/docker_img.yaml +++ b/.github/workflows/docker_img.yaml @@ -42,7 +42,12 @@ jobs: - "-esp32" - "-esp32-qemu" - "-infineon" - - "-imx" + # NOTE: imx image requires too much space for GitHub-hosted runners. It fails with: + # ``` + # .... + # ApplyLayer exit status 1 stdout: stderr: write /opt/fsl-imx-xwayland/5.15-kirkstone/sysroots/armv8a-poky-linux/opt/ltp/testcases/bin/fanotify15: no space left on device + # ``` + # - "-imx" - "-k32w" - "-mbed-os" - "-nrf-platform" From 3899b665418e2f79e229a5ba9498b59027de400d Mon Sep 17 00:00:00 2001 From: Sid Hsu Date: Tue, 23 Aug 2022 01:54:37 +0800 Subject: [PATCH 04/15] [Infineon] Fix CYW30739 KVS to pass the storage API audit. (#21995) * Support key length upto PersistentStorageDelegate::kKeyLengthMax. * _Get and _Put methods can handle zero-size data correctly. --- .../CYW30739/KeyValueStoreManagerImpl.cpp | 56 ++++++++++++------- .../CYW30739/KeyValueStoreManagerImpl.h | 18 +++++- 2 files changed, 50 insertions(+), 24 deletions(-) diff --git a/src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.cpp b/src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.cpp index 00e7a063614bb9..e61edab6ebfd18 100644 --- a/src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.cpp +++ b/src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.cpp @@ -44,15 +44,14 @@ CHIP_ERROR KeyValueStoreManagerImpl::Init(void) for (uint8_t configID = 0; configID < mMaxEntryCount; configID++) { - char key[CHIP_CONFIG_PERSISTED_STORAGE_MAX_KEY_LENGTH]; - memset(key, 0, sizeof(key)); - size_t keyLength; - err = CYW30739Config::ReadConfigValueStr(CYW30739ConfigKey(Config::kChipKvsKey_KeyBase, configID), key, sizeof(key), - keyLength); + KeyStorage keyStorage; + size_t keyStorageLength; + err = CYW30739Config::ReadConfigValueBin(CYW30739ConfigKey(Config::kChipKvsKey_KeyBase, configID), &keyStorage, + sizeof(keyStorage), keyStorageLength); if (err != CHIP_NO_ERROR) continue; - KeyConfigIdEntry * entry = Platform::New(configID, key, keyLength); + KeyConfigIdEntry * entry = Platform::New(configID, keyStorage); VerifyOrExit(entry != nullptr, err = CHIP_ERROR_NO_MEMORY); slist_add_tail(entry, &mKeyConfigIdList); @@ -75,14 +74,24 @@ CHIP_ERROR KeyValueStoreManagerImpl::_Get(const char * key, void * value, size_t VerifyOrReturnError(offset_bytes == 0, CHIP_ERROR_NOT_IMPLEMENTED); - const size_t keyLength = strnlen(key, CHIP_CONFIG_PERSISTED_STORAGE_MAX_KEY_LENGTH); - VerifyOrExit(keyLength != 0 && keyLength <= CHIP_CONFIG_PERSISTED_STORAGE_MAX_KEY_LENGTH && + const size_t keyLength = strnlen(key, PersistentStorageDelegate::kKeyLengthMax); + VerifyOrExit(keyLength != 0 && keyLength <= PersistentStorageDelegate::kKeyLengthMax && value_size <= kMaxPersistedValueLengthSupported, err = CHIP_ERROR_INVALID_ARGUMENT); entry = FindEntry(key); VerifyOrExit(entry != nullptr, err = CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); - VerifyOrExit(value_size != 0, err = CHIP_ERROR_BUFFER_TOO_SMALL); + + if (value_size == 0 || entry->GetValueSize() == 0) + { + if (read_bytes_size != nullptr) + *read_bytes_size = 0; + + if (value_size >= entry->GetValueSize()) + ExitNow(err = CHIP_NO_ERROR); + else + ExitNow(err = CHIP_ERROR_BUFFER_TOO_SMALL); + } size_t byte_count; err = CYW30739Config::ReadConfigValueBin(entry->GetValueConfigKey(), value, value_size, byte_count); @@ -94,6 +103,8 @@ CHIP_ERROR KeyValueStoreManagerImpl::_Get(const char * key, void * value, size_t *read_bytes_size = byte_count; } + VerifyOrExit(value_size >= entry->GetValueSize(), err = CHIP_ERROR_BUFFER_TOO_SMALL); + exit: return err; } @@ -101,10 +112,10 @@ CHIP_ERROR KeyValueStoreManagerImpl::_Get(const char * key, void * value, size_t CHIP_ERROR KeyValueStoreManagerImpl::_Put(const char * key, const void * value, size_t value_size) { CHIP_ERROR err = CHIP_NO_ERROR; - const KeyConfigIdEntry * entry; + KeyConfigIdEntry * entry; - const size_t keyLength = strnlen(key, CHIP_CONFIG_PERSISTED_STORAGE_MAX_KEY_LENGTH + 1); - VerifyOrExit(keyLength != 0 && keyLength <= CHIP_CONFIG_PERSISTED_STORAGE_MAX_KEY_LENGTH && + const size_t keyLength = strnlen(key, PersistentStorageDelegate::kKeyLengthMax + 1); + VerifyOrExit(keyLength != 0 && keyLength <= PersistentStorageDelegate::kKeyLengthMax && value_size <= kMaxPersistedValueLengthSupported, err = CHIP_ERROR_INVALID_ARGUMENT); @@ -112,9 +123,13 @@ CHIP_ERROR KeyValueStoreManagerImpl::_Put(const char * key, const void * value, VerifyOrExit(entry != nullptr, ChipLogError(DeviceLayer, "%s AllocateEntry %s", __func__, ErrorStr(err)); err = CHIP_ERROR_NO_MEMORY); - SuccessOrExit(err = CYW30739Config::WriteConfigValueBin(entry->GetValueConfigKey(), value, value_size)); + if (value_size != 0) + { + SuccessOrExit(err = CYW30739Config::WriteConfigValueBin(entry->GetValueConfigKey(), value, value_size)); + } - SuccessOrExit(err = CYW30739Config::WriteConfigValueStr(entry->GetKeyConfigKey(), key, keyLength)); + entry->SetValueSize(value_size); + SuccessOrExit(err = CYW30739Config::WriteConfigValueBin(entry->GetKeyConfigKey(), &entry->mStorage, sizeof(entry->mStorage))); exit: return err; @@ -125,8 +140,8 @@ CHIP_ERROR KeyValueStoreManagerImpl::_Delete(const char * key) CHIP_ERROR err; KeyConfigIdEntry * entry; - const size_t keyLength = strnlen(key, CHIP_CONFIG_PERSISTED_STORAGE_MAX_KEY_LENGTH); - VerifyOrExit(keyLength != 0 && keyLength <= CHIP_CONFIG_PERSISTED_STORAGE_MAX_KEY_LENGTH, err = CHIP_ERROR_INVALID_ARGUMENT); + const size_t keyLength = strnlen(key, PersistentStorageDelegate::kKeyLengthMax); + VerifyOrExit(keyLength != 0 && keyLength <= PersistentStorageDelegate::kKeyLengthMax, err = CHIP_ERROR_INVALID_ARGUMENT); entry = FindEntry(key); VerifyOrExit(entry != nullptr, err = CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); @@ -156,14 +171,13 @@ CHIP_ERROR KeyValueStoreManagerImpl::EraseAll(void) return CHIP_NO_ERROR; } -KeyValueStoreManagerImpl::KeyConfigIdEntry::KeyConfigIdEntry(uint8_t configID, const char * key, size_t keyLength) : - mConfigID(configID) +KeyValueStoreManagerImpl::KeyStorage::KeyStorage(const char * key, size_t keyLength) : mValueSize(0) { memset(mKey, 0, sizeof(mKey)); memcpy(mKey, key, keyLength); } -bool KeyValueStoreManagerImpl::KeyConfigIdEntry::IsMatchKey(const char * key) const +bool KeyValueStoreManagerImpl::KeyStorage::IsMatchKey(const char * key) const { return strncmp(mKey, key, sizeof(mKey)) == 0; } @@ -175,7 +189,7 @@ KeyValueStoreManagerImpl::KeyConfigIdEntry * KeyValueStoreManagerImpl::AllocateE ReturnErrorCodeIf(newEntry != nullptr, newEntry); ReturnErrorCodeIf(!freeConfigID.HasValue(), nullptr); - newEntry = Platform::New(freeConfigID.Value(), key, keyLength); + newEntry = Platform::New(freeConfigID.Value(), KeyStorage(key, keyLength)); ReturnErrorCodeIf(newEntry == nullptr, nullptr); KeyConfigIdEntry * entry = static_cast(slist_tail(&mKeyConfigIdList)); @@ -220,7 +234,7 @@ KeyValueStoreManagerImpl::KeyConfigIdEntry * KeyValueStoreManagerImpl::FindEntry { entry = entry->Next(); - if (entry->IsMatchKey(key)) + if (entry->mStorage.IsMatchKey(key)) return entry; if (freeConfigID != nullptr && !freeConfigID->HasValue() && entry != slist_tail(&mKeyConfigIdList)) diff --git a/src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.h b/src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.h index a719bc6c2af7ac..5938bd28a56c98 100644 --- a/src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.h +++ b/src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.h @@ -23,6 +23,7 @@ #pragma once +#include #include #include @@ -56,11 +57,20 @@ class KeyValueStoreManagerImpl final : public KeyValueStoreManager static constexpr uint8_t mMaxEntryCount = 128; - struct KeyConfigIdEntry : public slist_node_t + struct KeyStorage { - KeyConfigIdEntry(uint8_t configID, const char * key, size_t keyLength); + KeyStorage(const char * key = nullptr, size_t keyLength = 0); bool IsMatchKey(const char * key) const; + + size_t mValueSize; + char mKey[PersistentStorageDelegate::kKeyLengthMax]; + }; + + struct KeyConfigIdEntry : public slist_node_t + { + KeyConfigIdEntry(uint8_t configID, const KeyStorage & keyStorage) : mConfigID(configID), mStorage(keyStorage) {} + constexpr Config::Key GetValueConfigKey() const { return Internal::CYW30739ConfigKey(Config::kChipKvsValue_KeyBase, mConfigID); @@ -71,9 +81,11 @@ class KeyValueStoreManagerImpl final : public KeyValueStoreManager } constexpr KeyConfigIdEntry * Next() const { return static_cast(next); } constexpr uint8_t NextConfigID() const { return mConfigID + 1; } + constexpr size_t GetValueSize() const { return mStorage.mValueSize; } + constexpr void SetValueSize(size_t valueSize) { mStorage.mValueSize = valueSize; } uint8_t mConfigID; - char mKey[CHIP_CONFIG_PERSISTED_STORAGE_MAX_KEY_LENGTH]; + KeyStorage mStorage; }; KeyConfigIdEntry * AllocateEntry(const char * key, size_t keyLength); From 15ec1792a4a6e47fa62fc127d5f9463ecb1ee99c Mon Sep 17 00:00:00 2001 From: Sandeep Mistry Date: Mon, 22 Aug 2022 13:55:44 -0400 Subject: [PATCH 05/15] [Docs] Update building guide for Ubuntu 2022.04 (#21636) --- docs/guides/BUILDING.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/guides/BUILDING.md b/docs/guides/BUILDING.md index 5bcd865ca5db1b..00bf6d97a581f9 100644 --- a/docs/guides/BUILDING.md +++ b/docs/guides/BUILDING.md @@ -8,7 +8,7 @@ Tested on: - macOS 10.15 - Debian 11 -- Ubuntu 20.04 LTS +- Ubuntu 22.04 LTS Build system features: @@ -81,9 +81,8 @@ dependency. ### Installing prerequisites on Raspberry Pi 4 -Using `rpi-imager`, install the Ubuntu _21.04_ 64-bit _server_ OS for arm64 -architectures on a micro SD card. This release will have bluez 5.55 or newer -which is required for BLE functionality. +Using `rpi-imager`, install the Ubuntu _22.04_ 64-bit _server_ OS for arm64 +architectures on a micro SD card. Boot the SD card, login with the default user account "ubuntu" and password "ubuntu", then proceed with From a71a002e5377f267a57cf112980e4a49f010e5f7 Mon Sep 17 00:00:00 2001 From: jmartinez-silabs <67972863+jmartinez-silabs@users.noreply.github.com> Date: Mon, 22 Aug 2022 14:05:00 -0400 Subject: [PATCH 06/15] More cleanup for the openthread build targets and EFR32 (#22049) --- examples/chef/efr32/BUILD.gn | 1 + examples/light-switch-app/efr32/BUILD.gn | 1 + examples/lighting-app/efr32/BUILD.gn | 1 + examples/lock-app/efr32/BUILD.gn | 1 + examples/shell/shell_common/BUILD.gn | 15 ++--- examples/thermostat/efr32/BUILD.gn | 1 + examples/window-app/efr32/BUILD.gn | 1 + src/inet/BUILD.gn | 2 +- src/platform/EFR32/BUILD.gn | 4 +- src/test_driver/efr32/BUILD.gn | 1 + third_party/openthread/BUILD.gn | 21 ++++++- third_party/openthread/ot-efr32 | 2 +- third_party/silabs/BUILD.gn | 78 ++++++++++-------------- 13 files changed, 67 insertions(+), 62 deletions(-) diff --git a/examples/chef/efr32/BUILD.gn b/examples/chef/efr32/BUILD.gn index 662933081bc331..c567ae9d8f1cbf 100644 --- a/examples/chef/efr32/BUILD.gn +++ b/examples/chef/efr32/BUILD.gn @@ -207,6 +207,7 @@ efr32_executable("chef_app") { if (chip_enable_openthread) { deps += [ "${chip_root}/third_party/openthread:openthread", + "${chip_root}/third_party/openthread:openthread_device", "${examples_plat_dir}:efr-matter-shell", ] } diff --git a/examples/light-switch-app/efr32/BUILD.gn b/examples/light-switch-app/efr32/BUILD.gn index 3118b7a6dadc18..e2705abdedcb65 100644 --- a/examples/light-switch-app/efr32/BUILD.gn +++ b/examples/light-switch-app/efr32/BUILD.gn @@ -200,6 +200,7 @@ efr32_executable("light_switch_app") { if (chip_enable_openthread) { deps += [ "${chip_root}/third_party/openthread:openthread", + "${chip_root}/third_party/openthread:openthread_device", "${examples_plat_dir}:efr-matter-shell", ] } diff --git a/examples/lighting-app/efr32/BUILD.gn b/examples/lighting-app/efr32/BUILD.gn index 76430e8586e8d3..060b9f67343aa0 100644 --- a/examples/lighting-app/efr32/BUILD.gn +++ b/examples/lighting-app/efr32/BUILD.gn @@ -205,6 +205,7 @@ efr32_executable("lighting_app") { if (chip_enable_openthread) { deps += [ "${chip_root}/third_party/openthread:openthread", + "${chip_root}/third_party/openthread:openthread_device", "${examples_plat_dir}:efr-matter-shell", ] } diff --git a/examples/lock-app/efr32/BUILD.gn b/examples/lock-app/efr32/BUILD.gn index bb6530f56e5313..2f8f2dc6bf67b4 100644 --- a/examples/lock-app/efr32/BUILD.gn +++ b/examples/lock-app/efr32/BUILD.gn @@ -202,6 +202,7 @@ efr32_executable("lock_app") { if (chip_enable_openthread) { deps += [ "${chip_root}/third_party/openthread:openthread", + "${chip_root}/third_party/openthread:openthread_device", "${examples_plat_dir}:efr-matter-shell", ] } diff --git a/examples/shell/shell_common/BUILD.gn b/examples/shell/shell_common/BUILD.gn index d4b57df2f969ee..0217eb057fdff4 100644 --- a/examples/shell/shell_common/BUILD.gn +++ b/examples/shell/shell_common/BUILD.gn @@ -52,17 +52,10 @@ static_library("shell_common") { if (chip_enable_openthread && (current_os == "freertos" || current_os == "zephyr")) { - if (chip_openthread_ftd) { - public_deps += [ - "${chip_root}/third_party/openthread/repo:libopenthread-cli-ftd", - "${chip_root}/third_party/openthread/repo:libopenthread-ftd", - ] - } else { - public_deps += [ - "${chip_root}/third_party/openthread/repo:libopenthread-cli-mtd", - "${chip_root}/third_party/openthread/repo:libopenthread-mtd", - ] - } + public_deps += [ + "${chip_root}/third_party/openthread:openthread_cli", + "${chip_root}/third_party/openthread:openthread_device", + ] } if (chip_shell_cmd_server) { diff --git a/examples/thermostat/efr32/BUILD.gn b/examples/thermostat/efr32/BUILD.gn index fe2be76adf88a8..edb03073686e3e 100644 --- a/examples/thermostat/efr32/BUILD.gn +++ b/examples/thermostat/efr32/BUILD.gn @@ -196,6 +196,7 @@ efr32_executable("thermostat_app") { if (chip_enable_openthread) { deps += [ "${chip_root}/third_party/openthread:openthread", + "${chip_root}/third_party/openthread:openthread_device", "${examples_plat_dir}:efr-matter-shell", ] } diff --git a/examples/window-app/efr32/BUILD.gn b/examples/window-app/efr32/BUILD.gn index 7d2bfbec6dca1f..c7a3f57e4b9ff8 100644 --- a/examples/window-app/efr32/BUILD.gn +++ b/examples/window-app/efr32/BUILD.gn @@ -188,6 +188,7 @@ efr32_executable("window_app") { if (chip_enable_openthread) { deps += [ "${chip_root}/third_party/openthread:openthread", + "${chip_root}/third_party/openthread:openthread_device", "${examples_plat_dir}:efr-matter-shell", ] } diff --git a/src/inet/BUILD.gn b/src/inet/BUILD.gn index cb86a45780df9c..a042007d02c5a3 100644 --- a/src/inet/BUILD.gn +++ b/src/inet/BUILD.gn @@ -107,7 +107,7 @@ static_library("inet") { } if (chip_system_config_use_open_thread_inet_endpoints) { - public_deps += [ "${chip_root}/third_party/openthread:openthread" ] + public_deps += [ "${chip_root}/third_party/openthread:openthread_device" ] } if (chip_inet_config_enable_tcp_endpoint) { diff --git a/src/platform/EFR32/BUILD.gn b/src/platform/EFR32/BUILD.gn index e406ce994eedee..eb73a6f80f85cf 100644 --- a/src/platform/EFR32/BUILD.gn +++ b/src/platform/EFR32/BUILD.gn @@ -98,9 +98,9 @@ static_library("EFR32") { "$dir_pw_kvs", ] if (chip_enable_openthread) { - public_deps += [ "${chip_root}/third_party/openthread:openthread" ] + public_deps += [ "${chip_root}/third_party/openthread:openthread_device" ] - deps += [ "${chip_root}/third_party/silabs:openthread_cli" ] + deps += [ "${chip_root}/third_party/openthread:openthread_cli" ] sources += [ "../OpenThread/OpenThreadUtils.cpp", diff --git a/src/test_driver/efr32/BUILD.gn b/src/test_driver/efr32/BUILD.gn index 45e4aff6fe40a7..8ee3c4f3e59c69 100644 --- a/src/test_driver/efr32/BUILD.gn +++ b/src/test_driver/efr32/BUILD.gn @@ -96,6 +96,7 @@ efr32_executable("efr32_device_tests") { if (chip_enable_openthread) { deps += [ "${chip_root}/third_party/openthread:openthread", + "${chip_root}/third_party/openthread:openthread_device", "${examples_plat_dir}:efr-matter-shell", ] } diff --git a/third_party/openthread/BUILD.gn b/third_party/openthread/BUILD.gn index 752f245738a750..9ee8e905551837 100644 --- a/third_party/openthread/BUILD.gn +++ b/third_party/openthread/BUILD.gn @@ -16,10 +16,27 @@ group("openthread") { "${chip_root}/third_party/openthread/platforms:libopenthread-platform", "${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils", ] + } +} + +group("openthread_device") { + if (chip_openthread_target != "") { + public_deps = [ chip_openthread_target ] + } else { + if (chip_openthread_ftd) { + public_deps = [ "${openthread_root}:libopenthread-ftd" ] + } else { + public_deps = [ "${openthread_root}:libopenthread-mtd" ] + } + } +} + +group("openthread_cli") { + if (chip_openthread_target == "") { if (chip_openthread_ftd) { - public_deps += [ "${openthread_root}:libopenthread-ftd" ] + public_deps = [ "${openthread_root}:libopenthread-cli-ftd" ] } else { - public_deps += [ "${openthread_root}:libopenthread-mtd" ] + public_deps = [ "${openthread_root}:libopenthread-cli-mtd" ] } } } diff --git a/third_party/openthread/ot-efr32 b/third_party/openthread/ot-efr32 index fd77faf7a3443f..1e10a32228c96f 160000 --- a/third_party/openthread/ot-efr32 +++ b/third_party/openthread/ot-efr32 @@ -1 +1 @@ -Subproject commit fd77faf7a3443f7941dfd9e9713aea09eb08e9b9 +Subproject commit 1e10a32228c96f273603612ef7d5ce693ecdf887 diff --git a/third_party/silabs/BUILD.gn b/third_party/silabs/BUILD.gn index c4f96d18d339f5..1589f72e7865ae 100644 --- a/third_party/silabs/BUILD.gn +++ b/third_party/silabs/BUILD.gn @@ -31,18 +31,6 @@ group("efr32_sdk") { public_deps = [ efr32_sdk_target ] } -if (chip_enable_openthread) { - group("openthread_cli") { - if (!use_silabs_thread_lib) { - if (chip_openthread_ftd) { - public_deps = [ "${sl_openthread_root}:libopenthread-cli-ftd" ] - } else { - public_deps = [ "${sl_openthread_root}:libopenthread-cli-mtd" ] - } - } - } -} - if (use_silabs_thread_lib) { config("libopenthread-platform_config") { include_dirs = [ "${sl_openthread_root}/examples/platforms" ] @@ -74,7 +62,6 @@ if (use_silabs_thread_lib) { "RADIO_CONFIG_DMP_SUPPORT=1", "${efr32_board}=1", "${efr32_mcu}", - "USE_SL_THREAD_CERT_LIB", "OPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE=\"openthread-core-efr32-config-check.h\"", ] @@ -88,7 +75,6 @@ if (use_silabs_thread_lib) { source_set("openthread_core_config_efr32") { sources = [ - "${sl_openthread_root}/src/cli/cli_config.h", "${sl_ot_efr32_root}/src/src/openthread-core-efr32-config-check.h", "${sl_ot_efr32_root}/src/src/openthread-core-efr32-config.h", ] @@ -102,37 +88,39 @@ if (use_silabs_thread_lib) { } source_set("ot-efr32-cert") { - sources = [ - "${sl_openthread_root}/examples/apps/cli/cli_uart.cpp", - "${sl_openthread_root}/src/cli/cli.cpp", - "${sl_openthread_root}/src/cli/cli.hpp", - "${sl_openthread_root}/src/cli/cli_coap.cpp", - "${sl_openthread_root}/src/cli/cli_coap.hpp", - "${sl_openthread_root}/src/cli/cli_coap_secure.cpp", - "${sl_openthread_root}/src/cli/cli_coap_secure.hpp", - "${sl_openthread_root}/src/cli/cli_commissioner.cpp", - "${sl_openthread_root}/src/cli/cli_commissioner.hpp", - "${sl_openthread_root}/src/cli/cli_config.h", - "${sl_openthread_root}/src/cli/cli_dataset.cpp", - "${sl_openthread_root}/src/cli/cli_dataset.hpp", - "${sl_openthread_root}/src/cli/cli_history.cpp", - "${sl_openthread_root}/src/cli/cli_history.hpp", - "${sl_openthread_root}/src/cli/cli_joiner.cpp", - "${sl_openthread_root}/src/cli/cli_joiner.hpp", - "${sl_openthread_root}/src/cli/cli_network_data.cpp", - "${sl_openthread_root}/src/cli/cli_network_data.hpp", - "${sl_openthread_root}/src/cli/cli_output.cpp", - "${sl_openthread_root}/src/cli/cli_output.hpp", - "${sl_openthread_root}/src/cli/cli_srp_client.cpp", - "${sl_openthread_root}/src/cli/cli_srp_client.hpp", - "${sl_openthread_root}/src/cli/cli_srp_server.cpp", - "${sl_openthread_root}/src/cli/cli_srp_server.hpp", - "${sl_openthread_root}/src/cli/cli_tcp.cpp", - "${sl_openthread_root}/src/cli/cli_tcp.hpp", - "${sl_openthread_root}/src/cli/cli_udp.cpp", - "${sl_openthread_root}/src/cli/cli_udp.hpp", - "${sl_openthread_root}/src/cli/x509_cert_key.hpp", - ] + if (enable_openthread_cli) { + sources = [ + "${sl_openthread_root}/examples/apps/cli/cli_uart.cpp", + "${sl_openthread_root}/src/cli/cli.cpp", + "${sl_openthread_root}/src/cli/cli.hpp", + "${sl_openthread_root}/src/cli/cli_coap.cpp", + "${sl_openthread_root}/src/cli/cli_coap.hpp", + "${sl_openthread_root}/src/cli/cli_coap_secure.cpp", + "${sl_openthread_root}/src/cli/cli_coap_secure.hpp", + "${sl_openthread_root}/src/cli/cli_commissioner.cpp", + "${sl_openthread_root}/src/cli/cli_commissioner.hpp", + "${sl_openthread_root}/src/cli/cli_config.h", + "${sl_openthread_root}/src/cli/cli_dataset.cpp", + "${sl_openthread_root}/src/cli/cli_dataset.hpp", + "${sl_openthread_root}/src/cli/cli_history.cpp", + "${sl_openthread_root}/src/cli/cli_history.hpp", + "${sl_openthread_root}/src/cli/cli_joiner.cpp", + "${sl_openthread_root}/src/cli/cli_joiner.hpp", + "${sl_openthread_root}/src/cli/cli_network_data.cpp", + "${sl_openthread_root}/src/cli/cli_network_data.hpp", + "${sl_openthread_root}/src/cli/cli_output.cpp", + "${sl_openthread_root}/src/cli/cli_output.hpp", + "${sl_openthread_root}/src/cli/cli_srp_client.cpp", + "${sl_openthread_root}/src/cli/cli_srp_client.hpp", + "${sl_openthread_root}/src/cli/cli_srp_server.cpp", + "${sl_openthread_root}/src/cli/cli_srp_server.hpp", + "${sl_openthread_root}/src/cli/cli_tcp.cpp", + "${sl_openthread_root}/src/cli/cli_tcp.hpp", + "${sl_openthread_root}/src/cli/cli_udp.cpp", + "${sl_openthread_root}/src/cli/cli_udp.hpp", + "${sl_openthread_root}/src/cli/x509_cert_key.hpp", + ] + } public_configs = [ ":openthread_efr32_config", From f68b948bd78986ed85b1ee326e05da5361e83eff Mon Sep 17 00:00:00 2001 From: jmartinez-silabs <67972863+jmartinez-silabs@users.noreply.github.com> Date: Mon, 22 Aug 2022 15:23:22 -0400 Subject: [PATCH 07/15] Fix GetBootReason prototype so it overrides the generic one, Replace sl_ot_sys_init by manual call. OT efr32MiscInit was 'stealing' the reboot cause from the matter stack (#22077) --- examples/platform/efr32/init_efrPlatform.cpp | 3 ++- src/platform/EFR32/ConfigurationManagerImpl.cpp | 5 +++-- src/platform/EFR32/ConfigurationManagerImpl.h | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/platform/efr32/init_efrPlatform.cpp b/examples/platform/efr32/init_efrPlatform.cpp index a0e33702b40e68..36ee0018e8a814 100644 --- a/examples/platform/efr32/init_efrPlatform.cpp +++ b/examples/platform/efr32/init_efrPlatform.cpp @@ -68,7 +68,8 @@ void init_efrPlatform(void) #endif #if CHIP_ENABLE_OPENTHREAD - sl_ot_sys_init(); + efr32RadioInit(); + efr32AlarmInit(); #endif // CHIP_ENABLE_OPENTHREAD } diff --git a/src/platform/EFR32/ConfigurationManagerImpl.cpp b/src/platform/EFR32/ConfigurationManagerImpl.cpp index 64a66be824f61a..0dd8170da5d3b5 100644 --- a/src/platform/EFR32/ConfigurationManagerImpl.cpp +++ b/src/platform/EFR32/ConfigurationManagerImpl.cpp @@ -97,7 +97,7 @@ CHIP_ERROR ConfigurationManagerImpl::IncreaseBootCount(void) return EFR32Config::WriteConfigValue(EFR32Config::kConfigKey_BootCount, bootCount + 1); } -uint32_t ConfigurationManagerImpl::GetBootReason(void) +CHIP_ERROR ConfigurationManagerImpl::GetBootReason(uint32_t & bootReason) { // rebootCause is obtained at bootup. BootReasonType matterBootCause; @@ -150,7 +150,8 @@ uint32_t ConfigurationManagerImpl::GetBootReason(void) matterBootCause = BootReasonType::kUnspecified; #endif - return to_underlying(matterBootCause); + bootReason = to_underlying(matterBootCause); + return CHIP_NO_ERROR; } CHIP_ERROR ConfigurationManagerImpl::GetTotalOperationalHours(uint32_t & totalOperationalHours) diff --git a/src/platform/EFR32/ConfigurationManagerImpl.h b/src/platform/EFR32/ConfigurationManagerImpl.h index aaebd3ea65ac91..2f40d8d260a363 100644 --- a/src/platform/EFR32/ConfigurationManagerImpl.h +++ b/src/platform/EFR32/ConfigurationManagerImpl.h @@ -40,7 +40,7 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp // This returns an instance of this class. static ConfigurationManagerImpl & GetDefaultInstance(); - uint32_t GetBootReason(void); + CHIP_ERROR GetBootReason(uint32_t & bootReason); CHIP_ERROR GetRebootCount(uint32_t & rebootCount); CHIP_ERROR IncreaseBootCount(void); CHIP_ERROR GetTotalOperationalHours(uint32_t & totalOperationalHours); From 6681060d7d44832bac7534464a84cab72bec62b1 Mon Sep 17 00:00:00 2001 From: Ricardo Casallas <77841255+rcasallas-silabs@users.noreply.github.com> Date: Mon, 22 Aug 2022 16:41:58 -0400 Subject: [PATCH 08/15] [EFR32] Fix CSR length. (#22080) --- src/platform/EFR32/CHIPCryptoPALPsaEfr32.cpp | 4 +++- src/platform/EFR32/Efr32PsaOpaqueKeypair.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/platform/EFR32/CHIPCryptoPALPsaEfr32.cpp b/src/platform/EFR32/CHIPCryptoPALPsaEfr32.cpp index 6077681f19eb57..72c4706501f851 100644 --- a/src/platform/EFR32/CHIPCryptoPALPsaEfr32.cpp +++ b/src/platform/EFR32/CHIPCryptoPALPsaEfr32.cpp @@ -894,7 +894,9 @@ P256Keypair::~P256Keypair() CHIP_ERROR P256Keypair::NewCertificateSigningRequest(uint8_t * out_csr, size_t & csr_length) const { MutableByteSpan csr(out_csr, csr_length); - return GenerateCertificateSigningRequest(this, csr); + CHIP_ERROR err = GenerateCertificateSigningRequest(this, csr); + csr_length = (CHIP_NO_ERROR == err) ? csr.size() : 0; + return err; } CHIP_ERROR VerifyCertificateSigningRequest(const uint8_t * csr_buf, size_t csr_length, P256PublicKey & pubkey) diff --git a/src/platform/EFR32/Efr32PsaOpaqueKeypair.cpp b/src/platform/EFR32/Efr32PsaOpaqueKeypair.cpp index b1c32dc028471d..da72af848bab51 100644 --- a/src/platform/EFR32/Efr32PsaOpaqueKeypair.cpp +++ b/src/platform/EFR32/Efr32PsaOpaqueKeypair.cpp @@ -407,7 +407,9 @@ CHIP_ERROR EFR32OpaqueP256Keypair::Deserialize(P256SerializedKeypair & input) CHIP_ERROR EFR32OpaqueP256Keypair::NewCertificateSigningRequest(uint8_t * out_csr, size_t & csr_length) const { MutableByteSpan csr(out_csr, csr_length); - return GenerateCertificateSigningRequest(this, csr); + CHIP_ERROR err = GenerateCertificateSigningRequest(this, csr); + csr_length = (CHIP_NO_ERROR == err) ? csr.size() : 0; + return err; } CHIP_ERROR EFR32OpaqueP256Keypair::ECDSA_sign_msg(const uint8_t * msg, size_t msg_length, P256ECDSASignature & out_signature) const From f6929bb913bca7f5d5d7b770788e8d6f3c74ed29 Mon Sep 17 00:00:00 2001 From: jmartinez-silabs <67972863+jmartinez-silabs@users.noreply.github.com> Date: Mon, 22 Aug 2022 18:12:16 -0400 Subject: [PATCH 09/15] Set MAX_EXCHANGE_CONTEXT and NUM_UDP_ENDPOINT to match minimal requirements of matter spec (#22078) --- src/platform/EFR32/CHIPPlatformConfig.h | 2 +- src/platform/EFR32/InetPlatformConfig.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platform/EFR32/CHIPPlatformConfig.h b/src/platform/EFR32/CHIPPlatformConfig.h index decc6c59602779..cffeb4645ec29d 100644 --- a/src/platform/EFR32/CHIPPlatformConfig.h +++ b/src/platform/EFR32/CHIPPlatformConfig.h @@ -57,7 +57,7 @@ #endif // CHIP_CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS #ifndef CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS -#define CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS 8 +#define CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS 20 #endif // CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS #ifndef CHIP_LOG_FILTERING diff --git a/src/platform/EFR32/InetPlatformConfig.h b/src/platform/EFR32/InetPlatformConfig.h index 3e8bb9a2f6d229..fe3304fa5d9915 100644 --- a/src/platform/EFR32/InetPlatformConfig.h +++ b/src/platform/EFR32/InetPlatformConfig.h @@ -49,5 +49,5 @@ #endif // INET_CONFIG_NUM_TCP_ENDPOINTS #ifndef INET_CONFIG_NUM_UDP_ENDPOINTS -#define INET_CONFIG_NUM_UDP_ENDPOINTS 6 +#define INET_CONFIG_NUM_UDP_ENDPOINTS 20 #endif // INET_CONFIG_NUM_UDP_ENDPOINTS From 095f6b5a25ca44d2b130816ed326d0130ed70697 Mon Sep 17 00:00:00 2001 From: chirag-silabs <100861685+chirag-silabs@users.noreply.github.com> Date: Tue, 23 Aug 2022 09:14:02 +0530 Subject: [PATCH 10/15] [EFR32] Setting the network interface type to WIFI for wifi devices (#22041) * EFR32 wifi setting the network interface type to WIFI * Changes as per the suggestions * Changing the if condition * Correcting the code by adding ; for the build to be succeed --- src/platform/EFR32/DiagnosticDataProviderImpl.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/platform/EFR32/DiagnosticDataProviderImpl.cpp b/src/platform/EFR32/DiagnosticDataProviderImpl.cpp index a6d4833b65fe4b..31858125a0665b 100644 --- a/src/platform/EFR32/DiagnosticDataProviderImpl.cpp +++ b/src/platform/EFR32/DiagnosticDataProviderImpl.cpp @@ -264,7 +264,8 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** ifp->name = CharSpan::fromCharString(ifp->Name); ifp->isOperational = true; Inet::InterfaceType interfaceType; - if (interfaceIterator.GetInterfaceType(interfaceType) == CHIP_NO_ERROR) + CHIP_ERROR err = interfaceIterator.GetInterfaceType(interfaceType); + if (err == CHIP_NO_ERROR || err == CHIP_ERROR_NOT_IMPLEMENTED) { switch (interfaceType) { @@ -283,6 +284,9 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** case Inet::InterfaceType::Cellular: ifp->type = EMBER_ZCL_INTERFACE_TYPE_CELLULAR; break; + default: + ifp->type = EMBER_ZCL_INTERFACE_TYPE_WI_FI; + break; } } else From 3b41dbe4dc520544be62be3b19e2b63140bb8428 Mon Sep 17 00:00:00 2001 From: rgoliver Date: Mon, 22 Aug 2022 23:46:58 -0400 Subject: [PATCH 11/15] OTA: Add SetMetadataForProvider to requestor (#22005) * OTA: Add SetMetadataForProvider to requestor Add a setter for the OTA MetadataForProvider, which is provided during the QueryImageRequest. * RPC: Add RPC to set ota metadata for provider Add an RPC to set the TLV data in metadata for provider, which is used during the SendQueryImageRequest. --- .../pigweed/protos/device_service.options | 1 + .../pigweed/protos/device_service.proto | 5 +++ examples/common/pigweed/rpc_services/Device.h | 33 +++++++++++++++++-- .../ota-requestor/DefaultOTARequestor.cpp | 1 + .../ota-requestor/DefaultOTARequestor.h | 5 +++ .../ota-requestor/OTARequestorInterface.h | 3 ++ 6 files changed, 45 insertions(+), 3 deletions(-) diff --git a/examples/common/pigweed/protos/device_service.options b/examples/common/pigweed/protos/device_service.options index b5f9da673ff778..a0798688c38a84 100644 --- a/examples/common/pigweed/protos/device_service.options +++ b/examples/common/pigweed/protos/device_service.options @@ -5,3 +5,4 @@ chip.rpc.PairingInfo.qr_code max_size:256 chip.rpc.PairingInfo.qr_code_url max_size:256 chip.rpc.SpakeInfo.verifier max_size:97 // kSpake2p_VerifierSerialized_Length chip.rpc.SpakeInfo.salt max_size:32 // kSpake2p_Max_PBKDF_Salt_Length +chip.rpc.MetadataForProvider.tlv max_size:512 // length defined in chip spec 11.20.6.7 diff --git a/examples/common/pigweed/protos/device_service.proto b/examples/common/pigweed/protos/device_service.proto index 1c13d7d7281f14..6903e4a9055414 100644 --- a/examples/common/pigweed/protos/device_service.proto +++ b/examples/common/pigweed/protos/device_service.proto @@ -41,10 +41,15 @@ message PairingState { bool pairing_enabled = 1; } +message MetadataForProvider { + bytes tlv = 1; +} + service Device { rpc FactoryReset(pw.protobuf.Empty) returns (pw.protobuf.Empty){} rpc Reboot(pw.protobuf.Empty) returns (pw.protobuf.Empty){} rpc TriggerOta(pw.protobuf.Empty) returns (pw.protobuf.Empty){} + rpc SetOtaMetadataForProvider(MetadataForProvider) returns (pw.protobuf.Empty){} rpc GetDeviceInfo(pw.protobuf.Empty) returns (DeviceInfo){} rpc GetDeviceState(pw.protobuf.Empty) returns (DeviceState){} rpc SetPairingState(PairingState) returns (pw.protobuf.Empty){} diff --git a/examples/common/pigweed/rpc_services/Device.h b/examples/common/pigweed/rpc_services/Device.h index d3d5afd165810d..4a80cb44516236 100644 --- a/examples/common/pigweed/rpc_services/Device.h +++ b/examples/common/pigweed/rpc_services/Device.h @@ -223,7 +223,7 @@ class Device : public pw_rpc::nanopb::Device::Service virtual pw::Status TriggerOta(const pw_protobuf_Empty & request, pw_protobuf_Empty & response) { -#if CONFIG_CHIP_OTA_REQUESTOR +#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR chip::DeviceLayer::PlatformMgr().ScheduleWork( [](intptr_t) { chip::OTARequestorInterface * requestor = chip::GetRequestorInstance(); @@ -238,10 +238,33 @@ class Device : public pw_rpc::nanopb::Device::Service }, reinterpret_cast(nullptr)); return pw::OkStatus(); -#else +#else // CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR ChipLogError(AppServer, "Trigger OTA requested, but OTA requestor not compiled in."); return pw::Status::Unimplemented(); -#endif +#endif // CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR + } + + virtual pw::Status SetOtaMetadataForProvider(const chip_rpc_MetadataForProvider & request, pw_protobuf_Empty & response) + { +#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR + chip::OTARequestorInterface * requestor = chip::GetRequestorInstance(); + if (requestor == nullptr) + { + ChipLogError(SoftwareUpdate, "Can't get the CASESessionManager"); + return pw::Status::Unavailable(); + } + else if (sizeof(metadataForProviderBuffer) < request.tlv.size) + { + return pw::Status::ResourceExhausted(); + } + memcpy(metadataForProviderBuffer, request.tlv.bytes, request.tlv.size); + DeviceLayer::StackLock lock; + requestor->SetMetadataForProvider(chip::ByteSpan(metadataForProviderBuffer, request.tlv.size)); + return pw::OkStatus(); +#else // CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR + ChipLogError(AppServer, "OTA set metadata for provider requested, but OTA requestor not compiled in."); + return pw::Status::Unimplemented(); +#endif // CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR } virtual pw::Status SetPairingState(const chip_rpc_PairingState & request, pw_protobuf_Empty & response) @@ -415,6 +438,10 @@ class Device : public pw_rpc::nanopb::Device::Service } private: +#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR + static constexpr size_t kMaxMetadataForProviderLength = 512; // length defined in chip spec 11.20.6.7 + uint8_t metadataForProviderBuffer[kMaxMetadataForProviderLength]; +#endif // CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR Internal::CommissionableDataProviderRpcWrapper mCommissionableDataProvider; }; diff --git a/src/app/clusters/ota-requestor/DefaultOTARequestor.cpp b/src/app/clusters/ota-requestor/DefaultOTARequestor.cpp index f31bb2e0c5408a..f96b85ed9b4963 100644 --- a/src/app/clusters/ota-requestor/DefaultOTARequestor.cpp +++ b/src/app/clusters/ota-requestor/DefaultOTARequestor.cpp @@ -767,6 +767,7 @@ CHIP_ERROR DefaultOTARequestor::SendQueryImageRequest(Messaging::ExchangeManager args.location.SetValue(CharSpan("XX", strlen("XX"))); } + args.metadataForProvider = mMetadataForProvider; Controller::OtaSoftwareUpdateProviderCluster cluster(exchangeMgr, sessionHandle, mProviderLocation.Value().endpoint); return cluster.InvokeCommand(args, this, OnQueryImageResponse, OnQueryImageFailure); diff --git a/src/app/clusters/ota-requestor/DefaultOTARequestor.h b/src/app/clusters/ota-requestor/DefaultOTARequestor.h index 9f9902858c3141..938f2be59f671a 100644 --- a/src/app/clusters/ota-requestor/DefaultOTARequestor.h +++ b/src/app/clusters/ota-requestor/DefaultOTARequestor.h @@ -92,6 +92,10 @@ class DefaultOTARequestor : public OTARequestorInterface, public BDXDownloader:: void GetProviderLocation(Optional & providerLocation) override { providerLocation = mProviderLocation; } + // Set the metadata value for the provider to be used in the next query and OTA update process + // NOTE: Does not persist across reboot. + void SetMetadataForProvider(ByteSpan metadataForProvider) override { mMetadataForProvider.SetValue(metadataForProvider); } + // Add a default OTA provider to the cached list CHIP_ERROR AddDefaultOtaProvider(const ProviderLocationType & providerLocation) override; @@ -319,6 +323,7 @@ class DefaultOTARequestor : public OTARequestorInterface, public BDXDownloader:: BDXDownloader * mBdxDownloader = nullptr; // TODO: this should be OTADownloader BDXMessenger mBdxMessenger; // TODO: ideally this is held by the application uint8_t mUpdateTokenBuffer[kMaxUpdateTokenLen]; + Optional mMetadataForProvider; ByteSpan mUpdateToken; uint32_t mCurrentVersion = 0; uint32_t mTargetVersion = 0; diff --git a/src/app/clusters/ota-requestor/OTARequestorInterface.h b/src/app/clusters/ota-requestor/OTARequestorInterface.h index f24563d36c3c79..bd09f833971cc0 100644 --- a/src/app/clusters/ota-requestor/OTARequestorInterface.h +++ b/src/app/clusters/ota-requestor/OTARequestorInterface.h @@ -203,6 +203,9 @@ class OTARequestorInterface // Set the provider location to be used in the next query and OTA update process virtual void SetCurrentProviderLocation(ProviderLocationType providerLocation) = 0; + // Set the metadata value for the provider to be used in the next query and OTA update process + virtual void SetMetadataForProvider(chip::ByteSpan metadataForProvider) = 0; + // If there is an OTA update in progress, returns the provider location for the current OTA update, otherwise, returns the // provider location that was last used virtual void GetProviderLocation(Optional & providerLocation) = 0; From 48f87f3ce2b3b8457af63f8e68dbf3f1e42ae219 Mon Sep 17 00:00:00 2001 From: Tennessee Carmel-Veilleux Date: Mon, 22 Aug 2022 23:47:09 -0400 Subject: [PATCH 12/15] Add missing validity checks to CSR verification (#22069) * Add missing validity checks to CSR verification - SDK's CSR verification (VerifyCertificateSigningRequest) allowed trailing garbage past the end of the buffer if the primary SEQUENCE element is OK and checks-out. This is looser enforcement than some crypto libraries which expect a CSR to be 100% valid ASN.1 DER and have no unnecessary bytes or otherwise unparsable bytes. Fixes #22068 This PR: - Adds validity checks for size and basic format that catches the problem. - Adds unit tests that use externally generated CSRs to validate the `VerifyCertificateSigningRequest` logic, rather than only relying on round-trips with generation. Testing done: - Added new unit tests. Existing unit tests pass - Tested under OpenSSL, BoringSSL and mbedTLS * Fix docs typo --- src/crypto/CHIPCryptoPAL.cpp | 23 +++ src/crypto/CHIPCryptoPAL.h | 15 ++ src/crypto/CHIPCryptoPALOpenSSL.cpp | 2 + src/crypto/CHIPCryptoPALTinyCrypt.cpp | 2 + src/crypto/CHIPCryptoPALmbedTLS.cpp | 2 + src/crypto/tests/CHIPCryptoPALTest.cpp | 165 +++++++++++++++++++ src/platform/EFR32/CHIPCryptoPALPsaEfr32.cpp | 2 + 7 files changed, 211 insertions(+) diff --git a/src/crypto/CHIPCryptoPAL.cpp b/src/crypto/CHIPCryptoPAL.cpp index ec2e415806c23b..859f5809e4b742 100644 --- a/src/crypto/CHIPCryptoPAL.cpp +++ b/src/crypto/CHIPCryptoPAL.cpp @@ -1092,5 +1092,28 @@ CHIP_ERROR GenerateCertificateSigningRequest(const P256Keypair * keypair, Mutabl return err; } +CHIP_ERROR VerifyCertificateSigningRequestFormat(const uint8_t * csr, size_t csr_length) +{ + // Ensure we have enough size to validate header + VerifyOrReturnError((csr_length >= 16) && (csr_length <= kMAX_CSR_Length), CHIP_ERROR_UNSUPPORTED_CERT_FORMAT); + + Reader reader(csr, csr_length); + + // Ensure we have an outermost SEQUENCE + uint8_t seq_header = 0; + ReturnErrorOnFailure(reader.Read8(&seq_header).StatusCode()); + VerifyOrReturnError(seq_header == kSeqTag, CHIP_ERROR_UNSUPPORTED_CERT_FORMAT); + + uint8_t seq_length = 0; + VerifyOrReturnError(ReadDerLength(reader, seq_length) == CHIP_NO_ERROR, CHIP_ERROR_UNSUPPORTED_CERT_FORMAT); + + // Ensure that outer length matches sequence length + tag overhead, otherwise + // we have trailing garbage + size_t header_overhead = (seq_length <= 127) ? 2 : 3; + VerifyOrReturnError(csr_length == (seq_length + header_overhead), CHIP_ERROR_UNSUPPORTED_CERT_FORMAT); + + return CHIP_NO_ERROR; +} + } // namespace Crypto } // namespace chip diff --git a/src/crypto/CHIPCryptoPAL.h b/src/crypto/CHIPCryptoPAL.h index ea67c59a5765c1..544a554dcb31eb 100644 --- a/src/crypto/CHIPCryptoPAL.h +++ b/src/crypto/CHIPCryptoPAL.h @@ -640,8 +640,23 @@ CHIP_ERROR AES_CCM_decrypt(const uint8_t * ciphertext, size_t ciphertext_length, **/ CHIP_ERROR GenerateCertificateSigningRequest(const P256Keypair * keypair, MutableByteSpan & csr_span); +/** + * @brief Common code to validate ASN.1 format/size of a CSR, used by VerifyCertificateSigningRequest. + * + * Ensures it's not obviously malformed and doesn't have trailing garbage. + * + * @param csr CSR in DER format + * @param csr_length The length of the CSR buffer + * @return CHIP_ERROR_UNSUPPORTED_CERT_FORMAT on invalid format, CHIP_NO_ERROR otherwise. + */ +CHIP_ERROR VerifyCertificateSigningRequestFormat(const uint8_t * csr, size_t csr_length); + /** * @brief Verify the Certificate Signing Request (CSR). If successfully verified, it outputs the public key from the CSR. + * + * The CSR is valid if the format is correct, the signature validates with the embedded public + * key, and there is no trailing garbage data. + * * @param csr CSR in DER format * @param csr_length The length of the CSR * @param pubkey The public key from the verified CSR diff --git a/src/crypto/CHIPCryptoPALOpenSSL.cpp b/src/crypto/CHIPCryptoPALOpenSSL.cpp index 761294d0cc84ee..d1211bccbc5da2 100644 --- a/src/crypto/CHIPCryptoPALOpenSSL.cpp +++ b/src/crypto/CHIPCryptoPALOpenSSL.cpp @@ -1254,6 +1254,8 @@ CHIP_ERROR P256Keypair::NewCertificateSigningRequest(uint8_t * out_csr, size_t & CHIP_ERROR VerifyCertificateSigningRequest(const uint8_t * csr, size_t csr_length, P256PublicKey & pubkey) { + ReturnErrorOnFailure(VerifyCertificateSigningRequestFormat(csr, csr_length)); + ERR_clear_error(); CHIP_ERROR error = CHIP_NO_ERROR; int result = 0; diff --git a/src/crypto/CHIPCryptoPALTinyCrypt.cpp b/src/crypto/CHIPCryptoPALTinyCrypt.cpp index ae166a294744fc..aa9df451cc692a 100644 --- a/src/crypto/CHIPCryptoPALTinyCrypt.cpp +++ b/src/crypto/CHIPCryptoPALTinyCrypt.cpp @@ -777,6 +777,8 @@ CHIP_ERROR P256Keypair::NewCertificateSigningRequest(uint8_t * out_csr, size_t & CHIP_ERROR VerifyCertificateSigningRequest(const uint8_t * csr_buf, size_t csr_length, P256PublicKey & pubkey) { #if defined(MBEDTLS_X509_CSR_PARSE_C) + ReturnErrorOnFailure(VerifyCertificateSigningRequestFormat(csr_buf, csr_length)); + // TODO: For some embedded targets, mbedTLS library doesn't have mbedtls_x509_csr_parse_der, and mbedtls_x509_csr_parse_free. // Taking a step back, embedded targets likely will not process CSR requests. Adding this action item to reevaluate // this if there's a need for this processing for embedded targets. diff --git a/src/crypto/CHIPCryptoPALmbedTLS.cpp b/src/crypto/CHIPCryptoPALmbedTLS.cpp index 9bce7e94430796..dfbd993f023d8d 100644 --- a/src/crypto/CHIPCryptoPALmbedTLS.cpp +++ b/src/crypto/CHIPCryptoPALmbedTLS.cpp @@ -889,6 +889,8 @@ CHIP_ERROR P256Keypair::NewCertificateSigningRequest(uint8_t * out_csr, size_t & CHIP_ERROR VerifyCertificateSigningRequest(const uint8_t * csr_buf, size_t csr_length, P256PublicKey & pubkey) { #if defined(MBEDTLS_X509_CSR_PARSE_C) + ReturnErrorOnFailure(VerifyCertificateSigningRequestFormat(csr_buf, csr_length)); + // TODO: For some embedded targets, mbedTLS library doesn't have mbedtls_x509_csr_parse_der, and mbedtls_x509_csr_parse_free. // Taking a step back, embedded targets likely will not process CSR requests. Adding this action item to reevaluate // this if there's a need for this processing for embedded targets. diff --git a/src/crypto/tests/CHIPCryptoPALTest.cpp b/src/crypto/tests/CHIPCryptoPALTest.cpp index 8c76468e6158ea..485ead2cf99322 100644 --- a/src/crypto/tests/CHIPCryptoPALTest.cpp +++ b/src/crypto/tests/CHIPCryptoPALTest.cpp @@ -1034,6 +1034,170 @@ static void TestP256_Keygen(nlTestSuite * inSuite, void * inContext) NL_TEST_ASSERT(inSuite, keypair.Pubkey().ECDSA_validate_msg_signature(test_msg, msglen, test_sig) == CHIP_NO_ERROR); } +void TestCSR_Verify(nlTestSuite * inSuite, void * inContext) +{ + Crypto::P256PublicKey pubKey; + CHIP_ERROR err; + + // First case: there is trailing garbage in the CSR + { + const uint8_t kBadTrailingGarbageCsr[255] = { + 0x30, 0x81, 0xda, 0x30, 0x81, 0x81, 0x02, 0x01, 0x00, 0x30, 0x0e, 0x31, 0x0c, 0x30, 0x0a, 0x06, 0x03, 0x55, 0x04, 0x0b, + 0x0c, 0x03, 0x43, 0x53, 0x41, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, + 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0x72, 0x48, 0xc0, 0x36, 0xf0, 0x12, 0x5f, 0xd1, + 0x68, 0x92, 0x2d, 0xee, 0x57, 0x2b, 0x8e, 0x20, 0x9d, 0x97, 0xfa, 0x73, 0x92, 0xf1, 0xa0, 0x91, 0x0e, 0xfd, 0x04, 0x93, + 0x66, 0x47, 0x3c, 0xa3, 0xf0, 0xa8, 0x47, 0xa1, 0xa3, 0x1e, 0x13, 0x3b, 0x67, 0x3b, 0x18, 0xca, 0x77, 0xd1, 0xea, 0xe3, + 0x74, 0x93, 0x49, 0x8b, 0x9d, 0xdc, 0xef, 0xf9, 0xd5, 0x9b, 0x27, 0x19, 0xad, 0x6e, 0x90, 0xd2, 0xa0, 0x11, 0x30, 0x0f, + 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x0e, 0x31, 0x02, 0x30, 0x00, 0x30, 0x0a, 0x06, 0x08, 0x2a, + 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, 0x48, 0x00, 0x30, 0x45, 0x02, 0x20, 0x6a, 0x2e, 0x15, 0x34, 0x1b, 0xde, + 0xcb, 0x8f, 0xd2, 0xfd, 0x35, 0x03, 0x89, 0x0e, 0xed, 0x23, 0x54, 0xff, 0xcb, 0x79, 0xf9, 0xcb, 0x40, 0x33, 0x59, 0xb4, + 0x27, 0x69, 0xeb, 0x07, 0x3b, 0xd5, 0x02, 0x21, 0x00, 0xb0, 0x25, 0xc9, 0xc2, 0x21, 0xe8, 0x54, 0xcc, 0x08, 0x12, 0xf5, + 0x10, 0x3a, 0x0b, 0x25, 0x20, 0x0a, 0x61, 0x38, 0xc8, 0x6f, 0x82, 0xa7, 0x51, 0x84, 0x61, 0xae, 0x93, 0x69, 0xe4, 0x74, + 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + + Crypto::ClearSecretData(pubKey.Bytes(), pubKey.Length()); + + err = VerifyCertificateSigningRequest(&kBadTrailingGarbageCsr[0], sizeof(kBadTrailingGarbageCsr), pubKey); + + // On first test case, check if CSRs are supported at all, and skip test if they are not. + if (err == CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE) + { + ChipLogError(Crypto, "The current platform does not support CSR parsing."); + return; + } + + NL_TEST_ASSERT(inSuite, err != CHIP_NO_ERROR); + + err = VerifyCertificateSigningRequestFormat(&kBadTrailingGarbageCsr[0], sizeof(kBadTrailingGarbageCsr)); + NL_TEST_ASSERT(inSuite, err == CHIP_ERROR_UNSUPPORTED_CERT_FORMAT); + } + + // Second case: correct CSR + { + const uint8_t kGoodCsr[205] = { + 0x30, 0x81, 0xca, 0x30, 0x70, 0x02, 0x01, 0x00, 0x30, 0x0e, 0x31, 0x0c, 0x30, 0x0a, 0x06, 0x03, 0x55, 0x04, 0x0a, + 0x0c, 0x03, 0x43, 0x53, 0x52, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, + 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0xa3, 0xbe, 0xa1, 0xf5, 0x42, 0x01, + 0x07, 0x3c, 0x4b, 0x75, 0x85, 0xd8, 0xe2, 0x98, 0xac, 0x2f, 0xf6, 0x98, 0xdb, 0xd9, 0x5b, 0xe0, 0x7e, 0xc1, 0x04, + 0xd5, 0x73, 0xc5, 0xb0, 0x90, 0x77, 0x27, 0x00, 0x1e, 0x22, 0xc7, 0x89, 0x5e, 0x4d, 0x75, 0x07, 0x89, 0x82, 0x0f, + 0x49, 0xb6, 0x59, 0xd5, 0xc5, 0x15, 0x7d, 0x93, 0xe6, 0x80, 0x5c, 0x70, 0x89, 0x0a, 0x43, 0x10, 0x3d, 0xeb, 0x3d, + 0x4a, 0xa0, 0x00, 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x05, 0x00, 0x03, 0x48, + 0x00, 0x30, 0x45, 0x02, 0x20, 0x1d, 0x86, 0x21, 0xb4, 0xc2, 0xe1, 0xa9, 0xf3, 0xbc, 0xc8, 0x7c, 0xda, 0xb4, 0xb9, + 0xc6, 0x8c, 0xd0, 0xe4, 0x9a, 0x9c, 0xef, 0x02, 0x93, 0x98, 0x27, 0x7e, 0x81, 0x21, 0x5d, 0x20, 0x9d, 0x32, 0x02, + 0x21, 0x00, 0x8b, 0x6b, 0x49, 0xb6, 0x7d, 0x3e, 0x67, 0x9e, 0xb1, 0x22, 0xd3, 0x63, 0x82, 0x40, 0x4f, 0x49, 0xa4, + 0xdc, 0x17, 0x35, 0xac, 0x4b, 0x7a, 0xbf, 0x52, 0x05, 0x58, 0x68, 0xe0, 0xaa, 0xd2, 0x8e, + }; + const uint8_t kGoodCsrSubjectPublicKey[65] = { + 0x04, 0xa3, 0xbe, 0xa1, 0xf5, 0x42, 0x01, 0x07, 0x3c, 0x4b, 0x75, 0x85, 0xd8, 0xe2, 0x98, 0xac, 0x2f, + 0xf6, 0x98, 0xdb, 0xd9, 0x5b, 0xe0, 0x7e, 0xc1, 0x04, 0xd5, 0x73, 0xc5, 0xb0, 0x90, 0x77, 0x27, 0x00, + 0x1e, 0x22, 0xc7, 0x89, 0x5e, 0x4d, 0x75, 0x07, 0x89, 0x82, 0x0f, 0x49, 0xb6, 0x59, 0xd5, 0xc5, 0x15, + 0x7d, 0x93, 0xe6, 0x80, 0x5c, 0x70, 0x89, 0x0a, 0x43, 0x10, 0x3d, 0xeb, 0x3d, 0x4a, + }; + + Crypto::ClearSecretData(pubKey.Bytes(), pubKey.Length()); + + err = VerifyCertificateSigningRequestFormat(&kGoodCsr[0], sizeof(kGoodCsr)); + NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + + err = VerifyCertificateSigningRequest(&kGoodCsr[0], sizeof(kGoodCsr), pubKey); + NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + + Crypto::P256PublicKey expected(kGoodCsrSubjectPublicKey); + NL_TEST_ASSERT(inSuite, pubKey.Matches(expected)); + } + + // Third case: bad signature + { + const uint8_t kBadSignatureSignatureCsr[205] = { + 0x30, 0x81, 0xca, 0x30, 0x70, 0x02, 0x01, 0x00, 0x30, 0x0e, 0x31, 0x0c, 0x30, 0x0a, 0x06, 0x03, 0x55, 0x04, 0x0a, + 0x0c, 0x03, 0x43, 0x53, 0x52, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, + 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0xa3, 0xbe, 0xa1, 0xf5, 0x42, 0x01, + 0x07, 0x3c, 0x4b, 0x75, 0x85, 0xd8, 0xe2, 0x98, 0xac, 0x2f, 0xf6, 0x98, 0xdb, 0xd9, 0x5b, 0xe0, 0x7e, 0xc1, 0x04, + 0xd5, 0x73, 0xc5, 0xb0, 0x90, 0x77, 0x27, 0x00, 0x1e, 0x22, 0xc7, 0x89, 0x5e, 0x4d, 0x75, 0x07, 0x89, 0x82, 0x0f, + 0x49, 0xb6, 0x59, 0xd5, 0xc5, 0x15, 0x7d, 0x93, 0xe6, 0x80, 0x5c, 0x70, 0x89, 0x0a, 0x43, 0x10, 0x3d, 0xeb, 0x3d, + 0x4a, 0xa0, 0x00, 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x05, 0x00, 0x03, 0x48, + 0x00, 0x30, 0x45, 0x02, 0x20, 0x1d, 0x86, 0x21, 0xb4, 0xc2, 0xe1, 0xa9, 0xf3, 0xbc, 0xc8, 0x7c, 0xda, 0xb4, 0xb9, + 0xc6, 0x8c, 0xd0, 0xe4, 0x9a, 0x9c, 0xef, 0x02, 0x93, 0x98, 0x27, 0x7e, 0x81, 0x21, 0x5d, 0x20, 0x9d, 0x32, 0x02, + 0x21, 0x00, 0x8b, 0x6b, 0x49, 0xb6, 0x7d, 0x3e, 0x67, 0x9e, 0xb1, 0x21, 0xd3, 0x63, 0x82, 0x40, 0x4f, 0x49, 0xa4, + 0xdc, 0x17, 0x35, 0xac, 0x4b, 0x7a, 0xbf, 0x52, 0x05, 0x58, 0x68, 0xe0, 0xaa, 0xd2, 0x8e, + }; + + Crypto::ClearSecretData(pubKey.Bytes(), pubKey.Length()); + + err = VerifyCertificateSigningRequestFormat(&kBadSignatureSignatureCsr[0], sizeof(kBadSignatureSignatureCsr)); + NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + + err = VerifyCertificateSigningRequest(&kBadSignatureSignatureCsr[0], sizeof(kBadSignatureSignatureCsr), pubKey); + NL_TEST_ASSERT(inSuite, err != CHIP_NO_ERROR); + } + + // Fourth case: CSR too big + { + const uint8_t kBadTooBigCsr[256] = { + 0x30, 0x81, 0xda, 0x30, 0x81, 0x81, 0x02, 0x01, 0x00, 0x30, 0x0e, 0x31, 0x0c, 0x30, 0x0a, 0x06, 0x03, 0x55, 0x04, 0x0b, + 0x0c, 0x03, 0x43, 0x53, 0x41, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, + 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0x72, 0x48, 0xc0, 0x36, 0xf0, 0x12, 0x5f, 0xd1, + 0x68, 0x92, 0x2d, 0xee, 0x57, 0x2b, 0x8e, 0x20, 0x9d, 0x97, 0xfa, 0x73, 0x92, 0xf1, 0xa0, 0x91, 0x0e, 0xfd, 0x04, 0x93, + 0x66, 0x47, 0x3c, 0xa3, 0xf0, 0xa8, 0x47, 0xa1, 0xa3, 0x1e, 0x13, 0x3b, 0x67, 0x3b, 0x18, 0xca, 0x77, 0xd1, 0xea, 0xe3, + 0x74, 0x93, 0x49, 0x8b, 0x9d, 0xdc, 0xef, 0xf9, 0xd5, 0x9b, 0x27, 0x19, 0xad, 0x6e, 0x90, 0xd2, 0xa0, 0x11, 0x30, 0x0f, + 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x0e, 0x31, 0x02, 0x30, 0x00, 0x30, 0x0a, 0x06, 0x08, 0x2a, + 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, 0x48, 0x00, 0x30, 0x45, 0x02, 0x20, 0x6a, 0x2e, 0x15, 0x34, 0x1b, 0xde, + 0xcb, 0x8f, 0xd2, 0xfd, 0x35, 0x03, 0x89, 0x0e, 0xed, 0x23, 0x54, 0xff, 0xcb, 0x79, 0xf9, 0xcb, 0x40, 0x33, 0x59, 0xb4, + 0x27, 0x69, 0xeb, 0x07, 0x3b, 0xd5, 0x02, 0x21, 0x00, 0xb0, 0x25, 0xc9, 0xc2, 0x21, 0xe8, 0x54, 0xcc, 0x08, 0x12, 0xf5, + 0x10, 0x3a, 0x0b, 0x25, 0x20, 0x0a, 0x61, 0x38, 0xc8, 0x6f, 0x82, 0xa7, 0x51, 0x84, 0x61, 0xae, 0x93, 0x69, 0xe4, 0x74, + 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + }; + + Crypto::ClearSecretData(pubKey.Bytes(), pubKey.Length()); + err = VerifyCertificateSigningRequestFormat(&kBadTooBigCsr[0], sizeof(kBadTooBigCsr)); + NL_TEST_ASSERT(inSuite, err == CHIP_ERROR_UNSUPPORTED_CERT_FORMAT); + + err = VerifyCertificateSigningRequest(&kBadTooBigCsr[0], sizeof(kBadTooBigCsr), pubKey); + NL_TEST_ASSERT(inSuite, err != CHIP_NO_ERROR); + } + + // Fifth case: obviously invalid CSR (1/2) + { + const uint8_t kTooSmallCsr[10] = { 0x30, 0x81, 0xda, 0x30, 0x81, 0x81, 0x02, 0x01, 0x00, 0x30 }; + + Crypto::ClearSecretData(pubKey.Bytes(), pubKey.Length()); + + err = VerifyCertificateSigningRequestFormat(&kTooSmallCsr[0], sizeof(kTooSmallCsr)); + NL_TEST_ASSERT(inSuite, err == CHIP_ERROR_UNSUPPORTED_CERT_FORMAT); + + err = VerifyCertificateSigningRequest(&kTooSmallCsr[0], sizeof(kTooSmallCsr), pubKey); + NL_TEST_ASSERT(inSuite, err != CHIP_NO_ERROR); + } + + // Sixth case: obviously invalid CSR (2/2) + { + const uint8_t kNotSequenceCsr[205] = { + 0x31, 0x81, 0xca, 0x30, 0x70, 0x02, 0x01, 0x00, 0x30, 0x0e, 0x31, 0x0c, 0x30, 0x0a, 0x06, 0x03, 0x55, 0x04, 0x0a, + 0x0c, 0x03, 0x43, 0x53, 0x52, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, + 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0xa3, 0xbe, 0xa1, 0xf5, 0x42, 0x01, + 0x07, 0x3c, 0x4b, 0x75, 0x85, 0xd8, 0xe2, 0x98, 0xac, 0x2f, 0xf6, 0x98, 0xdb, 0xd9, 0x5b, 0xe0, 0x7e, 0xc1, 0x04, + 0xd5, 0x73, 0xc5, 0xb0, 0x90, 0x77, 0x27, 0x00, 0x1e, 0x22, 0xc7, 0x89, 0x5e, 0x4d, 0x75, 0x07, 0x89, 0x82, 0x0f, + 0x49, 0xb6, 0x59, 0xd5, 0xc5, 0x15, 0x7d, 0x93, 0xe6, 0x80, 0x5c, 0x70, 0x89, 0x0a, 0x43, 0x10, 0x3d, 0xeb, 0x3d, + 0x4a, 0xa0, 0x00, 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x05, 0x00, 0x03, 0x48, + 0x00, 0x30, 0x45, 0x02, 0x20, 0x1d, 0x86, 0x21, 0xb4, 0xc2, 0xe1, 0xa9, 0xf3, 0xbc, 0xc8, 0x7c, 0xda, 0xb4, 0xb9, + 0xc6, 0x8c, 0xd0, 0xe4, 0x9a, 0x9c, 0xef, 0x02, 0x93, 0x98, 0x27, 0x7e, 0x81, 0x21, 0x5d, 0x20, 0x9d, 0x32, 0x02, + 0x21, 0x00, 0x8b, 0x6b, 0x49, 0xb6, 0x7d, 0x3e, 0x67, 0x9e, 0xb1, 0x22, 0xd3, 0x63, 0x82, 0x40, 0x4f, 0x49, 0xa4, + 0xdc, 0x17, 0x35, 0xac, 0x4b, 0x7a, 0xbf, 0x52, 0x05, 0x58, 0x68, 0xe0, 0xaa, 0xd2, 0x8e, + }; + + Crypto::ClearSecretData(pubKey.Bytes(), pubKey.Length()); + + err = VerifyCertificateSigningRequestFormat(&kNotSequenceCsr[0], sizeof(kNotSequenceCsr)); + NL_TEST_ASSERT(inSuite, err == CHIP_ERROR_UNSUPPORTED_CERT_FORMAT); + + err = VerifyCertificateSigningRequest(&kNotSequenceCsr[0], sizeof(kNotSequenceCsr), pubKey); + NL_TEST_ASSERT(inSuite, err != CHIP_NO_ERROR); + } +} + void TestCSR_GenDirect(nlTestSuite * inSuite, void * inContext) { uint8_t csrBuf[kMAX_CSR_Length]; @@ -2136,6 +2300,7 @@ static const nlTest sTests[] = { NL_TEST_DEF("Test adding entropy sources", TestAddEntropySources), NL_TEST_DEF("Test PBKDF2 SHA256", TestPBKDF2_SHA256_TestVectors), NL_TEST_DEF("Test P256 Keygen", TestP256_Keygen), + NL_TEST_DEF("Test CSR Verification + PK extraction", TestCSR_Verify), NL_TEST_DEF("Test CSR Generation via P256Keypair method", TestCSR_GenByKeypair), NL_TEST_DEF("Test Direct CSR Generation", TestCSR_GenDirect), NL_TEST_DEF("Test Keypair Serialize", TestKeypair_Serialize), diff --git a/src/platform/EFR32/CHIPCryptoPALPsaEfr32.cpp b/src/platform/EFR32/CHIPCryptoPALPsaEfr32.cpp index 72c4706501f851..27289aeea069aa 100644 --- a/src/platform/EFR32/CHIPCryptoPALPsaEfr32.cpp +++ b/src/platform/EFR32/CHIPCryptoPALPsaEfr32.cpp @@ -902,6 +902,8 @@ CHIP_ERROR P256Keypair::NewCertificateSigningRequest(uint8_t * out_csr, size_t & CHIP_ERROR VerifyCertificateSigningRequest(const uint8_t * csr_buf, size_t csr_length, P256PublicKey & pubkey) { #if defined(MBEDTLS_X509_CSR_PARSE_C) + ReturnErrorOnFailure(VerifyCertificateSigningRequestFormat(csr_buf, csr_length)); + // TODO: For some embedded targets, mbedTLS library doesn't have mbedtls_x509_csr_parse_der, and mbedtls_x509_csr_parse_free. // Taking a step back, embedded targets likely will not process CSR requests. Adding this action item to reevaluate // this if there's a need for this processing for embedded targets. From 5f94d380c22c46267c521a008aff36653b902ecb Mon Sep 17 00:00:00 2001 From: Shubham Patil Date: Tue, 23 Aug 2022 18:48:29 +0530 Subject: [PATCH 13/15] [ESP32] Support disabling SOFTAP for saving some flash (#22096) * [ESP32] Support disabling SOFTAP support for saving some flash * Disable softap by default in examples * If rendezvous mode is softap then enable softap configurations --- config/esp32/components/chip/Kconfig | 1 + .../esp32/main/Kconfig.projbuild | 2 + .../all-clusters-app/esp32/sdkconfig.defaults | 3 ++ .../esp32/main/Kconfig.projbuild | 2 + .../esp32/sdkconfig.defaults | 3 ++ examples/bridge-app/esp32/sdkconfig.defaults | 3 ++ examples/chef/esp32/main/Kconfig.projbuild | 2 + examples/chef/esp32/sdkconfig.defaults | 3 ++ .../light-switch-app/esp32/sdkconfig.defaults | 5 ++- .../lighting-app/esp32/sdkconfig.defaults | 3 ++ examples/lock-app/esp32/sdkconfig.defaults | 3 ++ .../ota-provider-app/esp32/sdkconfig.defaults | 3 ++ .../esp32/sdkconfig.defaults | 3 ++ .../esp32/sdkconfig.defaults | 3 ++ src/platform/ESP32/CHIPDevicePlatformConfig.h | 2 + src/platform/ESP32/ConnectivityManagerImpl.h | 42 +++++++++++-------- .../ESP32/ConnectivityManagerImpl_WiFi.cpp | 23 ++++++++-- src/platform/ESP32/ESP32Utils.cpp | 9 +++- src/platform/ESP32/ESP32Utils.h | 2 + src/platform/ESP32/PlatformManagerImpl.cpp | 3 +- 20 files changed, 95 insertions(+), 25 deletions(-) diff --git a/config/esp32/components/chip/Kconfig b/config/esp32/components/chip/Kconfig index 4a6cc6dd6e889e..55cafa1c8a07a8 100644 --- a/config/esp32/components/chip/Kconfig +++ b/config/esp32/components/chip/Kconfig @@ -387,6 +387,7 @@ menu "CHIP Device Layer" menu "WiFi AP Options" config ENABLE_WIFI_AP + depends on ESP_WIFI_SOFTAP_SUPPORT bool "Enable CHIP WIFI AP" default y help diff --git a/examples/all-clusters-app/esp32/main/Kconfig.projbuild b/examples/all-clusters-app/esp32/main/Kconfig.projbuild index 8791a80a443e71..22edca7a03b264 100644 --- a/examples/all-clusters-app/esp32/main/Kconfig.projbuild +++ b/examples/all-clusters-app/esp32/main/Kconfig.projbuild @@ -53,6 +53,7 @@ menu "Demo" config RENDEZVOUS_MODE_SOFTAP bool "Soft-AP" + select ESP_WIFI_SOFTAP_SUPPORT config RENDEZVOUS_MODE_BLE bool "BLE" depends on BT_ENABLED @@ -60,6 +61,7 @@ menu "Demo" bool "On-Network" config RENDEZVOUS_MODE_SOFTAP_ON_NETWORK bool "Soft-AP / On-Network" + select ESP_WIFI_SOFTAP_SUPPORT config RENDEZVOUS_MODE_BLE_ON_NETWORK bool "BLE / On-Network" endchoice diff --git a/examples/all-clusters-app/esp32/sdkconfig.defaults b/examples/all-clusters-app/esp32/sdkconfig.defaults index 5f996f40946d68..a9c28a1a863a25 100644 --- a/examples/all-clusters-app/esp32/sdkconfig.defaults +++ b/examples/all-clusters-app/esp32/sdkconfig.defaults @@ -53,3 +53,6 @@ CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y # Serial Flasher config CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y CONFIG_ESPTOOLPY_FLASHSIZE="4MB" + +# Disable softap support by default +CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n diff --git a/examples/all-clusters-minimal-app/esp32/main/Kconfig.projbuild b/examples/all-clusters-minimal-app/esp32/main/Kconfig.projbuild index 8791a80a443e71..22edca7a03b264 100644 --- a/examples/all-clusters-minimal-app/esp32/main/Kconfig.projbuild +++ b/examples/all-clusters-minimal-app/esp32/main/Kconfig.projbuild @@ -53,6 +53,7 @@ menu "Demo" config RENDEZVOUS_MODE_SOFTAP bool "Soft-AP" + select ESP_WIFI_SOFTAP_SUPPORT config RENDEZVOUS_MODE_BLE bool "BLE" depends on BT_ENABLED @@ -60,6 +61,7 @@ menu "Demo" bool "On-Network" config RENDEZVOUS_MODE_SOFTAP_ON_NETWORK bool "Soft-AP / On-Network" + select ESP_WIFI_SOFTAP_SUPPORT config RENDEZVOUS_MODE_BLE_ON_NETWORK bool "BLE / On-Network" endchoice diff --git a/examples/all-clusters-minimal-app/esp32/sdkconfig.defaults b/examples/all-clusters-minimal-app/esp32/sdkconfig.defaults index 5f996f40946d68..a9c28a1a863a25 100644 --- a/examples/all-clusters-minimal-app/esp32/sdkconfig.defaults +++ b/examples/all-clusters-minimal-app/esp32/sdkconfig.defaults @@ -53,3 +53,6 @@ CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y # Serial Flasher config CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y CONFIG_ESPTOOLPY_FLASHSIZE="4MB" + +# Disable softap support by default +CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n diff --git a/examples/bridge-app/esp32/sdkconfig.defaults b/examples/bridge-app/esp32/sdkconfig.defaults index 6a6589e1040577..d76496f541c9ba 100644 --- a/examples/bridge-app/esp32/sdkconfig.defaults +++ b/examples/bridge-app/esp32/sdkconfig.defaults @@ -39,3 +39,6 @@ CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y + +# Disable softap support by default +CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n diff --git a/examples/chef/esp32/main/Kconfig.projbuild b/examples/chef/esp32/main/Kconfig.projbuild index 307b7f6ccb83bc..695222b7f43c45 100644 --- a/examples/chef/esp32/main/Kconfig.projbuild +++ b/examples/chef/esp32/main/Kconfig.projbuild @@ -55,6 +55,7 @@ menu "Demo" bool "Bypass" config RENDEZVOUS_MODE_SOFTAP bool "Soft-AP" + select ESP_WIFI_SOFTAP_SUPPORT config RENDEZVOUS_MODE_BLE bool "BLE" depends on BT_ENABLED @@ -62,6 +63,7 @@ menu "Demo" bool "On-Network" config RENDEZVOUS_MODE_SOFTAP_ON_NETWORK bool "Soft-AP / On-Network" + select ESP_WIFI_SOFTAP_SUPPORT config RENDEZVOUS_MODE_BLE_ON_NETWORK bool "BLE / On-Network" endchoice diff --git a/examples/chef/esp32/sdkconfig.defaults b/examples/chef/esp32/sdkconfig.defaults index ab2bb7c5dcb419..a3a1d8a272b8b3 100644 --- a/examples/chef/esp32/sdkconfig.defaults +++ b/examples/chef/esp32/sdkconfig.defaults @@ -47,3 +47,6 @@ CONFIG_STACK_CHECK=y # Serial Flasher config CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y CONFIG_ESPTOOLPY_FLASHSIZE="4MB" + +# Disable softap support by default +CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n diff --git a/examples/light-switch-app/esp32/sdkconfig.defaults b/examples/light-switch-app/esp32/sdkconfig.defaults index f8d119e98c2bec..4e780d862ad614 100644 --- a/examples/light-switch-app/esp32/sdkconfig.defaults +++ b/examples/light-switch-app/esp32/sdkconfig.defaults @@ -45,4 +45,7 @@ CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y CONFIG_ESPTOOLPY_FLASHSIZE="4MB" #enable debug shell -CONFIG_ENABLE_CHIP_SHELL=y \ No newline at end of file +CONFIG_ENABLE_CHIP_SHELL=y + +# Disable softap support by default +CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n diff --git a/examples/lighting-app/esp32/sdkconfig.defaults b/examples/lighting-app/esp32/sdkconfig.defaults index 23a3766c340c04..e051a3f2b37aee 100644 --- a/examples/lighting-app/esp32/sdkconfig.defaults +++ b/examples/lighting-app/esp32/sdkconfig.defaults @@ -43,3 +43,6 @@ CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y # Serial Flasher config CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y CONFIG_ESPTOOLPY_FLASHSIZE="4MB" + +# Disable softap support by default +CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n diff --git a/examples/lock-app/esp32/sdkconfig.defaults b/examples/lock-app/esp32/sdkconfig.defaults index c9b513d752fc6c..d53bfc85c76c22 100644 --- a/examples/lock-app/esp32/sdkconfig.defaults +++ b/examples/lock-app/esp32/sdkconfig.defaults @@ -43,3 +43,6 @@ CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y #Lock app PID CONFIG_DEVICE_PRODUCT_ID=0x8006 + +# Disable softap support by default +CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n diff --git a/examples/ota-provider-app/esp32/sdkconfig.defaults b/examples/ota-provider-app/esp32/sdkconfig.defaults index 537c6deab2897f..7fce894e5a80d8 100644 --- a/examples/ota-provider-app/esp32/sdkconfig.defaults +++ b/examples/ota-provider-app/esp32/sdkconfig.defaults @@ -58,3 +58,6 @@ CONFIG_USE_TEST_SETUP_DISCRIMINATOR=0xF01 # Enable chip shell CONFIG_ENABLE_CHIP_SHELL=y + +# Disable softap support by default +CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n diff --git a/examples/ota-requestor-app/esp32/sdkconfig.defaults b/examples/ota-requestor-app/esp32/sdkconfig.defaults index beec4822b35cdf..17b6e378f65ca9 100644 --- a/examples/ota-requestor-app/esp32/sdkconfig.defaults +++ b/examples/ota-requestor-app/esp32/sdkconfig.defaults @@ -59,3 +59,6 @@ CONFIG_DEVICE_SOFTWARE_VERSION_NUMBER=2 # Enable Chip Shell CONFIG_ENABLE_CHIP_SHELL=y + +# Disable softap support by default +CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n diff --git a/examples/temperature-measurement-app/esp32/sdkconfig.defaults b/examples/temperature-measurement-app/esp32/sdkconfig.defaults index 4659af909a144f..dcd05c0734f36a 100644 --- a/examples/temperature-measurement-app/esp32/sdkconfig.defaults +++ b/examples/temperature-measurement-app/esp32/sdkconfig.defaults @@ -84,3 +84,6 @@ CONFIG_ESP_MAIN_TASK_STACK_SIZE=4096 #enable lwIP route hooks CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y + +# Disable softap support by default +CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n diff --git a/src/platform/ESP32/CHIPDevicePlatformConfig.h b/src/platform/ESP32/CHIPDevicePlatformConfig.h index 3bc56162c00350..c40cd8c565e11d 100644 --- a/src/platform/ESP32/CHIPDevicePlatformConfig.h +++ b/src/platform/ESP32/CHIPDevicePlatformConfig.h @@ -59,11 +59,13 @@ #define CHIP_DEVICE_CONFIG_MAX_SCAN_NETWORKS_RESULTS CONFIG_MAX_SCAN_NETWORKS_RESULTS #define CHIP_DEVICE_CONFIG_WIFI_SCAN_COMPLETION_TIMEOUT CONFIG_WIFI_SCAN_COMPLETION_TIMEOUT #define CHIP_DEVICE_CONFIG_WIFI_CONNECTIVITY_TIMEOUT CONFIG_WIFI_CONNECTIVITY_TIMEOUT +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP #define CHIP_DEVICE_CONFIG_WIFI_AP_SSID_PREFIX CONFIG_WIFI_AP_SSID_PREFIX #define CHIP_DEVICE_CONFIG_WIFI_AP_CHANNEL CONFIG_WIFI_AP_CHANNEL #define CHIP_DEVICE_CONFIG_WIFI_AP_MAX_STATIONS CONFIG_WIFI_AP_MAX_STATIONS #define CHIP_DEVICE_CONFIG_WIFI_AP_BEACON_INTERVAL CONFIG_WIFI_AP_BEACON_INTERVAL #define CHIP_DEVICE_CONFIG_WIFI_AP_IDLE_TIMEOUT CONFIG_WIFI_AP_IDLE_TIMEOUT +#endif /* CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP */ #define CHIP_DEVICE_CONFIG_ENABLE_WIFI_TELEMETRY CONFIG_ENABLE_WIFI_TELEMETRY #define CHIP_DEVICE_CONFIG_ENABLE_WIFI CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP | CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION #endif // CONFIG_IDF_TARGET_ESP32H2 diff --git a/src/platform/ESP32/ConnectivityManagerImpl.h b/src/platform/ESP32/ConnectivityManagerImpl.h index 3bdd1418c23564..9c7f7774317318 100644 --- a/src/platform/ESP32/ConnectivityManagerImpl.h +++ b/src/platform/ESP32/ConnectivityManagerImpl.h @@ -109,15 +109,6 @@ class ConnectivityManagerImpl final : public ConnectivityManager, CHIP_ERROR _SetWiFiStationReconnectInterval(System::Clock::Timeout val); bool _IsWiFiStationProvisioned(void); void _ClearWiFiStationProvision(void); - WiFiAPMode _GetWiFiAPMode(void); - CHIP_ERROR _SetWiFiAPMode(WiFiAPMode val); - bool _IsWiFiAPActive(void); - bool _IsWiFiAPApplicationControlled(void); - void _DemandStartWiFiAP(void); - void _StopOnDemandWiFiAP(void); - void _MaintainOnDemandWiFiAP(void); - System::Clock::Timeout _GetWiFiAPIdleTimeout(void); - void _SetWiFiAPIdleTimeout(System::Clock::Timeout val); CHIP_ERROR _GetAndLogWiFiStatsCounters(void); bool _CanStartWiFiScan(); void _OnWiFiScanDone(); @@ -126,13 +117,9 @@ class ConnectivityManagerImpl final : public ConnectivityManager, // ===== Private members reserved for use by this class only. System::Clock::Timestamp mLastStationConnectFailTime; - System::Clock::Timestamp mLastAPDemandTime; WiFiStationMode mWiFiStationMode; WiFiStationState mWiFiStationState; - WiFiAPMode mWiFiAPMode; - WiFiAPState mWiFiAPState; System::Clock::Timeout mWiFiStationReconnectInterval; - System::Clock::Timeout mWiFiAPIdleTimeout; BitFlags mFlags; CHIP_ERROR InitWiFi(void); @@ -144,10 +131,27 @@ class ConnectivityManagerImpl final : public ConnectivityManager, void ChangeWiFiStationState(WiFiStationState newState); static void DriveStationState(::chip::System::Layer * aLayer, void * aAppState); +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP + WiFiAPMode _GetWiFiAPMode(void); + CHIP_ERROR _SetWiFiAPMode(WiFiAPMode val); + bool _IsWiFiAPActive(void); + void _DemandStartWiFiAP(void); + void _StopOnDemandWiFiAP(void); + void _MaintainOnDemandWiFiAP(void); + System::Clock::Timeout _GetWiFiAPIdleTimeout(void); + void _SetWiFiAPIdleTimeout(System::Clock::Timeout val); + bool _IsWiFiAPApplicationControlled(void); + + System::Clock::Timestamp mLastAPDemandTime; + WiFiAPMode mWiFiAPMode; + WiFiAPState mWiFiAPState; + System::Clock::Timeout mWiFiAPIdleTimeout; + void DriveAPState(void); CHIP_ERROR ConfigureWiFiAP(void); void ChangeWiFiAPState(WiFiAPState newState); static void DriveAPState(::chip::System::Layer * aLayer, void * aAppState); +#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP void UpdateInternetConnectivityState(void); void OnStationIPv4AddressAvailable(const ip_event_got_ip_t & got_ip); @@ -174,16 +178,12 @@ inline bool ConnectivityManagerImpl::_IsWiFiStationConnected(void) return mWiFiStationState == kWiFiStationState_Connected; } -inline bool ConnectivityManagerImpl::_IsWiFiAPApplicationControlled(void) -{ - return mWiFiAPMode == kWiFiAPMode_ApplicationControlled; -} - inline System::Clock::Timeout ConnectivityManagerImpl::_GetWiFiStationReconnectInterval(void) { return mWiFiStationReconnectInterval; } +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP inline ConnectivityManager::WiFiAPMode ConnectivityManagerImpl::_GetWiFiAPMode(void) { return mWiFiAPMode; @@ -199,6 +199,12 @@ inline System::Clock::Timeout ConnectivityManagerImpl::_GetWiFiAPIdleTimeout(voi return mWiFiAPIdleTimeout; } +inline bool ConnectivityManagerImpl::_IsWiFiAPApplicationControlled(void) +{ + return mWiFiAPMode == kWiFiAPMode_ApplicationControlled; +} +#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP + inline bool ConnectivityManagerImpl::_CanStartWiFiScan() { return mWiFiStationState != kWiFiStationState_Connecting; diff --git a/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp b/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp index f00c92803908aa..2eb2e1b3ad11e0 100644 --- a/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp +++ b/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp @@ -110,10 +110,13 @@ void ConnectivityManagerImpl::_ClearWiFiStationProvision(void) esp_wifi_set_config(WIFI_IF_STA, &stationConfig); DeviceLayer::SystemLayer().ScheduleWork(DriveStationState, NULL); +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP DeviceLayer::SystemLayer().ScheduleWork(DriveAPState, NULL); +#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP } } +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP CHIP_ERROR ConnectivityManagerImpl::_SetWiFiAPMode(WiFiAPMode val) { CHIP_ERROR err = CHIP_NO_ERROR; @@ -167,6 +170,7 @@ void ConnectivityManagerImpl::_SetWiFiAPIdleTimeout(System::Clock::Timeout val) mWiFiAPIdleTimeout = val; DeviceLayer::SystemLayer().ScheduleWork(DriveAPState, NULL); } +#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP #define WIFI_BAND_2_4GHZ 2400 #define WIFI_BAND_5_0GHZ 5000 @@ -382,13 +386,17 @@ CHIP_ERROR ConnectivityManagerImpl::_GetAndLogWiFiStatsCounters(void) CHIP_ERROR ConnectivityManagerImpl::InitWiFi() { mLastStationConnectFailTime = System::Clock::kZero; - mLastAPDemandTime = System::Clock::kZero; mWiFiStationMode = kWiFiStationMode_Disabled; mWiFiStationState = kWiFiStationState_NotConnected; - mWiFiAPMode = kWiFiAPMode_Disabled; - mWiFiAPState = kWiFiAPState_NotActive; mWiFiStationReconnectInterval = System::Clock::Milliseconds32(CHIP_DEVICE_CONFIG_WIFI_STATION_RECONNECT_INTERVAL); - mWiFiAPIdleTimeout = System::Clock::Milliseconds32(CHIP_DEVICE_CONFIG_WIFI_AP_IDLE_TIMEOUT); + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP + mLastAPDemandTime = System::Clock::kZero; + mWiFiAPMode = kWiFiAPMode_Disabled; + mWiFiAPState = kWiFiAPState_NotActive; + mWiFiAPIdleTimeout = System::Clock::Milliseconds32(CHIP_DEVICE_CONFIG_WIFI_AP_IDLE_TIMEOUT); +#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP + mFlags.SetRaw(0); // TODO Initialize the Chip Addressing and Routing Module. @@ -435,7 +443,10 @@ CHIP_ERROR ConnectivityManagerImpl::InitWiFi() // Queue work items to bootstrap the AP and station state machines once the Chip event loop is running. ReturnErrorOnFailure(DeviceLayer::SystemLayer().ScheduleWork(DriveStationState, NULL)); + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP ReturnErrorOnFailure(DeviceLayer::SystemLayer().ScheduleWork(DriveAPState, NULL)); +#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP return CHIP_NO_ERROR; } @@ -478,6 +489,7 @@ void ConnectivityManagerImpl::OnWiFiPlatformEvent(const ChipDeviceEvent * event) ChipLogProgress(DeviceLayer, "WIFI_EVENT_STA_STOP"); DriveStationState(); break; +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP case WIFI_EVENT_AP_START: ChipLogProgress(DeviceLayer, "WIFI_EVENT_AP_START"); ChangeWiFiAPState(kWiFiAPState_Active); @@ -492,6 +504,7 @@ void ConnectivityManagerImpl::OnWiFiPlatformEvent(const ChipDeviceEvent * event) ChipLogProgress(DeviceLayer, "WIFI_EVENT_AP_STACONNECTED"); MaintainOnDemandWiFiAP(); break; +#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP default: break; } @@ -769,6 +782,7 @@ void ConnectivityManagerImpl::DriveStationState(::chip::System::Layer * aLayer, sInstance.DriveStationState(); } +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP void ConnectivityManagerImpl::DriveAPState() { CHIP_ERROR err = CHIP_NO_ERROR; @@ -952,6 +966,7 @@ void ConnectivityManagerImpl::DriveAPState(::chip::System::Layer * aLayer, void { sInstance.DriveAPState(); } +#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP void ConnectivityManagerImpl::UpdateInternetConnectivityState(void) { diff --git a/src/platform/ESP32/ESP32Utils.cpp b/src/platform/ESP32/ESP32Utils.cpp index 9391ee586e3eb6..e6dd3ea4df09c3 100644 --- a/src/platform/ESP32/ESP32Utils.cpp +++ b/src/platform/ESP32/ESP32Utils.cpp @@ -38,6 +38,7 @@ using namespace ::chip::DeviceLayer::Internal; using chip::DeviceLayer::Internal::DeviceNetworkInfo; +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP CHIP_ERROR ESP32Utils::IsAPEnabled(bool & apEnabled) { wifi_mode_t curWiFiMode; @@ -53,6 +54,7 @@ CHIP_ERROR ESP32Utils::IsAPEnabled(bool & apEnabled) return CHIP_NO_ERROR; } +#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP CHIP_ERROR ESP32Utils::IsStationEnabled(bool & staEnabled) { @@ -130,6 +132,7 @@ CHIP_ERROR ESP32Utils::EnableStationMode(void) return ESP32Utils::MapError(err); } +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP // If station mode is not already enabled (implying the current mode is WIFI_MODE_AP), change // the mode to WIFI_MODE_APSTA. if (curWiFiMode == WIFI_MODE_AP) @@ -144,15 +147,19 @@ CHIP_ERROR ESP32Utils::EnableStationMode(void) return ESP32Utils::MapError(err); } } +#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP return CHIP_NO_ERROR; } CHIP_ERROR ESP32Utils::SetAPMode(bool enabled) { - wifi_mode_t curWiFiMode, targetWiFiMode; + wifi_mode_t curWiFiMode; + wifi_mode_t targetWiFiMode = WIFI_MODE_STA; +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP targetWiFiMode = (enabled) ? WIFI_MODE_APSTA : WIFI_MODE_STA; +#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP // Get the current ESP WiFI mode. esp_err_t err = esp_wifi_get_mode(&curWiFiMode); diff --git a/src/platform/ESP32/ESP32Utils.h b/src/platform/ESP32/ESP32Utils.h index 94a98e0f8b281e..716b85e8434d3a 100644 --- a/src/platform/ESP32/ESP32Utils.h +++ b/src/platform/ESP32/ESP32Utils.h @@ -29,7 +29,9 @@ namespace Internal { class ESP32Utils { public: +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP static CHIP_ERROR IsAPEnabled(bool & apEnabled); +#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP static CHIP_ERROR IsStationEnabled(bool & staEnabled); static bool IsStationProvisioned(void); static CHIP_ERROR IsStationConnected(bool & connected); diff --git a/src/platform/ESP32/PlatformManagerImpl.cpp b/src/platform/ESP32/PlatformManagerImpl.cpp index c96caeb03934ef..d2254692924cca 100644 --- a/src/platform/ESP32/PlatformManagerImpl.cpp +++ b/src/platform/ESP32/PlatformManagerImpl.cpp @@ -84,8 +84,9 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) wifi_init_config_t cfg; uint8_t ap_mac[6]; wifi_mode_t mode; - +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP esp_netif_create_default_wifi_ap(); +#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP esp_netif_create_default_wifi_sta(); esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, PlatformManagerImpl::HandleESPSystemEvent, NULL); From 543ae309d7ddcb313a8e706a91f15c2fce35e104 Mon Sep 17 00:00:00 2001 From: jmartinez-silabs <67972863+jmartinez-silabs@users.noreply.github.com> Date: Tue, 23 Aug 2022 09:22:23 -0400 Subject: [PATCH 14/15] address PR22049 post-merge commments (#22085) --- examples/chef/efr32/BUILD.gn | 2 +- examples/light-switch-app/efr32/BUILD.gn | 2 +- examples/lighting-app/efr32/BUILD.gn | 2 +- examples/lock-app/efr32/BUILD.gn | 2 +- examples/shell/shell_common/BUILD.gn | 2 +- examples/thermostat/efr32/BUILD.gn | 2 +- examples/window-app/efr32/BUILD.gn | 2 +- src/inet/BUILD.gn | 2 +- src/platform/EFR32/BUILD.gn | 2 +- src/test_driver/efr32/BUILD.gn | 2 +- third_party/openthread/BUILD.gn | 4 ++-- third_party/silabs/BUILD.gn | 2 +- 12 files changed, 13 insertions(+), 13 deletions(-) diff --git a/examples/chef/efr32/BUILD.gn b/examples/chef/efr32/BUILD.gn index c567ae9d8f1cbf..e23b747fcad1dd 100644 --- a/examples/chef/efr32/BUILD.gn +++ b/examples/chef/efr32/BUILD.gn @@ -207,7 +207,7 @@ efr32_executable("chef_app") { if (chip_enable_openthread) { deps += [ "${chip_root}/third_party/openthread:openthread", - "${chip_root}/third_party/openthread:openthread_device", + "${chip_root}/third_party/openthread:openthread-platform", "${examples_plat_dir}:efr-matter-shell", ] } diff --git a/examples/light-switch-app/efr32/BUILD.gn b/examples/light-switch-app/efr32/BUILD.gn index e2705abdedcb65..2d628f537f9f6e 100644 --- a/examples/light-switch-app/efr32/BUILD.gn +++ b/examples/light-switch-app/efr32/BUILD.gn @@ -200,7 +200,7 @@ efr32_executable("light_switch_app") { if (chip_enable_openthread) { deps += [ "${chip_root}/third_party/openthread:openthread", - "${chip_root}/third_party/openthread:openthread_device", + "${chip_root}/third_party/openthread:openthread-platform", "${examples_plat_dir}:efr-matter-shell", ] } diff --git a/examples/lighting-app/efr32/BUILD.gn b/examples/lighting-app/efr32/BUILD.gn index 060b9f67343aa0..fbd5a88a7909b9 100644 --- a/examples/lighting-app/efr32/BUILD.gn +++ b/examples/lighting-app/efr32/BUILD.gn @@ -205,7 +205,7 @@ efr32_executable("lighting_app") { if (chip_enable_openthread) { deps += [ "${chip_root}/third_party/openthread:openthread", - "${chip_root}/third_party/openthread:openthread_device", + "${chip_root}/third_party/openthread:openthread-platform", "${examples_plat_dir}:efr-matter-shell", ] } diff --git a/examples/lock-app/efr32/BUILD.gn b/examples/lock-app/efr32/BUILD.gn index 2f8f2dc6bf67b4..e76b9cd48f1d1e 100644 --- a/examples/lock-app/efr32/BUILD.gn +++ b/examples/lock-app/efr32/BUILD.gn @@ -202,7 +202,7 @@ efr32_executable("lock_app") { if (chip_enable_openthread) { deps += [ "${chip_root}/third_party/openthread:openthread", - "${chip_root}/third_party/openthread:openthread_device", + "${chip_root}/third_party/openthread:openthread-platform", "${examples_plat_dir}:efr-matter-shell", ] } diff --git a/examples/shell/shell_common/BUILD.gn b/examples/shell/shell_common/BUILD.gn index 0217eb057fdff4..d601f0b54764b8 100644 --- a/examples/shell/shell_common/BUILD.gn +++ b/examples/shell/shell_common/BUILD.gn @@ -53,8 +53,8 @@ static_library("shell_common") { if (chip_enable_openthread && (current_os == "freertos" || current_os == "zephyr")) { public_deps += [ + "${chip_root}/third_party/openthread:openthread", "${chip_root}/third_party/openthread:openthread_cli", - "${chip_root}/third_party/openthread:openthread_device", ] } diff --git a/examples/thermostat/efr32/BUILD.gn b/examples/thermostat/efr32/BUILD.gn index edb03073686e3e..7e4e923992ff70 100644 --- a/examples/thermostat/efr32/BUILD.gn +++ b/examples/thermostat/efr32/BUILD.gn @@ -196,7 +196,7 @@ efr32_executable("thermostat_app") { if (chip_enable_openthread) { deps += [ "${chip_root}/third_party/openthread:openthread", - "${chip_root}/third_party/openthread:openthread_device", + "${chip_root}/third_party/openthread:openthread-platform", "${examples_plat_dir}:efr-matter-shell", ] } diff --git a/examples/window-app/efr32/BUILD.gn b/examples/window-app/efr32/BUILD.gn index c7a3f57e4b9ff8..a9aa7cf402911c 100644 --- a/examples/window-app/efr32/BUILD.gn +++ b/examples/window-app/efr32/BUILD.gn @@ -188,7 +188,7 @@ efr32_executable("window_app") { if (chip_enable_openthread) { deps += [ "${chip_root}/third_party/openthread:openthread", - "${chip_root}/third_party/openthread:openthread_device", + "${chip_root}/third_party/openthread:openthread-platform", "${examples_plat_dir}:efr-matter-shell", ] } diff --git a/src/inet/BUILD.gn b/src/inet/BUILD.gn index a042007d02c5a3..cb86a45780df9c 100644 --- a/src/inet/BUILD.gn +++ b/src/inet/BUILD.gn @@ -107,7 +107,7 @@ static_library("inet") { } if (chip_system_config_use_open_thread_inet_endpoints) { - public_deps += [ "${chip_root}/third_party/openthread:openthread_device" ] + public_deps += [ "${chip_root}/third_party/openthread:openthread" ] } if (chip_inet_config_enable_tcp_endpoint) { diff --git a/src/platform/EFR32/BUILD.gn b/src/platform/EFR32/BUILD.gn index eb73a6f80f85cf..1b5d6c45bbe3ba 100644 --- a/src/platform/EFR32/BUILD.gn +++ b/src/platform/EFR32/BUILD.gn @@ -98,7 +98,7 @@ static_library("EFR32") { "$dir_pw_kvs", ] if (chip_enable_openthread) { - public_deps += [ "${chip_root}/third_party/openthread:openthread_device" ] + public_deps += [ "${chip_root}/third_party/openthread:openthread" ] deps += [ "${chip_root}/third_party/openthread:openthread_cli" ] diff --git a/src/test_driver/efr32/BUILD.gn b/src/test_driver/efr32/BUILD.gn index 8ee3c4f3e59c69..1d6f87637a99db 100644 --- a/src/test_driver/efr32/BUILD.gn +++ b/src/test_driver/efr32/BUILD.gn @@ -96,7 +96,7 @@ efr32_executable("efr32_device_tests") { if (chip_enable_openthread) { deps += [ "${chip_root}/third_party/openthread:openthread", - "${chip_root}/third_party/openthread:openthread_device", + "${chip_root}/third_party/openthread:openthread-platform", "${examples_plat_dir}:efr-matter-shell", ] } diff --git a/third_party/openthread/BUILD.gn b/third_party/openthread/BUILD.gn index 9ee8e905551837..7a183e681867dc 100644 --- a/third_party/openthread/BUILD.gn +++ b/third_party/openthread/BUILD.gn @@ -8,7 +8,7 @@ declare_args() { chip_openthread_target = "" } -group("openthread") { +group("openthread-platform") { if (chip_openthread_target != "") { public_deps = [ chip_openthread_target ] } else { @@ -19,7 +19,7 @@ group("openthread") { } } -group("openthread_device") { +group("openthread") { if (chip_openthread_target != "") { public_deps = [ chip_openthread_target ] } else { diff --git a/third_party/silabs/BUILD.gn b/third_party/silabs/BUILD.gn index 1589f72e7865ae..7e885642cdd6f2 100644 --- a/third_party/silabs/BUILD.gn +++ b/third_party/silabs/BUILD.gn @@ -131,7 +131,7 @@ if (use_silabs_thread_lib) { ":libopenthread-platform", ":openthread_core_config_efr32", "${segger_rtt_root}:segger_rtt", - "${sl_openthread_root}/include/openthread:openthread", + "${sl_openthread_root}/include/openthread:openthread-platform", "${sl_openthread_root}/src/core/:libopenthread_core_headers", ] From 65d9ccf7461f8c45b4a07c4ca3e9c764dcc5793d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20Kr=C3=B3lik?= <66667989+Damian-Nordic@users.noreply.github.com> Date: Tue, 23 Aug 2022 15:34:51 +0200 Subject: [PATCH 15/15] [nrfconnect] Fix Docker build due to conflicting PIP packages (#22072) nRF Connect Docker image build started to fail due to some conflicts in documentation dependencies. We don't need those dependencies in Matter CI, so get rid off them. Signed-off-by: Damian Krolik Signed-off-by: Damian Krolik --- integrations/docker/images/chip-build-nrf-platform/Dockerfile | 2 +- integrations/docker/images/chip-build/version | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integrations/docker/images/chip-build-nrf-platform/Dockerfile b/integrations/docker/images/chip-build-nrf-platform/Dockerfile index f27f0813c748b3..280534cac6c9fe 100644 --- a/integrations/docker/images/chip-build-nrf-platform/Dockerfile +++ b/integrations/docker/images/chip-build-nrf-platform/Dockerfile @@ -61,7 +61,7 @@ RUN set -x \ && (apt-get remove -fy python3-yaml && apt-get autoremove || exit 0) \ && python3 -m pip install -U --no-cache-dir cmake==3.22.5 \ && python3 -m pip install --no-cache-dir -r /opt/NordicSemiconductor/nrfconnect/zephyr/scripts/requirements.txt \ - && python3 -m pip install --no-cache-dir -r /opt/NordicSemiconductor/nrfconnect/nrf/scripts/requirements.txt \ + && python3 -m pip install --no-cache-dir -r /opt/NordicSemiconductor/nrfconnect/nrf/scripts/requirements-build.txt \ && python3 -m pip install --no-cache-dir -r /opt/NordicSemiconductor/nrfconnect/bootloader/mcuboot/scripts/requirements.txt \ && : # last line diff --git a/integrations/docker/images/chip-build/version b/integrations/docker/images/chip-build/version index 0791656d59351a..1cb8eca1c7f032 100644 --- a/integrations/docker/images/chip-build/version +++ b/integrations/docker/images/chip-build/version @@ -1 +1 @@ -0.5.94 Version bump reason: Install ccache to the chip-build image +0.5.95 Version bump reason: Fix nrfconnect Docker build