is a generic and open source processor emulator which can emulate i386, x86_64, MIPS, MIPSEL, PowerPC and SPARC systems. In case of MIPS or MIPSEL, it can emulate a platform with an IDE controller, and IDE hard disk, an Ethernet card and a serial port. It still lacks a graphic card and screen support, so the installation is done through the emulated serial port.
The Etch distribution provides kernel support this emulated platform. That makes a cheap development platform. The emulated system running on an Athlon 64 X2 3800+ is around 10% faster than an SGI Indy with and R4400SC 200MHz, and possibly with much more RAM (my emulated system has 512MiB of RAM).
This howto has been written for a host system, but could be easily adapted for other distributions. It also has been written for a MIPS emulated system, but there are very few differences compared to a MIPSEL emulated system. They simply differ by the endianess (MIPS is big endian, MIPSEL is little endian). When not explicitely specified in this howto, just replace mips by mipsel.
Alternatively prebuilt images are also available.
Installing QEMUis currently available as a in the distribution, you will need at least version 0.9.0. If you want to compile it yourself, here is the procedure:
To build QEMU a few packages like SDL needs to be installed on your system. gcc version 3.4 is also needed, as some parts of QEMU do not build with newer gcc versions. As QEMU is present in the archive, just run:
Then run the configure script:
$ ./configure
Then compile it:
And install it on your system:
First you need to create an image of the hard disk. In my case I 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 MIPS machine.
It is necessary to have a MIPS or MIPSEL kernel image to pass to QEMU and an initrd image of the Debian-Installer.
For MIPS:
$ wget http://ftp.de.debian.org/debian/dists/etch/main/installer-mips/current/images/qemu/netboot/initrd.gz
And for MIPSEL:
$ wget http://ftp.de.debian.org/debian/dists/etch/main/installer-mipsel/current/images/qemu/netboot/initrd.gz
To start the installation process, use the following line:
After a few seconds you should see the kernel booting:
And then the first screen of the Debian-Installer:
Proceed exacty as with a normal installation, until you get to the following screen. If you need some documentation, please refer to the
Near to the end of the installation you will get the following error screen:
Consider this message as harmless. There is no need for a bootloader, as QEMU is able to directly load a kernel and an initrd.
Then you will get to the end of the installation. Congratulations!
When the systems reboot, just exit QEMU as different parameters have to be used to boot the installed system. Personally, I use killall qemu-system-mips, but other methods could also work.
Using the system First bootTo start the system use the following command:
After a few seconds the system should give you a login prompt:
Enjoy your new MIPS or MIPSEL platform:
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 512MiB; if you try to use more memory, the additional memory will not be visible.
Connect your emulated machine to a real networkWhen no option is specified QEMU uses a non priviledged 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:
auto eth0
iface eth0 inet dhcp
After:
auto br0
iface br0 inet dhcp
bridge_ports eth0
bridge_maxwait 0
Then you need to install the bridge-utils package and restart your network interface:
# ifdown eth0
# ifup br0
Create a script call /etc/qemu-ifup that will be executed upon the start of QEMU:
echo "Executing /etc/qemu-ifup"
echo "Bringing up $1 for bridged mode..."
sudo /sbin/ifconfig $1 0.0.0.0 promisc up
echo "Adding $1 to br0..."
sudo /usr/sbin/brctl addif br0 $1
sleep 2
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):
Cmnd_Alias QEMU = /usr/sbin/brctl, /sbin/ifconfig
%qemu ALL=NOPASSWD: QEMU
Finally you can start your emulated machine using the following command