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.

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-by: Randall Spangler <>
Commit-Ready: Simon Glass <>
Tested-by: Simon Glass <>
diff --git a/host/lib/ b/host/lib/
index 16ee589..08a6a63 100644
--- a/host/lib/
+++ b/host/lib/
@@ -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'])