world leader in high performance signal processing
Trace: » cross_compiling

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

  • include file directories should be modified to point to those used by the Distribution. This can normally be done in the Application Makefile
  • the uClinux Distribution libraries should be used instead of glibc
  • uClibc contains most of the needed components from glibc but you may find one or two components missing. Here you have a couple of options.
    1. Rework the package source to use available library components
    2. Add the missing components to uClibc

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.

Complete Table of Contents/Topics