Using qemu for ARM

hello friends !!!

Those of you who want toย  work on arm might first wish to taste its flavour, then go for the board.

This scenario demands for virtual arm processors to work on & and there comes the QEMU… ๐Ÿ™‚

lets first be familiar with QEMU ( Quick Emualator) is an open source machine emulator and virtualizer. It has two operating modes-

  1. ย User mode emulation – for running single programs cross-compiled for various architectures like ARM, Power PC, etc..
  2. Computer emulation – for emulating full computer system, virtualizing the whole processor. ๐Ÿ™‚

However, There is lot of stuff on wiki, you can refer there for detailed info.. ๐Ÿ™‚

In this article, we will focus on various HOW-TOs for installing qemu and executing the programs for ARM architecture.. ๐Ÿ™‚

for installation there are two options ๐Ÿ™‚

  1. get it directly from repository- using apt-get-install or yum etc.. as per your distros..
  • for fedora – yum install qemu (it will automatically download and install qemu for all architectures).

2. download the source code and compile it..

You can check various arcitectures in the terminal using command

$ qemu

n den press tab..

list of supported architectures by qemu

After we have qemu installed on our system, now is the turn to start our journey to virtualization:

lets start with the arm processor … we will write a small HELLO WORLD program and cross-compile it for the arm architecture and finally execute it in user-mode-emulation…

so here is our smallest program : hello_world.c

hello world program

now comes the step of cross-compiling it for ARM architecture.. well, cross-compiling means to compile a code on our pc (i.e.. host) for different target board (arm in this case).

Well in the previous post it is done with all the necessary steps ๐Ÿ™‚ that includes toolchain installation and compilation-

There it is compiled dynamically, (better if memory is limited, and diff programs share same libraries).

$ arm-none-linux-gnueabi-gcc <myfile> -o <desired name>

which means when you execute the finalย  binary, you will have to give the path to the libraries (glibc). and the emulation command becomes –

$ qemu-arm -L <path of the library file to be linked to> ./file-name


For the static compilation, just add static keyword

$ arm-none-linux-gnueabi-gcc -static <myfile> -o <desired name>

this will resolve all the function at the compilation time itself producing a stand-alone executable.. ๐Ÿ™‚ better choice is memory is no issue. ๐Ÿ™‚

the emulation step is

$ qemu-arm ./file-name


so simple ๐Ÿ™‚

i have used static compilation as it seems easy to implement… lol

In our case:

$arm-none-linux-gnueabi-gcc -static hello_world.c -o hello_world

for emulation

qemu emulation step for hello_world

You see !!! dat was so simple..

well, this is just the beginning… ๐Ÿ™‚ we’ll see how to compile linux kernel and will build a minimal root filesystem for arm processor. ๐Ÿ™‚

About Shantanu Sharma

Currently working as Software R&D member in Samsung R&D India.

Posted on July 17, 2012, in Embedded Linux and tagged , , , , , , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s