wiki:ARM_QEMU

Version 6 (modified by bennylp, 16 years ago) (diff)

--

Toolchain Directory Structure

For this tutorial, we will put the toolchain in /arm directory rather than the usual /usr/local. I prefer this approach since it's easier to manage (for example, to delete everything when things don't work or when we're finished with it, or to put it on portable drive to be carried to different system).

We'll put files related to installation in /arm/setup directory:

 /arm
  +- setup
     +- download     --> Put downloaded .tgz files here
     +- srcs         --> Unpack .tgz source files here
     +- objs         --> Build sources here

Once the toolchain is built, they'll be installed in these directories:

 /arm
  +- arm-elf
  +- bin
  +- include
  +- info
  +- lib
.. etc..

This tutorial assumes that you have write access to /arm directory.

Prepare Toolchains

Download Latest binutils, GCC, and newlib

Download latest toolchain:

  $ mkdir -p /arm/setup/download
  $ cd /arm/setup/download
  $ wget -c http://ftp.gnu.org/gnu/binutils/binutils-2.18.tar.bz2
  $ wget -c http://ftp.gnu.org/gnu/gcc/gcc-3.4.6/gcc-3.4.6.tar.bz2
  $ wget -c ftp://sources.redhat.com/pub/newlib/newlib-1.16.0.tar.gz

You will also need mkinfo from texinfo package to build the toolchain (for building the manuals etc). On Debian based system (Debian, Ubuntu, etc.) you can install it with:

  $ sudo apt-get install texinfo

Or if you're with RedHat (Fedora, etc), you can install it with:

  $ yum install texinfo

Preparing to build

Unpack archives

  $ mkdir -p /arm/setup/srcs
  $ cd /arm/setup/srcs
  $ tar xjf ../download/binutils-2.18.tar.bz2
  $ tar xjf ../download/gcc-3.4.6.tar.bz2
  $ tar xzf ../download/newlib-1.16.0.tar.gz

Build Everything

Build binutils

  $ mkdir -p /arm/setup/objs/binutils-arm
  $ cd /arm/setup/objs/binutils-arm
  $ ../../srcs/binutils-2.18/configure --target=arm-elf --prefix=/arm
  $ make
  $ make install

(if you're wondering, that will take 5 minutes on a Core2Duo 2GHz)

Update binutils Path

Before we build gcc and the rest of the toolchain, add the path to (thew newly installed) binutils.

(if you're using Bash):

  $ export PATH=/arm/bin:$PATH

Build gcc

First prepare newlib to be built along with gcc:

  $ cd /arm/setup/srcs/gcc-3.4.6
  $ ln -sd ../newlib-1.16.0/newlib .

Now lets build the beast:

  $ mkdir -p /arm/setup/objs/gcc-arm
  $ cd /arm/setup/objs/gcc-arm
  $ ../../srcs/gcc-3.4.6/configure --target=arm-elf --prefix=/arm --enable-threads \
                                  --with-cpu=arm9 --enable-languages=c,c++ \
                                  --disable-nls --with-newlib --disable-shared \
                                  --with-float=soft
  $ make
  $ make install
  $ cd ..

(if you're wondering again, that will take about 8 minutes on a Core2Duo 2GHz)

PJSIP

Build

  $ cd /your/pjproject/directory
  $ make distclean
  $ ./aconfigure --host=arm-elf --disable-floating-point --disable-sound CFLAGS='-msoft-float'
  $ make dep
  $ make

Common Problems

Link Errors Because of Floating Point Mismatch

You may get error about configure not being able to create executable, and config.log reveals error message similar to:

ERROR: foo uses hardware FP, whereas bar uses software FP

I think, this error was caused by lack of --with-float=soft when configuring gcc.