Hi Bin,
I am putting down the steps below as to how to debug u-boot bare-metal on qemu.
git clone git://git.denx.de/u-boot-x86.git
cd u-boot-x86
export BUILD_ROM=y
make qemu-x86_defconfig
make all
qemu-system-i386 -nographic -bios u-boot.rom -net nic -net user,tftp=/tftpboot
We will have a u-boot prompt at this instance as shown below.
=>Terminal-
U-Boot 2015.07-rc1-20475-g257e98e (May 13 2015 - 23:35:32)
CPU: x86, vendor Intel, device 663h
DRAM: 128 MiB
Using default environment
Video: 640x480x16
Model: QEMU x86
SCSI: controller reset failed (0x1009)
scanning bus for devices...
Invalid port number 1
Found 0 device(s).
Net: e1000: 52:54:00:12:34:56
e1000#0
Warning: e1000#0 using MAC address from net device
In order to boot Linux, the kernel image and rootfs should be present in the /tftp directory. Note /tftpboot is the root directory for QEMU's tftp server.
You will need to setup U-Boot network environment variables before 'run ramboot' to boot linux.
#u-boot> dhcp
#u-boot> run ramboot