Early in the class most of the exercises we will do will all run on the BeagleBoard. You'll be able to edit (gedit), compile (gcc) and run all on the Beagle. Later, when we start compiling the kernel [1] or the boot loader, (U-boot) you will need to cross compile on a Linux machine and copy the results to the Beagle.

The purpose of this exercise is to install all the tools needed for compiling on your host so they will be ready when you need them.

Instructions for building Ångström are given here; however there are a few changes you have to make. Here's what I did.

Tip: Run this exercise using a wired connection if you can. The Ubuntu wireless driver can be finicky, and if it stops working you'll have to restart some of this.

Install development environment v1

The step is to get the crosscompilers, etc. installed. Generally you do this install on your local copy of Linux. Some of these installs can take a long time (one took me 12 hours, slow download times), so you may want to install on a remote server that's always connected to the internet. If so, see the tips [[ | below]]

Get the setup scripts

First install git by running the following on your host computer.

host$ sudo apt-get install git-core

(Here is a nice git tutorial. Take a look at it if you want to understand the commands that follow. We'll explore it in more depth in a later exercise.)

Here you can tell it how many parallel threads to run. If you have several cores on your machine, make this number big. If you have only one core, you might be better performance setting it to 1. If you have no clue which value to pick, Gentoo users suggest 1 more than the number of cores in your computer. More details are here.

PARALLEL_MAKE sets the number "gcc" threads (same as make -j4 at compile time

BB_NUMBER_THREADS sets the number of bitbake threads, (one thread can be downloading, while another compiles)

To save you a lot of time, it is useful to disable locale generation for all but the one you need. Add this to local.conf

This will bring in all the tools you need. The config took about 3.5 minutes on my machine, update took about 1 minute.

Build a small program

Before the first time you run bitbake you need to do the following to set up the environmental variables:

host$ source ~/.oe/environment-angstromv2012.05

Take a look in the file and see what it is doing.

host$ less ~/.oe/environment-angstromv2012.05

To see if everything is ready, run the following

host$ bitbake nano

nano is a small editor. We really don't need nano, but if it can be compiled we know we have everything in place. I get the following error when I run the bitbake:

Pseudo is not present but is required, building this first before the main build
.
.
.
ERROR: Poky's config sanity checker detected a potential misconfiguration.
Either fix the cause of this error or at your own risk disable the checker (see sanity.conf).
Following is the list of potential problems / advisories:
Please install following missing utilities: diffstat,texi2html,makeinfo,cvs,svn,chrpath
ERROR: Execution of event handler 'check_sanity_eventhandler' failed

Here you see directories that contain information about various repositories that were used in pulling together all the sources used to build the kernel, u-boot, and the cross-compilers. Look around a bit an see what you can learn.

We are interested in the second directory. This is where the Angstrom build is kept, it's the 2012 version. Open Embedded can support other distributions and the software is set up so you can work with more than one distribution as the time. We're only working with Angstrom though.

The -eglibc tells us what libraries were used in making the build. We'll talk about libraries later. Look further:

I'm not sure what all of these are for, but I know the cross-compilers are kept in sysroots. Go and explore. See if you can find them. We'll work with them in a later exercise. What we want is in the work directory:

These directories contain tools based on what they work on. x86_64-linux, for example, has the tools that run on your host computer. armv7a-angstrom-linux-gnueabi has things that run on all arm processors. beagleboard-angstrom-linux-gnueabi has things that are Beagle specific, and that's where we find the kernel.

It looks like we're running the 3.2.5+ kernel. But what if you don't want the most recent kernel? You need to find the bitbake recipe for the kernel you are running. Here's how I did it, back to the host:

The find command looks for files and directories that contain the string 2.6.32, the grep command then displays only those that contain the string recipe in the name. What you find is the the name of the recipe for building the kernel we're interested in. Now all you have to do is bitbake it. Be sure the conf/local.conf file is set as described earlier so that the sources aren't deleted.

Download and Compile U-boot

While were' at it, let's get the boot loader we'll be using...

host$ bitbake u-boot

Mine took about 8 minutes.

Once installed you are ready for kernel work.

Installing on a Remote Machine

Installing the cross development tools and the kernel on a laptop is nice, but sometimes the downloads are too long for such a portable device. I've had a bitbake run some 12 hours. Another option is to use a remote machine. In my case our CSSE department has created a virtual machine with Ubuntu 12.04 installed on it.

To install on a remote machine are the same as above; However here's a couple of tips to make it easier.

First, ssh to the remote machine. Assume the machine is called csse and your login name is beagle.

local$ ssh -CX beagle@csse

You can leave the beagle@ off if you have the same login on both machine. The -C says to compress everything that's moved between the machines over the network. This is good for slow connections. The X says to pass the X11 display information to the remote machine. This way you can run graphical programs, such as gedit, on the remote machine and the graphics will display on your local machine (assuming you are running X11 on your local machine).

If you are sshing a lot check out the tip here about suspending ssh and the tip here about authorizing ssh so you don't have to enter your password every time.

Once logged on to the removed machine run

remote$ sudo apt-get install byobu

This installs byobu which is a program that lets you connect to the same shell from multiple machines. Once installed run

remote$ byobu

You'll see something like:

So what? Run a couple of commands, like ls or who, then hit F6. This will suspend your session. Now run byobu again. You'll be back in the same session. The session keeps running, even when you aren't connected.

Do you see the use?

Fire up byobu

Start a long bitbake

Once you are sure it running OK, hit F6 and go home.

From home fire up byobu and you'll see your bitbake (probably still running).

You can F6 and check on it later.

Try opening another terminal and running byobu in both terminals. You'll see the same thing in both.