Basic steps used to install Tool 
chains of ARM and AVR

  1. Installing xcode $ gcc –version
  2. If the response is similar to powerpc-apple-darwin9-gcc-4.0.1 (GCC) 4.0 then GCC is already available and probably there is no need to install it again. However, if the response is -bash: gcc: command not found,,,,,,,,,, then GCC is already available and probably there is no need to install it again. However, if the response is-bash: gcc: command not found.

  1. Download tool chain sources:
$ makdir toolchain
cd toolchain

  1. Now use the following commands to download the sources.

    $ curl -O ftp://gcc.gnu.org/pub/binutils/releases/binutils-2.18.tar.bz2
    $ curl -O ftp://gcc.gnu.org/pub/gcc/releases/gcc-4.2.2/gcc-core-4.2.2.tar.bz2
    $ curl -O ftp://gcc.gnu.org/pub/gcc/releases/gcc-4.2.2/gcc-g++-4.2.2.tar.bz2
  1. `Additionally we need the C libraries, avr-libc for the AVR or newlib for the ARM platform. Get the new lib sources with
  2. To download AVR gcc lib.
  3. after downloading you have to change to file formats from Zip,gzip,tar etc. By using
    $ tar -xjf binutils-2.18.tar.bz2
    $ tar -xjf gcc-core-4.2.2.tar.bz2
    $ tar -xjf gcc-g++-4.2.2.tar.bz2
    $ tar -xjf gdb-6.7.1.tar.bz2 and $ tar -xjf avr-libc-1.6.1.tar.bz2
  4. for the AVR library or $ tar -xzf newlib-1.16.0.tar.gz

these are basic to store all the 3 lib. In toolchain folder.






Build Environment Setup

The toolchain will be built in 5 steps:

  1. Building the binary utilities.
  2. Building the compiler.
  3. Building the libraries.
  4. Rebuilding the compiler (ARM).
  5. Building the debugger.

In the second step we get different results while building for AVR or ARM. For ARM targets we are building an intermediate compiler first, which is rebuilt in step 4.

The last step, building GDB, is optional and needed for in-circuit debugging only. This requires some additional tools, which are not discussed in this document.

In all steps we are going to use the same environment. Thus, once set in the Terminal window, you need to keep the window open to preserve these settings.

First we specify the target platform:

$ export target=avr

for the AVR or

$ export target=arm-elf

for the ARM toolchain. For both targets we set

$ export prefix=/usr/local/$target

which defines the directory where the final binaries will be installed.Within this folder we need to create a bin directory in advance and add that to our PATH variable.

$ sudo mkdir -p $prefix/bin
$ export PATH=$prefix/bin:$PATH

Note, that we need root authorization to access the path /usr/local, which had been stored in the variable $prefix.

1).Building the Binary Utilities

GNU binutils is a collection of binary tools, which needs to be build first. As with all parts of the toolchain, we create a specific build directory inside the package's directory.

$ cd binutils-2.18
$ mkdir build-$target
$ cd build-$target/

The next command, which configures the build, differs slightly among targets.

For the AVR we simply use

$ ../configure --target=$target --prefix=$prefix \ --disable-nls --disable-shared --disable-threads --with-gcc --with-gnu-as --with-gnu-ld

while the ARM requires

$ ../configure --target=$target --prefix=$prefix --enable-interwork --enable-multilib \
--disable-nls --disable-shared --disable-threads --with-gcc --with-gnu-as --with-gnu-ld

When this went through without errors, we can start building and installing the binaries.

$ make
$ sudo make install
$ cd ../..

$ avr-as –version to check the AVR build or

$ arm-elf-as –version to check the ARM variant.

This should display the GNU assembler version information. If the command can't be found, check your PATH and prefix settings.



Building the Compiler

Building the ARM compiler requires a readily built library. Building the newlib library, however, requires a compiler. To solve this chicken and egg problem, we build an intermediate bootstrap compiler first, which requires the library's header files only. For the AVR, however, the final compiler is built in this step.

For both targets, create a build directory and change to it.

$ cd gcc-4.2.2
$ mkdir build-$target
$ cd build-$target/

. For the AVR use

$ ../configure --target=$target --prefix=$prefix \ --disable-nls --disable-shared --disable-threads \ --with-gcc --with-gnu-ld --with-gnu-as --with-dwarf2 \ --enable-languages=c,c++ --disable-libssp -v

The intermediate ARM compiler is configured as follows.

$ sudo ../configure --target=$target --prefix=$prefix \--disable-nls --disable-shared --disable-threads \--with-gcc --with-gnu-ld --with-gnu-as --with-dwarf2 \ --enable-languages=c,c++ --enable-interwork \--enable-multilib --with-newlib \ --with-headers=../../newlib-1.16.0/newlib/libc/include \ --disable-libssp --disable-libstdcxx-pch \ --disable-libmudflap --disable-libgomp -v


Building and installing the AVR compiler

$ make
$ sudo make install
$ cd ../..

To build and install the intermediate ARM compiler

$ mkdir -p libiberty libcpp fixincludes
$ make all-gcc
$ sudo make install-gcc
$ cd ../..

$ avr-gcc –version to test the AVR compiler or

$ arm-elf-gcc –version for the ARM compiler. T


Building the Libraries


To configure the AVR build,

$ cd avr-libc-1.6.1
$ mkdir build-$target
$ cd build-$target/
$ ../configure --prefix=$prefix --build=`../config.guess` --host=$target


To configure the ARM library.

$ cd newlib-1.16.0
$ mkdir build-$target
$ cd build-$target/
$ ../configure --target=$target --prefix=$prefix --enable-interwork --enable-multilib

Both libraries are built over here

$ make
$ sudo make install
$ cd ../..

Rebuilding the Compiler

for the ARM target.

$ cd gcc-4.2.2/build-$target
$ make
$ sudo make install
$ cd ../..

Building the Debugger


Even if we do not have all tools available for in-circuit debugging, it is a good idea to build the GNU debugger now, so it will be available later. Here are the related commands, valid for both targets:

$ cd gdb-6.7.1
$ mkdir build-$target
$ cd build-$target/
$ ../configure --target=$target --prefix=$prefix --disable-nls
$ sudo make install
$ cd ../..
In an additional step we may strip the installed binaries to save disk space and decrease load times.

$ sudo strip $prefix/bin/*
$ sudo strip $prefix/$target/bin/*
$ sudo strip $prefix/libexec/gcc/$target/4.2.2/*

Comments