xtensa-build-zephyr.py: don't extract SOF_BUILD from generated .h file

This replaces and simplifies commit a823958a8d ("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 9f8cce1522 ("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>
This commit is contained in:
Marc Herbert 2023-05-02 04:55:01 +00:00 committed by Kai Vehmanen
parent d132e25480
commit 2d3c7eae4f
2 changed files with 17 additions and 10 deletions

View File

@ -8,6 +8,10 @@ set(VERSION_BUILD_COUNTER_CMAKE_PATH ${CMAKE_CURRENT_LIST_DIR}/version-build-cou
set(BUILD_COUNTER_PATH "${SOF_ROOT_BINARY_DIRECTORY}/.build")
# Among many other differences, the Zephyr build does not invoke
# sof_add_build_counter_rule() at build time. In other words, Zephyr has
# never supported incrementing the BLD_COUNTERS: SOF_BUILD is always
# equal to the starting value below when building with Zephyr.
if(NOT EXISTS "${BUILD_COUNTER_PATH}")
file(WRITE "${BUILD_COUNTER_PATH}" "1")
endif()

View File

@ -60,7 +60,6 @@ west_top = pathlib.Path(SOF_TOP, "..").resolve()
default_rimage_key = pathlib.Path(SOF_TOP, "keys", "otc_private_key.pem")
sof_fw_version = None
sof_build_version = None
if py_platform.system() == "Windows":
xtensa_tools_version_postfix = "-win32"
@ -444,17 +443,16 @@ def west_update():
execute_command(["west", "update"], check=True, timeout=3000, cwd=west_top)
def get_build_and_sof_version(abs_build_dir):
"""[summary] Get version string major.minor.micro and build of SOF
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_fw_version
global sof_build_version
if sof_fw_version and sof_build_version:
return sof_fw_version, sof_build_version
if sof_fw_version:
return sof_fw_version
versions = {}
with open(pathlib.Path(abs_build_dir,
@ -465,9 +463,8 @@ def get_build_and_sof_version(abs_build_dir):
versions[words[1]] = words[2]
sof_fw_version = versions['SOF_MAJOR'] + '.' + versions['SOF_MINOR'] + '.' + \
versions['SOF_MICRO']
sof_build_version = versions['SOF_BUILD']
return sof_fw_version, sof_build_version
return sof_fw_version
def rmtree_if_exists(directory):
"This is different from ignore_errors=False because it deletes everything or nothing"
@ -674,11 +671,17 @@ def build_platforms():
sign_cmd += ["--tool-data", str(rimage_config), "--", "-k", str(signing_key)]
sof_fw_vers, sof_build_vers = get_build_and_sof_version(abs_build_dir)
sof_fw_vers = get_sof_version(abs_build_dir)
sign_cmd += ["-f", sof_fw_vers]
sign_cmd += ["-b", sof_build_vers]
# Default value is 0 in rimage but for Zephyr the "build counter" has always
# been hardcoded to 1 in CMake and there is even a (broken) test that fails
# when it's not hardcoded to 1.
# FIXME: drop this line once the following test is fixed
# tests/avs/fw_00_basic/test_01_load_fw_extended.py::TestLoadFwExtended::()::
# test_00_01_load_fw_and_check_version
sign_cmd += ["-b", "1"]
if args.ipc == "IPC4":
rimage_desc = pathlib.Path(SOF_TOP, "rimage", "config", platform_dict["IPC4_RIMAGE_DESC"])