CrossCompileOEClassicTutorial

From IcedTea

Revision as of 08:51, 9 January 2012 by Xerxes (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

Contents

What are OE Classic?

OpenEmbedded, OE for short are a cross compile infrastructure that can be used to build a complete root filesystem with openjdk included from scratch. OE are good to use if you want to cross-compile openjdk and make sure that you can cross-compile all the build and runtime dependencies that openjdk need as well. Many embedded Linux distributions use the openembedded recipes for all their software cross-compile needs.

"OE Classic" refers to the use of the build recipes inside the http://cgit.openembedded.org/openembedded/log/?h=org.openembedded.dev git tree for cross compilation.

OE Classic are still actively maintained but are today mostly reciving maintance updates. New features gets first tested in the new layered OE-core/meta-oe git trees.

History

The openjdk build recipes inside OE Classic was originally developed by the Jalimo project and most of the recipes have got merged into OE Classic. For more background information on Jalimo see: [1] Some addon recipes are still left in the Jalimo svn tree like maemo specific cross-compile recipes for libSWT: [2]

Preparation

The instructions on this page have been tested and found to be working, 2011-05-19.

First make sure you have the following requirements: Harddrive space: about 50gig A fast internet connection: you will download about 2gig of sourcecode.

Install all dependencies of openembedded, if you are running Debian or Ubuntu then you can install them easily by executing the following command:

sudo apt-get install git python-ply python-progressbar texi2html cvs subversion gawk chrpath texinfo

On Ubuntu you will need to change /bin/sh to point to bash instead of dash, you can do this by running the following command and answer "No" if you want to use dash in the question box that gets displayed.

sudo dpkg-reconfigure dash

Now decide a place to use for openembedded with sufficient disk space

mkdir /usr/src/openembedded
cd /usr/src/openembedded

Now you will have to create your own copy of bitbake, openembedded from its various sources. The openembedded git tree are quite heavy about 500Mb in size, so be patient.

wget http://download.berlios.de/bitbake/bitbake-1.12.0.tar.gz
tar zxvf bitbake-1.12.0.tar.gz
git clone git://git.openembedded.org/openembedded org.openembedded.dev

Create your build directory

mkdir build
mkdir build/conf

Create your own local.conf A tested minimal build/conf/local.conf configuration can look like this:

vi build/conf/local.conf

# look in org.openembedded.dev/conf/distro
# for various preconfigured distro targets.
DISTRO = "angstrom-2010.x"

# look in org.openembedded.dev/conf/machine 
# for various preconfigured machine targets.
# If you want to build packages for the same architecture
# as bitbake are running on then change this to MACHINE = "native"
MACHINE = "beagleboard"

# Comment out *one* of the two lines below
#DISTRO_TYPE = "debug"
DISTRO_TYPE = "release"

#This row instructs bitbake to both create jffs2 compressed filesystems for embedded flash disks
#and tar.gz tarballs to be unpacked on removable compact flash sd cards.
IMAGE_FSTYPES = "jffs2 tar.gz "

#
# The default build uses glibc
# Uncomment the line below if you want uclibc instead of glibc
# be prepared for a lot of package breakage!
# 'uclibc' or 'glibc' or 'eglibc'
ANGSTROMLIBC = "glibc"

#
# If you enable glibc and encounter qemu-native build issues
# uncomment the line below.
ENABLE_BINARY_LOCALE_GENERATION=0

# specifies where BitBake should place the downloaded sources
DL_DIR = "${OETOP}/sources"

# specifies where BitBake should create its temporary files
TMPDIR = ${OETOP}/${MYBUILDDIR}/tmp

# specifies that BitBake should emit the log if a build fails
BBINCLUDELOGS = "yes"

# collection setup
BBFILES="${OEBRANCH}/recipes/*/*.bb ${USERBRANCH}/packages/*/*.bb"

BBFILE_COLLECTIONS="oe user" 

BBFILE_PATTERN_oe="^${OEBRANCH}/packages"
BBFILE_PATTERN_user="^${USERBRANCH}/packages"

BBFILE_PRIORITY_oe="5"
BBFILE_PRIORITY_user="15"

# Uncomment these lines to enable parallel make.
# This allows make to spawn mutliple processes to take advantage of multiple
# processors. Useful on SMP machines
PARALLEL_MAKE = "-j 4"
BB_NUMBER_THREADS = "4"

# some of the OE provided native tools are a bit buggy
# uncomment the line below if you run into build failures due to the packages listed below
# you will also need to install your distro's version of these packages on your build machine
#ASSUME_PROVIDED += "gdk-pixbuf-csource-native imagemagick-native librsvg-native


Then you have to configure your environment variables to place bitbake in your path Do this by creating a simple bash script like this:

vi run.sh

#
# Environment setup for oe
#

export MYBUILDDIR="build"

export BB_ENV_EXTRAWHITE="MACHINE DISTRO ANGSTROM_MODE OETOP OEBRANCH USERBRANCH MYBUILDDIR"

export OETOP="/usr/src/openembedded"
export OEBRANCH="${OETOP}/org.openembedded.dev"
export USERBRANCH="${OETOP}/user.collection"


export PATH="${OETOP}/bitbake-1.12.0/bin/:$PATH"
export BBPATH="${OETOP}/${MYBUILDDIR}:${USERBRANCH}:${OEBRANCH}"

umask 0002
bash
#
# end oe setup
#

now run this script before you want to build something using oe.

chmod +x run.sh

./run.sh

If you have installed and configured bitbake, created your OE configuration and ran your setup-script then CONGRATULATIONS! Now cross-compiling various configuration of IcedTea are now very easy, simply run:

bitbake openjdk-6

You can look inside the http://cgit.openembedded.org/cgit.cgi/openembedded/tree/recipes/openjdk tree to see all the bitbake targets that you can use to bitbake openjdk.

Help! the compilation using bitbake failed for some reason. Now what?

If it complains that the checksum for a downloaded file are missing then add then add the checksum to org.openembedded.dev/conf/checksums.ini or add this line to your build/conf/local.conf

OE_ALLOW_INSECURE_DOWNLOADS=1

update the fast changing org.openembedded.dev tree by running

cd org.openembedded.dev
git pull

Try restart the failing build by first cleaning it up

bitbake -c clean openjdk-6
bitbake openjdk-6

Try fix bugs by entering the interactive devshell, it will openup a terminal window with initialized build environment, from here you can run make etc and poke around like you are used to when doing manual Icedtea build.

bitbake -c devshell openjdk-6

Openembedded-uses the quilt tool to manage patches on top of the source-tree, to list all applied extra patches inside the dev-shell run:

quilt series
quilt help

Keep your sources directory! it contains all compressed source-code files and you do not want to download this again (about 2gig).

If you need more information try make your best to follow these two guides:

http://wiki.openembedded.net/index.php/Getting_started
https://wiki.evolvis.org/jalimo/index.php/Building_with_OpenEmbedded

Help! my compilation succeeded, What now?

If your builds ends with:

... NOTE: Running task 2661 of 2661 (ID: 9, /usr/src/openembedded/org.openembedded.dev/recipes/openjdk/openjdk-6_6b18-1.8.5.bb, do_build) NOTE: package openjdk-6-jre-6b18-1.8.5-r11.1: task do_build: Started NOTE: package openjdk-6-jre-6b18-1.8.5-r11.1: task do_build: Succeeded NOTE: Tasks Summary: Attempted 2661 tasks of which 0 didn't need to be rerun and 0 failed.

Then Yay, wohoo!!! jump around happy and blog about it!

You can find your created packages and image files in /usr/src/openembedded/build/tmp/deploy

You can find the compiled binarys used to make the packages in the /usr/src/openembedded/build/tmp/work/arch/openjdk-6-* directory.

How do I update the Packages.gz files so that the deploy directory can be used as a opkg .ipk feed?

bitbake -f -b org.openembedded.dev/recipes/meta/package-index.b

Personal tools