SDK/Toolchain/Application Developer Toolkit

From Openembedded.org
Revision as of 18:14, 22 December 2010 by Bgamari (talk | contribs)
Jump to navigation Jump to search

Along with recipes for building a compiler for internal its own use, OpenEmbedded has recipes to create a full cross-compiler environment for the host. First, you need to have a working OpenEmbedded environment (see Getting_started). Note that throughout this article we will use the example of working on the ARM architecture. While particular file names may differ in your case, the general process should be similar. To build the cross-compiler, build the meta-toolchain recipe,

$ bitbake meta-toolchain

This will produce a tarball in a subdirectory of deploy/sdk. This tarball includes compiler executables, libraries, and core headers, as well as a small environment script, all under the prefix of usr/local/angstrom. To install this tarball, simply untar into /,

$ tar -C / -pxvjf $SDK_ROOT/sdk- 

To cross-compile a package for your target platform, simply source the provided environment-setup script and compile as usual,

$ source /usr/local/angstrom/arm/environment-setup
$ make

Note that the meta-toolchain environment does not include any of the libraries included in your target image.

Cross-compiling the kernel

Because of the self-contained nature of the kernel, one must proceed slightly differently than with cross-compiling user-mode software. Namely, one must not use the environment-setup script provided with meta-toolchain. This script modifies environment required by the host compiler used to compile tools used during the build process, resulting in difficult to trace errors.[1][2]

Instead, one simply must pass the target architecture and the cross-compiler executable name prefix to Kbuild,

$ cd linux-2.6
$ export ARCH=arm
$ export CROSS_COMPILE=/usr/local/angstrom/arm/bin/
$ make menuconfig
$ make 

The kernel Makefile also contains useful rules for packing the kernel image and modules into a tarball, for easy installation on the target,

$ make