cros_bundle_firmware: Make storm coreboot image size hack the default
This patch generalizes the method of using the coreboot (CBFS) image
size defined in the fmap.dts file (instead of hardcoding it to the last
MB of the file) that was introduced for Storm in commit 9f36e714 (cbf:
accommodate storm coreboot layout) and later extended to Rush-based
boards. This method is certainly more correct/extensible than the
previous one and a better stopgap until the eventual complete overhaul
of cros_bundle_firmware. It also allows coreboot to pad its output
coreboot.rom file to the actual (physical) ROM size on non-x86 boards.
All fmap.dts definitions for existing boards (except for the three that
were already using this method before) specify their ro-boot section
correctly as either the first or the last MB of the image (and in the
former case produce a 1MB coreboot.rom), so they will pick up the exact
same bytes with this method. The only exception is Cosmos with 0.5MB at
the beginning of the image, which should still produce the same results
since the old coreboot.rom image for Cosmos was also only 0.5MB in size.
BUG=None
TEST=Booted on Veyron_Pinky, Nyan_Blaze and Falco. Compiled Cosmos
and noticed that it doesn't build on ToT anyway.
Change-Id: Ic957150a7e93db1bad6be1a8af2d71d6b68a02f0
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/231475
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
diff --git a/host/lib/bundle_firmware.py b/host/lib/bundle_firmware.py
index 8f535fe..c597c98 100644
--- a/host/lib/bundle_firmware.py
+++ b/host/lib/bundle_firmware.py
@@ -923,20 +923,9 @@
bootstub_copy = os.path.join(self._tools.outdir, 'coreboot-8mb.rom')
self._tools.WriteFile(bootstub_copy, data)
- if self._board in ('storm', 'rush', 'rush_ryu', ):
- # This is a hack, as storm does not fall into any of the two
- # categories of images covered by the [-0x100000:] range. Not applying
- # this to all targets yet, as it is not clear that they all would fit
- # this scheme where the /flash/ro-boot node has the 'reg' property
- # showing the location of the ro coreboot part in the image.
- #
- # The upcoming refactor of this tool will have to take care of this in
- # a more consistent way.
- fdt_ro_boot = fdt.GetProp('/flash/ro-boot', 'reg')
- rom_range = [int(x) for x in fdt_ro_boot.split()]
- self._tools.WriteFile(bootstub, data[rom_range[0]:rom_range[1]])
- else:
- self._tools.WriteFile(bootstub, data[-0x100000:])
+ # Use offset and size from fmap.dts to extract CBFS area from coreboot.rom
+ cbfs_offset, cbfs_size = fdt.GetFlashPart('ro', 'boot')
+ self._tools.WriteFile(bootstub, data[cbfs_offset:cbfs_offset+cbfs_size])
pack.AddProperty('fdtmap', fdt.fname)
image = os.path.join(self._tools.outdir, 'image.bin')