Dirk Raffel’s Weblog

Just another WordPress.com weblog

Building a GNU ARM cross-compiler toolchain on Mac OS X

with 9 comments

I’m starting a new embedded project with ARM7 processor in March so I wanted to play around with the GNU ARM toolchain. Basically I’m interested in doing cross development on my Macbook Pro on Mac OS X, using a GCC cross compiler together with Eclipse CDT. We’ll see if that works out. 😉

So as a first step, here is how I built a GNU ARM toolchain on Mac OS X (this should be no different than building the toolchain on Linux):

First download and unpack the necessary packages: binutils, gcc, newlib and gdb.

$ mkdir ~/crossgcc && cd ~/crossgcc
$ wget ftp://sourceware.org/pub/binutils/snapshots/binutils-2.18.50.tar.bz2
$ tar jxf binutils-2.18.50.tar.bz2
$ wget http://ftp.gnu.org/pub/gnu/gcc/gcc-4.2.3/gcc-4.2.3.tar.bz2
$ tar jxf gcc-4.2.3.tar.bz2
$ wget ftp://sources.redhat.com/pub/newlib/newlib-1.16.0.tar.gz
$ tar zxf newlib-1.16.0.tar.gz
$ wget http://ftp.gnu.org/pub/gnu/gdb/gdb-6.6.tar.gz
$ tar zxf gdb-6.6.tar.gz

The installation directory should be /usr/local/crossgcc.

$ sudo mkdir /usr/local/crossgcc
$ sudo chmod 777 /usr/local/crossgcc

First we build the binutils:

$ mkdir build-binutils && cd build-binutils
$ ../binutils-2.18.50/configure --target=arm-elf \
--prefix=/usr/local/crossgcc/ 2>&1 | tee configure.log
$ make all install 2>&1 | tee make.log
$ export PATH=$PATH:/usr/local/crossgcc/bin

Build the gcc compiler with C/C++ support:

$ cd ../gcc-4.2.3
$ ln -s ../newlib-1.16.0/newlib .
$ ln -s ../newlib-1.16.0/libgloss .
$ cd ..
$ mkdir build-gcc && cd build-gcc
$ ../gcc-4.2.3/configure --target=arm-elf \
--prefix=/usr/local/crossgcc/ --with-newlib \
--with-gnu-as --with-gnu-ld --enable-languages=c,c++ 2>&1 | tee configure.log
$ make all install 2>&1 | tee make.log

Build the gdb debugger:

$ cd ..
$ mkdir build-gdb && cd build-gdb
$ ../gdb-6.6/configure --target=arm-elf --prefix=/usr/local/crossgcc/
$ make all install 2>&1 | tee make.log

Advertisements

Written by Dirk Raffel

February 22, 2008 at 3:54 pm

Posted in Embedded

9 Responses

Subscribe to comments with RSS.

  1. An alternative would be to use the MAC ports. Then just issue “sudo port install arm-elf-gcc”.

    sodabeer

    March 6, 2008 at 7:01 pm

  2. Great tut! can i use it for sparc etc?

    Thijs Burema

    July 1, 2008 at 11:13 am

  3. Hi Dirk! Newlib is fine for eCos, but with Linux on the target uClibc is better. Interestingly, cross-compiling GNU C++ for uClibc has a compile-time dependency for the library itself… so one is required to bootstrap the compiler, starting with a plain C compiler first. Just my two cents, Micha.

    micha

    November 21, 2008 at 9:37 pm

  4. Is there a difference between ARM7 and ARM9 Compiler?
    I’m trying out various builds for OLIMEX 9302 and TS-7250 boards, but none really works.
    What are your experiences? Did you get a working compiler?

    Kind Regards

    horste

    December 11, 2008 at 9:39 pm

  5. I’m trying this right now… had no success at all when compiling GCC (but I got binutils, gmp and mpfr) … hope your instructions work!!

    Glass

    January 21, 2009 at 11:32 am

  6. Oh, yes, it Works flawlessly 🙂

    Glass

    January 21, 2009 at 1:04 pm

  7. Tutorial working.

    Note that wget is no longer available under mac os X. (But you can still download it from mac ports)

    Zanrek

    February 25, 2009 at 1:45 pm

  8. […] I start, I’d like to reference this tutorial for building an ARM cross-compiler on OS X. It provided a pretty good roadmap for me as I set out on my […]

  9. I am trying to install the ARM tool chain to Eclipse on a Linux machine. I guess downloading and configuring the ARM Toolchain is the first thing I need to do.

    How do I get the compiled toochain into Eclipse??

    Aquib

    September 28, 2009 at 11:41 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: