EBC Exercise 08a Cross-Compiling

From eLinux.org
Revision as of 23:25, 22 March 2010 by Ypolius (Talk | contribs)

Jump to: navigation, search




Step 1 - get Open Embedded metadata

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

sudo apt-get install git-core

Then run the following to load the meta data.

export OETREE="${HOME}/oe"
git clone git://git.openembedded.org/openembedded.git openembedded
cd openembedded
git checkout origin/stable/2009 -b stable/2009


Now run the following to update the metadata:

cd ${OETREE}/openembedded 
git pull


Step 2 - Installing bitbake and friends


sudo apt-get install bitbake
sudo apt-get install g++
sudo apt-get install help2man diffstat texi2html cvs texinfo subversion gawk
sudo apt-get autoremove


cd /bin
sudo mv sh sh.old
sudo ln -s bash sh

Finally edit the file /etc/sysctl.conf using:

sudo gedit /etc/sysctl.conf

Add the following at the end and save.

# This is for bitbake
vm.mmap_min_addr = 0

Now you should be ready to run bitbake.

Tools.svg Give to the community: Psyco JIT compiler


sudo apt-get install python-psyco

Step 3 - Setting up for the BeagleBoard

Now let's setup local.conf for our needs:

mkdir -p ${OETREE}/build/conf


MACHINE ?= "beagleboard" 

Also, look at this block of lines:

# Make use of SMP and fast disks


  • 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)


GLIBC_GENERATE_LOCALES = "en_US.UTF-8 en_GB.UTF-8 de_DE.UTF-8 fr_FR.UTF-8 pt_BR.UTF-8 es_ES.UTF-8 kn_IN.UTF-8 ml_IN.UTF-8 ta_IN.UTF-8"

Step 4 - Start building

We need to create a small script to setup the environment

cd ${OETREE}
wget -c http://www.angstrom-distribution.org/files/source-me.txt
  • Take a second to read the script, and notice that it configures a download directory, a build directory, and a staging directory. Can you explain why ${PATH} is modified in this script?

Now we are almost ready for compiling

#Go to the OpenEmbedded folder
cd ${OETREE}/openembedded 

#Make sure it's up to date
git pull --rebase

#Set environment variables
cd ${OETREE}
source source-me.txt 

#Start building
bitbake nano


We'll use this data to see what the best settings are.
Initial bitbake nano runtime
Processor Settings Run Time
Intel Pentium-M@2.0Ghz PARALLEL_MAKE = "-j1"
Psyco? Yes.
4.9 hours
Intel Atom N330@1.6Ghz PARALLEL_MAKE = "-j4"
Psyco? No.
3.15 hours
Intel Core2Quad Q9300@2.5Ghz PARALLEL_MAKE = "-j5"
Psyco? No.
44 minutes
Intel Core2Quad Q9300@2.5Ghz PARALLEL_MAKE = "-j8"
Psyco? No.
17 minutes
T2600@2.16 GHz PARALLEL_MAKE = "-j4"
Psyco? Yes.
All Locals
2.5 hours
T2600@2.16 GHz PARALLEL_MAKE = "-j4"
Psyco? Yes.
US Only
73 minutes
E8400@3.00 GHz PARALLEL_MAKE = "-j4"
Psyco? No.
All Locals 1.4 hours
US only 43 Minutes
Psyco? No.
56.08 minutes
Psyco? No.
57.83 minutes
Psyco? No.
53.86 minutes
Psyco? No.
61.75 minutes
Core 2 Duo
Psyco? No (64-bit).

Step 5 - Building a complete image


bitbake console-image



locate image | grep /oe/


Step 6 - Loading your SD card




  • Rename uImage-beagleboard.bin as uImage and load on your SD as before (ECE597 Getting your Beagle running (precompiled)).
  • Boot and explore. What's there? What's missing?

Congratulations you've just build Linux from source. Try this:

beagleboard login: root
root@beagleboard:~# cd /sys/class
root@beagleboard:/sys/class# ls -F
bdi/          hwmon/        misc/         scsi_generic/ usb_device/
block/        i2c-adapter/  mmc_host/     scsi_host/    usb_endpoint/
bluetooth/    i2c-dev/      mtd/          sound/        usb_host/
bmi/          ieee80211/    net/          spi_master/   usbmon/
display/      input/        regulator/    spidev/       vc/
firmware/     leds/         rtc/          thermal/      vtconsole/
gpio/         mdio_bus/     scsi_device/  tty/
graphics/     mem/          scsi_disk/    ubi/


root@beagleboard:/sys/class# cd leds/
beagleboard::usr0@ beagleboard::usr1@
none nand-disk mmc0 mmc1 [heartbeat]




Step 7 - Building a complete Beagle demo image


time bitbake beagle????-image


If you're having trouble with Gimp and/or gnumeric, consult ECE597 OpenEmbedded Issues and Problem_Solving.

Step 7.5 Building a complete unstable Beagle demo image

I did not have as much luck getting Ångström working in the stable OE branch, but I was able to make dev work. You should see that there are two branches available to to choose from.

$ git branch
* stable/2009

So switch to the .dev branch by saying

$ git checkout org.openembedded.dev
$ git pull # may not be needed

The OE dev branch does not ship with its own version of bitbake, so you will need to obtain bitbake from another source. Compiling from the OE dev branch seems to require an up-to-date version of bitbake. Install this by running

$ cd ${OETREE}
$ tar -xvf bitbake-1.8.18.tar.gz

This will download and unpack version 1.8.18 of bitbake. Currently, this version seems to work well with the OE dev branch. You must now edit the path that points to bitbake in the source-me.txt file so that it will point to the directory containing this version of bitbake. You should change the line containing


to the following:


NOTE: If you have modified the GLIBC_GENERATE_LOCALES setting in ${OETREE}/build/conf/local.conf to contain only en_US.UTF-8, your build may fail due to missing required locales. You should have this set to GLIBC_GENERATE_LOCALES = "en_US.UTF-8 en_GB.UTF-8 de_DE.UTF-8 fr_FR.UTF-8 pt_BR.UTF-8 es_ES.UTF-8 kn_IN.UTF-8 ml_IN.UTF-8 ta_IN.UTF-8" for the build to be successful. If you local.conf file does not have a line containing GLIBC_GENERATE_LOCALES, your build still should be successful as it will, by default, include all available locales, including those mentioned above. Can you figure out where this list of locals came from?

We must now wipe out our stable build directory, as the two branches are not compatible. (Feel free to make a backup if you feel inclined).

$ rm -rf ${OETREE}/angstrom-dev/

Now you may follow the directions above by running

$ time bitbake beagle????-image

This will take a VERY long time, as it must recompile everything that was done previously. On my E8400 it took 10.4 hours to run with all locales, and 9.3 hours with only the ones I needed. It also used 17gb of space.

Once it has finished take a look in

$ ls ${OETREE}/angstrom-dev/deploy/glibc/images/beagleboard

You should recognize the files from when you previously installed Angstrom, if not re-read ECE597_Getting_your_Beagle_running_(precompiled)

The first boot of my beagle took a very long time...a few minutes (subsequent boots are faster), the beagle will hang on the below screen for a while, just let it go and it will continue.

INIT: version 2.86 booting
Error. Cannot create canvas. Abort.

I also saw a lot of these errors, again you can probably ignore them. (if you can figure out how to fix, post fix here)

Cannot find fifo at /mnt/.splash/exquisite.