Skip to main content

#4: Qemu Tool Chain for the Beaglebone Black

So far my adventures with the Beaglebone Black left something to be desired, so I decided to make my own ARM tool chain and try to get Fedora 20 to run properly on it.

The easiest way to prepare code for the BBB is with Qemu.  This way, one can make a native ARM system for test and debug on a fast computer and then one can simply copy the resultant programs over to the slow little BBB.

Well, that is the idea anyway.

Qemu

On a Mac, installing Qemu is an adventure in and of itself, so I eventually called it quits and rather installed it on a Fedora 20 virtual machine on the Mac - a virtual machine inside a virtual machine.  It makes my head hurt just to think about the computing contortions required underneath it all, but if it works, it works - except when it doesn't wanna...

Therefore, start here: http://www.aeronetworks.ca/2014/01/fedora-20-on-virtualbox.html

Instaling Qemu on Fedora is super simple, since it is very well supported:
# yum install qemu -y

which will install the whole catastrophe with all the different processors that Qemu can emulate.

This one liner is quite a contrast with trying to make Qemu work on a Mac.

Fedora 20 ARM on Qemu

There is a good guide on the Fedora web site on this:
https://fedoraproject.org/wiki/Architectures/ARM/HowToQemu

So, let's plod through that and see what happens.  That guide describes various ways to do it, with and without libvirt, with or without a cross compiler and so on.  It is worth scanning through the whole thing once before you start.

As is usual with Linux, something is bound to screw up spectacularly somewhere along the line.

Debugging Qemu

Some more information:
http://qemu.weilnetz.de/qemu-doc.html
http://fedoraproject.org/wiki/How_to_debug_Virtualization_problems 
http://www.aurel32.net/info/debian_arm_qemu.php

Using Qemu with libvirt

If one can get this method to work, the advantage is easy access to NAT and DHCP utilities, so connecting to the virtual machine and managing it, is more convenient.

Details here: http://wiki.libvirt.org/page/QEMUSwitchToLibvirt

We need a few more goodies:
# yum groupinstall virtualization

If you installed all of Qemu above, then this will do nothing:
# yum install qemu-system-arm
  
Start her up:
# service libvirtd start

ARM Root File System
# cd /var/lib/libvirt/images

Get it:
http://cdot.senecac.on.ca/arm/arm1.xml \
http://cdot.senecac.on.ca/arm/arm1.img.gz

That takes a while - So far, so good!

Now unzippit:
# gunzip arm1.img.gz 
# restorecon * 
# virsh define arm1.xml
error: Failed to define domain from arm1.xml
error: unsupported configuration: Unknown architecture arm

Bah, humbug...

Something is amiss here in file arm1.xml:
<vcpu>1</vcpu>
  <os>
    <type arch='arm' machine='versatileab'>hvm</type>


The problem is that "arm" is not correct.  It should be "armv7l".  So let's edit the arm1.xml file and try again:
# virsh define arm1.xml
Domain arm1 defined from arm1.xml

Cool, now we are progressing again.

SELinux

We need to loosen the access control a little bit to allow Qemu to run:
# setsebool -P virt_use_execmem 1

That takes a few seconds.

Virtual Machine Manager

Try System Tools>Virtual Machine Manager on the LXDE menu.  It should ask for the root password and then start a simple GUI with one VM called arm1.

The initial root password for the ARM VM image is fedoraarm.

As soon as I try to run the VM however, I get a monitor error and none of the available monitor types work:
Error starting domain: internal error: process exited while connecting to monitor: Error: Cirrus VGA not available

Bah, Humbug #2...

The command virsh start arm1 gives the same error, while virt-viewer arm1 brings up a dialogue with the message "waiting for guest domain to start", which really doesn't help a lot now does it?

Looking at the XML file again, there is a VNC option left to try, but for that I need a VNC viewer - sigh...
# yum install tigervnc -y
So, let's try to run the VM with a VNC server:
# virsh vncdisplay arm1
error: Domain is not running


Bah humbug #3, that error message is extremely unhelpful.

To known the exact error, look in the guest log:
# less /var/log/libvirt/qemu/arm1.logError: Cirrus VGA not available
2014-04-26 12:16:04.790+0000: shutting down


So it is really just the same old problem.

After some more experimentation with the Virtual Machine Manager, I found that a combination of NIC=RTL8139Display=VNC and Video=Xen runs, but that combination is not exactly the BBB hardware.

Hmmm, maybe I spoke too soon, because the whole F20 virtual machine locked up and I had to restart it...

On a second try,  I could connect to it with TigerVNC localhost:5900 and log in as root with password fedoraarm.  So it can work, I just don't know for how long or why it died before.

Here is the proof!

So now what can I do with it?

Hmm, when I try to pause Qemu, VNC exits and the F20 virtual machine becomes unusable.  It still runs, but most things don't work and it needs to be reset.  

Cross Compiler

Normally, one would use a cross compiler to develop for an  embedded system, since compiling something on a dinky little ARM processor will chug along till the sun goes nova and few people have that much time on their hands.

A good Linux cross compiler system is available here:

In general, two versions are available using either glibc or uclibc.
However, I would like to compile natively inside Qemu just for fun.  Yes, it will be slow, but a modern umpteen Gigahertz computer should be plenty fast enough - I hope.
Anyhoo, this is supposed to be fun, for various values of pain...


Native Compiler

As with most things, this has been done before,  but not necessarily on Qemu.

Very good ARM support is available with Arch Linux:
http://archlinuxarm.org/platforms/armv7/ti/beaglebone-black

I'll probably have to abandon Fedora and work with Arch - sigh...

A whole lot more information can be had here:
This guide, while it is out of date, really explains a lot of things regarding making your own tool chain and is worth reading attentively:

To be continued!

H.

Comments

Popular posts from this blog

Parasitic Quadrifilar Helical Antenna

This article was reprinted in OSCAR News, March 2018:  http://www.amsat-uk.org If you want to receive Satellite Weather Pictures , then you need a decent antenna, otherwise you will receive more noise than picture. For polar orbit satellites, one needs an antenna with a mushroom shaped radiation pattern .  It needs to have strong gain towards the horizon where the satellites are distant, less gain upwards where they are close and as little as possible downwards, which would be wasted and a source of noise.  Most satellites are spin stabilized and therefore the antenna also needs circular polarization, otherwise the received signal will flutter as the antennas rotate through nulls. The helical antenna, first proposed by Kraus in 1948, is the natural solution to circular polarized satellite communications.  It is a simple twisted wire - there seems to be nothing to it.  Various papers have been published on helix antennas, so the operation is pretty well understood. Therefore,

Weather Satellite Turnstile Antennas for the 2 meter Band

NEC2, 2 m band, 146 MHz, Yagi Turnstile Simulation and Build This article describes a Turnstile Antenna for the 2 meter band, 146 MHz amateur satcom, 137 MHz NOAA and Russian Meteor weather satellites.  Weather satellite reception is described here .  A quadrifilar helical antenna is described here .   Engineering, is the art of making what you need,  from what you can get. Radiation Pattern of the Three Element Yagi-Uda Antenna Once one combine and cross two Yagis, the pattern becomes distinctly twisted. The right hand polarization actually becomes visible in the radiation pattern plot, which I found really cool. Radiation Pattern of Six Element Turnstile Antenna Only a true RF Geek can appreciate the twisted invisible inner beauty of a herring bone antenna... Six Element Turnstile Antenna Essentially, it is three crosses on a stick.  The driven elements are broken in the middle at the drive points.  The other elements can go straight throug

Patch Antenna Design with NEC2

The older free Numerical Electromagnetic Code version 2 (NEC2) from Lawrence Livermore Lab assumes an air dielectric.  This makes it hard (but not impossible) for a radio amateur to experiment with Printed Circuit Board Patch antennas and micro strip lines. Air Spaced Patch Antenna Radiation Pattern You could use the free ASAP simulation program , which handles thin dielectrics, you could shell out a few hundred Dollars for a copy of NEC4 , You could buy GEMACS if you live in the USA, or you could add distributed capacitors to a NEC2 model with LD cards (hook up one capacitor in the middle of each element.), but that is far too much money/trouble for most. More information on driving an array antenna can be found here: https://www.aeronetworks.ca/2019/03/driving-quad-patch-array-antenna.htm l Air Dielectric Patch   The obvious lazy solution is to accept the limitation and make an air dielectric patch antenna. An advantage of using air dielectric, is that the antenn