-
Notifications
You must be signed in to change notification settings - Fork 23
Usage
This section describes some of the devices that can be configured on the qemu command line. It provides background and partial command lines.
For full qemu command lines please see the Examples section.
As of Qemu 5.1, basic userspace network emulation can be provided by
passing -nic user
and no other options. This starts Qemu with an
emulated network; the BMC gets 10.0.2.15
and the qemu host (eg tftp
server) is 10.0.2.2
.
If you wish to ssh into the bmc, add hostfwd=::2222-:22
. This allows
you to ssh into the bmc with ssh -p 2222 root@localhost
and scp files
with scp -P 2222 myfile root@localhost:/tmp/
.
If you wish to load files into the BMC with tftp, for example booting a
kernel from u-boot, add tftp=/path/to/dir
. Qemu will emulate a tftp
server with /path/to/dir
as the root, so you can eg. get an IP address
and load files from u-boot with the dhcp
and tftp
commands.
Qemu supports emulating spi-nor flash with the -drive option by
specifying if=mtd
.
You can supply a raw flash image from the output of yocto:
-drive file=flash-romulus,format=raw,if=mtd
Qemu supports emulating spi-nor flash with the -drive option by
specifying type=sd
.
You must specify the index of the device you wish to emulate, with the eMMC device on the AST2600 being the third device (SD slot 1, SD slot 2, eMMC).
-drive file=sd.img,format=raw,if=sd
You can also specify a qcow2 image instead of a raw file. The advantage of this method is the qcow2 can be sparse and compressed.
The conversion processs is:
qemu-img convert -c -O qcow2 rootfs.ext4 rootfs.ext4.qcow2
And use the following to boot it:
-file=rootfs.ext4.qcow2,if=sd,index=2
These examples show a full qemu command line that can be used. They are written with Qemu 5.1 in mind.
To boot an ast2600 EVB machine with an emmc device from your kernel build tree tree:
qemu-system-arm -machine ast2600-evb \
-nographic -no-reboot \
-nic user \
-kernel arch/arm/boot/zImage \
-dtb arch/arm/boot/dts/aspeed-ast2600-evb.dtb \
-drive file=rootfs.ext4.qcow2,if=sd,index=2 \
-append "console=ttyS4 rootwait root=/dev/mmcblk0"
A prebuilt rootfs.ext4.qcow2 can be downloaded if you do not have one to test with.
Note that Qemu as of 5.1 doesn't yet support booting from eMMC directly with the Aspeed machine type. Patches are welcome.
To boot an openbmc image on the ast2500, such as Romulus, grab the flash image from Jenkins and then boot it as follows:
qemu-system-arm -machine romulus-bmc \
-nographic -no-reboot \
-nic user \
-drive file=flash-romulus,format=raw,if=mtd
You can use this to test a kernel built by yocto with an existing flash or eMMC image.
Download the image-kernel file
from the build artifacts on Jenkins, or grab one from your local
build at build/tmp/deploy/iamges/romgulus/image-kernel
.
Run qemu with the 'tftp' option set to the directory where you
downloaded the above image-kernel. You will need to halt it at the
u-boot prompt, set a MAC with setenv ethaddr DE:AD:BE:EF:CA:FE
,
and run dhcp image-kernel
:
$ qemu-system-arm -machine romulus-bmc \
-nographic -no-reboot \
-nic user,tftp=$PWD \
-drive file=flash-romulus,format=raw,if=mtd
U-Boot 2016.07 (Jan 16 2019 - 00:21:48 +0000)
Hit any key to stop autoboot: 1
ast# setenv ethaddr DE:AD:BE:EF:CA:FE
ast# dhcp image-kernel
aspeednic#0: PHY at 0x00
set_mac_control_register 1453
Found NCSI Network Controller at (0, 0)
Found NCSI Network Controller at (0, 1)
BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (2 ms)
Using device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15
Filename 'image-kernel'.
Load address: 0x83000000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
###############################################
62.2 MiB/s
done
Bytes transferred = 4372700 (42b8dc hex)
ast# bootm
## Loading kernel from FIT Image at 83000000 ...
Using 'conf@aspeed-bmc-opp-romulus.dtb' configuration
Trying 'kernel@1' kernel subimage
Description: Linux kernel
Type: Kernel Image
This is a work in progress
QEMU currently has a limitation where a SD image must be a power of two, so extend the size of the image to 16GB using the truncate
tool. We then create a compressed qcow2 image to save space.
wget https://jenkins.openbmc.org/view/latest/job/latest-master/label=docker-builder,target=witherspoon-tacoma/lastSuccessfulBuild/artifact/openbmc/build/tmp/deploy/images/witherspoon-tacoma/aspeed-bmc-opp-tacoma.dtb
wget https://jenkins.openbmc.org/view/latest/job/latest-master/label=docker-builder,target=witherspoon-tacoma/lastSuccessfulBuild/artifact/openbmc/build/tmp/deploy/images/witherspoon-tacoma/fitImage-linux.bin-witherspoon-tacoma
wget https://jenkins.openbmc.org/view/latest/job/latest-master/label=docker-builder,target=witherspoon-tacoma/lastSuccessfulBuild/artifact/openbmc/build/tmp/deploy/images/witherspoon-tacoma/obmc-phosphor-image-witherspoon-tacoma.wic.xz
unxz obmc-phosphor-image-witherspoon-tacoma.wic.xz
truncate -s 16G obmc-phosphor-image-witherspoon-tacoma.wic
qemu-img convert -c -O qcow2 obmc-phosphor-image-witherspoon-tacoma.wic obmc-phosphor-image-witherspoon-tacoma.wic.qcow2
qemu-system-arm -M tacoma-bmc -nic user,hostfwd=::2222-:22,tftp=/srv/tftp/ -nographic \
-drive file=obmc-phosphor-image-witherspoon-tacoma.wic.qcow2,if=sd,index=2 -snapshot \
-kernel fitImage-linux.bin-witherspoon-tacoma -dtb aspeed-bmc-opp-tacoma.dtb \
-append "console=ttyS4,115200n8 root=PARTLABEL=rofs-a"
Note that the image as of 2020-10-08 will fail to mount /home
and stop booting.
To emulate a USB mass storage device plugged into the host port of the BMC:
-usb -drive if=none,id=usbstick,format=raw,file=test.img -device usb-storage,drive=usbstick