cros_bundle_firmware: Select u-boot or u-boot.elf for x86

When using coreboot we need the elf file, not the binary. Select this
automatically for now.

Another solution might be to add a separate parameter for specifying a
U-Boot elf file, or perhaps explicitly requiring that the correct one
should be given. In the transition this method is convenient, though,
since we don't break any ebuilds.

BUG=chrome-os-partner:7969
TEST=manual
Use 'cros_bundle_firmware -u' with a u-boot.bin and see that it correctly
picks up the u-boot elf file instead.

Change-Id: I07ec26f30b121a8d3d7c251918080b59c2e196b2
Reviewed-on: https://gerrit.chromium.org/gerrit/24769
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/bundle_firmware.py b/host/lib/bundle_firmware.py
index 16ee589..08a6a63 100644
--- a/host/lib/bundle_firmware.py
+++ b/host/lib/bundle_firmware.py
@@ -542,8 +542,14 @@
       CmdError if a command fails.
     """
     bootstub = os.path.join(self._tools.outdir, 'coreboot-full.rom')
-    uboot_elf = uboot.replace(".bin", ".elf")
-    shutil.copyfile(coreboot, bootstub)
+
+    # U-Boot itself does not put a .elf extension on the elf file.
+    # The U-Boot ebuild does, but we shouldn't actually require it since
+    # devs may want to just use what U-Boot creates.
+    uboot_elf = uboot.replace('.bin', '')
+    if not os.path.exists(self._tools.Filename(uboot_elf)):
+      uboot_elf = uboot.replace('.bin', '.elf')
+    shutil.copyfile(self._tools.Filename(coreboot), bootstub)
     if seabios:
         self._tools.Run('cbfstool', [bootstub, 'add-payload', seabios,
             'fallback/payload', 'lzma'])