Toolchain

The toolchain is a set of binaries, system libraries and tools which allow you to build (in our case, cross-compile) u-boot and the kernel for a target platform. This will, to some limited extent, need to match the target rootfs. A large and incompatible change has taken place recently, through the Hard Float ABI. Now, two different debian and ubuntu ports are binary incompatible with each other.

= Part of distributions =

Recent (from 12.04 on)
A complete cross toolchain is available as a package, just run:

apt-get install gcc-arm-linux-gnueabihf

Older
For older versions, you need to use an external repository.

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

Debian
To install Cross-development Toolchains for Debian follow the instructions on Debian Wiki.

Note: Debian now has cross-toolchains in the archive, superseding those at emdebian.org

Currently (October 2014) only available for unstable. Backported cross-compilers for testing are available at people.debian.org/~wookey/tools/debian

Install Cross Compiler and build utilities: dpkg --add-architecture armhf apt-get update apt-get install g++-arm-linux-gnueabihf You might want additional tools for building a sunxi kernel that are not related to the cross-compiler: apt-get install build-essential git debootstrap u-boot-tools

Gentoo
The crossdev tool is the standard way of dealing with crosscompilers in Gentoo. Even though Gentoo normally uses armv7a-hardfloat-linux-gnueabi as the toolchain triplet on ARM, we can also use Debian alike arm-linux-gnueabihf variant in order to be able to use the instructions from the linux-sunxi wiki as-is (without substituting the toolchain name). Building the crosscompiler is easy: emerge crossdev crossdev --kernel =3.18 --libc =2.20-r1 --binutils =2.24-r3 --gcc =4.8.4 --genv 'USE="-fortran -mudflap -nls -openmp multilib" EXTRA_ECONF="--with-cpu=cortex-a8 --with-float=hard"' -t arm-linux-gnueabihf Any arbitrary mix of different versions of the kernel headers, glibc, binutils and gcc can be used. You can also use the -S option instead, just to use whatever is considered to be stable at the moment. But in this case the crosscompiler will be also upgraded with the regular distribution updates, which might be a bit annoying.

= Standalone =

These standalone toolchains are big tarballs which come with everything you need.

Download
Linaro has been very good at changing the location and availability of just about everything, making it very hard to keep a wiki up to date which refers to it. So the below download locations might be stale already.

Currently, the main selection page is here.

It lists the following toolchains:
 * gcc-linaro 4.5 (4.5-2012.03):
 * gcc-linaro 4.6 (4.6-2013.05):
 * gcc-linaro 4.7 (4.7-2014.06):
 * gcc-linaro 4.8 (4.8-2014.04):
 * gcc-linaro 4.9 (4.9-2014.07): (this link will go dead the quickest.)

When in doubt, try 4.7 first.

'''WARNING: Do not use the 4.8 gcc versions of the linaro toolchain to build legacy kernels (sunxi-3.4 etc.), those seem to have issues building the kernel. Use an earlier version instead.'''.

Usage
Take a gcc-linaro-. - . .tar.xz file and untar it. You will find a bin directory in there. Temporarily add it to the environment you are building from:

export PATH="$PATH":/home/user/folder/gcc-linaro-arm-linux-gnueabihf-*_linux/bin/

no hardfloat?
Recent linaro toolchains are Hard Float (hf), this will be used throughout the wiki you see something like: make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-

Replace arm-linux-gnueabihf- with arm-linux-gnueabi- if your are not using a hardfloat toolchain.

Code Sourcery
Another option is to install the Sourcery toolchain from Code Sourcery (now in Mentor Graphics). Download Code Sourcery G++ 2010 9-50 https://sourcery.mentor.com/sgpp/lite/arm/portal/release1600 (official link, email registration required)

Direct link: https://netst.org/pub/linux/ARM/CodeSourcery/arm-2010.09-50-arm-none-linux-gnueabi.bin (unofficial link)

chmod +x arm-2010.09-50-arm-none-linux-gnueabi.bin ./arm-2010.09-50-arm-none-linux-gnueabi.bin

If you are using Ubuntu, you may need to switch to use bash shell (instead of dash shell) sudo dpkg-reconfigure -plow dash     ( then choose [No], this changes from using dash shell to using bash shell )

It will now install CodeSourcery with a GUI installer

Follow default settings and do Next, Next, Next, etc…

It should install in: ~/CodeSourcery/     ( for example: /home/penguin/CodeSourcery/ )

Make sure the CodeSourcery binaries are added to your path (if your username is penguin, then this should be correct):

echo "export PATH=~/CodeSourcery/Sourcery_G++_Lite/bin:\${PATH}" >> ~/.bashrc export PATH=~/CodeSourcery/Sourcery_G++_Lite/bin:$PATH  (or you can just spawn a new terminal window to update the path) echo $PATH (make sure your path is updated)

= External links =
 * Homepage ( mentor.com )
 * Direct download ( mentor.com )