From 2c0c837873e9964a35dbc0fefa3cadd09df5834e Mon Sep 17 00:00:00 2001 From: Junior Martinez Date: Mon, 17 Jul 2023 12:37:22 -0400 Subject: [PATCH 1/3] Add option of user to configure silabs_pre_gen or slc_gen paths --- examples/lighting-app/silabs/BUILD.gn | 1 + examples/smoke-co-alarm-app/silabs/BUILD.gn | 1 + scripts/examples/gn_silabs_example.sh | 6 ++++++ third_party/silabs/efr32_sdk.gni | 10 ++++++---- third_party/silabs/silabs_board.gni | 3 +++ third_party/silabs/slc_gen/run_slc.py | 2 +- 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/examples/lighting-app/silabs/BUILD.gn b/examples/lighting-app/silabs/BUILD.gn index ded0e41c42b70a..daf3201512c322 100644 --- a/examples/lighting-app/silabs/BUILD.gn +++ b/examples/lighting-app/silabs/BUILD.gn @@ -60,6 +60,7 @@ if (slc_generate) { "${use_wstk_leds}", "${use_external_flash}", "${silabs_mcu}", + "${slc_gen_path}", ], "list lines")) } diff --git a/examples/smoke-co-alarm-app/silabs/BUILD.gn b/examples/smoke-co-alarm-app/silabs/BUILD.gn index d4ebe73cf0475c..9a090eb6f11052 100644 --- a/examples/smoke-co-alarm-app/silabs/BUILD.gn +++ b/examples/smoke-co-alarm-app/silabs/BUILD.gn @@ -60,6 +60,7 @@ if (slc_generate) { "${use_wstk_leds}", "${use_external_flash}", "${silabs_mcu}", + "${slc_gen_path}", ], "list lines")) } diff --git a/scripts/examples/gn_silabs_example.sh b/scripts/examples/gn_silabs_example.sh index 1f181fc75564af..9efd662bcd2fe9 100755 --- a/scripts/examples/gn_silabs_example.sh +++ b/scripts/examples/gn_silabs_example.sh @@ -98,6 +98,12 @@ if [ "$#" == "0" ]; then Periodic query timeout variable for OTA in seconds rs91x_wpa3_transition Support for WPA3 transition mode on RS91x + slc_gen_path + Allow users to define a path where slc generates boards files. (requires --slc_generate or --slc_reuse_files) + (default: /third_party/silabs/slc_gen//) + sl_pre_gen_path + Allow users to define a path to pre-generated boards files + (default: /third_party/silabs/matter_support/matter///) sl_matter_version Use provided software version at build time sl_matter_version_str diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index 11aa2d0e651ed6..a98f961d6c79f4 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -56,7 +56,6 @@ declare_args() { # Argument to enable IPv4 for wifi # aligning to match chip_inet_config_enable_ipv4 default configuration chip_enable_wifi_ipv4 = false - silabs_gen_folder = "" # Calls SLC-CLI at run time slc_generate = false @@ -72,14 +71,17 @@ declare_args() { sl_ot_efr32_root = "${efr32_sdk_root}/protocol/openthread/platform-abstraction/efr32" sl_openthread_root = "${efr32_sdk_root}/util/third_party/openthread" + + # board related pre-generated files path (default) + sl_pre_gen_path = + "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/" } if (slc_generate || slc_reuse_files) { - silabs_gen_folder = "${chip_root}/third_party/silabs/slc_gen/${silabs_board}/" + silabs_gen_folder = slc_gen_path } else { print("Using pre-generate files") - silabs_gen_folder = - "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/" + silabs_gen_folder = sl_pre_gen_path } # Defines an efr32 SDK build target. diff --git a/third_party/silabs/silabs_board.gni b/third_party/silabs/silabs_board.gni index bba3f060f8898d..924d0eb12848c8 100644 --- a/third_party/silabs/silabs_board.gni +++ b/third_party/silabs/silabs_board.gni @@ -48,6 +48,9 @@ declare_args() { declare_args() { # Enables LCD Qr Code on supported devices show_qr_code = !disable_lcd + + # board related generated files path (used if slc_generate or slc_reuse_files is set) + slc_gen_path = "${chip_root}/third_party/silabs/slc_gen/${silabs_board}/" } if (silabs_board == "") { diff --git a/third_party/silabs/slc_gen/run_slc.py b/third_party/silabs/slc_gen/run_slc.py index 87a481ea3c9a80..41426439897202 100644 --- a/third_party/silabs/slc_gen/run_slc.py +++ b/third_party/silabs/slc_gen/run_slc.py @@ -27,10 +27,10 @@ def isMG24(partnumber): use_wstk_leds = asBoolean(sys.argv[5]) use_external_flash = asBoolean(sys.argv[6]) silabs_mcu = str(sys.argv[7]) +output_path = str(sys.argv[8]) slcp_file_path = os.path.join(root_path, "examples/platform/silabs/matter-platform.slcp") template_path = os.path.join(root_path, "third_party/silabs/slc_gen/") -output_path = template_path + sys.argv[2] + '/' slc_arguments = "" From c927ac36820672d0dd70cd8fcc93ba4262b0278d Mon Sep 17 00:00:00 2001 From: Junior Martinez Date: Tue, 18 Jul 2023 08:44:51 -0400 Subject: [PATCH 2/3] slc_gen_path can be in efr32_sdk.gni --- third_party/silabs/efr32_sdk.gni | 3 +++ third_party/silabs/silabs_board.gni | 3 --- third_party/silabs/slc_gen/run_slc.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index a98f961d6c79f4..3267d87e9bd398 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -75,6 +75,9 @@ declare_args() { # board related pre-generated files path (default) sl_pre_gen_path = "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/" + + # board related generated files path (used if slc_generate or slc_reuse_files is set) + slc_gen_path = "${chip_root}/third_party/silabs/slc_gen/${silabs_board}/" } if (slc_generate || slc_reuse_files) { diff --git a/third_party/silabs/silabs_board.gni b/third_party/silabs/silabs_board.gni index 924d0eb12848c8..bba3f060f8898d 100644 --- a/third_party/silabs/silabs_board.gni +++ b/third_party/silabs/silabs_board.gni @@ -48,9 +48,6 @@ declare_args() { declare_args() { # Enables LCD Qr Code on supported devices show_qr_code = !disable_lcd - - # board related generated files path (used if slc_generate or slc_reuse_files is set) - slc_gen_path = "${chip_root}/third_party/silabs/slc_gen/${silabs_board}/" } if (silabs_board == "") { diff --git a/third_party/silabs/slc_gen/run_slc.py b/third_party/silabs/slc_gen/run_slc.py index 41426439897202..6d204eabbe938d 100644 --- a/third_party/silabs/slc_gen/run_slc.py +++ b/third_party/silabs/slc_gen/run_slc.py @@ -4,7 +4,7 @@ import subprocess import sys -if len(sys.argv) != 8: +if len(sys.argv) != 9: print("wrong number of arguments") sys.exit(1) From 9b15dc78a68e047ddab1ef6992f6c0c0a84eacf6 Mon Sep 17 00:00:00 2001 From: Junior Martinez Date: Tue, 18 Jul 2023 12:47:45 -0400 Subject: [PATCH 3/3] Fix pathing issue, use the active python3 installation on any env. Make sure slc has a configured and trusted gsdk set --- .github/workflows/examples-efr32.yaml | 12 ++++++------ examples/lighting-app/silabs/BUILD.gn | 2 +- examples/smoke-co-alarm-app/silabs/BUILD.gn | 2 +- scripts/examples/gn_silabs_example.sh | 7 +++---- third_party/silabs/slc_gen/run_slc.py | 10 ++++++++++ 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/.github/workflows/examples-efr32.yaml b/.github/workflows/examples-efr32.yaml index 141033ffc2a4bd..59d4d7f111e44e 100644 --- a/.github/workflows/examples-efr32.yaml +++ b/.github/workflows/examples-efr32.yaml @@ -55,12 +55,12 @@ jobs: with: gh-context: ${{ toJson(github) }} -# - name: Test SLC gen - # timeout-minutes: 30 - # run: | - # scripts/examples/gn_silabs_example.sh examples/lighting-app/silabs ./out/light-app BRD4187C --slc_generate --docker - # scripts/examples/gn_silabs_example.sh examples/lighting-app/silabs ./out/light-app BRD4164A --slc_generate --docker - # rm -rf ./out/ + - name: Test SLC gen + timeout-minutes: 30 + run: | + scripts/examples/gn_silabs_example.sh examples/lighting-app/silabs ./out/light-app BRD4187C --slc_generate --docker + scripts/examples/gn_silabs_example.sh examples/lighting-app/silabs ./out/light-app BRD4164A --slc_generate --docker + rm -rf ./out/ - name: Build some BRD4187C variants run: | ./scripts/run_in_build_env.sh \ diff --git a/examples/lighting-app/silabs/BUILD.gn b/examples/lighting-app/silabs/BUILD.gn index daf3201512c322..63a206ee8ffaab 100644 --- a/examples/lighting-app/silabs/BUILD.gn +++ b/examples/lighting-app/silabs/BUILD.gn @@ -60,7 +60,7 @@ if (slc_generate) { "${use_wstk_leds}", "${use_external_flash}", "${silabs_mcu}", - "${slc_gen_path}", + rebase_path(slc_gen_path), ], "list lines")) } diff --git a/examples/smoke-co-alarm-app/silabs/BUILD.gn b/examples/smoke-co-alarm-app/silabs/BUILD.gn index 9a090eb6f11052..cafd4b6f7cc1bd 100644 --- a/examples/smoke-co-alarm-app/silabs/BUILD.gn +++ b/examples/smoke-co-alarm-app/silabs/BUILD.gn @@ -60,7 +60,7 @@ if (slc_generate) { "${use_wstk_leds}", "${use_external_flash}", "${silabs_mcu}", - "${slc_gen_path}", + rebase_path(slc_gen_path), ], "list lines")) } diff --git a/scripts/examples/gn_silabs_example.sh b/scripts/examples/gn_silabs_example.sh index 9efd662bcd2fe9..f966cebed9dd62 100755 --- a/scripts/examples/gn_silabs_example.sh +++ b/scripts/examples/gn_silabs_example.sh @@ -99,10 +99,10 @@ if [ "$#" == "0" ]; then rs91x_wpa3_transition Support for WPA3 transition mode on RS91x slc_gen_path - Allow users to define a path where slc generates boards files. (requires --slc_generate or --slc_reuse_files) + Allow users to define a path where slc generates board files. (requires --slc_generate or --slc_reuse_files) (default: /third_party/silabs/slc_gen//) sl_pre_gen_path - Allow users to define a path to pre-generated boards files + Allow users to define a path to pre-generated board files (default: /third_party/silabs/matter_support/matter///) sl_matter_version Use provided software version at build time @@ -287,7 +287,6 @@ else fi if [ "$USE_SLC" == true ]; then - PYTHON_PATH="/usr/bin/python3" if [ "$GN_PATH_PROVIDED" == false ]; then GN_PATH=./.environment/cipd/packages/pigweed/gn fi @@ -295,9 +294,9 @@ else # Activation needs to be after SLC generation which is done in gn gen. # Zap generation requires activation and is done in the build phase source "$CHIP_ROOT/scripts/activate.sh" - PYTHON_PATH=$VIRTUAL_ENV"/bin/python3" fi + PYTHON_PATH="$(which python3)" BUILD_DIR=$OUTDIR/$SILABS_BOARD echo BUILD_DIR="$BUILD_DIR" diff --git a/third_party/silabs/slc_gen/run_slc.py b/third_party/silabs/slc_gen/run_slc.py index 6d204eabbe938d..4ec7f59b9ae600 100644 --- a/third_party/silabs/slc_gen/run_slc.py +++ b/third_party/silabs/slc_gen/run_slc.py @@ -58,6 +58,16 @@ def isMG24(partnumber): print(slc_arguments) +if "GSDK_ROOT" in os.environ: + gsdk_root = os.getenv('GSDK_ROOT') +else: + # If no gsdk path is set in the environment, use the standard path to the submodule + gsdk_root = os.path.join(root_path, "third_party/silabs/gecko_sdk/") + +# make sure we have a configured and trusted gsdk in slc +subprocess.run(["slc", "configuration", "--sdk", gsdk_root], check=True) +subprocess.run(["slc", "signature", "trust", "--sdk", gsdk_root], check=True) + subprocess.run(["slc", "generate", slcp_file_path, "-d", output_path, "--with", slc_arguments], check=True) # cleanup of unwanted files