Kernel and Rootfs Build System
From BUG Wiki
Contents |
Overview
Open Embedded (OE) is a Linux distribution for small computers. It is essentially a set of python scripts and package metadata used to evaluate dependencies and build binaries. The OE community is fairly large and the number of target devices and available packages is also fairly large. Poky Linux is a reduction of the packages and target machines to a known, stable set that is well maintained. While it offers less variety than OE, it works more consistently and has clear documentation. In most cases they can be considered interchangeable as the metadata and tools (bitbake) is the same with both projects.
Further Reading
Open Embedded: http://oe.linuxtogo.org/
Poky Linux: http://www.pokylinux.org/
Embedded Linux Blog Planet: http://planet.linuxtogo.org/
Opened Hand Blog: http://labs.o-hand.com/
Some OE tips: http://www.uv-ac.de/openembedded/openembedded-11.html
OpenMoko Wiki Info: http://wiki.openmoko.org/wiki/OpenEmbedded
Setup
System Requirements
Currently we test on Gentoo and Ubuntu GNU/Linux. Support is claimed for other distros.
There is a minimal set of packages required to run OE/Poky. The system will tell you what it's missing when you run it. More information is available here.
- Ubuntu
sudo apt-get install gawk diffstat help2man texi2html texinfo build-essential subversion cvs
Also on Ubuntu, you need to switch /bin/sh so that it points to /bin/bash rather than /bin/dash:
sudo dpkg-reconfigure dash
and choose "<No>" from the menu. (dash is the default in Ubuntu, but newer versions of Poky's sanity check warn about this: Using dash as /bin/sh causes various subtle build problems, please use bash instead.).
- Fedora
yum install help2man texi2html
Install
Checkout com.buglabs.build.oe from svn.buglabs.net:
svn co svn://svn.buglabs.net/bug/trunk/com.buglabs.build.oe
You'll find a directory meta-bug which contains all the build scripts (metadata) that are BUG specific. The other directories are general Poky directories. Keeping our stuff separate helps when we need to upgrade or change out various parts.
Poky-QEMU
If you would like to use the QEMU emulator, you will need a patched version. For Debian/Ubuntu systems, add the appropriate repository to your /etc/apt/sources.list file Then
sudo apt-get update sudo apt-get upgrade sudo apt-get install poky-scripts
Build
The steps below outline how to build the standard BUG Rootfs for R1.3. If you want to add additional packages, or change some of the configurations, please see the information about Tweaking Your Build.
Preparing For a Build
Begin by setting the environment variables. This primarily means the $BBPATH, and on Ubuntu systems the mmap_min_addr
On all systems begin by setting the $BBPATH
source reinstate-build-env
On Ubuntu systems, reset mmap_min_addr to 0
sudo -i echo 0 > /proc/sys/vm/mmap_min_addr
Or you can edit /etc/sysctl.conf and change the mmap_min_addr value to 0.
BUG Kernel
You can see our kernel package in the meta-bug directory:
$ ls meta-bug/packages/linux/ linux-bug-2.6.19.2 linux-bug-2.6.24.4 linux-bug.inc linux-bug_2.6.19.2.bb linux-bug_2.6.24.4.bb
The .inc file is the base "recipe" or configuration file for the kernel. Executing bitbake with the package name will generate the kernel:
bitbake linux-bug
The binary image is available in your temp directory:
$ ls build/tmp/deploy/images/ modules-2.6.19.2-bug.tgz zImage-2.6.19.2-bug-20080528151613.bin zImage-bug.bin
Building Java
CacaoVM & GNU Classpath
This is a replacement for PhoneME, based off Java SE, it is a package provided by OpenEmbedded
Required packages on Ubuntu:
sudo apt-get install gawk diffstat help2man texi2html texinfo build-essential
Potential Problems & Their Solutions:
- ERROR: Nothing PROVIDES 'cacao' (but '[]' DEPENDS on or otherwise requires it)
- Solution: source reinstate-build-env
- Check build/conf/local.conf for
BBFILES = "\
${OEROOT}/meta/packages/*/*.bb \
${OEROOT}/meta-bug/packages/*/*.bb \
${OEROOT}/meta-oe/packages/*/*.bb \
${OEROOT}/meta-jalimo/packages/*/*.bb \
"
- ERROR: Could not inherit file classes/qt3x11.bbclass while parsing /home/kschultz/kgilmer/com.buglabs.build.oe/meta-oe/packages/qt/qt-x11-free_3.3.6.bb
- Solution: source reinstate-build-env
- ERROR: system_mmap_anonymous: mmap failed: Permission denied
- Solution:
sudo -i $echo 0 > /proc/sys/vm/mmap_min_addr
PhoneME
PhoneME is a package provided by us. It's in the meta-bug directory:
$ ls meta-bug/packages/phoneme-advanced/ phoneme-advanced-foundation_0.0.bb phoneme-advanced-personal_0.0.bb phoneme-advanced.inc
There are two recipes: foundation and personal. To build the headless JVM simply run:
bitbake phoneme-advanced-foundation
For the full Phoneme Advanced stack
bitbake phoneme-advanced-personal
Concierge
To build Java packages such as Concierge other recipies are required. Jalimo is a project that is working to bring more Java stuff into Open Embedded. We fetch it as meta-jalimo.
You should be able to build Java packages such as Concierge:
$ bitbake concierge
Execute OSGI with:
cd /opt/concierge cacao -cp concierge.jar:ch.ethz.iks.concierge.framework.jar ch.ethz.iks.concierge.framework.Framework
Complete Rootfs
The recipe that defines the root filesystem for the production bug is called:
bug-image-production
The recipie that defines the root filesystem for the testing bug is called:
bug-image-testing
They both live in the images directory in the bug metadata section:
[POKY ROOT]/meta-bug/packages/images
To build the full production root filesystem, simply run bitbake with the image name:
$ bitbake bug-image-production
Putting the Rootfs and Kernel onto your BUG
You now have several choices as to the means of deployment for your rootfs and kernel image. The latter is a touch harder to deploy, but see the Poky Deployment wiki about how to do this.
Run Kernel and Root Filesystem in QEMU
If you haven't downloaded the poky scripts for qemu, please see Downloading and Using Prebuilt Images on the poky site. The instructions there apply just to getting the tools. You'll need to set up your repositories (if you use debian) and
sudo apt-get install qemu poky-scripts
You will also want the poky/qemu kernel, as our kernel may be incompatible with qemu. Download the Kernel Image and run qemu in the form poky-qemu zImage-2.6.23-pinky-3.1-qemuarm.bin <rootfs image>
$ poky-qemu path/to/zImage-2.6.23-pinky-3.1-qemuarm.bin tmp/deploy/images/bug-image-production-bug-<date-time>.rootfs.ext2
Networking in QEMU
Off the bat you're probably going to want to get networking set up so you don't have to use the terminal and its tiny font. This is taken from the Poky Handbook...
above not tested yet with this exact config. jconnolly 02:41, 6 August 2008 (UTC)
Host Setup
On Ubuntu, Debian or similar distributions you can have the network automatically configured. You can also enable masquerading between the QEMU system and the rest of your network. To do this you need to edit /etc/network/interfaces on your host system to include:
allow-hotplug tap0
iface tap0 inet static
address 192.168.7.200
netmask 255.255.255.0
network 192.168.7.0
post-up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.7.0/24
post-up echo 1 > /proc/sys/net/ipv4/ip_forward
post-up iptables -P FORWARD ACCEPT
This ensures the tap0, created by QEMU as the virtual interface, will be up everytime you run QEMU and it will have network/internet access.
BUG emulated environment
Under emulation there are two steps to configure for internet access via tap0. The first step is to configure routing:
ifconfig eth0 up ifconfig eth0 192.168.7.200 route add default gw 192.168.7.1
The second is to configure name resolution which is configured in the /etc/resolv.conf file. The simplest solution is to copy it's content from the host machine, or pass an external dns, like 4.2.2.2
echo "nameserver 4.2.2.2">>/etc/resolv.conf
Notes and Tips
Bitbake Tips
Debugging
To see the contents of all bitbake variables:
$ bitbake -e
To run bitbake on a particular bb recipe, use
$ bitbake -b path/to/recipe.bb
This is especially helpful in debugging, as is the devshell...
To run bitbake in interactive mode (devshell):
$ bitbake [recipe name] -c devshell
phoneME SVN
There seems to be a problem with the phoneME svn and authentication sessions. To get around this you can either modify your phoneme-advanced.inc SRC_URI flag to log in using your SVN credentials:
svn://username:password@phoneme.dev.java.net/svn/phoneme/builds/phoneme_advanced-mr2-dev-${PR};module=cdc;proto=https;rev=${SVN_REV};localdir=cdc \
or log into the svn server prior to running the bitbake script. This does some svn session handling magic behind the scenes and everything works okay. More info, see here about a similar issue with the Gumstix team:
http://www.nabble.com/OpenEmbedded-and-I2C-IO-td15622831.html
QEMU & OpenVPN
There is a conflict with using qemu and openvpn simultaneously. Namely, that openvpn owns /dev/net/tun while it's running. A sample error message:
$ sudo poky-qemu tmp/deploy/images/zImage-qemuarm.bin tmp/deploy/images/poky-image-sato-bug.ext2 Warning: distccd not present, no distcc support loaded. Running qemu-system-arm using sudo... /usr/bin/qemu-system-arm -kernel tmp/deploy/images/zImage-qemuarm.bin -net nic,vlan=0 -net tap,vlan=0,ifname=tap0,script=/usr/share/poky-scripts/poky-qemu-ifup,downscript=/usr/share/poky-scripts/poky- qemu-ifdown -M versatilepb -hda tmp/deploy/images/poky-image-sato-bug.ext2 -usb -usbdevice wacom-tablet -no-reboot --append root=/dev/sda console=ttyAMA0 console=tty0 mem=64M warning: could not configure /dev/net/tun: no virtual network emulation Could not initialize device 'tap'
As a workaround, you'll have to stop openvpn
$ sudo /etc/init.d/openvpn stop $ sudo tunctl -d tap0
Letting QEMU create interface tap0. You can also change the interface that QEMU creates, probably to tap1. You'll have to do more work for that though.
