From 72c1797cb0e81890224327514d5bd8c5f98e0ba3 Mon Sep 17 00:00:00 2001 From: Chao Song Date: Fri, 22 Sep 2023 10:54:26 +0800 Subject: [PATCH] xtensa-build-zephyr: sign firmware with toml from sof repo As image toml files are copied to sof repo now, use them for image signing. Signed-off-by: Chao Song --- scripts/xtensa-build-zephyr.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/scripts/xtensa-build-zephyr.py b/scripts/xtensa-build-zephyr.py index 5f8cdd5ce361..a1e1d5ea9c4b 100755 --- a/scripts/xtensa-build-zephyr.py +++ b/scripts/xtensa-build-zephyr.py @@ -82,7 +82,6 @@ class PlatformConfig: XTENSA_CORE: str DEFAULT_TOOLCHAIN_VARIANT: str = "xt-clang" RIMAGE_KEY: pathlib.Path = pathlib.Path(SOF_TOP, "keys", "otc_private_key_3k.pem") - IPC4_RIMAGE_DESC: str = None IPC4_CONFIG_OVERLAY: str = "ipc4_overlay.conf" aliases: list = dataclasses.field(default_factory=list) @@ -93,7 +92,6 @@ class PlatformConfig: f"RG-2017.8{xtensa_tools_version_postfix}", "cavs2x_LX6HiFi3_2017_8", "xcc", - IPC4_RIMAGE_DESC = "tgl-cavs.toml", aliases = ['adl', 'ehl'] ), "tgl-h" : PlatformConfig( @@ -101,7 +99,6 @@ class PlatformConfig: f"RG-2017.8{xtensa_tools_version_postfix}", "cavs2x_LX6HiFi3_2017_8", "xcc", - IPC4_RIMAGE_DESC = "tgl-h-cavs.toml", aliases = ['adl-s'] ), "mtl" : PlatformConfig( @@ -550,7 +547,7 @@ def rimage_west_configuration(platform_dict, dest_dir): # the user input. We could just append and leave duplicates but that would be # at best confusing and at worst relying on undocumented rimage precedence. extra_args = [] - for default_opt in rimage_options(platform_dict): + for default_opt in rimage_options(platform_dict, dest_dir): if not default_opt[0] in workspace_extra_args: extra_args += default_opt @@ -585,8 +582,22 @@ def build_rimage(): rimage_build_cmd.append("-v") execute_command(rimage_build_cmd, cwd=west_top) +def prepare_rimage_desc(platform_name, dest_dir): + toml_name = platform_name + '.toml' + platform_desc = SOF_TOP / "config" / "platform" / toml_name + module_desc = SOF_TOP / "config" / "module" / toml_name + out_toml = dest_dir / toml_name -def rimage_options(platform_dict): + with open(platform_desc, 'r') as p, open(module_desc, 'r') as m, open(out_toml, 'w') as o: + lines = p.readlines() + o.writelines(lines) + o.write('\n') # Append a new line between files + lines = m.readlines() + o.writelines(lines) + + return str(out_toml) + +def rimage_options(platform_dict, dest_dir): """Return a list of default rimage options as a list of tuples, example: [ (-f, 2.5.0), (-b, 1), (-k, key.pem),... ] @@ -619,12 +630,8 @@ def rimage_options(platform_dict): # test_00_01_load_fw_and_check_version opts.append(("-b", "1")) - if platform_dict.get("IPC4_RIMAGE_DESC", None) is not None: - rimage_desc = platform_dict["IPC4_RIMAGE_DESC"] - else: - rimage_desc = platform_dict["name"] + ".toml" - - opts.append(("-c", str(RIMAGE_SOURCE_DIR / "config" / rimage_desc))) + rimage_desc = prepare_rimage_desc(platform_dict["name"], dest_dir) + opts.append(("-c", rimage_desc)) return opts