环境:Ubuntu 12.10 主机上的 QEMU qemu-system-arm 版本 1.2.0。访客:内核 3.2.21
仿真板:ARMv7l Verstatile Express
使用 Buildroot 12.08 版构建的支持 X 的根文件系统等;TinyX X 服务器。
Ran qem:
/usr/bin/qemu-system-arm -M vexpress-a9 -kernel <kernel> -drive file=<rootfs-ext2-img>,if=sd -append "console=ttyAMA0,115200 root=/dev/mmcblk0 init=/myinit.sh" -serial stdio -net nic,model=lan9118 -net user
一旦来宾运行,我们就会有一个控制台窗口和一个图形 qemu 窗口(一开始是空的)。
在来宾控制台窗口中: 启动 X:
Xfbdev :0 -keybd evdev,,device=/dev/input/event0 -mouse evdev,,device=/dev/input/event1 &
然后加载xterm等。
我使用一个简单的脚本,这里是:
# cat Xstart.sh
#!/bin/ash
unset USERNAME LOGNAME
echo Setting up X server ..
# kill any stale instance
kill $(ps |grep Xfb|head -n1|awk '{print $1}') 2> /dev/null
export DISPLAY=:0
# How to determine 'mouse' dev?
# dmesg shows :
# input: AT Raw Set 2 keyboard as /devices/mb:kmi0/serio0/input/input0
# input: ImExPS/2 Generic Explorer Mouse as /devices/mb:kmi1/serio1/input/input1
# QEMU_ARM_BR / # ls /sys//devices/mb:kmi1/serio1/input/input1
# capabilities/ id/ name properties uniq
# device@ modalias phys subsystem@
# event1/ mouse0/ power/ uevent
# Can see the only 'event' file is 'event1', so we use it!
Xfbdev :0 -keybd evdev,,device=/dev/input/event0 -mouse evdev,,device=/dev/input/event1 &
sleep 1
echo "Running fluxbox & xterm .."
DISPLAY=:0 xterm 2> /dev/null &
DISPLAY=:0 fluxbox 2> /dev/null &
echo "### Please wait a bit for X to initialize & come up ... ###"
sleep 3
echo "Press [Enter] to use this console..."
read
#
请注意有关如何确定鼠标、键盘设备的提示:查找 dmesg 输出..