diff --git a/examples/chef/chef.py b/examples/chef/chef.py index c4462401f7cc53..fb075f27a49ff9 100755 --- a/examples/chef/chef.py +++ b/examples/chef/chef.py @@ -150,10 +150,7 @@ def bundle(platform: str, device_name: str) -> None: flush_print(f"No bundle function for {platform}!") exit(1) flush_print(f"Copying {matter_file}") - src_item = os.path.join(_REPO_BASE_PATH, - "zzz_generated", - "chef-"+device_name, - "zap-generated", + src_item = os.path.join(_DEVICE_FOLDER, matter_file) dest_item = os.path.join(_CD_STAGING_DIR, matter_file) shutil.copy(src_item, dest_item) @@ -322,8 +319,15 @@ def main(argv: Sequence[str]) -> None: dest="use_zzz", action="store_true") parser.add_option("", "--build_all", help="For use in CD only. Builds and bundles all chef examples for the specified platform. Uses --use_zzz. Chef exits after completion.", dest="build_all", action="store_true") + parser.add_option("-k", "--keep_going", help="For use in CD only. Continues building all sample apps in the event of an error.", + dest="keep_going", action="store_true") parser.add_option( "", "--ci", help="Builds Chef examples defined in cicd_config. Uses --use_zzz. Uses specified target from -t. Chef exits after completion.", dest="ci", action="store_true") + parser.add_option( + "", "--ipv6only", help="Compile build which only supports ipv6. Linux only.", + action="store_true") + parser.add_option( + "", "--cpu_type", help="CPU type to compile for. Linux only.", choices=["arm64", "x64"]) options, _ = parser.parse_args(argv) @@ -387,13 +391,17 @@ def main(argv: Sequence[str]) -> None: except RuntimeError as build_fail_error: failed_builds.append((device_name, platform, "build")) flush_print(str(build_fail_error)) - break + if not options.keep_going: + exit(1) + continue try: bundle(platform, device_name) except FileNotFoundError as bundle_fail_error: failed_builds.append((device_name, platform, "bundle")) flush_print(str(bundle_fail_error)) - break + if not options.keep_going: + exit(1) + continue archive_name = f"{label}-{device_name}" archive_full_name = archive_prefix + archive_name + archive_suffix flush_print(f"Adding build output to archive {archive_full_name}") @@ -501,6 +509,7 @@ def main(argv: Sequence[str]) -> None: # if options.do_build: + sw_ver_string = "" if options.do_automated_test_stamp: branch = "" for branch_text in shell.run_cmd("git branch", return_cmd_output=True).split("\n"): @@ -557,7 +566,8 @@ def main(argv: Sequence[str]) -> None: set(CONFIG_DEVICE_VENDOR_ID {options.vid}) set(CONFIG_DEVICE_PRODUCT_ID {options.pid}) set(CONFIG_ENABLE_PW_RPC {"1" if options.do_rpc else "0"}) - set(SAMPLE_NAME {options.sample_device_type_name})""")) + set(SAMPLE_NAME {options.sample_device_type_name}) + set(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING \"{sw_ver_string}\")""")) if options.build_target == "esp32": shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}/esp32") @@ -591,17 +601,48 @@ def main(argv: Sequence[str]) -> None: elif options.build_target == "linux": shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}/linux") + + linux_args = [] + if options.do_rpc: + linux_args.append('import("//with_pw_rpc.gni")') + linux_args.extend([ + 'import("//build_overrides/chip.gni")', + 'import("${chip_root}/config/standalone/args.gni")', + 'chip_shell_cmd_server = false', + 'chip_build_libshell = true', + 'chip_config_network_layer_ble = false', + f'target_defines = ["CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID={options.vid}", "CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID={options.pid}", "CONFIG_ENABLE_PW_RPC={int(options.do_rpc)}"]', + ]) + if options.cpu_type == "arm64": + uname_resp = shell.run_cmd("uname -m", return_cmd_output=True) + if "aarch" not in uname_resp and "arm" not in uname_resp: + if ( + "aarch" not in uname_resp and + "arm" not in uname_resp and + "SYSROOT_AARCH64" not in shell.env): + flush_print( + "SYSROOT_AARCH64 env variable not set. " + "AARCH64 toolchain needed for cross-compiling for arm64.") + exit(1) + shell.env["PKG_CONFIG_PATH"] = ( + f'{shell.env["SYSROOT_AARCH64"]}/lib/aarch64-linux-gnu/pkgconfig') + linux_args.append('target_cpu="arm64"') + linux_args.append('is_clang=true') + linux_args.append('chip_crypto="mbedtls"') + linux_args.append(f'sysroot="{shell.env["SYSROOT_AARCH64"]}"') + elif options.cpu_type == "x64": + uname_resp = shell.run_cmd("uname -m", return_cmd_output=True) + if "x64" not in uname_resp and "x86_64" not in uname_resp: + flush_print(f"Unable to cross compile for x64 on {uname_resp}") + exit(1) + if options.ipv6only: + linux_args.append("chip_inet_config_enable_ipv4=false") + + if sw_ver_string: + linux_args.append( + f'chip_device_config_device_software_version_string = "{sw_ver_string}"') with open(f"{_CHEF_SCRIPT_PATH}/linux/args.gni", "w") as f: - sw_ver_string_config_text = f"chip_device_config_device_software_version_string = \"{sw_ver_string}\"" if options.do_automated_test_stamp else "" - f.write(textwrap.dedent(f"""\ - import("//build_overrides/chip.gni") - import("${{chip_root}}/config/standalone/args.gni") - chip_shell_cmd_server = false - chip_build_libshell = true - chip_config_network_layer_ble = false - target_defines = ["CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID={options.vid}", "CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID={options.pid}", "CONFIG_ENABLE_PW_RPC={'1' if options.do_rpc else '0'}"] - {sw_ver_string_config_text} - """)) + f.write("\n".join(linux_args)) with open(f"{_CHEF_SCRIPT_PATH}/linux/sample.gni", "w") as f: f.write(textwrap.dedent(f"""\ sample_zap_file = "{options.sample_device_type_name}.zap" @@ -609,11 +650,7 @@ def main(argv: Sequence[str]) -> None: """)) if options.do_clean: shell.run_cmd(f"rm -rf out") - if options.do_rpc: - shell.run_cmd( - "gn gen out --args='import(\"//with_pw_rpc.gni\")'") - else: - shell.run_cmd("gn gen out --args=''") + shell.run_cmd("gn gen out") shell.run_cmd("ninja -C out") # diff --git a/zzz_generated/chef-rootnode_contactsensor_lFAGG1bfRO/zap-generated/rootnode_contactsensor_lFAGG1bfRO.matter b/examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.matter similarity index 100% rename from zzz_generated/chef-rootnode_contactsensor_lFAGG1bfRO/zap-generated/rootnode_contactsensor_lFAGG1bfRO.matter rename to examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.matter diff --git a/zzz_generated/chef-rootnode_dimmablelight_bCwGYSDpoe/zap-generated/rootnode_dimmablelight_bCwGYSDpoe.matter b/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter similarity index 100% rename from zzz_generated/chef-rootnode_dimmablelight_bCwGYSDpoe/zap-generated/rootnode_dimmablelight_bCwGYSDpoe.matter rename to examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter diff --git a/zzz_generated/chef-rootnode_flowsensor_1zVxHedlaV/zap-generated/rootnode_flowsensor_1zVxHedlaV.matter b/examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.matter similarity index 100% rename from zzz_generated/chef-rootnode_flowsensor_1zVxHedlaV/zap-generated/rootnode_flowsensor_1zVxHedlaV.matter rename to examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.matter diff --git a/zzz_generated/chef-rootnode_heatingcoolingunit_ncdGai1E5a/zap-generated/rootnode_heatingcoolingunit_ncdGai1E5a.matter b/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter similarity index 100% rename from zzz_generated/chef-rootnode_heatingcoolingunit_ncdGai1E5a/zap-generated/rootnode_heatingcoolingunit_ncdGai1E5a.matter rename to examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter diff --git a/zzz_generated/chef-rootnode_humiditysensor_Xyj4gda6Hb/zap-generated/rootnode_humiditysensor_Xyj4gda6Hb.matter b/examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.matter similarity index 100% rename from zzz_generated/chef-rootnode_humiditysensor_Xyj4gda6Hb/zap-generated/rootnode_humiditysensor_Xyj4gda6Hb.matter rename to examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.matter diff --git a/zzz_generated/chef-rootnode_occupancysensor_iHyVgifZuo/zap-generated/rootnode_occupancysensor_iHyVgifZuo.matter b/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter similarity index 100% rename from zzz_generated/chef-rootnode_occupancysensor_iHyVgifZuo/zap-generated/rootnode_occupancysensor_iHyVgifZuo.matter rename to examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter diff --git a/zzz_generated/chef-rootnode_onofflightswitch_FsPlMr090Q/zap-generated/rootnode_onofflightswitch_FsPlMr090Q.matter b/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.matter similarity index 100% rename from zzz_generated/chef-rootnode_onofflightswitch_FsPlMr090Q/zap-generated/rootnode_onofflightswitch_FsPlMr090Q.matter rename to examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.matter diff --git a/zzz_generated/chef-rootnode_onoffpluginunit_Wtf8ss5EBY/zap-generated/rootnode_onoffpluginunit_Wtf8ss5EBY.matter b/examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.matter similarity index 100% rename from zzz_generated/chef-rootnode_onoffpluginunit_Wtf8ss5EBY/zap-generated/rootnode_onoffpluginunit_Wtf8ss5EBY.matter rename to examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.matter diff --git a/zzz_generated/chef-rootnode_pressuresensor_s0qC9wLH4k/zap-generated/rootnode_pressuresensor_s0qC9wLH4k.matter b/examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.matter similarity index 100% rename from zzz_generated/chef-rootnode_pressuresensor_s0qC9wLH4k/zap-generated/rootnode_pressuresensor_s0qC9wLH4k.matter rename to examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.matter diff --git a/zzz_generated/chef-rootnode_speaker_RpzeXdimqA/zap-generated/rootnode_speaker_RpzeXdimqA.matter b/examples/chef/devices/rootnode_speaker_RpzeXdimqA.matter similarity index 100% rename from zzz_generated/chef-rootnode_speaker_RpzeXdimqA/zap-generated/rootnode_speaker_RpzeXdimqA.matter rename to examples/chef/devices/rootnode_speaker_RpzeXdimqA.matter diff --git a/zzz_generated/chef-rootnode_temperaturesensor_Qy1zkNW7c3/zap-generated/rootnode_temperaturesensor_Qy1zkNW7c3.matter b/examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.matter similarity index 100% rename from zzz_generated/chef-rootnode_temperaturesensor_Qy1zkNW7c3/zap-generated/rootnode_temperaturesensor_Qy1zkNW7c3.matter rename to examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.matter diff --git a/zzz_generated/chef-rootnode_thermostat_bm3fb8dhYi/zap-generated/rootnode_thermostat_bm3fb8dhYi.matter b/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter similarity index 100% rename from zzz_generated/chef-rootnode_thermostat_bm3fb8dhYi/zap-generated/rootnode_thermostat_bm3fb8dhYi.matter rename to examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter diff --git a/zzz_generated/chef-rootnode_windowcovering_RLCxaGi9Yx/zap-generated/rootnode_windowcovering_RLCxaGi9Yx.matter b/examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.matter similarity index 100% rename from zzz_generated/chef-rootnode_windowcovering_RLCxaGi9Yx/zap-generated/rootnode_windowcovering_RLCxaGi9Yx.matter rename to examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.matter diff --git a/examples/chef/esp32/CMakeLists.txt b/examples/chef/esp32/CMakeLists.txt index d86d3efac2586e..cbf870141d89ee 100644 --- a/examples/chef/esp32/CMakeLists.txt +++ b/examples/chef/esp32/CMakeLists.txt @@ -37,8 +37,12 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) include(${CMAKE_CURRENT_LIST_DIR}/../project_include.cmake) message(STATUS "Product ID " ${CONFIG_DEVICE_PRODUCT_ID}) message(STATUS "Vendor ID " ${CONFIG_DEVICE_VENDOR_ID}) +message(STATUS "SW Version String" ${CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING}) idf_build_set_property(COMPILE_OPTIONS "-DCHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID=${CONFIG_DEVICE_PRODUCT_ID}" APPEND) idf_build_set_property(COMPILE_OPTIONS "-DCHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID=${CONFIG_DEVICE_VENDOR_ID}" APPEND) +if(NOT ${CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING} STREQUAL "") + idf_build_set_property(COMPILE_OPTIONS "-DCHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING=\"${CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING}\"" APPEND) +endif() idf_build_set_property(COMPILE_OPTIONS "-DCHIP_PLATFORM_ESP32=1" APPEND) project(chip-shell) diff --git a/examples/chef/linux/with_pw_rpc.gni b/examples/chef/linux/with_pw_rpc.gni index 8cfadcc758bc85..756a93469bf072 100644 --- a/examples/chef/linux/with_pw_rpc.gni +++ b/examples/chef/linux/with_pw_rpc.gni @@ -41,3 +41,4 @@ pw_build_LINK_DEPS = [ chip_enable_pw_rpc = true chip_build_pw_trace_lib = true +chip_use_pw_logging = true diff --git a/examples/common/pigweed/rpc_console/py/chip_rpc/console.py b/examples/common/pigweed/rpc_console/py/chip_rpc/console.py index 65fdfc034f60ab..c74b6617396e59 100644 --- a/examples/common/pigweed/rpc_console/py/chip_rpc/console.py +++ b/examples/common/pigweed/rpc_console/py/chip_rpc/console.py @@ -253,7 +253,8 @@ def write_to_output(data: bytes, "E": logging.ERROR, "F": logging.FATAL, "V": logging.DEBUG, "D": logging.DEBUG, "": logging.INFO, "": logging.DEBUG, "": logging.ERROR, "": logging.INFO, "": logging.WARNING, - "": logging.ERROR, "": logging.DEBUG} + "": logging.ERROR, "": logging.DEBUG, + "ERR": logging.ERROR, "DBG": logging.DEBUG, "INF": logging.INFO} ESP_CHIP_REGEX = r"(?P[IWEFV]) \((?P