cros_bundle_firmware: Add a 'firmware-type' in each firmware's fdt

We use the same fdt for each firmware type. But it is convenient to pass in
the firmware type so that U-Boot knows which type it is (RO, RW-A, RW-B).
Add slightly modified fdts for each. Flashmaps can use these blobs (dtb-rwa,
dtb-rwb) instead of 'dtb' in the relevant RW sections.

BUG=chrome-os-partner:14545
BRANCH=link
TEST=boot into U-Boot with pre-emable flags set to 0.

See that it indicates RO firmware:

> vboot_test fmap
...
Firmware type: 0

Then change to RW-A firmware:

> vboot_twostop
...

Once in RW-A firmware:

> vboot_test fmap
...
Firmware type: 1

Note: RW-B has not been tested. This can be done by modifying vboot to choose
B instead of A.

Change-Id: I51099e7d7ecbb4b96fd0f252cc5ed09b39ce4770
Reviewed-on: https://gerrit.chromium.org/gerrit/36203
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
diff --git a/host/lib/bundle_firmware.py b/host/lib/bundle_firmware.py
index b2ca3b6..af60d7f 100644
--- a/host/lib/bundle_firmware.py
+++ b/host/lib/bundle_firmware.py
@@ -833,6 +833,17 @@
     pack.AddProperty('skeleton', self.skeleton_fname)
     pack.AddProperty('dtb', fdt.fname)
 
+    # Let's create some copies of the fdt for vboot. These can be used to
+    # pass a different fdt to each firmware type. For now it is just used to
+    # check that the right fdt comes through.
+    fdt_rwa = fdt.Copy(os.path.join(self._tools.outdir, 'updated-rwa.dtb'))
+    fdt_rwa.PutString('/chromeos-config', 'firmware-type', 'rw-a')
+    pack.AddProperty('dtb-rwa', fdt_rwa.fname)
+    fdt_rwb = fdt.Copy(os.path.join(self._tools.outdir, 'updated-rwb.dtb'))
+    fdt_rwb.PutString('/chromeos-config', 'firmware-type', 'rw-b')
+    pack.AddProperty('dtb-rwb', fdt_rwb.fname)
+    fdt.PutString('/chromeos-config', 'firmware-type', 'ro')
+
     # If we are writing a kernel, add its offset from TEXT_BASE to the fdt.
     if self.kernel_fname:
       fdt.PutInteger('/config', 'kernel-offset', pack.image_size)