cros_bundle_firmware: Support a read-only EC binary property

We currently support the read-write EC binary. Add support for the read-only
binary as well so we can put this into the firmware image and update it.

Rename the existing 'ecbin' property to 'ecrw' since it is actually only the
read-write portion.

BUG=chrome-os-partner:12806
TEST=manual
Manually modify the device tree source file in U-Boot to request ecro, and
rebuild U-Boot

		ro-boot {
			label = "u-boot";
			size = <0x9a000>;
			read-only;
			type = "blob boot,dtb,ecrw,ecro";
			required;
		};

$ cros_bundle_firmware -b daisy -d exynos5250-snow -O out

See that the ecro region now appears in the image:

$ fdtdump out/updated.dtb
...
            ecrw {
                reg = <0x0006e894 0x0000a370>;
            };
            boot {
                reg = <0x00000000 0x000698d0>;
            };
            dtb {
                reg = <0x000698d0 0x00004fc3>;
            };
            ecro {
                reg = <0x00078c04 0x0000a500>;
            };

Change-Id: Ia6f0a2a3e9e280546a441727a877e836542aead7
Reviewed-on: https://gerrit.chromium.org/gerrit/30701
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
diff --git a/host/cros_bundle_firmware b/host/cros_bundle_firmware
index 7336909..c927f00 100755
--- a/host/cros_bundle_firmware
+++ b/host/cros_bundle_firmware
@@ -80,8 +80,8 @@
                   bmpblk=options.bmpblk, coreboot=options.coreboot,
                   postload=options.postload, seabios=options.seabios,
                   exynos_bl1=options.exynos_bl1, exynos_bl2=options.exynos_bl2,
-                  skeleton=options.skeleton, ecbin=options.ecbin,
-                  kernel=options.kernel)
+                  skeleton=options.skeleton, ecrw=options.ecrw,
+                  ecro=options.ecro, kernel=options.kernel)
   bundle.SetOptions(small=options.small)
 
   try:
@@ -155,8 +155,10 @@
       action='store', help='Hardware ID string to use')
   parser.add_option('--bmpblk', dest='bmpblk', type='string',
       action='store', help='Bitmap block to use')
-  parser.add_option('-e', '--ec', dest='ecbin', type='string',
+  parser.add_option('-e', '--ec', dest='ecrw', type='string',
         action='store', help='EC binary file')
+  parser.add_option('--ecro', type='string',
+        action='store', help='EC read-only binary file')
   parser.add_option('-F', '--flash', dest='flash_dest', type='string',
       action='store', help='Create a flasher to flash the device (spi, mmc)')
   parser.add_option('-k', '--key', dest='key', type='string', action='store',
diff --git a/host/lib/bundle_firmware.py b/host/lib/bundle_firmware.py
index d5a1d78..7de8d68 100644
--- a/host/lib/bundle_firmware.py
+++ b/host/lib/bundle_firmware.py
@@ -104,7 +104,8 @@
     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.ecbin_fname = None     # Filename of EC file
+    self.ecrw_fname = None     # Filename of EC file
+    self.ecro_fname = None      # Filename of EC read-only file
 
   def SetDirs(self, keydir):
     """Set up directories required for Bundle.
@@ -116,7 +117,7 @@
 
   def SetFiles(self, board, bct, uboot=None, bmpblk=None, coreboot=None,
                postload=None, seabios=None, exynos_bl1=None, exynos_bl2=None,
-               skeleton=None, ecbin=None, kernel=None):
+               skeleton=None, ecrw=None, ecro=None, kernel=None):
     """Set up files required for Bundle.
 
     Args:
@@ -130,7 +131,8 @@
       exynos_bl1: The filename of the exynos BL1 file
       exynos_bl2: The filename of the exynos BL2 file (U-Boot spl)
       skeleton: The filename of the coreboot skeleton file.
-      ecbin: The filename of the EC (Embedded Controller) file.
+      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.
     """
     self._board = board
@@ -143,7 +145,8 @@
     self.exynos_bl1 = exynos_bl1
     self.exynos_bl2 = exynos_bl2
     self.skeleton_fname = skeleton
-    self.ecbin_fname = ecbin
+    self.ecrw_fname = ecrw
+    self.ecro_fname = ecro
     self.kernel_fname = kernel
 
   def SetOptions(self, small):
@@ -194,8 +197,10 @@
       self.coreboot_fname = os.path.join(build_root, 'coreboot.rom')
     if not self.skeleton_fname:
       self.skeleton_fname = os.path.join(build_root, 'skeleton.bin')
-    if not self.ecbin_fname:
-      self.ecbin_fname = os.path.join(build_root, 'ec.RW.bin')
+    if not self.ecrw_fname:
+      self.ecrw_fname = os.path.join(build_root, 'ec.RW.bin')
+    if not self.ecro_fname:
+      self.ecro_fname = os.path.join(build_root, 'ec.RO.bin')
 
   def GetFiles(self):
     """Get a list of files that we know about.
@@ -743,8 +748,13 @@
       pack.AddProperty('image', signed)
     elif blob_type == 'exynos-bl1':
       pack.AddProperty(blob_type, self.exynos_bl1)
-    elif blob_type == 'ecbin':
-      pack.AddProperty(blob_type, self.ecbin_fname)
+
+    # TODO(sjg@chromium.org): Deprecate ecbin
+    elif blob_type in ['ecrw', 'ecbin']:
+      pack.AddProperty('ecrw', self.ecrw_fname)
+      pack.AddProperty('ecbin', self.ecrw_fname)
+    elif blob_type == 'ecro':
+      pack.AddProperty(blob_type, self.ecro_fname)
     elif blob_type == 'exynos-bl2':
       spl_payload = pack.GetBlobParams(blob_type)