How to run qemu sample application

Asked by Christopher Wilson

I'm having trouble getting the 'qemu' sample application working that comes with gcc-arm-none-eabi-4_9-2014q4/share/gcc-arm-none-eabi/samples/src/qemu/

(Disclaimer: this is my first time trying to use qemu and I'm very new to the GNU Tools for ARM Embedded Processors also)

1) change CORTEX_M=3 in samples/src/makefile.conf

2) build application

cd samples/src/qemu/
make

3) I installed qemu on Mac OSX Yosemite using Macports:

sudo port install qemu +target_arm

4) Try to run application in qemu

qemu-system-arm -machine none -cpu cortex-m3 -nographic -monitor null -serial null -semihosting -kernel hello-CM3.axf

5) It seems to just hang here, nothing is printed on the terminal. I would assume that it should print "Hello, world!".

FYI, I added "-machine none" because I get the following error without it:

No machine specified, and there is no default.
Use -machine help to list supported machines!

Here is my qemu version:

$ qemu-system-arm --version
QEMU emulator version 2.1.2, Copyright (c) 2003-2008 Fabrice Bellard

Can anybody give me a quick tutorial on getting this working?

Question information

Language:
English Edit question
Status:
Answered
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Christopher Wilson (cdwilson) said :
#1

Quick update, I just built a Ubuntu 12.04 VM and tested the same steps above. It works just fine in Ubuntu, but not in OSX:

$ qemu-system-arm -cpu cortex-m3 -nographic -monitor null -serial null -semihosting -kernel hello-CM3.axf
Hello, world!

If anybody knows why this doesn't work on OSX Yosemite, or can share how to get it working, it would be appreciated.

FYI, for anybody else trying to get this running in Ubuntu 12.04, I installed the following:

sudo apt-get install apt-file python-software-properties
sudo add-apt-repository ppa:terry.guo/gcc-arm-embedded
sudo apt-get update
sudo apt-get install gcc-arm-none-eabi
sudo apt-get install qemu-system

Revision history for this message
Terry Guo (terry.guo) said :
#2

Please try with command:

qemu-arm -cpu any hello-CM3.axf

Revision history for this message
Christopher Wilson (cdwilson) said :
#3

Hi Terry,

Thanks for the response. Here's what I get when I try on OSX:

$ qemu-arm -cpu any hello-CM3.axf
-bash: qemu-arm: command not found
$ sudo port search qemu
qemu @2.1.2 (emulators)
    Emulator for various architectures

qemu-usermode @0.9.0 (emulators)
    x86 and PowerPC Emulator

Found 2 ports.
$ sudo port install qemu +target_arm
...
$ qemu-
qemu-ga qemu-img qemu-io qemu-nbd qemu-system-aarch64 qemu-system-arm qemu-system-i386 qemu-system-x86_64

I don't seem to have "qemu-arm" installed, is that a typo/shorthand for "qemu-system-arm" or should I actually be looking for a "qemu-arm" command?

When I tried instead "qemu-system-arm" I get the following:

$ qemu-system-arm -cpu any hello-CM3.axf
No machine specified, and there is no default.
Use -machine help to list supported machines!

On OSX, qemu version:
$ qemu-system-arm --version
QEMU emulator version 2.1.2, Copyright (c) 2003-2008 Fabrice Bellard

On Ubuntu 12.04:
$ qemu-system-arm --version
QEMU emulator version 1.0.50 (Debian 1.0.50-2012.03-0ubuntu2.1), Copyright (c) 2003-2008 Fabrice Bellard

I don't know enough about this to know if there is a version incompatibility, or something just broken on OSX, etc...

Revision history for this message
Terry Guo (terry.guo) said :
#4

The qemu-arm and qemu-system-arm are two different things. My understanding is that qemu-arm models only the core part without the peripherals while the qemu-system-arm models both. Theoretically the qemu-arm should run faster than qemu-system-arm. But you can ignore such difference if your target application is tiny.

Another thing for qemu-system-arm is the option -machine which is corresponding to a real board. So when you use option -machine with a valid board name, you need to ensure your project follow the corresponding memory layout.

Revision history for this message
Joey Ye (jinyun-ye) said :
#5

My qemu-arm was built from qemu source tree after configuring with
../qemu/configure arm-softmmu,arm-linux-user

It is more handy than qemu-system who need a whole lot of options.

- Joey

Revision history for this message
Christopher Wilson (cdwilson) said :
#6

It looks like there is no support for "arm-bsd-user" target in the latest qemu release (2.2.0). Looks like I'm out of luck on Mac for now?

$ ./configure --help --enable-bsd-user

Usage: configure [options]
Options: [defaults in brackets after descriptions]

Standard options:
  --help print this message
  --prefix=PREFIX install in PREFIX [/usr/local]
  --interp-prefix=PREFIX where to find shared libraries, etc.
                           use %M for cpu name [/usr/gnemul/qemu-%M]
  --target-list=LIST set target list (default: build everything)
                           Available targets: aarch64-softmmu alpha-softmmu
                           arm-softmmu cris-softmmu i386-softmmu lm32-softmmu
                           m68k-softmmu microblaze-softmmu microblazeel-softmmu
                           mips-softmmu mips64-softmmu mips64el-softmmu
                           mipsel-softmmu moxie-softmmu or32-softmmu
                           ppc-softmmu ppc64-softmmu ppcemb-softmmu
                           s390x-softmmu sh4-softmmu sh4eb-softmmu
                           sparc-softmmu sparc64-softmmu tricore-softmmu
                           unicore32-softmmu x86_64-softmmu xtensa-softmmu
                           xtensaeb-softmmu i386-bsd-user sparc-bsd-user
                           sparc64-bsd-user x86_64-bsd-user
...

Revision history for this message
Joey Ye (jinyun-ye) said :
#7

x86_64-bsd-user ?

On Thu, Jan 15, 2015 at 11:21 AM, Christopher Wilson <
<email address hidden>> wrote:

> Question #260515 on GCC ARM Embedded changed:
> https://answers.launchpad.net/gcc-arm-embedded/+question/260515
>
> Christopher Wilson posted a new comment:
> It looks like there is no support for "arm-bsd-user" target in the
> latest qemu release (2.2.0). Looks like I'm out of luck on Mac for now?
>
> $ ./configure --help --enable-bsd-user
>
> Usage: configure [options]
> Options: [defaults in brackets after descriptions]
>
> Standard options:
> --help print this message
> --prefix=PREFIX install in PREFIX [/usr/local]
> --interp-prefix=PREFIX where to find shared libraries, etc.
> use %M for cpu name [/usr/gnemul/qemu-%M]
> --target-list=LIST set target list (default: build everything)
> Available targets: aarch64-softmmu alpha-softmmu
> arm-softmmu cris-softmmu i386-softmmu
> lm32-softmmu
> m68k-softmmu microblaze-softmmu
> microblazeel-softmmu
> mips-softmmu mips64-softmmu mips64el-softmmu
> mipsel-softmmu moxie-softmmu or32-softmmu
> ppc-softmmu ppc64-softmmu ppcemb-softmmu
> s390x-softmmu sh4-softmmu sh4eb-softmmu
> sparc-softmmu sparc64-softmmu tricore-softmmu
> unicore32-softmmu x86_64-softmmu xtensa-softmmu
> xtensaeb-softmmu i386-bsd-user sparc-bsd-user
> sparc64-bsd-user x86_64-bsd-user
> ...
>
> --
> You received this question notification because you are an answer
> contact for GCC ARM Embedded.
>

Can you help with this problem?

Provide an answer of your own, or ask Christopher Wilson for more information if necessary.

To post a message you must log in.