Skip to content

Commit

Permalink
xtensa-build-zephyr: sign firmware with toml from sof repo
Browse files Browse the repository at this point in the history
As image toml files are copied to sof repo now,
use them for image signing.

Signed-off-by: Chao Song <[email protected]>
  • Loading branch information
Chao Song committed Sep 22, 2023
1 parent f744c8f commit 72c1797
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions scripts/xtensa-build-zephyr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -93,15 +92,13 @@ 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(
"tgl-h", "intel_adsp_cavs25_tgph",
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(
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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),... ]
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 72c1797

Please sign in to comment.