Skip to content

Commit

Permalink
xtensa-build-zephyr.py: pass SOF firmware file version string to rimage
Browse files Browse the repository at this point in the history
Extract SOF firmware file version string major.minor.micro from the
generated sof_version.h, and pass the version string to rimage in the
signing phase. So rimage can write the version info to the firmware
manifest headers for cAVS platforms.

Signed-off-by: mengdonglin <mengdong.lin@intel.com>
(cherry picked from commit 55d8d90)
  • Loading branch information
mengdonglin authored and lgirdwood committed Jun 6, 2022
1 parent 165a784 commit 5786429
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions scripts/xtensa-build-zephyr.py
Expand Up @@ -23,6 +23,8 @@
west_top = pathlib.Path(SOF_TOP, "zephyrproject")
default_rimage_key = pathlib.Path("modules", "audio", "sof", "keys", "otc_private_key.pem")

sof_version = None

if platform.system() == "Windows":
xtensa_tools_version_postfix = "-win32"
elif platform.system() == "Linux":
Expand Down Expand Up @@ -323,6 +325,28 @@ def west_init_update():
# Do NOT "west update sof"!!
execute_command(["west", "update", "zephyr", "hal_xtensa"], timeout=300, cwd=west_top)

def get_sof_version(abs_build_dir):
"""[summary] Get version string major.minor.micro of SOF firmware
file. When building multiple platforms from the same SOF commit,
all platforms share the same version. So for the 1st platform,
generate the version string from sof_version.h and later platforms
will reuse it.
"""
global sof_version
if sof_version:
return sof_version

versions = {}
with open(pathlib.Path(abs_build_dir,
"zephyr/include/generated/sof_versions.h"), encoding="utf8") as hfile:
for hline in hfile:
words = hline.split()
if words[0] == '#define':
versions[words[1]] = words[2]
sof_version = versions['SOF_MAJOR'] + '.' + versions['SOF_MINOR'] + '.' + \
versions['SOF_MICRO']
return sof_version

def build_platforms():
global west_top, SOF_TOP
print(f"SOF_TOP={SOF_TOP}")
Expand Down Expand Up @@ -447,6 +471,8 @@ def build_platforms():
signing_key = default_rimage_key
sign_cmd += ["--tool-data", str(rimage_config), "--", "-k", str(signing_key)]

sign_cmd += ["-f", get_sof_version(abs_build_dir)]

if args.ipc == "IPC4":
rimage_desc = pathlib.Path(SOF_TOP, "rimage", "config", platform_dict["IPC4_RIMAGE_DESC"])
sign_cmd += ["-c", str(rimage_desc)]
Expand Down

0 comments on commit 5786429

Please sign in to comment.