Friday, April 19, 2013

Cross-compiling for ARM

Environment settings

export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabi-

ARCH defines the architecture we're building for.
CROSS_COMPILE defines the prefix of the gnu tools to use. Full path must be set if the ARM cross-compiling tools' path is not set in environment.

Multi-threaded build

If you have a multi-core CPU, you may want to enjoy a quicker build. To do so, define the number of threads used to build your linux

alias make='make -j2'

Usually, the specified number is obtained by multiplying the number of your cpu's cores by 2.


The configuration of the kernel is saved in a file named .config

The most common way of configuring your kernel for an embedded platform is to use the default configuration for your board / CPU. These files, if they exist, are stored in /arch/<arch>/configs/. To check their availability, run :

make help

An exemple of default configuration usage :

make myboard_defconfig

This operation overwrites the .config file.

If you don't have a default configuration file, you will either find a configuration file that fits your needs on the web or customize the kernel on your own (experts only). To do so, run :

make menuconfig


The final step :


Go grab a coffee, it may take a while...

Once built, the kernel is image is in /arch/<arch>/boot/. Several output format exists (bzImage, uImage, zImage,...) so be careful when copying the kernel to your target storage. The wrong image format will simply not boot...


Clean-up generated files

make clean

Clean-up generated files + .config file deletion

make mrproper


  1. To get the number of cpu cores of your system, type this command:
    cat /proc/cpuinfo | grep cores

  2. Get your Rasperry Pi configuration file bcmrpi_defconfig for 3.8 kernel at:


Note: Only a member of this blog may post a comment.