From 1081051cb73faf54ac702995cd862f15c57eb117 Mon Sep 17 00:00:00 2001 From: Junior Martinez <67972863+jmartinez-silabs@users.noreply.github.com> Date: Tue, 18 Jul 2023 21:09:55 -0400 Subject: [PATCH] [Silabs] Add user configurable paths for board configuration files (#28019) * Add option of user to configure silabs_pre_gen or slc_gen paths * slc_gen_path can be in efr32_sdk.gni * 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 | 1 + examples/smoke-co-alarm-app/silabs/BUILD.gn | 1 + scripts/examples/gn_silabs_example.sh | 9 +++++++-- third_party/silabs/efr32_sdk.gni | 13 +++++++++---- third_party/silabs/slc_gen/run_slc.py | 14 ++++++++++++-- 6 files changed, 36 insertions(+), 14 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 ded0e41c42b70a..63a206ee8ffaab 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}", + 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 d4ebe73cf0475c..cafd4b6f7cc1bd 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}", + rebase_path(slc_gen_path), ], "list lines")) } diff --git a/scripts/examples/gn_silabs_example.sh b/scripts/examples/gn_silabs_example.sh index 1f181fc75564af..f966cebed9dd62 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 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 board files + (default: /third_party/silabs/matter_support/matter///) sl_matter_version Use provided software version at build time sl_matter_version_str @@ -281,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 @@ -289,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/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index 11aa2d0e651ed6..3267d87e9bd398 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,20 @@ 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}/" + + # 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) { - 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/slc_gen/run_slc.py b/third_party/silabs/slc_gen/run_slc.py index 87a481ea3c9a80..4ec7f59b9ae600 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) @@ -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 = "" @@ -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