bundle_firmware: Add support for ifwi and sig2(cse_sign) blobs

For apollolake platform, two new blob types are required -- ifwi and
sig2(cse_sign). Both these blobs need to be simply copied from coreboot
image to final chromeos-bootimage using address and size from FMAP.

BUG=chrome-os-partner:53689
BRANCH=None
TEST=Tested by adding test ifwi and sig2 binaries to coreboot.rom
"emerge-reef chromeos-bootimage" generates bootimage with test ifwi and
sig2 binaries copied from coreboot.rom.

Change-Id: I3fa51ee9a2f55610cc95ca974b9a8348ea621ded
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://chromium-review.googlesource.com/348022
Commit-Ready: Aaron Durbin <adurbin@chromium.org>
Tested-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
diff --git a/host/lib/bundle_firmware.py b/host/lib/bundle_firmware.py
index dc76c0a..7b4c2fa 100644
--- a/host/lib/bundle_firmware.py
+++ b/host/lib/bundle_firmware.py
@@ -934,6 +934,18 @@
       self._PrepareCbfs(pack, blob_type)
     elif pack.GetProperty(blob_type):
       pass
+    elif blob_type == 'ifwi' or blob_type == 'sig2':
+      # Copy IFWI/CSE_SIGN(sig2) regions from coreboot copy and build a blob
+      # for the blob_type
+      cb_copy = pack.GetProperty('cb_with_fmap')
+      if cb_copy is None:
+        raise BlobDeferral("Waiting for 'cb_with_fmap' property")
+      blob_start, blob_size = fdt.GetFlashPart('ro', blob_type)
+      blob_file = blob_type + '.bin'
+      blob_path = os.path.join(self._tools.outdir, blob_file)
+      data = self._tools.ReadFile(cb_copy)
+      self._tools.WriteFile(blob_path, data[blob_start:blob_start+blob_size])
+      pack.AddProperty(blob_type, blob_path)
     elif blob_type in self.blobs:
       pack.AddProperty(blob_type, self.blobs[blob_type])
     else: