Emulating ARM On Debian - Ubuntu GitHub
Emulating ARM On Debian - Ubuntu GitHub
Liryna / ARMDebianUbuntu.md
Last active 19 days ago
ARMDebianUbuntu.md
If the below is too much, you can try Ubuntu-ARMv7-Qemu but note it contains non-free blobs.
#include <stdio.h>
int main(void) { return printf("Hello ARM!\n"); }
EOF
arm-linux-gnueabihf-gcc -static -ohello hello.c
file hello
hello: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked,
./hello
Hello ARM!
If you want a dynamically-linked executable, you've to pass the linker path too:
Install QEMU
You can then install Debian using an ISO CD or directly from vmlinuz
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):
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 ARMv5, v6. Raspberry Pi uses ARMv6. In this case, the cpu is arm1176 and machine is
versatilepb .
Create a virtual machine with 1024 MB RAM and a Cortex-A9 CPU. Note that we must -sd instead of -sda because vexpress
kernel doesn't support PCI SCSI hard disks. You'll install Debian on on MMC/SD card, that's all it means.
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). Make sure you install "ssh-server" in tasksel screen.
WAIT! Apparently, these Debian CD images are not bootable! But Ubuntu's ARM CD image works [2].
For armel
cp ~/qemu-mounted/boot/* after-copy/
Then pass the copied kernel and initrd to qemu-system-img. Also note that we are now booting from /dev/sda1 because
that is where Linux was installed
For armhf
Extract & copy the boot files exactly as before (but for armhf.img) and pass while invoking:
Once again, note the device ( mmcblk0p1 ) and partition ( armhf.img ) reflect SD-card usage.
Login to the guest OS and create a private/public key pair: ssh-keygen -t rsa .
On the host, just redirect some random port from the host to guest's port 22 (or whichever port the SSH server is running on,
see /etc/ssh/sshd_config)
Then you can connect to SSH just like ssh -p 5555 localhost .
After the install of your ARM, you will probably see that it is really slow. To speed up your arm, you can chroot it natively and
let qemu-user-static interpret the ARM instruction. [5]
$ uname -a
Linux cis-linux-arm 2.6.32 #19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013 armv7l GNU/Linux
N.B: After test, qemu 1.1 (Debian wheezy) had some strange behaviour but the 1.5 (Ubuntu saucy) was working perfectly !
When you finished your work you should unmount everything to avert bad behaviour. Do not forget to not start your VM
with Qemu before unmount everything !
References
As of qemu 2.7 at least, -redir tcp:5555::22 is deprecated: use -net user,hostfwd=tcp::5555-:22 instead. Thx for this great guide!
Hello @Liryna !
I'm looking at emulating CentOS 7 and Debian 8 on aarch64 using a local build of qemu 2.7.0. I'm looking at an non EFI environment, which
necessitates that I specify the kernel and its arguments.
Thank You !
eblot commented on Nov 17, 2016 • edited
There is an alternative way to store the installed kernel (vmlinuz*) and initrd to the host
Once the installation is complete, do not (yet) select "Finish installation" but "Start a shell", and:
chroot /target
cd boot/
scp * host:
exit
where host is the IP of the host then resume with "Finish installation"
No need to use qemu-nbd , as long as a scp client is installed in the guest and sshd runs on the host.
I'm unable to boot a Jessie image, even with QEMU's -dtb vexpress-v2p-ca9.dtb option, with netboot-console images.