u-boot fails to boot for qemu on x86_64 platform

I have compiled u-boot from source for x86_64 platform.
git clone https://source.denx.de/u-boot/u-boot.git
cd u-boot
make qemu-x86_64_defconfig
The u-boot.bin binary is generated successfully. However when I tried to load u-boot.bin, it failed to load.
$ qemu-system-x86_64 -nographic -bios u-boot.bin -M q35
qemu: could not load PC BIOS 'u-boot.bin'
When tried with u-boot.com, we found same error. I have used similar steps for ARM platform and it works fine.
$qemu-system-aarch64 -M virt -cpu cortex-a53 -nographic -bios u-boot.bin
U-Boot 2019.01 (Mar 06 2025 - 12:20:02 +0530)
DRAM: 128 MiB
Flash: 128 MiB
*** Warning - bad CRC, using default environment
In: pl011@9000000
Out: pl011@9000000
Err: pl011@9000000
Net: No ethernet found.
Hit any key to stop autoboot: 0
=>
Answer
Instead of using the raw u-boot.bin file, you need to use u-boot.rom which is properly formatted for x86_64 BIOS
make qemu-x86_64_deconfig
make
after build, look for the u-boot.rom file in your build directory and use that with QEMU
qemu-system-x86_64 -nographic -bios u-boot.rom -M q35
if you don't see a u-boot.rom file, you might need to explicitly build it:
make u-boot.rom
OR, if you want to use you existing u-boot.bin, you might need to specify it as a -kernel parameter instead of -bios
qemu-system-x86_64 -nographic -kernel u-boot.bin -M q35
Enjoyed this article?
Check out more content on our blog or follow us on social media.
Browse more articles