Hack it so that bundle_firmware forces one copy of the BCT for NAND.

This makes our NAND products build.

NOTE that NAND is not really well-tested or well supported
still, but this at least gets us something that seems to work.

This is part of a batch of CLs:
- http://gerrit.chromium.org/gerrit/7838
  Hack it so that bundle_firmware forces one copy of the BCT for NAND.
- http://gerrit.chromium.org/gerrit/5207
  CHROMIUM: cbootimage: Add Bctcopy parameter
- http://gerrit.chromium.org/gerrit/7841
  Revert "Hack tegra2_dev-board to think NAND block size is 64K."
- http://gerrit.chromium.org/gerrit/7837
  Add some very basic NAND support to cros_write_firmware.
- http://gerrit.chromium.org/gerrit/7840
  CHROMIUM: harmony: Very basic harmony (AKA dev-board) support.

BUG=chromium-os:17465
TEST=Used cros_write_firmware on both SPI Flash (tegra2_kaen) and
NAND (tegra2_dev-board).

Change-Id: I4df844d8242e1ba8b3144d322c5a4d1c6810dab2
Signed-off-by: Doug Anderson <dianders@chromium.org>
Reviewed-on: http://gerrit.chromium.org/gerrit/7838
diff --git a/host/lib/bundle_firmware.py b/host/lib/bundle_firmware.py
index 16656ef..09b0648 100644
--- a/host/lib/bundle_firmware.py
+++ b/host/lib/bundle_firmware.py
@@ -202,8 +202,17 @@
     fd.write('Version    = 1;\n')
     fd.write('Redundancy = 1;\n')
     fd.write('Bctfile    = %s;\n' % bct)
+
+    # TODO(dianders): Right now, we don't have enough space in our flash map
+    # for two copies of the BCT when we're using NAND, so hack it to 1.  Not
+    # sure what this does for reliability, but at least things will fit...
+    is_nand = "NvBootDevType_Nand" in self._tools.Run('bct_dump', [bct])
+    if is_nand:
+      fd.write('Bctcopy = 1;\n')
+
     fd.write('BootLoader = %s,%#x,%#x,Complete;\n' % (bootstub, text_base,
         text_base))
+
     fd.close()
 
     self._tools.Run('cbootimage', [config, signed])