cros_bundle_firmware: Allow arbitrary blob type
This would let us add new blob types to fmap structure of device tree
much easier when the blobs do not require special treatments.
BUG=chrome-os-partner:17716
TEST=with U-boot changes, be able to pack arbitrary blob type
Change-Id: I0f56199cb6807422a1bc7f118b88e5cebdcd60ba
Reviewed-on: https://gerrit.chromium.org/gerrit/43759
Tested-by: Che-Liang Chiou <clchiou@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Commit-Queue: Che-Liang Chiou <clchiou@chromium.org>
diff --git a/host/cros_bundle_firmware b/host/cros_bundle_firmware
index 307183d..ab875ad 100755
--- a/host/cros_bundle_firmware
+++ b/host/cros_bundle_firmware
@@ -83,7 +83,8 @@
postload=options.postload, seabios=options.seabios,
exynos_bl1=options.exynos_bl1, exynos_bl2=options.exynos_bl2,
skeleton=options.skeleton, ecrw=options.ecrw,
- ecro=options.ecro, kernel=options.kernel)
+ ecro=options.ecro, kernel=options.kernel,
+ blobs=options.add_blob)
bundle.SetOptions(small=options.small, gbb_flags=options.gbb_flags,
force_rw=options.force_rw)
if options.use_defaults:
@@ -139,6 +140,10 @@
parser.add_option('--bootsecure', dest='bootsecure',
default=False, action='store_true',
help='Boot command is simple (no arguments) and not interruptible')
+ parser.add_option('--add-blob', action='append', nargs=2,
+ metavar='BLOB_TYPE FILE', help='''Mark FILE as BLOB_TYPE.
+For this to work, the fmap structure of device tree should have entries of
+BLOB_TYPE.''')
# TODO(sjg): Support multiple BCT files
# TODO(sjg): Support source BCT files
parser.add_option('-c', '--bct', dest='bct', type='string', action='store',
diff --git a/host/lib/bundle_firmware.py b/host/lib/bundle_firmware.py
index 6bdb40f..0acb2c0 100644
--- a/host/lib/bundle_firmware.py
+++ b/host/lib/bundle_firmware.py
@@ -188,8 +188,9 @@
self.exynos_bl2 = None # Filename of Exynos BL2 (SPL)
self.spl_source = 'straps' # SPL boot according to board settings
self.skeleton_fname = None # Filename of Coreboot skeleton file
- self.ecrw_fname = None # Filename of EC file
+ self.ecrw_fname = None # Filename of EC file
self.ecro_fname = None # Filename of EC read-only file
+ self.blobs = {} # Table of (type, filename) of arbitrary blobs
self._small = False
def SetDirs(self, keydir):
@@ -203,7 +204,7 @@
def SetFiles(self, board, bct, uboot=None, bmpblk=None, coreboot=None,
coreboot_elf=None,
postload=None, seabios=None, exynos_bl1=None, exynos_bl2=None,
- skeleton=None, ecrw=None, ecro=None, kernel=None):
+ skeleton=None, ecrw=None, ecro=None, kernel=None, blobs=None):
"""Set up files required for Bundle.
Args:
@@ -221,6 +222,7 @@
ecrw: The filename of the EC (Embedded Controller) read-write file.
ecro: The filename of the EC (Embedded Controller) read-only file.
kernel: The filename of the kernel file if any.
+ blobs: List of (type, filename) of arbitrary blobs.
"""
self._board = board
self.uboot_fname = uboot
@@ -236,6 +238,7 @@
self.ecrw_fname = ecrw
self.ecro_fname = ecro
self.kernel_fname = kernel
+ self.blobs = dict(blobs or ())
def SetOptions(self, small, gbb_flags, force_rw=False):
"""Set up options supported by Bundle.
@@ -998,6 +1001,8 @@
pack.AddProperty(blob_type, bl2)
elif pack.GetProperty(blob_type):
pass
+ elif blob_type in self.blobs:
+ pack.AddProperty(blob_type, self.blobs[blob_type])
else:
raise CmdError("Unknown blob type '%s' required in flash map" %
blob_type)