Skip to contentSkip to conversation

simplest recipe for running yocto qemu images?

DISCUSSION Robert P. J. Day 2 participants 6 messages Mar 2, 2012

lore
Share & tools
lore
#0 lore raw

i want to do a short writeup on the *simplest* recipe for how to run
the pre-built yocto qemu image you can get here:

http://downloads.yoctoproject.org/releases/yocto/yocto-1.1/machines/qemu/

and what should have been a simple procedure got a bit messy. to be clear, i want to document the absolute *least* you need to do to run a yocto-built qemu image without having to build anything since, technically, you shouldn't have to. i'm aware of the writeup in the quick start guide, but that seems like overkill based on what i'm trying to do. so here's what i just went through.

first, starting with a fresh terminal window totally unconfigured
for yocto, download a matching kernel image and rootfs; in my case, just for fun, i downloaded for arm:

* zImage-qemuarm.bin
* core-image-minimal-qemuarm.ext3

now that i have that, the obvious next step is to use the convenient
"runqemu" wrapper in my yocto directory, so i'll extend my search path:

  $ PATH=~/yocto/git/scripts:$PATH

and i'll turn on shell debugging in that "runqemu" script and test it out:

$ runqemu qemuarm \
  zImage-2.6.37-qemuarm-1.0.bin \
  core-image-minimal-qemuarm.ext3
... snip ...
/home/rpjday/yocto/git/scripts/bitbake: line 106: -e: command not found
+ TMPDIR=
+ '[' -z '' ']'
+ echo 'Error: this script needs to be run from your build directory,'
Error: this script needs to be run from your build directory,
+ echo 'or you need to explicitly set TMPDIR in your environment'
or you need to explicitly set TMPDIR in your environment
+ exit 1
$

ok, not sure why simply running a qemu image requires invoking
bitbake, but the error message looks pretty straightforward, so i'll fix that and try again:

$ TMPDIR=/tmp runqemu qemuarm \
  zImage-2.6.37-qemuarm-1.0.bin \
  core-image-minimal-qemuarm.ext3
... snip ...

/home/rpjday/yocto/git/scripts/bitbake: line 106: -e: command not found
+ TMPDIR=
+ '[' -z '' ']'
+ echo 'Error: this script needs to be run from your build directory,'
Error: this script needs to be run from your build directory,
+ echo 'or you need to explicitly set TMPDIR in your environment' or you need to explicitly set TMPDIR in your environment
+ exit 1
$

well, that appeared to solve nothing despite the fact that i did
*exactly* what the earlier diagnostic suggested. oh, wait, there's this earlier in "runqemu":

# Don't use TMPDIR from the external environment, it may be a distro

# variable pointing to /tmp (e.g. within X on OpenSUSE)
# Instead, use OE_TMPDIR for passing this in externally.
TMPDIR="$OE_TMPDIR"

grrrrrrrr. ok, let's set OE_TMPDIR instead, whereupon we make
considerably more progress until:

... snip ...
++ tap='Error: Unable to find tunctl binary in '\''/tmp/sysroots/x86_64-linux/usr/bin'\'''
++ '[' 1 -ne 0 ']'
++ sudo /home/rpjday/yocto/git/scripts/runqemu-ifup 1000 /tmp/sysroots/x86_64-linux
Error: Unable to find tunctl binary in '/tmp/sysroots/x86_64-linux/usr/bin'
++ return
$

which is actually fine since, obviously, i need to have an
appropriate sysroot directory in my PATH to pick up commands liek "tunctl" and so on. no problem -- i've installed the appropriate ARM toolchain under /opt/poky so:

$ PATH=/opt/poky/1.1/sysroots/x86_64-pokysdk-linux/usr/bin:$PATH
$ type tunctl
tunctl is /opt/poky/1.1/sysroots/x86_64-pokysdk-linux/usr/bin/tunctl
$

all right, away we go again:

$ OE_TMPDIR=/tmp runqemu \
  qemuarm zImage-2.6.37-qemuarm-1.0.bin \
  core-image-minimal-qemuarm.ext3
... snip ...
/home/rpjday/yocto/git/scripts/bitbake: line 106: -e: command not found
Error: this script needs to be run from your build directory,
or you need to explicitly set TMPDIR in your environment
$

wait, i thought i took care of that. oh ...

$ type runqemu
runqemu is hashed (/opt/poky/1.1/sysroots/x86_64-pokysdk-linux/usr/bin/runqemu)
$

so now i'm picking up "runqemu" from the toolchain's sysroot directory, which does *not* have the OE_TMPDIR reference, only the earlier TMPDIR one. so let's completely remove my yocto install scripts directory from my search path, and use *only* the sysroots directory:

$ PATH=/opt/poky/1.1/sysroots/x86_64-pokysdk-linux/usr/bin:$PATH
$ TMPDIR=/tmp runqemu qemuarm \
  zImage-2.6.37-qemuarm-1.0.bin \
  core-image-minimal-qemuarm.ext3
... snip ...
Setting up tap interface under sudo
+++ sudo
/opt/poky/1.1/sysroots/x86_64-pokysdk-linux/usr/bin/runqemu-ifup 1000
/tmp/sysroots/x86_64-linux
++ tap='Error: Unable to find tunctl binary in
'\''/tmp/sysroots/x86_64-linux/usr/bin'\'''
++ '[' 1 -ne 0 ']'
++ sudo
/opt/poky/1.1/sysroots/x86_64-pokysdk-linux/usr/bin/runqemu-ifup 1000
/tmp/sysroots/x86_64-linux
Error: Unable to find tunctl binary in '/tmp/sysroots/x86_64-linux/usr/bin'
++ return
$

ok, it *has* to be easier than this. quite simply, if one wants to
do nothing more than *run* one of those qemu images, there should be no need to do any building or bitbaking, should there? am i missing something hideously obvious?

rday

Signature · 7 lines
========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================
#1 lore raw
Quoted 4 lines · On Friday 02 March 2012 06:57:57 Robert P. J. Day wrote:

ok, it *has* to be easier than this. quite simply, if one wants to
do nothing more than *run* one of those qemu images, there should be no need to do any building or bitbaking, should there? am i missing something hideously obvious?

Only that we assume you *have* built the image in order to be able to use the runqemu script. If you haven't, well, you won't necessarily have some of the utilities the script looks for (e.g. tunctl). When the script looks for TMPDIR it is not looking for a temporary directory, it's looking for the TMPDIR that would have been set in your local.conf.

The runqemu script just isn't designed to be used in the way that you're trying to use it.

Cheers,
Paul

Signature · 2 lines
Paul Eggleton
Intel Open Source Technology Centre
#2 lore raw
Quoted 13 lines · Paul Eggleton
Quoted 4 lines · On Friday 02 March 2012 06:57:57 Robert P. J. Day wrote:

ok, it *has* to be easier than this. quite simply, if one wants
to do nothing more than *run* one of those qemu images, there should be no need to do any building or bitbaking, should there? am i missing something hideously obvious?

Only that we assume you *have* built the image in order to be able to use the runqemu script. If you haven't, well, you won't necessarily have some of the utilities the script looks for (e.g. tunctl). When the script looks for TMPDIR it is not looking for a temporary directory, it's looking for the TMPDIR that would have been set in your local.conf.

Quoted 2 lines

The runqemu script just isn't designed to be used in the way that you're trying to use it.

i gathered that. but is it unreasonable to suggest that this is
something that *should* be easy to do? if new users simply want to see what a yocto-generated image looks like under qemu, shouldn't there be a way to let them do that without going through an entire build?

rday

Signature · 7 lines
========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================
#3 lore raw
Quoted 5 lines · On Friday 02 March 2012 07:16:08 Robert P. J. Day wrote:

i gathered that. but is it unreasonable to suggest that this is
something that *should* be easy to do? if new users simply want to see what a yocto-generated image looks like under qemu, shouldn't there be a way to let them do that without going through an entire build?

I see what you're saying, but the problem with this is the qemu version we build is not the same as qemu that might be installed on the host machine. We apply quite a number of patches to qemu in order to support features we need (such as GL); if you allow beginners to easily use something else then it just makes support harder because certain things that normally work in the current setup will not work when the host tools are being used instead.

Cheers,
Paul

Signature · 2 lines
Paul Eggleton
Intel Open Source Technology Centre
#4 lore raw
Quoted 7 lines · Paul Eggleton
Quoted 5 lines · On Friday 02 March 2012 07:16:08 Robert P. J. Day wrote:

i gathered that. but is it unreasonable to suggest that this is
something that *should* be easy to do? if new users simply want to see what a yocto-generated image looks like under qemu, shouldn't there be a way to let them do that without going through an entire build?

Quoted 7 lines

I see what you're saying, but the problem with this is the qemu version we build is not the same as qemu that might be installed on the host machine. We apply quite a number of patches to qemu in order to support features we need (such as GL); if you allow beginners to easily use something else then it just makes support harder because certain things that normally work in the current setup will not work when the host tools are being used instead.

i briefly saw your point until i noticed that the yocto toolchain i
installed comes with qemu-system-* executables, which would take precedence over the normal host ones, so i'm still skeptical.

i'm going to mess with this a bit longer since i can't believe it
should be hard to tweak this to get it to work. no matter what happens, i'm sure i'll come out of it smarter.

rday

Signature · 7 lines
========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================
#5 lore raw

Re: simplest recipe for running yocto qemu images? [SOLVED]

In reply to Paul Eggleton
Quoted 7 lines · Paul Eggleton
Quoted 5 lines · On Friday 02 March 2012 07:16:08 Robert P. J. Day wrote:

i gathered that. but is it unreasonable to suggest that this is
something that *should* be easy to do? if new users simply want to see what a yocto-generated image looks like under qemu, shouldn't there be a way to let them do that without going through an entire build?

Quoted 7 lines

I see what you're saying, but the problem with this is the qemu version we build is not the same as qemu that might be installed on the host machine. We apply quite a number of patches to qemu in order to support features we need (such as GL); if you allow beginners to easily use something else then it just makes support harder because certain things that normally work in the current setup will not work when the host tools are being used instead.

just for fun, i addressed the only thing that was stopping me, and
that was that runqemu was looking for a slightly different sysroots directory name than the toolchain provided, so:

/opt/poky/1.1/sysroots$ sudo ln -s x86_64-pokysdk-linux/ x86_64-linux

and then ran:

$ TMPDIR=/opt/poky/1.1 runqemu qemuarm zImage-2.6.37-qemuarm-1.0.bin
core-image-minimal-qemuarm.ext3

and it worked. yes, i'm sure i'm abusing all sorts of things but, in the end, once i dug through it, it seemed fairly easy to get it to work.

rday

Signature · 7 lines
========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================