EDIT (March 8, 2014): Updated for the 1.6.0 QEMU version. The recent release of the Raspberry Pi board raised a new wave of interest for the ARM platforms. As Red/System is already running on ARMv5+ platforms, a number of Red followers might want to test it on these platforms, so this article aims at giving you a quick way to setup a QEMU emulator for ARM and install a Debian GNU/Linux on top of it.
First thing first, let’s setup the platform. QEMU is the tool we want for that job. As explained on the QEMU web site: “QEMU is a generic and open source machine emulator and virtualizer.” The nice thing about QEMU is that it is able to emulate a good range of ARM platforms with different CPU versions.
QEMU is distributed as a source package, like most of open source tools, however this is not always convenient for Windows users, so you will also find a link to Windows pre-compiled binaries.
The simplest and quickest way to get a Linux/ARM distribution running on top of QEMU is to used pre-installed Debian images. These Virtual Machine images can be found there along with additional useful information (be sure to read them all). As you can see, there are two kind of images: standard and desktop. The desktop one gives you the full Debian GUI environment pre-installed, but be warned, it is extremely slow, even on my Core i7 box with a medium-level graphic card, so I recommend using the standard version pre-installed with Debian Squeeze (latest Debian release).
The files you need from the debian.org site are (direct links provided for convenience):
Put them all somewhere in the same folder.
The command line for starting QEMU with the pre-installed VM is provided on the debian.org page, here is a copy of the right command line for the standard VM with 2.6.32 kernel:
qemu-system-armw -L Bios -M versatilepb -kernel vmlinuz-2.6.32-5-versatile -initrd initrd.img-2.6.32-5-versatile -hda debian_squeeze_armel_standard.qcow2 -append "root=/dev/sda1"
For Windows users, the easiest way to start it is to make a shortcut on
qemu-system-arm , add the command-line arguments and insert the path to the VM files in the “working folder” field.
You can now just run the emulator and boot on Debian to test your environment.
For purists, it is also possible to install the Debian distro from scratch following this step-by-step tutorial.
As you will quickly discover, the network connection is not working out of the box, so you need to add more parameters to the command-line to make it work. From my own experience, it is a black art to make it work properly (the documentation is really poor and obscure on that topic), but I ended up making the network work (and the Internet connection through the host platform) by using these additional arguments:
-net nic -net user
Once the VM is rebooted, you can test it using a ping and then issue an
=r apt-get update=r. command. In case the ping test passes but not the apt-get, you might have wrong apt source URL, so you can change them by editing the /etc/apt/sources.list config file.
You have now a working ARM virtual platform, but in order to make it useful for Red/System testing, you need a simple way to pass compiled files to the guest OS (Red/System can only cross-compile to ARM due to the lack of a suitable REBOL interpreter).
In order to achieve that, you need to add new parameters to the command-line in order to map a guest OS TCP port to a host OS port. For example, to map guest OS port 22 (SSH) to port 1222 on host OS, just add:
So, the VM internal port 22 is now reachable from localhost:1222 on your host OS. You can now use your favorite SSH/SFTP/SCP client to get a remote shell and transfer files to the VM. You might need to setup a SSH server in the VM (I seem to recall that it is not installed by default in the above images), you can achieve that using the following command:
# sudo apt-get install
I use SSH for moving files in and out the VM using the still excellent SSH Secure Shell tool for Windows, but you could as well use FTP or any other TCP-based suitable protocol.
You can improve your experience with QEMU by adding more memory to the default emulated ARM platform which only has 128MB. Pushing it to 256MB (same as Raspberry PI Model A board now has) is highly recommended, just add to the command-line:
If you are using a non-english keyboard like myself, you can also emulate your preferred keyboard layout using for example, the following command:
will setup the keyboard with a french layout, other country codes are available here. In case you get an error message about the keymap not being found, just copy the Bios/keymaps folder one level up, so that it is just above your qemu-* binaries.
That’s all folks, I hope this would have help you get started! Let me know if there is any error or missing info in this article, and let me know if it worked well for you.