diff --git a/examples/chef/chef.py b/examples/chef/chef.py index 96c21182aacef8..f92e0d038f92fd 100755 --- a/examples/chef/chef.py +++ b/examples/chef/chef.py @@ -213,7 +213,50 @@ def bundle_linux(device_name: str) -> None: def bundle_nrfconnect(device_name: str) -> None: - pass + # src files + zephyr_exts = ["elf", "map", "hex"] + script_files = ["firmware_utils.py", + "nrfconnect_firmware_utils.py"] + # src dirs + nrf_root = os.path.join(_CHEF_SCRIPT_PATH, + "nrfconnect", + "build", + "zephyr") + scripts_root = os.path.join(_REPO_BASE_PATH, + "scripts", + "flashing") + # output prep + sub_dir = os.path.join(_CD_STAGING_DIR, device_name) + os.mkdir(sub_dir) + # copy src files + for zephyr_ext in zephyr_exts: + input_base = f"zephyr.{zephyr_ext}" + output_base = f"{device_name}.{zephyr_ext}" + if zephyr_ext == "hex": + dest_item = os.path.join(sub_dir, + output_base) + else: + dest_item = os.path.join(_CD_STAGING_DIR, + output_base) + src_item = os.path.join(nrf_root, + input_base) + shutil.copy(src_item, dest_item) + for script_file in script_files: + src_item = os.path.join(scripts_root, + script_file) + dest_item = os.path.join(sub_dir, + script_file) + shutil.copy(src_item, dest_item) + # gen flash script + shell.run_cmd(f"cd {sub_dir}") + gen_script_path = os.path.join(scripts_root, + "gen_flashing_script.py") + command = textwrap.dedent(f"""\ + python3 {gen_script_path} nrfconnect + --output {device_name}.flash.py + --application {device_name}.hex""") + command = command.replace("\n", " ") + shell.run_cmd(command) def bundle_esp32(device_name: str) -> None: @@ -235,7 +278,7 @@ def bundle_esp32(device_name: str) -> None: if os.sep in item: new_dir = item[:item.rindex(os.sep)] new_dir = os.path.join(_CD_STAGING_DIR, new_dir) - os.makedirs(new_dir) + os.makedirs(new_dir, exists_ok=True) src_item = os.path.join(esp_root, item) dest_item = os.path.join(_CD_STAGING_DIR, item) shutil.copy(src_item, dest_item) @@ -438,7 +481,7 @@ def main(argv: Sequence[str]) -> None: shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}") command = f"./chef.py -cbr --use_zzz -d {device_name} -t {options.build_target}" flush_print(f"Building {command}", with_border=True) - # shell.run_cmd(command) + shell.run_cmd(command) bundle(options.build_target, device_name) exit(0) @@ -460,7 +503,7 @@ def main(argv: Sequence[str]) -> None: flush_print(f"Building {command}", with_border=True) shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}") shell.run_cmd("export GNUARMEMB_TOOLCHAIN_PATH=\"$PW_ARM_CIPD_INSTALL_DIR\"") - # shell.run_cmd(command) + shell.run_cmd(command) bundle(platform, device_name) archive_name = f"{label}-{device_name}" archive_full_name = archive_prefix + archive_name + archive_suffix