Skip to content

Commit

Permalink
[EFR32] Provide a way to build matter examples using a openthread lib…
Browse files Browse the repository at this point in the history
…rary (#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
  • Loading branch information
jmartinez-silabs authored and pull[bot] committed Oct 12, 2022
1 parent f0a70f4 commit 4249145
Show file tree
Hide file tree
Showing 39 changed files with 243 additions and 136 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/examples-efr32.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 1 addition & 13 deletions examples/chef/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions examples/chef/efr32/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion examples/chef/efr32/include/AppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
extern "C" {
#endif

void efr32LogInit(void);
void efr32InitLog(void);

void efr32Log(const char * aFormat, ...);
#define EFR32_LOG(...) efr32Log(__VA_ARGS__);
Expand Down
14 changes: 1 addition & 13 deletions examples/light-switch-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions examples/light-switch-app/efr32/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion examples/light-switch-app/efr32/include/AppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
extern "C" {
#endif

void efr32LogInit(void);
void efr32InitLog(void);

void efr32Log(const char * aFormat, ...);
#define EFR32_LOG(...) efr32Log(__VA_ARGS__);
Expand Down
14 changes: 1 addition & 13 deletions examples/lighting-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions examples/lighting-app/efr32/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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"
14 changes: 1 addition & 13 deletions examples/lock-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions examples/lock-app/efr32/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion examples/lock-app/efr32/include/AppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
extern "C" {
#endif

void efr32LogInit(void);
void efr32InitLog(void);

void efr32Log(const char * aFormat, ...);
#define EFR32_LOG(...) efr32Log(__VA_ARGS__);
Expand Down
2 changes: 1 addition & 1 deletion examples/persistent-storage/efr32/include/AppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
extern "C" {
#endif

void efr32LogInit(void);
void efr32InitLog(void);

void efr32Log(const char * aFormat, ...);
#define EFR32_LOG(...) efr32Log(__VA_ARGS__);
Expand Down
2 changes: 1 addition & 1 deletion examples/pigweed-app/efr32/include/AppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 12 additions & 6 deletions examples/platform/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand All @@ -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") {
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/efr32/efr32_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
extern "C" {
#endif

void efr32LogInit(void);
void efr32InitLog(void);

void efr32Log(const char * aFormat, ...);
#define EFR32_LOG(...) efr32Log(__VA_ARGS__);
Expand Down
6 changes: 2 additions & 4 deletions examples/platform/efr32/init_efrPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion examples/shell/efr32/include/AppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
extern "C" {
#endif

void efr32LogInit(void);
void efr32InitLog(void);

void efr32Log(const char * aFormat, ...);
#define EFR32_LOG(...) efr32Log(__VA_ARGS__);
Expand Down
14 changes: 1 addition & 13 deletions examples/thermostat/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 1 addition & 13 deletions examples/window-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions examples/window-app/efr32/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion examples/window-app/efr32/include/AppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__);
Expand Down
6 changes: 4 additions & 2 deletions scripts/checkout_submodules.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,15 @@ 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}')

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)
Expand Down Expand Up @@ -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())
Expand All @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions scripts/examples/gn_efr32_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ set -x
env
USE_WIFI=false

SILABS_THREAD_TARGET=\""../silabs:ot-efr32-cert"\"
USAGE="./scripts/examples/gn_efr32_example.sh <AppRootFolder> <outputFolder> <efr32_board_name> [<Build options>]"

if [ "$#" == "0" ]; then
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 1 addition & 7 deletions src/inet/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading

0 comments on commit 4249145

Please sign in to comment.