Author: Siro Mugabi

Category: qemu

Summary:

This page covers obtaining QEMU for emulation of ARM boards.

Tags: qemu linux arm ubuntu

Update required. This material was written for QEMU v1.x

Obtaining QEMU ARM

QEMU provides two modes of emulation:

  • Full system emulation

    A complete and unmodified OS is run in a virtual environment. This is the environment created when the qemu-system-$ARCH command is run.

  • Linux user mode emulation

    A (set of) Linux process(es) compiled for one target CPU can be executed in a host environment based on another CPU. This is the virtual environment created when the qemu-$ARCH command is executed.

This entry mainly focuses on full system emulation mode. Configuration, installation and usage for Linux user mode emulation is covered in QEMU Usermode Emulation. For decent ARM support, at least QEMU v1.5.0 is recommended.

Build and Install From Sources

Download

  • Git

    QEMU is developed by way of git. The main tree is located here. The latest development happens on the master branch. The stable tree is located in a stable-0.XX branch where 0.XX is the minor release version.

    To download the latest development tree, use the following command:

    $ sudo apt-get install git
    $ git clone git://git.qemu.org/qemu.git
    

    Visit this page for more details.

  • Tarball

    Alternatively, direct HTTP download of a specific QEMU release in the form of a tarball archive can be performed. For example:

    $ wget -c http://wiki.qemu-project.org/download/qemu-1.7.0.tar.bz2
    

Configuration and Build

Once download (and extraction) is complete, the steps followed in configuring and building the QEMU binaries are identical regardless of the download type. Assuming that the QEMU sources are located in $QEMU_SRC1:

$ mkdir {qtemp,qinstall}
$ cd qtemp
$ ${QEMU_SRC}/configure --target-list=arm-softmmu[,arm-linux-user,armeb-linux-user] --enable-fdt --prefix=${PWD}/../qinstall

where:

  • --target-list= instructs the QEMU build process to only build ARM specific stuff. Otherwise, by default, the build process will build for all QEMU supported machine architectures.

  • The arm-linux-user and armeb-linux-user options will result in the build of the qemu-arm and qemu-armeb (respectively) utilities for Linux user mode emulation.

  • --enable-fdt (i.e. libfdt support) allows a user to specify a device tree on the qemu-system-arm comand line via the -dtb option. If the emulated ARM machine supports device trees, the Device Tree Blob (DTB) will be loaded to its memory and passed to the kernel on boot.

Now, build and install with:

$ make [-jN]
$ make install

To free up disk space, the qtemp build directory may now be deleted.

Ubuntu Install

For Ubuntu 14.04 simply running:

$ sudo apt-get install qemu-system-arm
$ qemu-system-arm -version
QEMU emulator version 2.0.0 (Debian 2.0.0+dfsg-2ubuntu1), Copyright (c) 2003-2008 Fabrice Bellard

should suffice to install a "decent" qemu-system-arm. For earlier Ubuntu versions, it may be necessary to update the system to use qemu-linaro from the Linaro Tools PPA since their default versions may be not include "decent" QEMU ARM support.

Linaro Tools PPA

Linaro QEMU, or qemu-linaro, is the QEMU tree maintained by the Linaro Working Groups that broadly tracks upstream QEMU trunk, adding some ARM specific improvements. Linaro regularly pushes fixes and updates of its tree to upstream QEMU.

For instance, on Ubuntu 12.04:

$ sudo apt-get install qemu-system 
$ qemu-system-arm -version
QEMU emulator version 1.0.50 (Debian 1.0.50-2012.03-0ubuntu2.1), Copyright (c) 2003-2008 Fabrice Bellard

So, to upgrade qemu-system-arm, update /etc/apt as follows:

$ sudo add-apt-repository ppa:linaro-maintainers/tools
$ sudo apt-get update

which creates:

$ cat /etc/apt/sources.list.d/linaro-maintainers-tools-precise.list
deb http://ppa.launchpad.net/linaro-maintainers/tools/ubuntu precise main
deb-src http://ppa.launchpad.net/linaro-maintainers/tools/ubuntu precise main

then re-install QEMU:

$ sudo apt-get install qemu-system 
$ qemu-system-arm -version
QEMU emulator version 1.5.0 (Debian 1.5.0-2013.06+git74+20130802+ef1b0ae-3linaroprecise1), Copyright (c) 2003-2008 Fabrice Bellard

The Linaro Tools PPA has been available for Ubuntu since Maverick (10.10).

QEMU ARM Machines, SoCs and CPU Cores

To view the available QEMU emulated ARM machine types:

$ qemu-system-arm -M ?
Supported machines are:
    ...
    smdkc210             Samsung SMDKC210 board (Exynos4210)
    ...
    versatilepb          ARM Versatile/PB (ARM926EJ-S)
    versatileab          ARM Versatile/AB (ARM926EJ-S)
    ...
    vexpress-a9          ARM Versatile Express for Cortex-A9
    ...
    vexpress-a15         ARM Versatile Express for Cortex-A15
    ...
    xilinx-zynq-a9       Xilinx Zynq Platform Baseboard for Cortex-A9

To view the ARM CPU cores supported by a QEMU ARM machine:

$ qemu-system-arm -M smdkc210 -cpu ?
Available CPUs:
    ...
    cortex-a15
    cortex-a8
    cortex-a9
    ...

Generally, these details can also aid in selecting -mcpu= or -mtune= options (gcc(1)) when generating code for the respective QEMU ARM target.

Passing a large value to the qemu-system -smp command line option (for multicore machines) can be used to identify the maximum number of CPUs supported, for instance:

$ qemu-system-arm -M vexpress-a15 -smp 5
Number of SMP cpus requested (5), exceeds max cpus supported by machine `vexpress-a15' (4)
  • https://wiki.linaro.org/Resources/HowTo/Qemu
  • https://wiki.linaro.org/PeterMaydell/QemuVersatileExpress

Also See

Resources

  • https://wiki.linaro.org/WorkingGroups/ToolChain/QEMU
  • https://wiki.linaro.org/WorkingGroups
  • http://releases.linaro.org/
  • https://launchpad.net/~linaro-maintainers/+archive/tools
  • http://git.qemu.org/qemu.git
  • http://wiki.qemu-project.org/download/

Footnotes

1. See Building Packages with GNU configure for a tutorial on using GNU configure [go back]