QEMU emulation of BeagleBone and Raring

3,672 views
Skip to first unread message

garyamort

unread,
Sep 19, 2013, 6:41:45 AM9/19/13
to beagl...@googlegroups.com
While digging through Robert Nelson's omap image builder, I noticed that he's using Qemu at some point to emulate the Beagle Bone from the PC and download/install packages.

Digging through his code left me confused...  I understand he is using the qemu-arm-static executable in order to execute a sequence of commands, but he also seems to be pulling some code from linuxCnC for the emulator image, leaving me confused.

What I'd like to do is use qemu-arm-system to boot up an image close to the BeagleBoneBlack in compatibility so I can do some compilation and installation from my desktop into the image.  https://wiki.edubuntu.org/ARM/RootfsFromScratch has instructions for setting this up to a degree, but it uses a rather old distribution and kernel[using armel instead of armhf].

Checking the current netboot images for omap4, http://ports.ubuntu.com/ubuntu-ports/dists/raring/main/installer-armhf/current/images/omap4/netboot/ the image files are different and include uBoot images rather than the single vmlinuz file[though that file is available under the generic folder, http://ports.ubuntu.com/ubuntu-ports/dists/raring/main/installer-armhf/current/images/generic/netboot/]

Can someone give me a summary of how to invoke qemu-arm-system to use the latest released omap4 images from http://ports.ubuntu.com/ubuntu-ports/dists/raring/main/installer-armhf/current/images/omap4/netboot/ ?

Also, do I need to get qemu from someplace specific to get a cpu/system emulator compatible with the BeagleBone?  I'm running QEMU emulator version 1.4.0 (Debian 1.4.0+dfsg-1expubuntu4) and the cpu options are: 
Available CPUs:
 arm1026
  arm1136
  arm1136-r2
  arm1176
  arm11mpcore
  arm926
  arm946
  cortex-a15
  cortex-a8
  cortex-a8-r2
  cortex-a9
  cortex-m3
  pxa250
  pxa255
  pxa260
  pxa261
  pxa262
  pxa270-a0
  pxa270-a1
  pxa270
  pxa270-b0
  pxa270-b1
  pxa270-c0
  pxa270-c5
  sa1100
  sa1110
  ti925t
  any


Thanks in advance for any help

Robert Nelson

unread,
Sep 19, 2013, 8:22:35 AM9/19/13
to Beagle Board
On Thu, Sep 19, 2013 at 5:41 AM, garyamort <gary...@gmail.com> wrote:
> While digging through Robert Nelson's omap image builder, I noticed that
> he's using Qemu at some point to emulate the Beagle Bone from the PC and
> download/install packages.
>
> Digging through his code left me confused... I understand he is using the
> qemu-arm-static executable in order to execute a sequence of commands, but

"qemu-arm-static" != full qemu... We are just using userspace qemu arm
emulation.. Using a full virtual qemu machine was a pain in the ass
and we dropped using that directly around ubuntu lucid time frame..


> he also seems to be pulling some code from linuxCnC for the emulator image,
> leaving me confused.

"linuxCNC" is another project that utilize the omap-image-builder
infrastructure, thus many of their extra build stuff is in the repo..


>
> What I'd like to do is use qemu-arm-system to boot up an image close to the
> BeagleBoneBlack in compatibility so I can do some compilation and
> installation from my desktop into the image.
> https://wiki.edubuntu.org/ARM/RootfsFromScratch has instructions for setting
> this up to a degree, but it uses a rather old distribution and kernel[using
> armel instead of armhf].

If your going to follow that wiki, make sure to get a time machine,
everything used on the page went EOL/un-maintained 2 years ago... (i
was one of the last developers/users using it, i ended up re-writing
the useful parts in my omap-image-builder scripts, hence the
"RootStock-NG.sh" name of one script..)

Regards,

--
Robert Nelson
http://www.rcn-ee.com/

Charles Steinkuehler

unread,
Sep 19, 2013, 7:42:43 AM9/19/13
to beagl...@googlegroups.com, garyamort
On 9/19/2013 5:41 AM, garyamort wrote:
> While digging through Robert Nelson's omap image builder, I noticed that
> he's using Qemu at some point to emulate the Beagle Bone from the PC and
> download/install packages.
>
> Digging through his code left me confused... I understand he is using the
> qemu-arm-static executable in order to execute a sequence of commands, but
> he also seems to be pulling some code from linuxCnC for the emulator image,
> leaving me confused.
>
<snip>
>
> Can someone give me a summary of how to invoke qemu-arm-system to use the
> latest released omap4 images from
> http://ports.ubuntu.com/ubuntu-ports/dists/raring/main/installer-armhf/current/images/omap4/netboot/

Robert's image builder isn't actually pulling in anything from LinuxCNC,
those are hooks for my MachineKit image:

http://bb-lcnc.blogspot.com/p/machinekit_16.html

...which is built with Robert's scripts and a slightly different
configuration. Robert has pulled my changes to his scripts and left the
MachineKit configuration files as an example of how to build a custom
image. If you don't create a custom config file (based on config.in or
config.machinekit), you'll get Robert's default build of various Debian
and Ubuntu images.

As for the qemu directions, it's super simple:

Setup a root filesystem for an ARM device. You can use debootstrap to
make one from scratch (the way Robert's scripts do), or use one of the
various pre-made root filesystems.

Copy the qemu-arm-static binary into ${arm-root-fs}/usr/bin/

arm-root-fs=/path/to/arm/root/filesystem/

sudo cp $(which qemu-arm-static) ${arm-root-fs}/usr/bin/

Then all you do is:

sudo chroot ${arm-root-fs} /bin/sh

...and you're running a shell in your arm rootfs. Type uname -a and
notice you are no longer on an x86 CPU! :)

--
Charles Steinkuehler
cha...@steinkuehler.net

signature.asc

M Robinson

unread,
Nov 22, 2013, 7:47:01 PM11/22/13
to beagl...@googlegroups.com, garyamort
Slow down a bit...

Which is this? It makes me think it's the SD card image, but...I'm not flashing my real Beaglebone for this exercise!
 


Copy the qemu-arm-static binary into ${arm-root-fs}/usr/bin/

arm-root-fs=/path/to/arm/root/filesystem/

sudo cp $(which qemu-arm-static) ${arm-root-fs}/usr/bin/

Then all you do is:

sudo chroot ${arm-root-fs} /bin/sh

...and you're running a shell in your arm rootfs.  Type uname -a and
notice you are no longer on an x86 CPU!  :)


OK, this chroot procedure kind of reminds me of when my grub bootloader kept dying on me everytime I tried to "fix" it. But I'm still not sure what reference to use for building the root file system.
 
--
Charles Steinkuehler
cha...@steinkuehler.net

Boris Rybalkin

unread,
Apr 2, 2014, 6:05:31 PM4/2/14
to beagl...@googlegroups.com, garyamort
Hi,

I want to automate installation of additional packages to default BBB image without using real device.

Option 1: qemu static

Problem here I have no network:

# ping 8.8.8.8
qemu: Unsupported syscall: 184
qemu: Unsupported syscall: 184
ping: cap_get_proc: Function not implemented

Do you have network working when you build images?

Option 2: Use full VM

qemu-system-arm -M versatilepb -cpu cortex-a8 -kernel ./vmlinuz -hda BBB-eMMC-flasher-ubuntu-13.10-2014-01-24-2gb.img -m 256 -append "root=/dev/sda2 rootfstype=ext4 rw" -redir tcp:5022::22
kernel: http://ports.ubuntu.com/ubuntu-ports/dists/lucid/main/installer-armel/current/images/versatile/netboot/vmlinuz

On boot it says 'The disk drive for /boot/ubuut is not ready, press S to skip'
If I press S it boots fine and I can run my build procedure.

Do you know if that uboot can disabled/auto skipped?

For the reference my similar raspberry image builder: https://github.com/syncloud/owncloud-setup/blob/master/build-image.sh

Thanks you.

Nuno Sucena Almeida

unread,
Apr 2, 2014, 7:37:42 PM4/2/14
to beagl...@googlegroups.com
On 04/02/2014 06:05 PM, Boris Rybalkin wrote:
> roblem here I have no network:

You might want to try adding something like the following to your qemu
calling parameters:

-net nic,model=rtl8139 -net user

regards,
Nuno

--
http://aeminium.org/nuno/

Boris Rybalkin

unread,
Apr 3, 2014, 3:29:48 AM4/3/14
to beagl...@googlegroups.com
Hi,

Qemu static means you do not run vm, it is just chroot into /path/to/arm/root/filesystem
having qemu-arm-static in /path/to/arm/root/filesystem/usr/bin

You provided argument for qemu vm which is second option in my question and I have no network issues there, only uboot question.

Thanks.

Boris Rybalkin

unread,
Apr 3, 2014, 7:31:12 PM4/3/14
to beagl...@googlegroups.com
Finally I figured out: http://geek.co.il/2010/03/14/how-to-build-a-chroot-jail-environment-for-centos

losetup -o 101711872 /dev/loop0 BBB-eMMC-flasher-ubuntu-13.10-2014-02-16-2gb.img
mount /dev/loop0 image
sudo mount --bind /dev image/dev
sudo mount --bind /proc image/proc
mkdir image/run/resolvconf
cp /run/resolvconf/resolv.conf image/run/resolvconf/resolv.conf

That fixed chroot network problems.
I also decided to build new images on device (no qemu at all) in chrooted environment in "continuous integration" mode.

Thanks.
Reply all
Reply to author
Forward
0 new messages