Skip to content

Commit 5786429

Browse files
mengdonglinlgirdwood
authored andcommitted
xtensa-build-zephyr.py: pass SOF firmware file version string to rimage
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)
1 parent 165a784 commit 5786429

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

scripts/xtensa-build-zephyr.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
west_top = pathlib.Path(SOF_TOP, "zephyrproject")
2424
default_rimage_key = pathlib.Path("modules", "audio", "sof", "keys", "otc_private_key.pem")
2525

26+
sof_version = None
27+
2628
if platform.system() == "Windows":
2729
xtensa_tools_version_postfix = "-win32"
2830
elif platform.system() == "Linux":
@@ -323,6 +325,28 @@ def west_init_update():
323325
# Do NOT "west update sof"!!
324326
execute_command(["west", "update", "zephyr", "hal_xtensa"], timeout=300, cwd=west_top)
325327

328+
def get_sof_version(abs_build_dir):
329+
"""[summary] Get version string major.minor.micro of SOF firmware
330+
file. When building multiple platforms from the same SOF commit,
331+
all platforms share the same version. So for the 1st platform,
332+
generate the version string from sof_version.h and later platforms
333+
will reuse it.
334+
"""
335+
global sof_version
336+
if sof_version:
337+
return sof_version
338+
339+
versions = {}
340+
with open(pathlib.Path(abs_build_dir,
341+
"zephyr/include/generated/sof_versions.h"), encoding="utf8") as hfile:
342+
for hline in hfile:
343+
words = hline.split()
344+
if words[0] == '#define':
345+
versions[words[1]] = words[2]
346+
sof_version = versions['SOF_MAJOR'] + '.' + versions['SOF_MINOR'] + '.' + \
347+
versions['SOF_MICRO']
348+
return sof_version
349+
326350
def build_platforms():
327351
global west_top, SOF_TOP
328352
print(f"SOF_TOP={SOF_TOP}")
@@ -447,6 +471,8 @@ def build_platforms():
447471
signing_key = default_rimage_key
448472
sign_cmd += ["--tool-data", str(rimage_config), "--", "-k", str(signing_key)]
449473

474+
sign_cmd += ["-f", get_sof_version(abs_build_dir)]
475+
450476
if args.ipc == "IPC4":
451477
rimage_desc = pathlib.Path(SOF_TOP, "rimage", "config", platform_dict["IPC4_RIMAGE_DESC"])
452478
sign_cmd += ["-c", str(rimage_desc)]

0 commit comments

Comments
 (0)