bundle_firmware: ensure correct RO CBFS source file for RW CBFS blobs
The 'coreboot' blob type within the fmap.dts specifies the location
of the RO CBFS. Additionally, the cbfs_files passed to the bundling
script specify additional files to add to each CBFS. In order for
the RO CBFS to be in sync with each RW CBFS defer the blob
processing of RW CBFS regions until the RO CBFS region has been
processed. That way the cbfs_files specified are duplicated to the
RW CBFS regions.
BUG=chrome-os-partner:44827
BUG=chromium:445938
BRANCH=None
TEST=Built for chell with RW CBFS regions. Verified CBFS files
match between regions.
Change-Id: Ie9e89294e3c5fd66ae01db8a1de947bf4a0de8da
Signed-off-by: Aaron Durbin <adurbin@chromiium.org>
Reviewed-on: https://chromium-review.googlesource.com/320560
Commit-Ready: Aaron Durbin <adurbin@chromium.org>
Tested-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
diff --git a/host/lib/bundle_firmware.py b/host/lib/bundle_firmware.py
index af51fc9..a88118a 100644
--- a/host/lib/bundle_firmware.py
+++ b/host/lib/bundle_firmware.py
@@ -735,6 +735,7 @@
"""Create a coreboot boot stub and add pack properties.
Args:
+ pack: a PackFirmware object describing the firmware image to build.
coreboot: Path to coreboot.rom
"""
bootstub = os.path.join(self._tools.outdir, 'coreboot-full.rom')
@@ -747,6 +748,14 @@
if self.cbfs_files:
self._AddCbfsFiles(bootstub)
+ # Create a coreboot copy to use as a scratch pad. Order matters. The
+ # cbfs_files were added prior to this action. That's so the RW CBFS
+ # regions inherit the files from the RO CBFS region.
+ cb_copy = os.path.abspath(os.path.join(self._tools.outdir, 'cb_copy'))
+ self._tools.WriteFile(cb_copy, self._tools.ReadFile(bootstub))
+ pack.AddProperty('cb_copy', cb_copy)
+
+
def _PackOutput(self, msg):
"""Helper function to write output from PackFirmware (verbose level 2).
@@ -774,10 +783,12 @@
copy is destined to
Raises:
CmdError if base coreboot image does not contain CBFS
+ BlobDeferral if coreboot image with fmap is not available yet.
"""
- if not self.coreboot_fname:
- raise CmdError("coreboot file needed for blob % s", blob_name)
+ cb_copy = pack.GetProperty('cb_copy')
+ if cb_copy is None:
+ raise BlobDeferral("Waiting for 'cb_copy' property.")
part_sections = blob_name.split('/')[1:]
@@ -791,11 +802,6 @@
except CmdError:
cbfs_config = None
- # Create a coreboot copy to use as a scratch pad.
- cb_copy = os.path.abspath(os.path.join(self._tools.outdir, 'cb_copy'))
- if not os.path.exists(cb_copy):
- self._tools.WriteFile(cb_copy, self._tools.ReadFile(self.coreboot_fname))
-
# Copy CBFS to the required offset
self._tools.Run('cbfstool', [cb_copy, 'copy', '-D',
'%d' % base, '-s', '%d' % size])