cros_bundle_firmware: Implement the boot source machine param

This allows us to select the SPL boot source.

BUG=chromium-os:28394
TEST=manual:
$ cros_bundle_firmware -b daisy -w sd: -B usb
See that it boots from SD, then goes into USB download mode instead
of booting U-Boot from SD
$ sudo smdk-usbdl -a 0x43e00000 -f out/u-boot-from-image.bin
See that it boots the U-Boot thus downloaded

Change-Id: I546e72a86560e0ed832f1c0d193c749ebadf9ecc
Reviewed-on: https://gerrit.chromium.org/gerrit/23406
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/lib/write_firmware.py b/host/lib/write_firmware.py
index 1520bfb..ff1253d 100644
--- a/host/lib/write_firmware.py
+++ b/host/lib/write_firmware.py
@@ -491,8 +491,22 @@
 
   def WriteToSd(self, flash_dest, disk, uboot, payload):
     if flash_dest:
-      image = self.PrepareFlasher(uboot, payload, self.update, self.verify,
+      raw_image = self.PrepareFlasher(uboot, payload, self.update, self.verify,
                                   flash_dest, '1:0')
+      bl1, bl2, payload_data = self._ExtractPayloadParts(payload)
+      spl_load_size = os.stat(raw_image).st_size
+      bl2 = self._bundle.ConfigureExynosBl2(self._fdt, spl_load_size, bl2,
+                                            'flasher')
+
+      data = self._tools.ReadFile(bl1) + self._tools.ReadFile(bl2)
+
+      # Pad BL2 out to the required size.
+      # We require that it be 24KB, but data will only contain 8KB + 14KB.
+      # Add the extra padding to bring it to 24KB.
+      data += '\0' * (0x6000 - len(data))
+      data += self._tools.ReadFile(raw_image)
+      image = os.path.join(self._tools.outdir, 'flasher-with-bl.bin')
+      self._tools.WriteFile(image, data)
       self._out.Progress('Writing flasher to %s' % disk)
     else:
       image = payload