22 April 2007

Build Your Own ARM Cross Compiler Toolchain

GNUARM is a set of open source GNU compiler for ARM microcontroller. The toolchain consists of the GNU binutils, GCC compiler set, Newlib and Insight, the graphical user interface to GNU debugger for Windows and Linux. This article will guide the building process of GNUARM toolchain only for Linux users. For Windows users, there have the installer executable EXE files already. www.scienceprog.com has a tutorial on setting up this tool on Windows environment.

Get the sources
I will demonstrate the building process for GCC-4.1 only. For the others version, you can find the GNUARM distributions files from here. Here is the list of files that are required for the installation.

  • binutils-2.17.tar.bz2 [13.1MB]

  • gcc-4.1.1.tar.bz2 [37.3MB]

  • newlib-1.14.0.tar.gz [7.61MB]

  • insight-6.5.tar.bz2 [20.4MB]


I compiled the sources code with gcc-4.1.1 on Fedora Core 6 (kernel-2.6.18). Note that I built the toolchain as root. I also wanted the arm-target stuff separate from my Linux-native stuff, so I put the toolchain in /usr/local/gnuarm.

Building Instruction
[home]# tar xvf binutils-2.17.tar.bz2
[home]# tar xvf gcc-4.1.1.tar.bz2
[home]# tar xvf newlib-1.14.0.tar.gz
[home]# tar xvf insight-6.5.tar.bz2
[home]# cd binutils-2.17
[binutils-2.17]# ./configure --target=arm-elf \
--prefix=/usr/local/gnuarm --enable-interwork --enable-multilib
[binutils-2.17]# make all install
[binutils-2.17]# export PATH="$PATH:/usr/local/gnuarm/bin"
[binutils-2.17]# cd ../gcc-4.1.1
[gcc-4.1.1]# ./configure --target=arm-elf \
--prefix=/usr/local/gnuarm --enable-interwork \
--enable-multilib --enable-languages="c,c++" \
--with-newlib --with-headers=../newlib-1.14.0/newlib/libc/include
[gcc-4.1.1]# make all-gcc install-gcc
[gcc-4.1.1]# cd ../newlib-1.14.0
[newlib-1.14.0]# ./configure --target=arm-elf \
--prefix=/usr/local/gnuarm --enable-interwork --enable-multilib
[newlib-1.14.0]# make all install
[newlib-1.14.0]# cd ../gcc-4.1.1
[gcc-4.1.1]# make all install
[gcc-4.1.1]# cd ../insight-6.5
[insight-6.5]# ./configure --target=arm-elf \
--prefix=/usr/local/gnuarm --enable-interwork --enable-multilib
[insight-6.5]# make all install

Now, I hope everthing is done. You can test by running arm-elf-gcc command in the shell.

No comments: