Skip to content

Commit

Permalink
[EFR32] Add support for efr32 MG24 for the chef example (project-chip…
Browse files Browse the repository at this point in the history
…#18621)

* Template app for chef

* chef update for BRD4186A thread
  • Loading branch information
mkardous-silabs authored and cpagravel committed Jun 15, 2022
1 parent c04af79 commit 12fbc53
Show file tree
Hide file tree
Showing 18 changed files with 1,863 additions and 5 deletions.
61 changes: 56 additions & 5 deletions examples/chef/chef.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def load_config() -> None:
config = dict()
config["nrfconnect"] = dict()
config["esp32"] = dict()
config["silabs-thread"] = dict()

configFile = f"{_CHEF_SCRIPT_PATH}/config.yaml"
if (os.path.exists(configFile)):
Expand All @@ -71,6 +72,10 @@ def load_config() -> None:
config["nrfconnect"]["TTY"] = None
config["esp32"]["IDF_PATH"] = os.environ.get('IDF_PATH')
config["esp32"]["TTY"] = None
config["silabs-thread"]["GECKO_SDK"] = f"{_REPO_BASE_PATH}third_party/efr32_sdk/repo"
config["silabs-thread"]["TTY"] = None
config["silabs-thread"]["CU"] = None

print(yaml.dump(config))
yaml.dump(config, configStream)
configStream.close()
Expand Down Expand Up @@ -110,6 +115,7 @@ def main(argv: Sequence[str]) -> None:
nrfconnect
esp32
linux
silabs-thread
Device Types:
{deviceTypes}
Expand Down Expand Up @@ -146,7 +152,7 @@ def main(argv: Sequence[str]) -> None:
action='store',
dest="build_target",
help="specifies target platform. Default is esp32. See info below for currently supported target platforms",
choices=['nrfconnect', 'esp32', 'linux', ],
choices=['nrfconnect', 'esp32', 'linux', 'silabs-thread'],
metavar="TARGET",
default="esp32")
parser.add_option("-r", "--rpc", help="enables Pigweed RPC interface. Enabling RPC disables the shell interface. Your sdkconfig configurations will be reverted to default. Default is PW RPC off. When enabling or disabling this flag, on the first build force a clean build with -c", action="store_true", dest="do_rpc")
Expand Down Expand Up @@ -188,6 +194,8 @@ def main(argv: Sequence[str]) -> None:
shell.run_cmd("export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb")
elif options.build_target == "linux":
pass
elif options.build_target == "silabs-thread":
print('Path to gecko sdk is configured within Matter.')
else:
print(f"Target {options.build_target} not supported")

Expand All @@ -204,6 +212,8 @@ def main(argv: Sequence[str]) -> None:
print("Updating toolchain")
shell.run_cmd(
f"cd {_REPO_BASE_PATH} && python3 scripts/setup/nrfconnect/update_ncs.py --update")
elif options.build_target == "silabs-thread":
print("Silabs-thread toolchain not supported. Skipping")
elif options.build_target == "linux":
print("Linux toolchain update not supported. Skipping")

Expand Down Expand Up @@ -256,6 +266,8 @@ def main(argv: Sequence[str]) -> None:
elif options.build_target == "nrfconnect":
shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}/nrfconnect")
shell.run_cmd("west build -t menuconfig")
elif (options.build_target == "silabs-thread") or (options.build_target == "silabs-wifi"):
print("Menuconfig not available on Silabs-thread target. Skipping")
elif options.build_target == "linux":
print("Menuconfig not available on Linux target. Skipping")

Expand All @@ -267,12 +279,18 @@ def main(argv: Sequence[str]) -> None:
print("Building...")
if options.do_rpc:
print("RPC PW enabled")
shell.run_cmd(
f"export SDKCONFIG_DEFAULTS={_CHEF_SCRIPT_PATH}/esp32/sdkconfig_rpc.defaults")
if options.build_target == "esp32":
shell.run_cmd(
f"export SDKCONFIG_DEFAULTS={_CHEF_SCRIPT_PATH}/esp32/sdkconfig_rpc.defaults")
else:
print(f"RPC PW on {options.build_target} not supported")

else:
print("RPC PW disabled")
if (options.build_target == "esp32"):
shell.run_cmd(
f"export SDKCONFIG_DEFAULTS={_CHEF_SCRIPT_PATH}/esp32/sdkconfig.defaults")

print(
f"Product ID 0x{options.pid:02X} / Vendor ID 0x{options.vid:02X}")
shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}")
Expand Down Expand Up @@ -301,6 +319,15 @@ def main(argv: Sequence[str]) -> None:
if options.do_rpc:
nrf_build_cmds.append("-- -DOVERLAY_CONFIG=rpc.overlay")
shell.run_cmd(" ".join(nrf_build_cmds))

elif options.build_target == "silabs-thread":
shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}/efr32")
if options.do_clean:
shell.run_cmd(f"rm -rf out/{options.sample_device_type_name}")
shell.run_cmd(
f"""{_REPO_BASE_PATH}/scripts/examples/gn_efr32_example.sh ./ out/{options.sample_device_type_name} BRD4186A \'sample_name=\"{options.sample_device_type_name}\"\' enable_openthread_cli=true chip_build_libshell=true \'{'import("//with_pw_rpc.gni")' if options.do_rpc else ""}\'""")
shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}")

elif options.build_target == "linux":
shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}/linux")
with open(f"{_CHEF_SCRIPT_PATH}/linux/args.gni", "w") as f:
Expand Down Expand Up @@ -345,6 +372,11 @@ def main(argv: Sequence[str]) -> None:
shell.run_cmd("west flash --erase")
else:
shell.run_cmd("west flash")
elif (options.build_target == "silabs-thread") or (options.build_target == "silabs-wifi"):
shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}/efr32")
shell.run_cmd(f"python3 out/{options.sample_device_type_name}/BRD4186A/chip-efr32-chef-example.flash.py")

shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}")

#
# Terminal interaction
Expand All @@ -364,6 +396,13 @@ def main(argv: Sequence[str]) -> None:
exit(1)
shell.run_cmd("killall screen")
shell.run_cmd(f"screen {config['nrfconnect']['TTY']} 115200")
elif (options.build_target == "silabs-thread"):
if config['silabs-thread']['TTY'] is None:
print('The path for the serial enumeration for silabs-thread is not set. Make sure silabs-thread.TTY is set on your config.yaml file')
exit(1)

shell.run_cmd("killall screen")
shell.run_cmd(f"screen {config['silabs-thread']['TTY']} 115200 8-N-1")
elif options.build_target == "linux":
print(
f"{_CHEF_SCRIPT_PATH}/linux/out/{options.sample_device_type_name}")
Expand All @@ -374,8 +413,20 @@ def main(argv: Sequence[str]) -> None:
# RPC Console
#
if options.do_rpc_console:
shell.run_cmd(
f"python3 -m chip_rpc.console --device {config['esp32']['TTY']}")
if options.build_target == "esp32":
shell.run_cmd(
f"python3 -m chip_rpc.console --device {config['esp32']['TTY']}")
elif (options.build_target == "silabs-thread"):
if (sys.platform == "linux") or (sys.platform == "linux2"):
if(config['silabs-thread']['TTY'] is None):
print('The path for the serial enumeration for silabs-thread is not set. Make sure silabs-thread.TTY is set on your config.yaml file')
exit(1)
shell.run_cmd(f"python3 -m chip_rpc.console --device {config['silabs-thread']['TTY']} -b 115200")
elif sys.platform == "darwin":
if(config['silabs-thread']['CU'] is None):
print('The path for the serial enumeration for silabs-thread is not set. Make sure silabs-thread.CU is set on your config.yaml file')
exit(1)
shell.run_cmd(f"python3 -m chip_rpc.console --device {config['silabs-thread']['CU']} -b 115200")

print("Done")

Expand Down
28 changes: 28 additions & 0 deletions examples/chef/efr32/.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright (c) 2020 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/build.gni")

# The location of the build configuration file.
buildconfig = "${build_root}/config/BUILDCONFIG.gn"

# CHIP uses angle bracket includes.
check_system_includes = true

default_args = {
target_cpu = "arm"
target_os = "freertos"
chip_openthread_ftd = true
import("//args.gni")
}
Loading

0 comments on commit 12fbc53

Please sign in to comment.