summaryrefslogtreecommitdiff
path: root/zephyr/zmake
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2021-04-28 16:10:22 -0600
committerCommit Bot <commit-bot@chromium.org>2021-04-29 23:19:00 +0000
commit8fcfef34ffed806a042f6b0ddbf06b7b96caf1bd (patch)
treedf216bdb6142ff6a7753ed76d4f617f87378155e /zephyr/zmake
parent1478d3811bee6edd1d34c7baa6b0eacc071500f6 (diff)
downloadchrome-ec-8fcfef34ffed806a042f6b0ddbf06b7b96caf1bd.tar.gz
zephyr: zmake: support version in FRID/FWID
Add version information to FRID/FWID using get_version_string. Note: static version option is not plumbed yet to main function, will handle in follow up CL later (non-critical feature). Note: version is not copied into build yet, will do that in a follow-up CL too, which will get rid of our cmake call to get_version.sh. BUG=b:184832251 BRANCH=none TEST=zmake configure -b -B /tmp/lazor projects/trogdor/lazor dump_fmap -x /tmp/lazor/outputs/zephyr.bin RO_FRID RW_FWID observe contents of RO_FRID RW_FWID Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I95e960b6d13360ac4dbad928da9580909b0e2ec7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2857915 Commit-Queue: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'zephyr/zmake')
-rw-r--r--zephyr/zmake/zmake/output_packers.py26
-rw-r--r--zephyr/zmake/zmake/zmake.py13
2 files changed, 31 insertions, 8 deletions
diff --git a/zephyr/zmake/zmake/output_packers.py b/zephyr/zmake/zmake/output_packers.py
index f33b0fb1c9..56d74b03d5 100644
--- a/zephyr/zmake/zmake/output_packers.py
+++ b/zephyr/zmake/zmake/output_packers.py
@@ -49,7 +49,7 @@ def _write_dts_file(dts_file, config_header, output_bin, ro_filename, rw_filenam
RO_FRID {{
type = "text";
size = <32>;
- text = "RO_FRID (not implemented)";
+ text-label = "version";
}};
}};
}};
@@ -64,7 +64,7 @@ def _write_dts_file(dts_file, config_header, output_bin, ro_filename, rw_filenam
RW_FWID {{
type = "text";
size = <32>;
- text = "RW_FWID (not implemented)";
+ text-label = "version";
}};
}};
}};
@@ -89,7 +89,7 @@ class BasePacker:
"""
yield 'singleimage', build_config.BuildConfig()
- def pack_firmware(self, work_dir, jobclient):
+ def pack_firmware(self, work_dir, jobclient, version_string=""):
"""Pack a firmware image.
Config names from the configs generator are passed as keyword
@@ -100,6 +100,8 @@ class BasePacker:
work_dir: A directory to write outputs and temporary files
into.
jobclient: A JobClient object to use.
+ version_string: The version string, which may end up in
+ certain parts of the outputs.
Yields:
2-tuples of the path of each file in the work_dir (or any
@@ -111,13 +113,15 @@ class BasePacker:
class ElfPacker(BasePacker):
"""Raw proxy for ELF output of a single build."""
- def pack_firmware(self, work_dir, jobclient, singleimage):
+ def pack_firmware(self, work_dir, jobclient, singleimage,
+ version_string=""):
yield singleimage / 'zephyr' / 'zephyr.elf', 'zephyr.elf'
class RawBinPacker(BasePacker):
"""Raw proxy for zephyr.bin output of a single build."""
- def pack_firmware(self, work_dir, jobclient, singleimage):
+ def pack_firmware(self, work_dir, jobclient, singleimage,
+ version_string=""):
yield singleimage / 'zephyr' / 'zephyr.bin', 'zephyr.bin'
@@ -136,7 +140,7 @@ class NpcxPacker(BasePacker):
yield 'ro', build_config.BuildConfig(kconfig_defs={'CONFIG_CROS_EC_RO': 'y'})
yield 'rw', build_config.BuildConfig(kconfig_defs={'CONFIG_CROS_EC_RW': 'y'})
- def pack_firmware(self, work_dir, jobclient, ro, rw):
+ def pack_firmware(self, work_dir, jobclient, ro, rw, version_string=""):
"""Pack the 'raw' binary.
This combines the RO and RW images as specified in the Kconfig file for
@@ -156,6 +160,7 @@ class NpcxPacker(BasePacker):
jobclient: The client used to run subprocesses.
ro: Directory containing the RO image build.
rw: Directory containing the RW image build.
+ version_string: The version string to use in FRID/FWID.
Returns:
Tuple mapping the resulting .bin file to the output filename.
@@ -172,8 +177,15 @@ class NpcxPacker(BasePacker):
ro_filename=ro / 'zephyr' / 'zephyr.packed.bin',
rw_filename=rw / 'zephyr' / 'zephyr.bin')
+ # Version in FRID/FWID can be at most 31 bytes long (32, minus
+ # one for null character).
+ if len(version_string) > 31:
+ version_string = version_string[:31]
+
proc = jobclient.popen(
- ['binman', '-v', '5', 'build', '-d', dts_file_path, '-m'],
+ ['binman', '-v', '5', 'build',
+ '-a', 'version={}'.format(version_string),
+ '-d', dts_file_path, '-m'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding='utf-8')
diff --git a/zephyr/zmake/zmake/zmake.py b/zephyr/zmake/zmake/zmake.py
index 13b113af02..0412654582 100644
--- a/zephyr/zmake/zmake/zmake.py
+++ b/zephyr/zmake/zmake/zmake.py
@@ -18,6 +18,7 @@ import zmake.multiproc
import zmake.project
import zmake.toolchains as toolchains
import zmake.util as util
+import zmake.version
def ninja_log_level_override(line, default_log_level):
@@ -218,6 +219,10 @@ class Zmake:
module_config = zmake.modules.setup_module_symlinks(
build_dir / 'modules', module_paths)
+ # Symlink the Zephyr base into the build directory so it can
+ # be used in the build phase.
+ util.update_symlink(zephyr_base, build_dir / 'zephyr_base')
+
dts_overlay_config = project.find_dts_overlays(module_paths)
if not toolchain:
@@ -297,6 +302,11 @@ class Zmake:
project = zmake.project.Project(build_dir / 'project')
+ # Compute the version string.
+ version_string = zmake.version.get_version_string(
+ project, build_dir / 'zephyr_base',
+ zmake.modules.locate_from_directory(build_dir / 'modules'))
+
for build_name, build_config in project.iter_builds():
with self.jobserver.get_job():
dirs[build_name] = build_dir / 'build-{}'.format(build_name)
@@ -340,7 +350,8 @@ class Zmake:
if output_files_out is None:
output_files_out = []
for output_file, output_name in project.packer.pack_firmware(
- packer_work_dir, self.jobserver, **dirs):
+ packer_work_dir, self.jobserver, version_string=version_string,
+ **dirs):
shutil.copy2(output_file, output_dir / output_name)
self.logger.info('Output file \'%r\' created.', output_file)
output_files_out.append(output_file)