Documentation/Platforms/ARM: Difference between revisions

From QEMU
(Graphics does work on -M virt nowadays, also restructure that section to have saner format and be more editable.)
 
(15 intermediate revisions by 5 users not shown)
Line 36: Line 36:
If it's a Linux image and you're mostly interested in the userspace software, then you may be able to extract the filesystem and use that with a different kernel which boots on a system QEMU does emulate.
If it's a Linux image and you're mostly interested in the userspace software, then you may be able to extract the filesystem and use that with a different kernel which boots on a system QEMU does emulate.


=== Generic ARM system emulation with -M virt ===
=== Generic ARM system emulation with the virt machine ===


If you don't care about reproducing the idiosyncrasies of a particular bit of hardware, such as small amount of RAM, no PCI or other hard disk, etc., and just want to run Linux, the best option is to use:
If you don't care about reproducing the idiosyncrasies of a particular bit of hardware, such as small amount of RAM, no PCI or other hard disk, etc., and just want to run Linux, the best option is to use:
Line 45: Line 45:


It supports PCI, virtio, recent CPUs and large amounts of RAM.
It supports PCI, virtio, recent CPUs and large amounts of RAM.
See [https://translatedcode.wordpress.com/2016/11/03/installing-debian-on-qemus-32-bit-arm-virt-board/ this tutorial] for information on getting 32-bit ARM Debian Linux running on the "virt" board.
For 64-bit ARM "virt" is also the best choice, and there's [https://translatedcode.wordpress.com/2017/07/24/installing-debian-on-qemus-64-bit-arm-virt-board/ a tutorial] for 64-bit ARM Debian Linux setup too.
The "versatilepb" machine has also often been used as a general-purpose Linux target in the past; its disadvantage is that it has a very old CPU and only 256MB of RAM, but it does at least have PCI and SCSI. You can find a description of how to install Debian on it [https://www.aurel32.net/info/debian_arm_qemu.php here] (the author of that tutorial has also provided [https://people.debian.org/~aurel32/qemu/armel/ some prebuilt images]). You're probably better off using "virt" though.
==== Guest kernel configuration for the virt machine ====
The 'defconfig' for Linux arm and arm64 should include the right device drivers for virtio and the PCI controller; some older kernel versions, especially for 32-bit Arm, did not have everything enabled by default. If you're not seeing PCI devices that you expect, then check that your guest config has:
CONFIG_PCI=y
CONFIG_VIRTIO_PCI=y
CONFIG_PCI_HOST_GENERIC=y
==== virt machine graphics ====


Graphics is also available, but unlike x86 there is no default display device enabled: you should select on from the Display devices section of "-device ?". One good option is to use:
Graphics is also available, but unlike x86 there is no default display device enabled: you should select on from the Display devices section of "-device ?". One good option is to use:
Line 50: Line 66:
  -device virtio-gpu-pci
  -device virtio-gpu-pci


and enable the following Linux kernel options:
and enable the following Linux kernel options (as well as the generic "virtio PCI for the virt machine" options listed earlier):


  CONFIG_DRM=y
  CONFIG_DRM=y
  CONFIG_DRM_VIRTIO_GPU=y
  CONFIG_DRM_VIRTIO_GPU=y


See [https://translatedcode.wordpress.com/2016/11/03/installing-debian-on-qemus-32-bit-arm-virt-board/ this tutorial] for information on getting 32-bit ARM Debian Linux running on the "virt" board.
Also, for some reason, the SDL graphic window does not open under certain circumstances as of v2.12, so you might need to use another method such as VNC:
 
-vnc :0
 
and then connect to it with:
 
vinagre :5900
 
=== Example for using the canon-a1100 machine ===
 
There is no Linux support for the canon-a1100 machine - you have to use a special firmware here like "barebox". To build a barebox image, download a tarball from https://www.barebox.org/download/ and then compile it like this:
 
<pre>
tar -xjf barebox-....tar.bz2
cd barebox-...
cp ./arch/arm/configs/canon-a1100_defconfig .config
make CROSS_PREFIX=arm-linux-gnu- ARCH=arm CC=arm-linux-gnu-gcc \
LD=arm-linux-gnu-ld OBJCOPY=arm-linux-gnu-objcopy olddefconfig
make CROSS_PREFIX=arm-linux-gnu- ARCH=arm CC=arm-linux-gnu-gcc \
LD=arm-linux-gnu-ld OBJCOPY=arm-linux-gnu-objcopy -j8
</pre>


For 64-bit ARM "virt" is also the best choice, and there's [https://translatedcode.wordpress.com/2017/07/24/installing-debian-on-qemus-64-bit-arm-virt-board/ a tutorial] for 64-bit ARM Debian Linux setup too.
Then you can run the image like this:


The "versatilepb" machine has also often been used as a general-purpose Linux target in the past; its disadvantage is that it has a very old CPU and only 256MB of RAM, but it does at least have PCI and SCSI. You can find a description of how to install Debian on it [https://www.aurel32.net/info/debian_arm_qemu.php here] (the author of that tutorial has also provided [https://people.debian.org/~aurel32/qemu/armel/ some prebuilt images]). You're probably better off using "virt" though.
<code>qemu-system-arm -M canon-a1100 -serial stdio -display none -bios barebox.canon-a1100.bin</code>


== Supported Machines ==
== Supported Machines ==
Line 178: Line 214:
   ./configure --target-list=arm-softmmu,aarch64-softmmu && make
   ./configure --target-list=arm-softmmu,aarch64-softmmu && make


== Suggested command-line==
== Suggested command-lines==
   qemu-system-aarch64 -m <memory size> -M <machine name> -drive if=none,file=<hard drive file name>,id=hd0 \
 
  -device virtio-blk-device,drive=hd0 -netdev type=tap,id=net0 -device virtio-net-device,netdev=net0
Using virtio-mmio (and the virt machine)
 
   qemu-system-aarch64 -m <memory size> -M virt -drive if=none,file=<hard drive file name>,id=hd0 \
    -device virtio-blk-device,drive=hd0 -netdev type=tap,id=net0 -device virtio-net-device,netdev=net0
 
However for more featureful guests it's recommended to use discoverable buses. So for example the same as above but now using a PCI bus on which sits a SCSI controller with a blockdevice and networks card (using userspace networking this time). The transport is still virtio
 
  qemu-system-aarch64 -m <memory size> -M virt -device virtio-scsi-pci \
    -device scsi-hd,drive=hd0 -blockdev node-name=hd0,filename=<hard drive file name> \
    -netdev user,id=unet -device virtio-net-pci,netdev=unet
 
A similar command line can be used for qemu-system-arm as long as the kernel supports the VIRTIO, GENERIC_PCI and SCSI_VIRTIO features.
 
== Pictures ==
<table style="border-spacing: 25px;">
<tr>
 
<td>[[File:qemu-osmc.png|300px|Open Source Media Center running in QEMU]]<br>
OSMC running in Raspberry Pi target of QEMU
</td>
 
<td>[[File:opensuse.png|270px|OpenSUSE playing a Youtube video]]<br>
OpenSUSE playing a Youtube video<br>inside QEMU
</td>
 
</tr>
</table>


== Picture ==
== Links ==
[[File:qemu-osmc.png|300px|Open Source Media Center running in QEMU]]<br>
[https://en.opensuse.org/openSUSE:AArch64#Using_an_emulator How to install OpenSUSE Linux in QEMU]
Open Source Media Center running in Raspberry Pi target of QEMU


== Contacts ==
== Contacts ==
Maintainer: Peter Maydell [mailto:peter.maydell@linaro.org peter.maydell@linaro.org]<br>
Maintainer: Peter Maydell [mailto:peter.maydell@linaro.org peter.maydell@linaro.org]<br>
[https://lists.nongnu.org/mailman/listinfo/qemu-arm QEMU ARM developer mailing list page]<br>
[https://lists.nongnu.org/mailman/listinfo/qemu-arm QEMU ARM developer mailing list page]<br>

Latest revision as of 15:28, 22 March 2021

QEMU ARM guest support

QEMU has generally good support for ARM guests. It has support for nearly fifty different machines. The reason we support so many is that ARM hardware is much more widely varying than x86 hardware. ARM CPUs are generally built into "system-on-chip" (SoC) designs created by many different companies with different devices, and these SoCs are then built into machines which can vary still further even if they use the same SoC. Even with fifty boards QEMU does not cover more than a small fraction of the ARM hardware ecosystem.

Because ARM systems differ so much and in fundamental ways, typically operating system or firmware images intended to run on one machine will not run at all on any other. This is often surprising for new users who are used to the x86 world where every system looks like a standard PC. (Once the kernel has booted, most userspace software cares much less about the detail of the hardware.)

The situation for 64-bit ARM is fairly similar, except that we don't implement so many different machines.

As well as the more common "A-profile" CPUs (which have MMUs and will run Linux) we also support the Cortex-M3 and Cortex-M4 "M-profile" CPUs (which are microcontrollers used in very embedded boards. We only have two boards which use the M-profile CPU at the moment: "lm3s811evb" and "lm3s6965evb" (which are both TI Stellaris evaluation boards).

Guidelines for choosing a QEMU machine

Accurate emulation of existing hardware

If you have a complete system image already that works on hardware and you want to boot with QEMU, check whether QEMU lists that machine in its '-machine help' output.

If it does, that's the best place to start. If it doesn't then unfortunately you're out of luck: your image won't boot on QEMU.

If it's a Linux image and you're mostly interested in the userspace software, then you may be able to extract the filesystem and use that with a different kernel which boots on a system QEMU does emulate.

Generic ARM system emulation with the virt machine

If you don't care about reproducing the idiosyncrasies of a particular bit of hardware, such as small amount of RAM, no PCI or other hard disk, etc., and just want to run Linux, the best option is to use:

-M virt

virt is a platform which doesn't correspond to any real hardware and is designed for use in virtual machines.

It supports PCI, virtio, recent CPUs and large amounts of RAM.

See this tutorial for information on getting 32-bit ARM Debian Linux running on the "virt" board.

For 64-bit ARM "virt" is also the best choice, and there's a tutorial for 64-bit ARM Debian Linux setup too.

The "versatilepb" machine has also often been used as a general-purpose Linux target in the past; its disadvantage is that it has a very old CPU and only 256MB of RAM, but it does at least have PCI and SCSI. You can find a description of how to install Debian on it here (the author of that tutorial has also provided some prebuilt images). You're probably better off using "virt" though.

Guest kernel configuration for the virt machine

The 'defconfig' for Linux arm and arm64 should include the right device drivers for virtio and the PCI controller; some older kernel versions, especially for 32-bit Arm, did not have everything enabled by default. If you're not seeing PCI devices that you expect, then check that your guest config has:

CONFIG_PCI=y
CONFIG_VIRTIO_PCI=y
CONFIG_PCI_HOST_GENERIC=y

virt machine graphics

Graphics is also available, but unlike x86 there is no default display device enabled: you should select on from the Display devices section of "-device ?". One good option is to use:

-device virtio-gpu-pci

and enable the following Linux kernel options (as well as the generic "virtio PCI for the virt machine" options listed earlier):

CONFIG_DRM=y
CONFIG_DRM_VIRTIO_GPU=y

Also, for some reason, the SDL graphic window does not open under certain circumstances as of v2.12, so you might need to use another method such as VNC:

-vnc :0

and then connect to it with:

vinagre :5900

Example for using the canon-a1100 machine

There is no Linux support for the canon-a1100 machine - you have to use a special firmware here like "barebox". To build a barebox image, download a tarball from https://www.barebox.org/download/ and then compile it like this:

tar -xjf barebox-....tar.bz2
cd barebox-...
cp ./arch/arm/configs/canon-a1100_defconfig .config
make CROSS_PREFIX=arm-linux-gnu- ARCH=arm CC=arm-linux-gnu-gcc \
 LD=arm-linux-gnu-ld OBJCOPY=arm-linux-gnu-objcopy olddefconfig
make CROSS_PREFIX=arm-linux-gnu- ARCH=arm CC=arm-linux-gnu-gcc \
 LD=arm-linux-gnu-ld OBJCOPY=arm-linux-gnu-objcopy -j8

Then you can run the image like this:

qemu-system-arm -M canon-a1100 -serial stdio -display none -bios barebox.canon-a1100.bin

Supported Machines

Supported in qemu-system-arm

MachineDescription
akita Sharp SL-C1000 (Akita) PDA (PXA270)
ast2500-evb Aspeed AST2500 EVB (ARM1176)
borzoi Sharp SL-C3100 (Borzoi) PDA (PXA270)
canon-a1100 Canon PowerShot A1100 IS
cheetah Palm Tungsten|E aka. Cheetah PDA (OMAP310)
collie Sharp SL-5500 (Collie) PDA (SA-1110)
connex Gumstix Connex (PXA255)
cubieboard cubietech cubieboard
highbank Calxeda Highbank (ECX-1000)
imx25-pdk ARM i.MX25 PDK board (ARM926)
integratorcp ARM Integrator/CP (ARM926EJ-S)
kzm ARM KZM Emulation Baseboard (ARM1136)
lm3s6965evb Stellaris LM3S6965EVB
lm3s811evb Stellaris LM3S811EVB
mainstone Mainstone II (PXA27x)
midway Calxeda Midway (ECX-2000)
musicpal Marvell 88w8618 / MusicPal (ARM926EJ-S)
n800 Nokia N800 tablet aka. RX-34 (OMAP2420)
n810 Nokia N810 tablet aka. RX-44 (OMAP2420)
netduino2 Netduino 2 Machine
none empty machine
nuri Samsung NURI board (Exynos4210)
palmetto-bmc OpenPOWER Palmetto BMC (ARM926EJ-S)
raspi2 Raspberry Pi 2
realview-eb ARM RealView Emulation Baseboard (ARM926EJ-S)
realview-eb-mpcore ARM RealView Emulation Baseboard (ARM11MPCore)
realview-pb-a8 ARM RealView Platform Baseboard for Cortex-A8
realview-pbx-a9 ARM RealView Platform Baseboard Explore for Cortex-A9
sabrelite Freescale i.MX6 Quad SABRE Lite Board (Cortex A9)
smdkc210 Samsung SMDKC210 board (Exynos4210)
spitz Sharp SL-C3000 (Spitz) PDA (PXA270)
sx1 Siemens SX1 (OMAP310) V2
sx1-v1 Siemens SX1 (OMAP310) V1
terrier Sharp SL-C3200 (Terrier) PDA (PXA270)
tosa Sharp SL-6000 (Tosa) PDA (PXA255)
verdex Gumstix Verdex (PXA270)
versatileab ARM Versatile/AB (ARM926EJ-S)
versatilepb ARM Versatile/PB (ARM926EJ-S)
vexpress-a15 ARM Versatile Express for Cortex-A15
vexpress-a9 ARM Versatile Express for Cortex-A9
virt-2.6 QEMU 2.6 ARM Virtual Machine
virt-2.7 QEMU 2.7 ARM Virtual Machine
virt QEMU 2.8 ARM Virtual Machine (alias of virt-2.8)
virt-2.8 QEMU 2.8 ARM Virtual Machine
xilinx-zynq-a9 Xilinx Zynq Platform Baseboard for Cortex-A9
z2 Zipit Z2 (PXA27x)


Supported in qemu-system-aarch64

MachineDescription
akita Sharp SL-C1000 (Akita) PDA (PXA270)
ast2500-evb Aspeed AST2500 EVB (ARM1176)
borzoi Sharp SL-C3100 (Borzoi) PDA (PXA270)
canon-a1100 Canon PowerShot A1100 IS
cheetah Palm Tungsten|E aka. Cheetah PDA (OMAP310)
collie Sharp SL-5500 (Collie) PDA (SA-1110)
connex Gumstix Connex (PXA255)
cubieboard cubietech cubieboard
highbank Calxeda Highbank (ECX-1000)
imx25-pdk ARM i.MX25 PDK board (ARM926)
integratorcp ARM Integrator/CP (ARM926EJ-S)
kzm ARM KZM Emulation Baseboard (ARM1136)
lm3s6965evb Stellaris LM3S6965EVB
lm3s811evb Stellaris LM3S811EVB
mainstone Mainstone II (PXA27x)
midway Calxeda Midway (ECX-2000)
musicpal Marvell 88w8618 / MusicPal (ARM926EJ-S)
n800 Nokia N800 tablet aka. RX-34 (OMAP2420)
n810 Nokia N810 tablet aka. RX-44 (OMAP2420)
netduino2 Netduino 2 Machine
none empty machine
nuri Samsung NURI board (Exynos4210)
palmetto-bmc OpenPOWER Palmetto BMC (ARM926EJ-S)
raspi2 Raspberry Pi 2
realview-eb ARM RealView Emulation Baseboard (ARM926EJ-S)
realview-eb-mpcore ARM RealView Emulation Baseboard (ARM11MPCore)
realview-pb-a8 ARM RealView Platform Baseboard for Cortex-A8
realview-pbx-a9 ARM RealView Platform Baseboard Explore for Cortex-A9
sabrelite Freescale i.MX6 Quad SABRE Lite Board (Cortex A9)
smdkc210 Samsung SMDKC210 board (Exynos4210)
spitz Sharp SL-C3000 (Spitz) PDA (PXA270)
sx1 Siemens SX1 (OMAP310) V2
sx1-v1 Siemens SX1 (OMAP310) V1
terrier Sharp SL-C3200 (Terrier) PDA (PXA270)
tosa Sharp SL-6000 (Tosa) PDA (PXA255)
verdex Gumstix Verdex (PXA270)
versatileab ARM Versatile/AB (ARM926EJ-S)
versatilepb ARM Versatile/PB (ARM926EJ-S)
vexpress-a15 ARM Versatile Express for Cortex-A15
vexpress-a9 ARM Versatile Express for Cortex-A9
virt-2.6 QEMU 2.6 ARM Virtual Machine
virt-2.7 QEMU 2.7 ARM Virtual Machine
virt QEMU 2.8 ARM Virtual Machine (alias of virt-2.8)
virt-2.8 QEMU 2.8 ARM Virtual Machine
xilinx-zynq-a9 Xilinx Zynq Platform Baseboard for Cortex-A9
xlnx-ep108 Xilinx ZynqMP EP108 board
xlnx-zcu102 Xilinx ZynqMP ZCU102 board
z2 Zipit Z2 (PXA27x)

Tips

To see a printout of all the supported machines use:

 qemu-system-arm -M help

or

 qemu-system-aarch64 -M help

Build Directions

 ./configure --target-list=arm-softmmu,aarch64-softmmu && make

Suggested command-lines

Using virtio-mmio (and the virt machine)

 qemu-system-aarch64 -m <memory size> -M virt -drive if=none,file=<hard drive file name>,id=hd0 \
   -device virtio-blk-device,drive=hd0 -netdev type=tap,id=net0 -device virtio-net-device,netdev=net0

However for more featureful guests it's recommended to use discoverable buses. So for example the same as above but now using a PCI bus on which sits a SCSI controller with a blockdevice and networks card (using userspace networking this time). The transport is still virtio

 qemu-system-aarch64 -m <memory size> -M virt -device virtio-scsi-pci \
   -device scsi-hd,drive=hd0 -blockdev node-name=hd0,filename=<hard drive file name> \
   -netdev user,id=unet -device virtio-net-pci,netdev=unet

A similar command line can be used for qemu-system-arm as long as the kernel supports the VIRTIO, GENERIC_PCI and SCSI_VIRTIO features.

Pictures

Open Source Media Center running in QEMU

OSMC running in Raspberry Pi target of QEMU

OpenSUSE playing a Youtube video

OpenSUSE playing a Youtube video
inside QEMU

Links

How to install OpenSUSE Linux in QEMU

Contacts

Maintainer: Peter Maydell peter.maydell@linaro.org
QEMU ARM developer mailing list page