Qemu에 ARM에뮬레이팅 하는 방법
ARM Emulation With QEMUPosted on 23 October 2007 by admin QEMU is well-known as a free replacement for VMware, allowing users to run a PC within a PC. What isn’t so well known about QEMU is that, in addition to emulating x86 architectures, it can emulate AMD64, Sparc, MIPS, PPC and ARM CPUs. In case of ARM, it can emulate an Integrator or a Versatile platform. The Versatile one is the most interesting as it includes a hard disk SCSI controller, an Ethernet card and a graphical display. It can provide a convenient, but slow environment in which development can be done for embedded systems. Using a kernel compiled with the right options, it is possible to install a Debian distribution on such an emulated platform. That makes a cheap development platform. The emulated system running on an Athlon 64 X2 3800+ is around 20% faster than the popular NSLU2 and possibly with much more RAM (my emulated system has 256MiB of RAM). This how to has been written for a Debian host system, but could be easily adapted for other distributions. Much of this information has been gleamed from Jarno Aurelien http://www.aurel32.net/perso/cv.php with tidbits from other sources. Please visit Jarno’s web site for more detailed information and explanations of the devices used in this article. Installing QEMUQEMU is currently available as a package in the Debian distribution, you will need a CVS version (later than 20070601). If you want to compile it yourself, here is the procedure: cvs -z3 -d:pserver:anonymous@cvs.savannah.nongnu.org:/sources/qemu co qemu To build QEMU a few packages like SDL needs to be installed on your system. As QEMU is present in the archive, just run: $ su -c "apt-get build-dep qemu" Then run the configure script. Note that you need to use gcc version 3.4, as some parts of QEMU do not build with newer gcc versions. Then compile it: $ make And install it on your system: $ su -c "make install" Preparing the installationFirst you need to create an image of the hard disk. In this case we have chosen to emulate a 10GB hard-disk, but this size could be changed to correspond to your needs. Note that the file is created in qcow format, so that only the non-empty sectors will be written in the file. A small tip: create a directory to hold all the files related to the emulated ARM machine. $ qemu-img create -f qcow hda.img 10G Debian currently does not support the Versatile platform natively, that means there is no kernel available for this platform. However there is full support for this platform in the upstream kernel. You can either compile your own kernel (using a cross-compiler or an other ARM machine), or use the kernel Jarno built: $ wget http://people.debian.org/~aurel32/arm-versatile/vmlinuz-2.6.18-5-versatile You also need to get the initrd of the Etch Debian-Installer: $ wget http://ftp.de.debian.org/debian/dists/etch/main/installer-arm/current/images/rpc/netboot/initrd.gz Installing Debian EtchTo start the installation process, use the following line: $ qemu-system-arm -M versatilepb -kernel vmlinuz-2.6.18-5-versatile -initrd initrd.gz -hda hda.img -append "root=/dev/ram" After a few seconds you should see the kernel booting: And then the first screen of the Debian-Installer: Proceed as a normal installation, until you get to the following screen. If you need some documentation, please refer to the Debian installation guide. The Debian-Installer complains that it can’t find kernel modules. This is normal because the initrd of another platform is used. This is not really a problem as the kernel provided has been compiled with the network driver, the disk driver and ext3 support built-in. However that means you won’t be able to install Debian on an XFS partition. This is a known limitation that will disappear if/when the Versatile kernel is integrated in the official Debian kernel. Just click Yes. During the installation, Debian installer will complain that it can not found a suitable kernel for this platform, as shown on the screenshot below. This is due to the fact that Debian currently does not support the ARM Versatile platform; the support will be added post-Etch. An unofficial kernel being provided directly to QEMU, you can safely ignore this message and continue the installation. Near to the end of the installation you will get the following error screen: Again consider this message as harmless. There is no need for a bootloader, as QEMU is able to directly load a kernel and an initrd. This is the end of the installation. When the systems reboot, just exit QEMU. Different parameters have to be used to boot the installed system. Using the systemFirst bootTo start the system use the following command: $ qemu-system-arm -M versatilepb -kernel vmlinuz-2.6.18-5-versatile -initrd initrd.img-2.6.18-5-versatile -hda hda.img -append "root=/dev/sda1" After a few seconds the system should give you a login prompt: The first thing to do is to install the kernel image corresponding to the running kernel. This will install all the modules that you may need. $ apt-get install initramfs-tools Using XorgYou now have a full Debian arm system that you can use for development or whatever. You can even run Xorg using the fb device. Not that you have to select a 256-color mode, with a resolution up to 1024×768. QEMU without XIf you don’t want to start QEMU in graphic mode, you can use the -nographic option, and ask the kernel to use ttyAMA0 as the console. The command to start the emulated machine then become: $ qemu-system-arm -M versatilepb -kernel vmlinuz-2.6.18-5-versatile -initrd initrd.img-2.6.18-R-versatile -hda hda.img -append "root=/dev/sda1 console=ttyAMA0" -nographic More RAMBy default QEMU emulate a machine with 128MiB of RAM. You can use the -m option to increase or decrease the size of the RAM. It is however limited to 256MiB, greater sizes will crash the kernel. Connect your emulated machine to a real networkWhen no option is specified QEMU uses a non privileged user mode network stack that gives the emulated machine access to the world. But you probably want to make your emulated machine accessible from the outside. It is possible by using the tap mode and bridging the tap interface with the network interface of the host machine. The first thing to do is to active a bridge on your host machine. For that you have to modify the/etc/network/interfaces file as follow: Before: After: Then you need to install the bridge-utils package and restart your network interface: # apt-get install bridge-utils Create a script call /etc/qemu-ifup that will be executed upon the start of QEMU: #!/bin/sh As you probably don’t want to execute QEMU as root, you need to create a qemu user group and authorize the brctl and ifconfig commands for users of the qemu via sudo. You need to add the following lines to /etc/sudoers (edit the file using visudo): Finally you can start your emulated machine using the following command $ qemu-system-arm -M versatilepb -kernel vmlinuz-2.6.18-5-versatile -initrd initrd.img-2.6.18-5-versatile -hda hda.img -append "root=/dev/sda1" -net nic,macaddr=XX:XX:XX:XX:XX:XX -net tap |
'작업일지 > QEMU' 카테고리의 다른 글
Windows에서 qemu의 qow같은 파일 만드는 방법 (0) | 2011.01.31 |
---|---|
zlib 컴파일 (0) | 2011.01.26 |
qemu, colinux network 작업 (0) | 2010.03.11 |
QEMU로 ARM에뮬레이팅 하기 (0) | 2010.03.01 |
QEMU Compile on Windows (0) | 2010.02.27 |