Skip to content

Commit 33fc7a3

Browse files
committed
xtensa-build-zephyr.py: don't extract SOF_BUILD from generated .h file
This replaces and simplifies commit a823958 ("xtensa-build-zephyr: pass sof build version to rimage") with a constant 1. That commit was submitted to avoid a test failure in a broken, internal test looking for an SOF_BUILD value... hardcoded to 1! (internal FW issue 257, test TestLoadFwExtended::()::test_00_01_load_fw_and_check_version") The final goal is for this script to stop extracting anything from `generated/sof_versions.h` so rimage can be configured _before_ the build has started. Other commits will deal with other parts of sof_versions.h SOF_BUILD can be replaced by a constant because it has always been one when building with Zephyr. The optional BLD_COUNTERS feature - disabled by default in XTOS since commit 9f8cce1 ("Disable __TIME__ and the non-reproducible build counter by default") for build reproducibility reasons - has never worked with Zephyr for the following reasons: - The sof_add_build_counter_rule() invocation is located in the top-level sof/CMakeLists.txt file which has never been used by the Zephyr build. - sof_add_build_counter_rule() registers a POST_BUILD command for the top-level "sof" CMake target but there is no "sof" build target in the Zephyr build. - Variables like VERSION_BUILD_COUNTER_CMAKE_PATH are not defined in the Zephyr build for some unknown reason. - Probably others. Signed-off-by: Marc Herbert <marc.herbert@intel.com>
1 parent 91dbc05 commit 33fc7a3

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

scripts/cmake/version-build-counter.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ set(VERSION_BUILD_COUNTER_CMAKE_PATH ${CMAKE_CURRENT_LIST_DIR}/version-build-cou
88

99
set(BUILD_COUNTER_PATH "${SOF_ROOT_BINARY_DIRECTORY}/.build")
1010

11+
# Among many other differences, the Zephyr build does not invoke
12+
# sof_add_build_counter_rule() at build time. In other words, Zephyr has
13+
# never supported incrementing the BLD_COUNTERS: SOF_BUILD is always
14+
# equal to the starting value below when building with Zephyr.
1115
if(NOT EXISTS "${BUILD_COUNTER_PATH}")
1216
file(WRITE "${BUILD_COUNTER_PATH}" "1")
1317
endif()

scripts/xtensa-build-zephyr.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
default_rimage_key = pathlib.Path(SOF_TOP, "keys", "otc_private_key.pem")
6161

6262
sof_fw_version = None
63-
sof_build_version = None
6463

6564
if py_platform.system() == "Windows":
6665
xtensa_tools_version_postfix = "-win32"
@@ -444,17 +443,16 @@ def west_update():
444443
execute_command(["west", "update"], check=True, timeout=3000, cwd=west_top)
445444

446445

447-
def get_build_and_sof_version(abs_build_dir):
448-
"""[summary] Get version string major.minor.micro and build of SOF
446+
def get_sof_version(abs_build_dir):
447+
"""[summary] Get version string major.minor.micro of SOF
449448
firmware file. When building multiple platforms from the same SOF
450449
commit, all platforms share the same version. So for the 1st platform,
451450
generate the version string from sof_version.h and later platforms will
452451
reuse it.
453452
"""
454453
global sof_fw_version
455-
global sof_build_version
456-
if sof_fw_version and sof_build_version:
457-
return sof_fw_version, sof_build_version
454+
if sof_fw_version:
455+
return sof_fw_version
458456

459457
versions = {}
460458
with open(pathlib.Path(abs_build_dir,
@@ -465,9 +463,8 @@ def get_build_and_sof_version(abs_build_dir):
465463
versions[words[1]] = words[2]
466464
sof_fw_version = versions['SOF_MAJOR'] + '.' + versions['SOF_MINOR'] + '.' + \
467465
versions['SOF_MICRO']
468-
sof_build_version = versions['SOF_BUILD']
469466

470-
return sof_fw_version, sof_build_version
467+
return sof_fw_version
471468

472469
def rmtree_if_exists(directory):
473470
"This is different from ignore_errors=False because it deletes everything or nothing"
@@ -674,11 +671,17 @@ def build_platforms():
674671

675672
sign_cmd += ["--tool-data", str(rimage_config), "--", "-k", str(signing_key)]
676673

677-
sof_fw_vers, sof_build_vers = get_build_and_sof_version(abs_build_dir)
674+
sof_fw_vers = get_sof_version(abs_build_dir)
678675

679676
sign_cmd += ["-f", sof_fw_vers]
680677

681-
sign_cmd += ["-b", sof_build_vers]
678+
# Default value is 0 in rimage but for Zephyr the "build counter" has always
679+
# been hardcoded to 1 in CMake and there is even a (broken) test that fails
680+
# when it's not hardcoded to 1.
681+
# FIXME: drop this line once the following test is fixed
682+
# tests/avs/fw_00_basic/test_01_load_fw_extended.py::TestLoadFwExtended::()::
683+
# test_00_01_load_fw_and_check_version
684+
sign_cmd += ["-b", "1"]
682685

683686
if args.ipc == "IPC4":
684687
rimage_desc = pathlib.Path(SOF_TOP, "rimage", "config", platform_dict["IPC4_RIMAGE_DESC"])

0 commit comments

Comments
 (0)