This post will show you how to set up a QEMU virtual device to play with your ARM code on an x86_64 host. It is quite simple, and you should be able to simply copy and paste into a terminal and get going relatively quickly.
As an example, we will be installing a debian build (wheezy) into your VM.
First off, we need to install the QEMU packages. I use Ubuntu/Mint, so this post will be somewhat biased towards that.
Let’s start off getting the packages we need:
sudo apt-get install qemu-kvm sudo apt-get install qemu-system-arm sudo apt-get install qemu-utils
Now we can check that everything is installed OK and ready to go with:
Make a directory to work with and then grab some files off your local debian mirror. Remember, we need the ARM based distro.
mkdir ~/arm-emul cd ~/arm-emul wget ftp://ftp.debian.org/debian/dists/wheezy/main/installer-armel/current/images/versatile/netboot/initrd.gz wget ftp://ftp.debian.org/debian/dists/wheezy/main/installer-armel/current/images/versatile/netboot/vmlinuz-3.2.0-4-versatile
Remember now that depending on your board/device, you may want to check if it supports ARM EL or ARM HF. As you can probably guess from the above filenames, we are working with ARM EL. There are a number of differences between the way (and efficiency) of the two device types, but if you don’t know, then you are probably using an ARM EL device. Also, it is worth checking with your manufacturer if you haven’t built your device yourself, as ARM HF is a way better buy!
Let’s create a virtual HDD now to host the code/OS:
qemu-img create -f raw hda.img 8G
I like to create a drive as big as my devices flash ROM. In this case, it is 8GB. Yours may vary.
Now, lets get the system up and running:
qemu-system-arm -m 256 -M versatilepb -kernel ~/arm-emul/vmlinuz-3.2.0-4-versatile -initrd ~/arm-emul/initrd.gz -hda ~/arm-emul/hda.img -append “root=/dev/ram”
Should get you started with the Debian installer. Do the installation and then close your VM.
Once complete, mount your filesystem, and then copy the relevant files around. You need to do this step as debian will not be able to install the bootloader, so you kind of have to do it manually.
mkdir mount sudo losetup /dev/loop0 hda.img sudo kpartx -a /dev/loop0 sudo mount /dev/mapper/loop0p1 mount cp ~/arm-emul/mount/boot/initrd.img-3.2.0-4-versatile ~/arm-emul/ sudo umount ~/arm-emul/mount
Now you can start up your brand new debian ARM VM with:
qemu-system-arm -M versatilepb -kernel ~/arm-emul/vmlinuz-3.2.0-4-versatile -initrd ~/arm-emul/initrd.img-3.2.0-4-versatile -hda ~/arm-emul/hda.img -append "root=/dev/sda1"
Great! Now off to make your custom OS and flash it to your board! Good luck!