cros_bundle_firmware: Pollute EC RO binary FMAP signature

We don't want to have two FMAP signatures in the image. At present
the EC RO binary includes an FMAP signature since for write-enabled
devices we still use flashrom to perform the EC RO update.

This is a temporary situation since s/w sync will eventually do the
RO bin image - see example CL here:

https://gerrit.chromium.org/gerrit/#/c/30866/

For now, change the fmap signature on this blob to __fMAP__ for this
blob only.

BUG=chrome-os-partner:13143
BRANCH=snow,link
TEST=manual
Check flashrom's fmap.h and see the signature:

Run 'cros_bundle_firmware -b daisy -d exynos5250-snow -O out'

Use ghex to look at out/updated-ecro.bin and see that it does not
include __FMAP__ anymore (the 'F' is changed to 'f').

Same with image:

$ strings out/image.bin |grep -i __fmap__
__fMAP__
__FMAP__

(the last one is the real FMAP)

Change-Id: I58789684184123bb2f914cbf2a28fc0199c5ddb2
Reviewed-on: https://gerrit.chromium.org/gerrit/31612
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
(cherry picked from commit 693b40ff91f27301091538098a2c366ce5849e18)
Reviewed-on: https://gerrit.chromium.org/gerrit/31757
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Katie Roberts-Hoffman <katierh@chromium.org>
diff --git a/host/lib/bundle_firmware.py b/host/lib/bundle_firmware.py
index a22077a..6d9418c 100644
--- a/host/lib/bundle_firmware.py
+++ b/host/lib/bundle_firmware.py
@@ -754,7 +754,18 @@
       pack.AddProperty('ecrw', self.ecrw_fname)
       pack.AddProperty('ecbin', self.ecrw_fname)
     elif blob_type == 'ecro':
-      pack.AddProperty(blob_type, self.ecro_fname)
+      # crosbug.com/p/13143
+      # We cannot have an fmap in the EC image since there can be only one,
+      # which is the main fmap describing the whole image.
+      # Ultimately the EC will not have an fmap, since with software sync
+      # there is no flashrom involvement in updating the EC flash, and thus
+      # no need for the fmap.
+      # For now, mangle the fmap name to avoid problems.
+      updated_ecro = os.path.join(self._tools.outdir, 'updated-ecro.bin')
+      data = self._tools.ReadFile(self.ecro_fname)
+      data = re.sub('__FMAP__', '__fMAP__', data)
+      self._tools.WriteFile(updated_ecro, data)
+      pack.AddProperty(blob_type, updated_ecro)
     elif blob_type == 'exynos-bl2':
       spl_payload = pack.GetBlobParams(blob_type)