Gillius's Programming

Understanding Angstrom Bitbake Recipes

I'm getting to play with the BeagleBone, an "embedded" ARM device. The "official" image for this device contains a build of the Angstrom distribution. Angstrom itself is based on OpenEmbedded. If you want to modify or make any software for the bone, or just stay on the cutting edge and build your own images, you want to build using the bitbake system (instructions are at the bottom of this page). Once you've gone this far, you might wonder if you can extend this to build your own software. Currently I'm trying to figure it out, but the documentation is very hard to find and I wanted to share the locations of the most useful information in the hope that this helps your search. Read on for more details.

First, some information on my understanding of bitbake so far. Bitbake:

The first page you will likely find on your searching is a very minimal and out-of-date (6 years old) bitbake manual. It explains a little bit about the syntax but not a lot about how to do recipes or how it's used within OpenEmbedded. There is some information also on the OpenEmbedded wiki but also nearly non-existant. After a LOT of searching, I've come across some more useful resources:

A "hello world' C program tutorial. This is useful but it doesn't work verbatim. However bitbake/Angstrom is now, the LICENSE and LIC_FILES_CHKSUM are required. This sounds like a great QA check for them, you have to say what the license is of the software and point to an actual file with that license and confirm it with a checksum. To just do my "hello" example I created an empty LICENSE file.

LICENSE = "TEST LICENSE"
LIC_FILES_CHKSUM = "file://LICENSE;md5=d41d8cd98f00b204e9800998ecf8427e"

SRC_URI = "file://hello.c\
           file://LICENSE"

I calculated the checksum simply with the "md5sums" command line tool. Now my package built and I got an ipk in the build/tmp-angstrom_2010_x-eglibc/deploy/ipk/armv7a directory. You can copy that ipk to the BeagleBone and install it "opkg install", then run hello.

This is as far as I've gone in practice so far, I want to start building real things soon, but this shows how easy it is. Just recently I finally found some real documentation that will let me take the next step. This documentation is a little old but still seems relevant to how things appear now. I found an OpenEmbedded manual linked from the beagleboard Google Group. There are three useful parts:

One of the first things you will notice is that bitbake recipes are more declarative than imperative. If you're a Java developer familar with Ant and Maven, bitbake seems more like Maven, although the tasks are defined via imperative functions similar to make or Ant. Because of this, recipes seem very magical, for example they just set SRC_URI and then not bitbake not only knows how to obtain the source, but if patch files are included in SRC_URI then bitbake knows they should be patches applied before building, automagically. This is why documentation is very important for such a system so I hope to find a better resource for this. However, a lot of the magic variables have a default definition which you can find in the bitbake .conf files. There are 3 places you should look at when trying to figure things out:

For example, from the openembedded conf file you can see the default definition of FILES_${PN}, which shows you the standard places that bitbake searches for files to go into your main package. That's how the hello world example automagically figured out that /usr/bin/hello should be packaged up.

And finally, of course the other good place to look is by example and the multitude of .bb files in the Angstrom layers. Once some of the magical variables are deceiphered, they should become more understandable.

I hope this helps you get started on your way, as it has for me. I'm still learning this so if I'm missing things, please leave a comment.