2011年7月26日 星期二

QEMU

Note: It seems to me that only some combinations of versions of qemu and linux/defconfig would work. Changing any of them is tends to fail.

CodeSourcery G++ lite arm-2009q1 toolchain is used to build target image.

Installation
apt-get install qemu qemu-kvm-extras kvm-pxe

The qemu-system-arm installed by Ubuntu 10.04 (qemu_0.12.3+noroms-0ubuntu9.16_i386, qemu-kvm-extras_0.12.3+noroms-0ubuntu9.16_i386) always require memory option, e.g. "-m 128M".

*The qemu-system-arm installed by Ubuntu 10.04 (qemu_0.12.3+noroms-0ubuntu9.16_i386, qemu-kvm-extras_0.12.3+noroms-0ubuntu9.16_i386) doesn't work even on qemu ARM disk image (arm-test-0.2.tar.gz). But it works on other images(e.g. 2.6.33 versatilepb image), reason unknown.

# qemu-system-arm -kernel zImage.integrator -initrd arm_root.img -nographic
qemu: hardware error: pl011_read: Bad offset 16000018

CPU #0:
R00=00000055 R01=2d02ef8d R02=16000000 R03=ffffffff
R04=00000055 R05=00013149 R06=41069265 R07=00000113
R08=00000100 R09=00000000 R10=00127d9c R11=0013120c
R12=00131210 R13=00131200 R14=00010954 R15=000105f0
PSR=200001d3 --C- A svc32
Aborted


It can be fixed by rebuild a new qemu (still 0.12.3), but loss the auto VNC connected window. I had to open a VNC client manually....


The above issue fixed by:
qemu-system-arm segmentation fault in Ubuntu Lucid « Balau
http://balau82.wordpress.com/2010/05/23/qemu-system-arm-segmentation-fault-in-ubuntu-lucid/
adding the memory option “-m 128M”


pci_add_option_rom: failed to find romfile “pxe-rtl8139.bin”
http://www.moe.co.uk/2011/01/07/pci_add_option_rom-failed-to-find-romfile-pxe-rtl8139-bin/
apt-get install kvm-pxe


Ubuntu -- Details of package kvm-pxe in lucid
http://packages.ubuntu.com/lucid/kvm-pxe
Etherboot is a free software package for making boot ROMS for booting Linux and other operating systems on x86 PCs over a network using Internet Protocols, i.e. bootp/DHCP and tftp.

This package contains PXE ROM's made especially to pxeboot kvm vm's.

kvm-pxe isn't really needed, but just to remove the error message.

Building Qemu from source
git clone git://git.debian.org/git/pkg-qemu/qemu.git
git clone git://git.qemu.org/qemu.git

Qemu stuff will be installed to ${DESTDIR}/${prefix}.
Default prefix is /usr/local, DESTDIR is "".

./configure --target-list=arm-linux-user
./configure --target-list=arm-linux-user,arm-softmmu
./configure --target-list=arm-linux-user,arm-softmmu --prefix=/usr

make

make install
make install DESTDIR=$(pwd)/target

I have only build v0.12.1 successfully on Ubuntu 10.04....
Error: zlib check failed
Make sure to have the zlib libs and headers installed.

FIX: apt-get install zlib1g-dev

Error: Building qemu v0.13.0..v0.14.1 on Ubuntu 10.04 failed
Not fixed yet.

Error: Building qemu v0.15.0..v1.0-rc4 on Ubuntu 10.04 failed
Even after all the required package is installed:
apt-get install libxen3 libxen3-dev libcurl3-dbg libxen3 libxen3-dev libbluetooth-dev libgnutls-dev check libcurl4-gnutls-dev libbrlapi-dev libvdeplug2-dev xfslibs-dev libpng12-dev libjpeg62-dev

But configuring qemu still failed with some strange compile error...
Not fixed yet.

(not verified) Ubuntu 11.10 can build v1.0-rc0.

User Mode Emulation
SYSROOT=/path/to/your/sysroot
qemu-arm -L ${SYSROOT} ${SYSROOT}/usr/bin/flex -V;

mkdir /etc/qemu-binfmt -p && rm /etc/qemu-binfmt/arm && ln -s ${SYSROOT} /etc/qemu-binfmt/arm;

# qemu-arm ${SYSROOT}/usr/bin/flex -V;
flex 2.5.35
# qemu-arm ${SYSROOT}/bin/gcc /test.c -o /test
gcc: error trying to exec '/tools/arm-2009q1/arm-none-linux-gnueabi/libc/bin/../libexec/gcc/arm-none-linux-gnueabi/4.3.3/cc1': execv: Exec format error


Prebuilt image
QEMU - Download
http://wiki.qemu.org/Download
(Provide Releases, Latest Source Code, QEMU disk images, QEMU Linux user mode emulation tests for basic testing)

ARM disk image arm-test-0.2.tar.gz
http://wiki.qemu.org/download/arm-test-0.2.tar.gz
Refer to the README in the tarball. Cannot work with Ubuntu 10.04 installed qemu, but work with a newly built qemu.

Debian images of various CPU for QEMU
http://people.debian.org/~aurel32/qemu/

Linux Support for the ARM Architecture - ARM
http://www.arm.com/community/software-enablement/linux.php
(in tab "Linux OS Downloads", section "Pre-built Kernel Images")
(has no luck trying any of those images)

Build images from source
(not verified) 2.6.35+qemu v1.0-rc0+(config?) will work...
-M realview-pb-a8 --cpu cortex-a8 -m 512M -kernel zImage -initrd ramdisk.img.gz -nographic --append "root=/dev/ram0 rw init=/linuxrc mem=512M console=ttyAMA0 debug" -net nic -net tap,ifname=tap0,script=no

mkl Note: [QEMU] Running Linux 2.6.33 ARM versatilepb
http://mkl-note.blogspot.com/2012/01/qemu-running-linux-2633-arm-versatilepb.html


Computer emulation

without network
./qemu-system-arm -M vexpress-a9 --cpu cortex-a9 -m 512M -kernel /path/to/zImage -initrd /path/to/ramdisk.img.gz -nographic --append "root=/dev/ram0 rw init=/linuxrc mem=512M console=ttyAMA0 debug"

with network
./qemu-system-arm -M vexpress-a9 --cpu cortex-a9 -m 512M -kernel /path/to/zImage -initrd /path/to/ramdisk.img.gz -nographic --append "root=/dev/ram0 rw init=/linuxrc mem=512M console=ttyAMA0 debug" -net nic -net tap,ifname=tap0,script=no


Setup network in HOST system
tunctl
tunctl -d tap0
ifconfig tap0 up
brctl addif br0 tap0
brctl delif br0 tap0


Documentation/Networking - QEMU
http://wiki.qemu.org/Documentation/Networking
You can also use -net nic,model=? to get a list of valid network devices that you can pass to the -net nic option. [If you'd like to know all of the virtual network devices that are currently provided in QEMU, a search for "NetClientInfo" in the source code may be useful.]

Ubuntu qumu 0.12.3
qemu: Supported NIC models: ne2k_pci,i82551,i82557b,i82559er,rtl8139,e1000,pcnet,virtio



QEMU/Networking
http://en.wikibooks.org/wiki/QEMU/Networking

[wiki] QEMU
http://en.wikipedia.org/wiki/QEMU

QEMU - Debian Wiki
http://wiki.debian.org/QEMU

Compiling Linux kernel for QEMU ARM emulator
http://balau82.wordpress.com/2010/03/22/compiling-linux-kernel-for-qemu-arm-emulator/

Debian ARM Linux on Qemu
http://909ers.apl.washington.edu/~dushaw/ARM/

Running Linux for ARM processors under QEMU
http://iomem.com/archives/2-Running-Linux-for-ARM-processors-under-QEMU.html

How To: Running Fedora-ARM under QEMU
http://fedoraproject.org/wiki/Architectures/ARM/HowToQemu

User Mode Emulation
http://qemu-buch.de/cgi-bin/moin.cgi/UserModeEmulation

Debugging non-native programs with QEMU + GDB
http://tinkering-is-fun.blogspot.com/2009/12/debugging-non-native-programs-with-qemu.html

Running ARM Linux on your desktop PC: The foreign chroot way
http://tinkering-is-fun.blogspot.com/2009/12/running-arm-linux-on-your-desktop-pc_12.html

Running ARM Linux on your desktop PC: The foreign chroot way (Debian)
http://tinkering-is-fun.blogspot.com/2009/12/running-arm-linux-on-your-desktop-pc_12.html

沒有留言: