Installation of the GNU tools

This page gives you help to set up the GNU crosscompiler toolchain for ARM processors.

It is assumed that you work on some unix-ish system, that is, BSD, Linux, MacOS-X or similar. If you use Microsoft® Windows®, you are on your own; my experience with that operating environment is limited to to Microsoft® Word® 1.0 and Minesweeper® on Windows® 3.1.

The process below tells you how to install the crosscompiler for a bare metal system. If you want to set up a crosscompiler for an ARM based Linux system, the process is much more involved and it is way beyond the scope of this manual.

Requirements

To set up the ARM crosscompiler toolchain, you will need the following packages to already having been installed on your system:

On a BSD or Linux system the above can usually be installed by simply telling your package manager to put them on (don't forget that you need the "development" package for gmp and mpfr). On MacOS-X it might be a little more complex than that, but a little research on the Web will help you through.

Installing cross-binutils

Download the binutils source from the FSF website or from a mirror. The following assumes that you have obtained binutils-2.20.1.tar.bz2 but the process is the same for any other version.
Unpack the source:

tar xfj binutils-2.20.1.tar.bz2

Do not go into the source directory. Create a separate build directry instead, then go there and configure binutils for arm-eabi target. If you prefer ELF over EABI, then use arm-elf instead of arm-eabi. If you have no idea what ELF and EABI are all about, you should first read ELF versus EABI at the end of this page and come back here.

mkdir build
cd build
../binutils-2.20.1/configure --target=arm-eabi

If configure did not complain about any missing packages, you can now build the binary utilities:

make

The above command should complete without error. Now you can install your crossassembler, linker, etc. Pretty much all GNU packages install in /usr/local by default, which is usually not writeable by ordinary users. So, you have to install as root, either by doing

sudo make install

or if you don't have sudo on your system, by becoming root (and, depending on your su configuration, going back to the build directory) and typing:

make install
exit

If the installaction succeeds, as it should, you should now get rid of the build directory:

cd ..
rm -rf build

Installing cross-gcc

Now that you have binutils installed, you are ready for the gcc installation.
Note that you must install binutils before you can compile gcc as it needs the already existing crossassembler and other tools to build the run-time library.
Also note that the instructions below allow you to install 4.0.x to 4.4.x versions of gcc. The 4.5.x or newer versions require additional packages, like a polyhedra library development package and alike to be installed.

Download the source rom the FSF website or from a mirror. The following assumes that you have obtained gcc-4.4.3.tar.bz2 but the process is the same for any other 4.[0-4].x version.
First, unpack the source:

tar xfj gcc-4.4.3.tar.bz2

Create a build directory and enter it:

mkdir build
cd build

Now configure to build a crosscompiler. There are a few configuration options that you have to pass. It wouldn't fit in a single line, so it is broken to multiple lines here, but it is a single command. Note that if you used arm-elf for binutils then you must use that for gcc as well.

../gcc-4.4.3/configure --target=arm-eabi --enable-interwork --disable-threads \ 
  --disable-tls --disable-libada --disable-libssp --disable-libgomp \
  --enable-languages=c

The command should finish without an error. If it complains about a package missing or being a too old revision, you will have to resolve that issue before being able to build the compiler. Assuming that configure finished successfully, you can build the crosscompiler:

make

It will take some time, several minutes (or several tens of minutes if you have some really old hardware) to complete. It should finish without any errors; although as it advances, you will see warning messages, but you can safely ignore them. When it's done, you can install it by:

sudo make install

just like you did with the binutils package. Get rid of the build directory before you forget:

cd ..
rm -rf build

To test that your install was really successful and everything is fine, you can try this:

echo 'void foo( void ) {}' > test.c
arm-elf-gcc -c test.c -o /dev/null

You should just get the prompt back, without any error messages. If that is the case, you have a working crosscompiler, you can compile the library, and of course your own stuff.

If you can not make up your mind regarding to the ELF vs. EABI issue, then you can install both, by going through the above configuration, compilation and installation procedure twice. When you are completely happy with everything, you can delete the source directories and the tarfiles:

rm -rf gcc-4.4.3* binutils-2.20.1*

ELF versus EABI

EABI stands for Embedded Application Binary Interface. It is basically a specification about register allocation, alignment rules, object sizes, calling conventions and so on. If your compiler conforms to the EABI, then the object code it generates will be usable by any other EABI compliant toolchain.

ELF stands for Executable and Link Format, a specification of how the object files and loadable executables are built. Among other things it is also an EABI, in that it specifies (most of) the conventions described by an EABI.

From your point of view both ELF and EABI are a specification of object size and alignment rules as well as register allocation and calling convention rules. Both will work. However, while they serve the same purpose, there are differences that you should be aware. Based on these differences you can make an informed decision about which one to use. The list below applies only to the 32-bit variants of ARM, for other processor architectures the rules are different!

In conclusion, as long as you don't use double and long long, EABI is more memory efficient. If you use 64-bit objects, then EABI is clearly advantageous on architectures with wide buses, caches and so on, as it will not have to split a 64-bit transfer into two 32-bit ones. On a purely 32-bit core with no caches, such as the ARM7TDMI, EABI will waste memory (and under some circumstances, execution time) if you have lots of 64-bit objects. An other factor to consider is that ELF support is vaning, gcc developers do not react too positively to arm-elf- problems, they tell you to use EABI instead.