Skip to content

Instantly share code, notes, and snippets.

@MihaelIsaev
Forked from Liryna/ARMDebianUbuntu.md
Created September 5, 2020 01:32
Show Gist options
  • Save MihaelIsaev/daf16bba35cc89a9bf1a4b22a9ab3cfe to your computer and use it in GitHub Desktop.
Save MihaelIsaev/daf16bba35cc89a9bf1a4b22a9ab3cfe to your computer and use it in GitHub Desktop.
Emulating ARM on Debian/Ubuntu

Install QEMU

sudo apt-get install qemu

Create a hard disk

Create a hard disk for your virtual machine with required capacity.

qemu-img create -f raw armdisk.img 8G

You can then install Debian using an ISO CD or directly from vmlinuz

Netboot from vmlinuz

First, you should decide what CPU and machine type you want to emulate.

You can get a list of all supported CPUs (to be passed with -cpu option, see later below):

qemu-system-arm -cpu help

You can get a list of all supported machines (to be passed with -M option, see later below):

qemu-system-arm -machine help

In this example, I chose the cortex-a9 CPU and vexpress-a9 machine. This is an ARMv7 CPU which Debian calls as armhf (ARM hard float). You must download vmlinuz and initrd files for, say Wheezy armhf netboot. Cortex-A8, A9, A15 are all ARMv7 CPUs.

You can emulate ARMv6 which Debian calls as armel by downloading the corresponding files for Wheezy armel netboot. Note that you need 'armel' for ARM v5, v6. Raspberry Pi uses ARMv6. In this case, the cpu is arm926 and machine is versatilepb.

Create a virtual machine with 1024 MB RAM and a Cortex-A9 CPU:

qemu-system-arm -m 1024M -hda armdisk.img \
                -M vexpress-a9 -cpu cortex-a9 \
                -kernel vmlinuz-3.2.0-4-vexpress -initrd initrd.gz \
                -append "root=/dev/ram" 

Specifying -cpu is optional. It defaults to -cpu=any. However, -M is mandatory.

This will start a new QEMU window and the Debian installer will kick-in. Just proceed with the installation (takes maybe 3 hours or so).

You can start your virtual machine after the installation complete as follows:

qemu -m 1024 -hda armdisk.img

NOTE: For creating ARMv6, just pass versatilepb:

qemu-system-arm -m 1024M -M versatilepb \
                -kernel vmlinuz-3.2.0-4-versatile -initrd initrd.gz \
                -append "root=/dev/ram" -hda armdisk.img

Netboot from ISO

Download netboot ISO for armhf or armel as needed.

WAIT! Apparently, these Debian CD images are not bootable! But Ubuntu's ARM CD image works [2].

[1] http://www.linuxforu.com/2011/05/quick-quide-to-qemu-setup/ [2] http://blog.troyastle.com/2010/07/building-arm-powered-debian-vm-with.html [3] Differences between ARM926, ARM1136, A8 and A9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment