Showing posts with label toolchain. Show all posts
Showing posts with label toolchain. Show all posts

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.

Configuration

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

Build

The final step :

make

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

Clean-up generated files

make clean

Clean-up generated files + .config file deletion

make mrproper

Wednesday, March 27, 2013

ARM toolchain installation

The toolchain consists of the GNU binutils, compiler set (GCC) and debugger (Insight for Windows and Linux, GDB only for MacOS). The toolchain includes the C and C++ compilers.

Ubuntu 10.10 and above :

sudo apt-get install gcc-arm-linux-gnueabi

Ubuntu 10.04 (maintained by Linaro) :

sudo add-apt-repository ppa:linaro-maintainers/toolchain
sudo apt-get update
sudo apt-get install gcc-arm-linux-gnueabi

 
biz.