From 4249145b260b188376619cb0163c98b64ffd46f5 Mon Sep 17 00:00:00 2001 From: jmartinez-silabs <67972863+jmartinez-silabs@users.noreply.github.com> Date: Tue, 16 Aug 2022 00:32:43 -0400 Subject: [PATCH] [EFR32] Provide a way to build matter examples using a openthread library (#21836) * WIP build with ot-lib * WIP compile from lib or source * Fix and cleanup build system * Fix efr32 path to internal thread source without breaking other platforms. Add new ot support to all efr32 examples * restyle * add recursive submodule update for efr to pull the openthread repo for ot-efr32 (temporary) * fix for wifi builds * Fix assert with ot lib * Use plaform dmp lib * Update ot-efr32 hash for new libs * Addresse comment by correcting how and where a openthread_target can be set. Change efr32 build system with those changes * restyle * some cleanup * more cleanup * Fix wifi build --- .github/workflows/examples-efr32.yaml | 2 +- .gitmodules | 3 +- examples/chef/efr32/BUILD.gn | 14 +- examples/chef/efr32/args.gni | 2 + examples/chef/efr32/include/AppConfig.h | 2 +- examples/light-switch-app/efr32/BUILD.gn | 14 +- examples/light-switch-app/efr32/args.gni | 2 + .../efr32/include/AppConfig.h | 2 +- examples/lighting-app/efr32/BUILD.gn | 14 +- examples/lighting-app/efr32/args.gni | 3 + examples/lock-app/efr32/BUILD.gn | 14 +- examples/lock-app/efr32/args.gni | 2 + examples/lock-app/efr32/include/AppConfig.h | 2 +- .../efr32/include/AppConfig.h | 2 +- .../pigweed-app/efr32/include/AppConfig.h | 2 +- examples/platform/efr32/BUILD.gn | 18 ++- examples/platform/efr32/efr32_utils.h | 2 +- examples/platform/efr32/init_efrPlatform.cpp | 6 +- examples/shell/efr32/include/AppConfig.h | 2 +- examples/thermostat/efr32/BUILD.gn | 14 +- examples/window-app/efr32/BUILD.gn | 14 +- examples/window-app/efr32/args.gni | 2 + examples/window-app/efr32/include/AppConfig.h | 2 +- scripts/checkout_submodules.py | 6 +- scripts/examples/gn_efr32_example.sh | 7 + src/inet/BUILD.gn | 8 +- src/platform/EFR32/BUILD.gn | 11 +- src/platform/EFR32/Logging.cpp | 4 +- src/platform/EFR32/ThreadStackManagerImpl.cpp | 5 + src/platform/EFR32/args.gni | 4 +- src/test_driver/efr32/.gn | 1 - src/test_driver/efr32/BUILD.gn | 14 +- src/test_driver/efr32/args.gni | 3 + src/test_driver/efr32/include/AppConfig.h | 2 +- third_party/openthread/BUILD.gn | 25 ++++ third_party/openthread/ot-efr32 | 2 +- .../openthread/platforms/efr32/BUILD.gn | 6 +- third_party/silabs/BUILD.gn | 138 ++++++++++++++++++ third_party/silabs/efr32_sdk.gni | 3 + 39 files changed, 243 insertions(+), 136 deletions(-) create mode 100644 third_party/openthread/BUILD.gn diff --git a/.github/workflows/examples-efr32.yaml b/.github/workflows/examples-efr32.yaml index 16aaaa42a189d4..320dad29dadd31 100644 --- a/.github/workflows/examples-efr32.yaml +++ b/.github/workflows/examples-efr32.yaml @@ -48,7 +48,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --platform efr32 + run: scripts/checkout_submodules.py --shallow --recursive --platform efr32 # - name: Out of Tree verification # run: third_party/silabs/out_of_tree_verification.sh diff --git a/.gitmodules b/.gitmodules index 16d589e739d539..abde0e5f8cdfd5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -78,7 +78,8 @@ platforms = qpg [submodule "third_party/openthread/ot-efr32"] path = third_party/openthread/ot-efr32 - url = https://github.com/openthread/ot-efr32.git + url = https://github.com/SiliconLabs/ot-efr32.git + branch = matter_sve platforms = efr32 [submodule "third_party/openthread/ot-ifx"] path = third_party/openthread/ot-ifx diff --git a/examples/chef/efr32/BUILD.gn b/examples/chef/efr32/BUILD.gn index e938574e195aa6..efaace05910a0b 100644 --- a/examples/chef/efr32/BUILD.gn +++ b/examples/chef/efr32/BUILD.gn @@ -206,21 +206,9 @@ efr32_executable("chef_app") { # OpenThread Settings if (chip_enable_openthread) { deps += [ - "${chip_root}/third_party/openthread/platforms:libopenthread-platform", - "${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils", + "${chip_root}/third_party/openthread:openthread", "${examples_plat_dir}:efr-matter-shell", ] - if (chip_openthread_ftd) { - deps += [ - "${chip_root}/third_party/openthread/repo:libopenthread-cli-ftd", - "${chip_root}/third_party/openthread/repo:libopenthread-ftd", - ] - } else { - deps += [ - "${chip_root}/third_party/openthread/repo:libopenthread-cli-mtd", - "${chip_root}/third_party/openthread/repo:libopenthread-mtd", - ] - } } if (chip_enable_ota_requestor) { diff --git a/examples/chef/efr32/args.gni b/examples/chef/efr32/args.gni index 7d077dce704c2f..4e322f1022501b 100644 --- a/examples/chef/efr32/args.gni +++ b/examples/chef/efr32/args.gni @@ -24,3 +24,5 @@ pw_rpc_CONFIG = "$dir_pw_rpc:disable_global_mutex" pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip" pw_assert_BACKEND = "$dir_pw_assert_log:check_backend" chip_enable_openthread = true +openthread_external_platform = + "${chip_root}/third_party/openthread/platforms/efr32:libopenthread-efr32" diff --git a/examples/chef/efr32/include/AppConfig.h b/examples/chef/efr32/include/AppConfig.h index 91501d889a6234..946b593cab50a4 100644 --- a/examples/chef/efr32/include/AppConfig.h +++ b/examples/chef/efr32/include/AppConfig.h @@ -32,7 +32,7 @@ extern "C" { #endif -void efr32LogInit(void); +void efr32InitLog(void); void efr32Log(const char * aFormat, ...); #define EFR32_LOG(...) efr32Log(__VA_ARGS__); diff --git a/examples/light-switch-app/efr32/BUILD.gn b/examples/light-switch-app/efr32/BUILD.gn index b3fb8fdd5b86c8..026dc46d13195c 100644 --- a/examples/light-switch-app/efr32/BUILD.gn +++ b/examples/light-switch-app/efr32/BUILD.gn @@ -199,21 +199,9 @@ efr32_executable("light_switch_app") { # OpenThread Settings if (chip_enable_openthread) { deps += [ - "${chip_root}/third_party/openthread/platforms:libopenthread-platform", - "${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils", + "${chip_root}/third_party/openthread:openthread", "${examples_plat_dir}:efr-matter-shell", ] - if (chip_openthread_ftd) { - deps += [ - "${chip_root}/third_party/openthread/repo:libopenthread-cli-ftd", - "${chip_root}/third_party/openthread/repo:libopenthread-ftd", - ] - } else { - deps += [ - "${chip_root}/third_party/openthread/repo:libopenthread-cli-mtd", - "${chip_root}/third_party/openthread/repo:libopenthread-mtd", - ] - } } # Attestation Credentials diff --git a/examples/light-switch-app/efr32/args.gni b/examples/light-switch-app/efr32/args.gni index 7df1c5e400f56f..8e1885d95d18d4 100644 --- a/examples/light-switch-app/efr32/args.gni +++ b/examples/light-switch-app/efr32/args.gni @@ -24,3 +24,5 @@ pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip" pw_assert_BACKEND = "$dir_pw_assert_log:check_backend" chip_enable_openthread = true pw_rpc_CONFIG = "$dir_pw_rpc:disable_global_mutex" +openthread_external_platform = + "${chip_root}/third_party/openthread/platforms/efr32:libopenthread-efr32" diff --git a/examples/light-switch-app/efr32/include/AppConfig.h b/examples/light-switch-app/efr32/include/AppConfig.h index 91501d889a6234..946b593cab50a4 100644 --- a/examples/light-switch-app/efr32/include/AppConfig.h +++ b/examples/light-switch-app/efr32/include/AppConfig.h @@ -32,7 +32,7 @@ extern "C" { #endif -void efr32LogInit(void); +void efr32InitLog(void); void efr32Log(const char * aFormat, ...); #define EFR32_LOG(...) efr32Log(__VA_ARGS__); diff --git a/examples/lighting-app/efr32/BUILD.gn b/examples/lighting-app/efr32/BUILD.gn index 9a9e4c15b8f33c..81a25554eb9ba2 100644 --- a/examples/lighting-app/efr32/BUILD.gn +++ b/examples/lighting-app/efr32/BUILD.gn @@ -204,21 +204,9 @@ efr32_executable("lighting_app") { # OpenThread Settings if (chip_enable_openthread) { deps += [ - "${chip_root}/third_party/openthread/platforms:libopenthread-platform", - "${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils", + "${chip_root}/third_party/openthread:openthread", "${examples_plat_dir}:efr-matter-shell", ] - if (chip_openthread_ftd) { - deps += [ - "${chip_root}/third_party/openthread/repo:libopenthread-cli-ftd", - "${chip_root}/third_party/openthread/repo:libopenthread-ftd", - ] - } else { - deps += [ - "${chip_root}/third_party/openthread/repo:libopenthread-cli-mtd", - "${chip_root}/third_party/openthread/repo:libopenthread-mtd", - ] - } } if (chip_enable_ota_requestor) { diff --git a/examples/lighting-app/efr32/args.gni b/examples/lighting-app/efr32/args.gni index 7df1c5e400f56f..1e5ed4ca14102c 100644 --- a/examples/lighting-app/efr32/args.gni +++ b/examples/lighting-app/efr32/args.gni @@ -24,3 +24,6 @@ pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip" pw_assert_BACKEND = "$dir_pw_assert_log:check_backend" chip_enable_openthread = true pw_rpc_CONFIG = "$dir_pw_rpc:disable_global_mutex" + +openthread_external_platform = + "${chip_root}/third_party/openthread/platforms/efr32:libopenthread-efr32" diff --git a/examples/lock-app/efr32/BUILD.gn b/examples/lock-app/efr32/BUILD.gn index a739b266110543..c98bebfed6d942 100644 --- a/examples/lock-app/efr32/BUILD.gn +++ b/examples/lock-app/efr32/BUILD.gn @@ -201,21 +201,9 @@ efr32_executable("lock_app") { # OpenThread Settings if (chip_enable_openthread) { deps += [ - "${chip_root}/third_party/openthread/platforms:libopenthread-platform", - "${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils", + "${chip_root}/third_party/openthread:openthread", "${examples_plat_dir}:efr-matter-shell", ] - if (chip_openthread_ftd) { - deps += [ - "${chip_root}/third_party/openthread/repo:libopenthread-cli-ftd", - "${chip_root}/third_party/openthread/repo:libopenthread-ftd", - ] - } else { - deps += [ - "${chip_root}/third_party/openthread/repo:libopenthread-cli-mtd", - "${chip_root}/third_party/openthread/repo:libopenthread-mtd", - ] - } } if (chip_enable_ota_requestor) { diff --git a/examples/lock-app/efr32/args.gni b/examples/lock-app/efr32/args.gni index b4a0322c442f40..9ff5e1fd3992f1 100644 --- a/examples/lock-app/efr32/args.gni +++ b/examples/lock-app/efr32/args.gni @@ -24,3 +24,5 @@ chip_enable_openthread = true pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip" pw_assert_BACKEND = "$dir_pw_assert_log:check_backend" pw_rpc_CONFIG = "$dir_pw_rpc:disable_global_mutex" +openthread_external_platform = + "${chip_root}/third_party/openthread/platforms/efr32:libopenthread-efr32" diff --git a/examples/lock-app/efr32/include/AppConfig.h b/examples/lock-app/efr32/include/AppConfig.h index 852083cb9cbd91..096560abefe349 100644 --- a/examples/lock-app/efr32/include/AppConfig.h +++ b/examples/lock-app/efr32/include/AppConfig.h @@ -32,7 +32,7 @@ extern "C" { #endif -void efr32LogInit(void); +void efr32InitLog(void); void efr32Log(const char * aFormat, ...); #define EFR32_LOG(...) efr32Log(__VA_ARGS__); diff --git a/examples/persistent-storage/efr32/include/AppConfig.h b/examples/persistent-storage/efr32/include/AppConfig.h index 74a5ae90e43c83..ae2846d90c6caa 100644 --- a/examples/persistent-storage/efr32/include/AppConfig.h +++ b/examples/persistent-storage/efr32/include/AppConfig.h @@ -24,7 +24,7 @@ extern "C" { #endif -void efr32LogInit(void); +void efr32InitLog(void); void efr32Log(const char * aFormat, ...); #define EFR32_LOG(...) efr32Log(__VA_ARGS__); diff --git a/examples/pigweed-app/efr32/include/AppConfig.h b/examples/pigweed-app/efr32/include/AppConfig.h index 61a5430dafeeb8..8935b7f3bb7284 100644 --- a/examples/pigweed-app/efr32/include/AppConfig.h +++ b/examples/pigweed-app/efr32/include/AppConfig.h @@ -39,7 +39,7 @@ extern "C" { #endif -void efr32LogInit(void); +void efr32InitLog(void); void efr32Log(const char * aFormat, ...); #define EFR32_LOG(...) efr32Log(__VA_ARGS__); void appError(int err); diff --git a/examples/platform/efr32/BUILD.gn b/examples/platform/efr32/BUILD.gn index ba36aeff00c83b..d1522f93d6d686 100644 --- a/examples/platform/efr32/BUILD.gn +++ b/examples/platform/efr32/BUILD.gn @@ -15,6 +15,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/efr32_sdk.gni") import("${chip_root}/src/lib/lib.gni") +import("${chip_root}/src/platform/device.gni") import("${efr32_sdk_build_root}/efr32_sdk.gni") config("chip_examples_project_config") { @@ -40,14 +41,19 @@ config("chip_examples_project_config") { } source_set("openthread_core_config_efr32_chip_examples") { - sources = [ "project_include/OpenThreadConfig.h" ] + if (chip_enable_openthread) { + sources = [ "project_include/OpenThreadConfig.h" ] - public_deps = [ - "${chip_root}/third_party/openthread/platforms/efr32:openthread_core_config_efr32", - "${efr32_sdk_build_root}:efr32_sdk", - ] + public_deps = [ "${efr32_sdk_build_root}:efr32_sdk" ] - public_configs = [ ":chip_examples_project_config" ] + if (use_silabs_thread_lib) { + public_deps += [ "${efr32_sdk_build_root}:openthread_core_config_efr32" ] + } else { + public_deps += [ "${chip_root}/third_party/openthread/platforms/efr32:openthread_core_config_efr32" ] + } + + public_configs = [ ":chip_examples_project_config" ] + } } source_set("efr-matter-shell") { diff --git a/examples/platform/efr32/efr32_utils.h b/examples/platform/efr32/efr32_utils.h index 610bde3e4e2511..98087091d9c0e9 100644 --- a/examples/platform/efr32/efr32_utils.h +++ b/examples/platform/efr32/efr32_utils.h @@ -24,7 +24,7 @@ extern "C" { #endif -void efr32LogInit(void); +void efr32InitLog(void); void efr32Log(const char * aFormat, ...); #define EFR32_LOG(...) efr32Log(__VA_ARGS__); diff --git a/examples/platform/efr32/init_efrPlatform.cpp b/examples/platform/efr32/init_efrPlatform.cpp index f251f48f5dbab1..d0fb913165c469 100644 --- a/examples/platform/efr32/init_efrPlatform.cpp +++ b/examples/platform/efr32/init_efrPlatform.cpp @@ -72,13 +72,11 @@ void init_efrPlatform(void) #endif #if EFR32_LOG_ENABLED - efr32LogInit(); + efr32InitLog(); #endif #if CHIP_ENABLE_OPENTHREAD - efr32RadioInit(); - efr32AlarmInit(); - efr32MiscInit(); + sl_ot_sys_init(); #endif // CHIP_ENABLE_OPENTHREAD } diff --git a/examples/shell/efr32/include/AppConfig.h b/examples/shell/efr32/include/AppConfig.h index a14ec9f589f735..743c6eddbb18ad 100644 --- a/examples/shell/efr32/include/AppConfig.h +++ b/examples/shell/efr32/include/AppConfig.h @@ -54,7 +54,7 @@ extern "C" { #endif -void efr32LogInit(void); +void efr32InitLog(void); void efr32Log(const char * aFormat, ...); #define EFR32_LOG(...) efr32Log(__VA_ARGS__); diff --git a/examples/thermostat/efr32/BUILD.gn b/examples/thermostat/efr32/BUILD.gn index 90f61b99ca1ad6..fe2be76adf88a8 100644 --- a/examples/thermostat/efr32/BUILD.gn +++ b/examples/thermostat/efr32/BUILD.gn @@ -195,21 +195,9 @@ efr32_executable("thermostat_app") { # OpenThread Settings if (chip_enable_openthread) { deps += [ - "${chip_root}/third_party/openthread/platforms:libopenthread-platform", - "${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils", + "${chip_root}/third_party/openthread:openthread", "${examples_plat_dir}:efr-matter-shell", ] - if (chip_openthread_ftd) { - deps += [ - "${chip_root}/third_party/openthread/repo:libopenthread-cli-ftd", - "${chip_root}/third_party/openthread/repo:libopenthread-ftd", - ] - } else { - deps += [ - "${chip_root}/third_party/openthread/repo:libopenthread-cli-mtd", - "${chip_root}/third_party/openthread/repo:libopenthread-mtd", - ] - } } # Attestation Credentials diff --git a/examples/window-app/efr32/BUILD.gn b/examples/window-app/efr32/BUILD.gn index fad09d7f4d3ce7..bcd17e3b6dddcf 100644 --- a/examples/window-app/efr32/BUILD.gn +++ b/examples/window-app/efr32/BUILD.gn @@ -187,21 +187,9 @@ efr32_executable("window_app") { # OpenThread Settings if (chip_enable_openthread) { deps += [ - "${chip_root}/third_party/openthread/platforms:libopenthread-platform", - "${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils", + "${chip_root}/third_party/openthread:openthread", "${examples_plat_dir}:efr-matter-shell", ] - if (chip_openthread_ftd) { - deps += [ - "${chip_root}/third_party/openthread/repo:libopenthread-cli-ftd", - "${chip_root}/third_party/openthread/repo:libopenthread-ftd", - ] - } else { - deps += [ - "${chip_root}/third_party/openthread/repo:libopenthread-cli-mtd", - "${chip_root}/third_party/openthread/repo:libopenthread-mtd", - ] - } } if (chip_enable_ota_requestor) { diff --git a/examples/window-app/efr32/args.gni b/examples/window-app/efr32/args.gni index 0b7ef403df72cd..26f97a8076d141 100644 --- a/examples/window-app/efr32/args.gni +++ b/examples/window-app/efr32/args.gni @@ -23,3 +23,5 @@ chip_enable_ota_requestor = true pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip" pw_assert_BACKEND = "$dir_pw_assert_log:check_backend" chip_enable_openthread = true +openthread_external_platform = + "${chip_root}/third_party/openthread/platforms/efr32:libopenthread-efr32" diff --git a/examples/window-app/efr32/include/AppConfig.h b/examples/window-app/efr32/include/AppConfig.h index d8a68d9982e4b8..a9957cf77b5bb9 100644 --- a/examples/window-app/efr32/include/AppConfig.h +++ b/examples/window-app/efr32/include/AppConfig.h @@ -57,7 +57,7 @@ extern "C" { #define COVER_LIFT_TILT_TIMEOUT 500 #endif -void efr32LogInit(void); +void efr32InitLog(void); void efr32Log(const char * aFormat, ...); #define EFR32_LOG(...) efr32Log(__VA_ARGS__); diff --git a/scripts/checkout_submodules.py b/scripts/checkout_submodules.py index 486a3e7b3b355d..b150b8df71253e 100755 --- a/scripts/checkout_submodules.py +++ b/scripts/checkout_submodules.py @@ -74,7 +74,7 @@ def make_chip_root_safe_directory() -> None: subprocess.check_call(['git', 'config', '--global', '--add', 'safe.directory', CHIP_ROOT]) -def checkout_modules(modules: list, shallow: bool, force: bool) -> None: +def checkout_modules(modules: list, shallow: bool, force: bool, recursive: bool) -> None: names = [module.name.replace('submodule "', '').replace('"', '') for module in modules] names = ', '.join(names) logging.info(f'Checking out: {names}') @@ -82,6 +82,7 @@ def checkout_modules(modules: list, shallow: bool, force: bool) -> None: cmd = ['git', '-C', CHIP_ROOT, 'submodule', 'update', '--init'] cmd += ['--depth', '1'] if shallow else [] cmd += ['--force'] if force else [] + cmd += ['--recursive'] if recursive else [] cmd += [module.path for module in modules] subprocess.check_call(cmd) @@ -109,6 +110,7 @@ def main(): parser.add_argument('--force', action='store_true', help='Perform action despite of warnings') parser.add_argument('--deinit-unmatched', action='store_true', help='Deinitialize submodules for non-matching platforms') + parser.add_argument('--recursive', action='store_true', help='Recursive init of the listed submodules') args = parser.parse_args() modules = list(load_module_info()) @@ -117,7 +119,7 @@ def main(): unmatched_modules = [m for m in modules if not module_matches_platforms(m, selected_platforms)] make_chip_root_safe_directory() - checkout_modules(selected_modules, args.shallow, args.force) + checkout_modules(selected_modules, args.shallow, args.force, args.recursive) if args.deinit_unmatched: deinit_modules(unmatched_modules, args.force) diff --git a/scripts/examples/gn_efr32_example.sh b/scripts/examples/gn_efr32_example.sh index 6882bba7d44d00..5b47c945c771a8 100755 --- a/scripts/examples/gn_efr32_example.sh +++ b/scripts/examples/gn_efr32_example.sh @@ -34,6 +34,7 @@ set -x env USE_WIFI=false +SILABS_THREAD_TARGET=\""../silabs:ot-efr32-cert"\" USAGE="./scripts/examples/gn_efr32_example.sh []" if [ "$#" == "0" ]; then @@ -102,6 +103,8 @@ if [ "$#" == "0" ]; then build wifi example variant for given exansion board --additional_data_advertising enable Addition data advertissing and rotating device ID + --use_ot_lib + use the silabs openthread library " elif [ "$#" -lt "2" ]; then echo "Invalid number of arguments @@ -149,6 +152,10 @@ else optArgs+="chip_enable_additional_data_advertising=true chip_enable_rotating_device_id=true " shift ;; + --use_ot_lib) + optArgs+="use_silabs_thread_lib=true chip_openthread_target=$SILABS_THREAD_TARGET openthread_external_platform=\"""\" " + shift + ;; *) if [ "$1" =~ *"use_rs911x=true"* ] || [ "$1" =~ *"use_wf200=true"* ]; then USE_WIFI=true diff --git a/src/inet/BUILD.gn b/src/inet/BUILD.gn index 6e671c0f7b358e..5a85beb667c25b 100644 --- a/src/inet/BUILD.gn +++ b/src/inet/BUILD.gn @@ -108,13 +108,7 @@ static_library("inet") { } if (chip_system_config_use_open_thread_inet_endpoints) { - if (chip_openthread_ftd) { - public_deps += - [ "${chip_root}/third_party/openthread/repo:libopenthread-ftd" ] - } else { - public_deps += - [ "${chip_root}/third_party/openthread/repo:libopenthread-mtd" ] - } + 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 cf1b3b77bcec1c..e406ce994eedee 100644 --- a/src/platform/EFR32/BUILD.gn +++ b/src/platform/EFR32/BUILD.gn @@ -97,15 +97,10 @@ static_library("EFR32") { "$dir_pw_checksum", "$dir_pw_kvs", ] - if (chip_enable_openthread) { - if (chip_openthread_ftd) { - public_deps += - [ "${chip_root}/third_party/openthread/repo:libopenthread-ftd" ] - } else { - public_deps += - [ "${chip_root}/third_party/openthread/repo:libopenthread-mtd" ] - } + public_deps += [ "${chip_root}/third_party/openthread:openthread" ] + + deps += [ "${chip_root}/third_party/silabs:openthread_cli" ] sources += [ "../OpenThread/OpenThreadUtils.cpp", diff --git a/src/platform/EFR32/Logging.cpp b/src/platform/EFR32/Logging.cpp index ad78dfae0a033a..ad0711fe930961 100644 --- a/src/platform/EFR32/Logging.cpp +++ b/src/platform/EFR32/Logging.cpp @@ -104,7 +104,7 @@ static void PrintLog(const char * msg) /** * Initialize Segger RTT for logging */ -extern "C" void efr32LogInit(void) +extern "C" void efr32InitLog(void) { #if EFR32_LOG_ENABLED #if LOG_RTT_BUFFER_INDEX != 0 @@ -344,7 +344,7 @@ extern "C" void debugHardfault(uint32_t * sp) if (sLogInitialized == false) { - efr32LogInit(); + efr32InitLog(); } snprintf(formattedMsg, sizeof formattedMsg, LOG_ERROR "HardFault:\n"); diff --git a/src/platform/EFR32/ThreadStackManagerImpl.cpp b/src/platform/EFR32/ThreadStackManagerImpl.cpp index a90db73b620d39..16d792276644e4 100644 --- a/src/platform/EFR32/ThreadStackManagerImpl.cpp +++ b/src/platform/EFR32/ThreadStackManagerImpl.cpp @@ -100,6 +100,11 @@ extern "C" void otPlatFree(void * aPtr) CHIPPlatformMemoryFree(aPtr); } +extern "C" __WEAK void sl_openthread_init(void) +{ + // Place holder for enabling Silabs specific features available only through Simplicity Studio +} + /** * @brief Openthread UART implementation for the CLI is conflicting * with the UART implemented for Pigweed RPC as they use the same UART port diff --git a/src/platform/EFR32/args.gni b/src/platform/EFR32/args.gni index a66bd28acf86ef..7b80e77e100190 100644 --- a/src/platform/EFR32/args.gni +++ b/src/platform/EFR32/args.gni @@ -43,14 +43,12 @@ chip_with_lwip = false chip_build_tests = false +openthread_root = "${chip_root}/third_party/openthread/ot-efr32/openthread" openthread_core_config_platform_check_file = "openthread-core-efr32-config-check.h" openthread_project_core_config_file = "OpenThreadConfig.h" openthread_core_config_deps = [ "${chip_root}/examples/platform/efr32:openthread_core_config_efr32_chip_examples" ] -openthread_external_platform = - "${chip_root}/third_party/openthread/platforms/efr32:libopenthread-efr32" - chip_config_memory_management = "platform" pw_build_LINK_DEPS = [ diff --git a/src/test_driver/efr32/.gn b/src/test_driver/efr32/.gn index 81cec9d11a421b..7bb85d530fae5c 100644 --- a/src/test_driver/efr32/.gn +++ b/src/test_driver/efr32/.gn @@ -23,6 +23,5 @@ check_system_includes = true default_args = { target_cpu = "arm" target_os = "freertos" - import("//args.gni") } diff --git a/src/test_driver/efr32/BUILD.gn b/src/test_driver/efr32/BUILD.gn index d794b4b0ef2485..45e4aff6fe40a7 100644 --- a/src/test_driver/efr32/BUILD.gn +++ b/src/test_driver/efr32/BUILD.gn @@ -88,21 +88,15 @@ efr32_executable("efr32_device_tests") { "${chip_root}/src:tests", "${chip_root}/src/lib", "${chip_root}/src/lib/support:testing", - "${chip_root}/third_party/openthread/platforms:libopenthread-platform", - "${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils", "${examples_plat_dir}/pw_sys_io:pw_sys_io_efr32", "${nlunit_test_root}:nlunit-test", ] - if (chip_openthread_ftd) { + # OpenThread Settings + if (chip_enable_openthread) { deps += [ - "${chip_root}/third_party/openthread/repo:libopenthread-cli-ftd", - "${chip_root}/third_party/openthread/repo:libopenthread-ftd", - ] - } else { - deps += [ - "${chip_root}/third_party/openthread/repo:libopenthread-cli-mtd", - "${chip_root}/third_party/openthread/repo:libopenthread-mtd", + "${chip_root}/third_party/openthread:openthread", + "${examples_plat_dir}:efr-matter-shell", ] } diff --git a/src/test_driver/efr32/args.gni b/src/test_driver/efr32/args.gni index 8addd1383ed934..8db9c5e87eb212 100644 --- a/src/test_driver/efr32/args.gni +++ b/src/test_driver/efr32/args.gni @@ -27,6 +27,9 @@ chip_enable_openthread = true chip_openthread_ftd = true chip_monolithic_tests = true +openthread_external_platform = + "${chip_root}/third_party/openthread/platforms/efr32:libopenthread-efr32" + #Fix me : Test driver should use same config as examples # Problem : Linker issue if set to true chip_system_config_use_open_thread_inet_endpoints = false diff --git a/src/test_driver/efr32/include/AppConfig.h b/src/test_driver/efr32/include/AppConfig.h index 302dba47799e5e..3b83d375b46219 100644 --- a/src/test_driver/efr32/include/AppConfig.h +++ b/src/test_driver/efr32/include/AppConfig.h @@ -25,7 +25,7 @@ extern "C" { #endif -void efr32LogInit(void); +void efr32InitLog(void); void efr32Log(const char * aFormat, ...); #define EFR32_LOG(...) efr32Log(__VA_ARGS__); void appError(int err); diff --git a/third_party/openthread/BUILD.gn b/third_party/openthread/BUILD.gn new file mode 100644 index 00000000000000..752f245738a750 --- /dev/null +++ b/third_party/openthread/BUILD.gn @@ -0,0 +1,25 @@ +import("//build_overrides/chip.gni") +import("//build_overrides/openthread.gni") + +import("${chip_root}/src/platform/device.gni") + +declare_args() { + # Use a different target, such as a prebuilt Thread library. + chip_openthread_target = "" +} + +group("openthread") { + if (chip_openthread_target != "") { + public_deps = [ chip_openthread_target ] + } else { + public_deps = [ + "${chip_root}/third_party/openthread/platforms:libopenthread-platform", + "${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils", + ] + if (chip_openthread_ftd) { + public_deps += [ "${openthread_root}:libopenthread-ftd" ] + } else { + public_deps += [ "${openthread_root}:libopenthread-mtd" ] + } + } +} diff --git a/third_party/openthread/ot-efr32 b/third_party/openthread/ot-efr32 index 7a567da02a0785..fd77faf7a3443f 160000 --- a/third_party/openthread/ot-efr32 +++ b/third_party/openthread/ot-efr32 @@ -1 +1 @@ -Subproject commit 7a567da02a078546eb34136c1c44170c8832dd55 +Subproject commit fd77faf7a3443f7941dfd9e9713aea09eb08e9b9 diff --git a/third_party/openthread/platforms/efr32/BUILD.gn b/third_party/openthread/platforms/efr32/BUILD.gn index 140070a57b9d8a..b6dba5b98d4351 100644 --- a/third_party/openthread/platforms/efr32/BUILD.gn +++ b/third_party/openthread/platforms/efr32/BUILD.gn @@ -37,9 +37,9 @@ config("openthread_efr32_config") { source_set("openthread_core_config_efr32") { sources = [ + "${openthread_efr32_root}/openthread/src/cli/cli_config.h", "${openthread_efr32_root}/src/src/openthread-core-efr32-config-check.h", "${openthread_efr32_root}/src/src/openthread-core-efr32-config.h", - "${openthread_root}/src/cli/cli_config.h", ] public_deps = [ "${efr32_sdk_build_root}:efr32_sdk" ] @@ -49,6 +49,7 @@ source_set("openthread_core_config_efr32") { source_set("libopenthread-efr32") { sources = [ + "${openthread_efr32_root}/openthread/examples/apps/cli/cli_uart.cpp", "${openthread_efr32_root}/src/src/alarm.c", "${openthread_efr32_root}/src/src/crypto.c", "${openthread_efr32_root}/src/src/entropy.c", @@ -58,12 +59,11 @@ source_set("libopenthread-efr32") { "${openthread_efr32_root}/src/src/security_manager.c", "${openthread_efr32_root}/src/src/sleep.c", "${openthread_efr32_root}/src/src/system.c", - "${openthread_root}/examples/apps/cli/cli_uart.cpp", ] public_deps = [ ":openthread_core_config_efr32", - "${openthread_root}/src/core:libopenthread_core_headers", + "${openthread_efr32_root}/openthread/src/core:libopenthread_core_headers", "..:libopenthread-platform", "..:libopenthread-platform-utils", ] diff --git a/third_party/silabs/BUILD.gn b/third_party/silabs/BUILD.gn index 718852a0a2f235..c4f96d18d339f5 100644 --- a/third_party/silabs/BUILD.gn +++ b/third_party/silabs/BUILD.gn @@ -12,12 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build_overrides/chip.gni") import("//build_overrides/efr32_sdk.gni") +import("//build_overrides/jlink.gni") +import("${chip_root}/src/platform/device.gni") import("${efr32_sdk_build_root}/efr32_sdk.gni") declare_args() { # Build target to use for efr32 SDK. Use this to set global SDK defines. efr32_sdk_target = "" + sl_ot_efr32_root = "${chip_root}/third_party/openthread/ot-efr32" + sl_openthread_root = "${chip_root}/third_party/openthread/ot-efr32/openthread" } assert(efr32_sdk_target != "", "efr32_sdk_target must be specified") @@ -25,3 +30,136 @@ assert(efr32_sdk_target != "", "efr32_sdk_target must be specified") 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" ] + } + + copy("copy_openthread_system") { + sources = [ "${sl_openthread_root}/examples/platforms/openthread-system.h" ] + + outputs = + [ "${root_gen_dir}/include/openthread/platform/{{source_file_part}}" ] + } + + source_set("openthread_system") { + sources = + [ "${root_gen_dir}/include/openthread/platform/openthread-system.h" ] + deps = [ ":copy_openthread_system" ] + } + + source_set("libopenthread-platform") { + sources = [ "${sl_openthread_root}/examples/platforms/openthread-system.h" ] + + public_deps = [ ":openthread_system" ] + + public_configs = [ ":libopenthread-platform_config" ] + } + + config("openthread_efr32_config") { + defines = [ + "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\"", + ] + + include_dirs = [ + "${chip_root}/examples/platform/efr32", + "${sdk_support_root}/matter/efr32/${efr32_family}/${efr32_board}", + "${sl_ot_efr32_root}/src/src", + "${sl_openthread_root}/src/", + ] + } + + 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", + ] + + public_deps = [ + ":libopenthread-platform", + "${efr32_sdk_build_root}:efr32_sdk", + ] + + public_configs = [ ":openthread_efr32_config" ] + } + + 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", + ] + + public_configs = [ + ":openthread_efr32_config", + ":libopenthread-platform_config", + ] + + public_deps = [ + ":libopenthread-platform", + ":openthread_core_config_efr32", + "${segger_rtt_root}:segger_rtt", + "${sl_openthread_root}/include/openthread:openthread", + "${sl_openthread_root}/src/core/:libopenthread_core_headers", + ] + + deps = [ "${efr32_sdk_build_root}:efr32_sdk" ] + + # selected thread device type FTD or MTD + XTD = "ftd" + if (!chip_openthread_ftd) { + XTD = "mtd" + } + + public_configs += [ "${sl_openthread_root}:openthread_${XTD}_config" ] + + libs = [ + "${sl_ot_efr32_root}/libs/libsl_ot_stack_${XTD}_${efr32_family}_gcc.a", + "${sl_ot_efr32_root}/libs/libsl_platform_${XTD}_dmp_${efr32_family}_gcc.a", + ] + } +} diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index e4af7e65333a28..727ecea7acd5ef 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -24,6 +24,9 @@ declare_args() { # Location of the efr32 SDK. efr32_sdk_root = "${chip_root}/third_party/silabs/gecko_sdk" sdk_support_root = "${chip_root}/third_party/silabs/matter_support" + + #Build openthread with prebuilt silabs lib + use_silabs_thread_lib = false enable_openthread_cli = true kvs_max_entries = 75