|
23 | 23 | west_top = pathlib.Path(SOF_TOP, "zephyrproject") |
24 | 24 | default_rimage_key = pathlib.Path("modules", "audio", "sof", "keys", "otc_private_key.pem") |
25 | 25 |
|
| 26 | +sof_version = None |
| 27 | + |
26 | 28 | if platform.system() == "Windows": |
27 | 29 | xtensa_tools_version_postfix = "-win32" |
28 | 30 | elif platform.system() == "Linux": |
@@ -323,6 +325,28 @@ def west_init_update(): |
323 | 325 | # Do NOT "west update sof"!! |
324 | 326 | execute_command(["west", "update", "zephyr", "hal_xtensa"], timeout=300, cwd=west_top) |
325 | 327 |
|
| 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 | + |
326 | 350 | def build_platforms(): |
327 | 351 | global west_top, SOF_TOP |
328 | 352 | print(f"SOF_TOP={SOF_TOP}") |
@@ -447,6 +471,8 @@ def build_platforms(): |
447 | 471 | signing_key = default_rimage_key |
448 | 472 | sign_cmd += ["--tool-data", str(rimage_config), "--", "-k", str(signing_key)] |
449 | 473 |
|
| 474 | + sign_cmd += ["-f", get_sof_version(abs_build_dir)] |
| 475 | + |
450 | 476 | if args.ipc == "IPC4": |
451 | 477 | rimage_desc = pathlib.Path(SOF_TOP, "rimage", "config", platform_dict["IPC4_RIMAGE_DESC"]) |
452 | 478 | sign_cmd += ["-c", str(rimage_desc)] |
|
0 commit comments