Table of Contents

Cross Compiling

Cross compiling refers to compiling source code on one platform (e.g. Linux x86 desktop) for execution on another platform (e.g. Blackfin). Because the target hardware is different, the standard gcc toolchain for x86 Linux cannot be used; this is why the Blackfin toolchain is required to compile U-Boot, uClinux, or any other program whose target is a Blackfin device. Information on installing the Blackfin toolchain is given in the section below.

The key to select the correct cross compiler is the fact that each system uses a unique prefix. This means that, for the Blackfin, gcc becomes bfin-elf-gcc or bfin-uclinux-gcc. The same prefix (bfin-elf-) is added to all the tools generated for the selected system. Once gcc has been invoked using a prefix it adds the same prefix to all the other toolchain components used to generate a system.

The uClinux Distribution and the Linux kernel sources use a variable CROSS_COMPILE which is defined in the config.arch file in the vendors/config/bfin directory.

Here is an example:

CROSS_COMPILE = bfin-uclinux-
CC            = $(CROSS_COMPILE)gcc $(CPUFLAGS)

Using configure

When using a configure script to set up a source package for a cross compiled system it quite often works if you define CROSS_COMPILE=bfin-uclinux- and then use the configure system. For example:

    CROSS_COMPILE=bfin-uclinux- ./configure

sometimes this is needed

    CC=bfin-uclinux-gcc ./configure

This will set up the package to be built on a development host for a cross compiled target.

Integrating External User Space Applications into the uClinux Build System

Follow the section on adding a simple Hello World application simple hello world application example

In most cases using the compiler definition and then configure will produce a system buildable for the selected targets.

You may have to consider the following points

Some source packages are designed to work as daemons and immediately use the fork system call to put themselves in the background. The fork system call is not available under uClinux since we don't have a MMU to provide memory mapping. In these cases it is often possible to remove the fork system call and run the program in the background from the shell using the & operator.


 myprog &

Other cases the fork may be replaced by a vfork call. See the living without forks page for more details.