Development Toolchain for Ubuntu 9.04
This manual is written to reproduce the steps to build an ARM/AVR Tool Chain. It applies to Ubuntu 9.04 Desktop Edtion.
It describes the installation process starting from a clean Ubuntu installation. It describes the download, compilation of source packages und the needed packages of the Ubuntu distribution. Ubuntu packages may be installed with the graphical package manager Synaptics or the CLI command of apt and dpkg:
apt-cache search [expression]
sudo apt-get install [package-name]
dpkg -l [package-name]
OS Installation
Install a clean Ubuntu 9.04 Desktop Edition using ubuntu-9.04-desktop-i386.iso
Logon to GUI
Open Shell Window
Update the Ubuntu System
sudo apt-get update
sudo apt-get dist-upgrade
If you are in a VMware VM install the VMware Tools for optimization
sudo apt-get install open-vm-toolbox
For have a working compiler environment you need the meta package build-essential. For testing do dpkg -l build-essential
sudo apt-get install build-essential
Needed for makeinfo for some builts
sudo apt-get install texinfo
For the GCC crosscompiler we need libraries and headers for GMP (Gnu multiple-precision arithmetic library) and MPFR (multiple-precision floating-point computations with correct rounding). The following packages are needed: libgmp3 libgmp3-dev libgmpxx4ldbl libmpfr libmpfr-dev ( libgmp3, libmpfr already there )
sudo apt-get install libgmp3-dev
sudo apt-get install libmpfr-dev
For Insight Debugger we need libx11-dev and libncurses5-dev
sudo apt-get install libx11-dev
sudo apt-get install libncurses5-dev
The arm-elf- Toolchain
First we start creating a temp folder in our home directory, where we will download and compile our packages.
cd ~
mkdir -p temp/arm-elf/src
cd temp/arm-elf/src/
Now we must download the source tarballs for the toolchain. The arm-elf toolchain consists of the following packages, where the used version number is recommended for propper functionality. For example it is not recommended to use GCC 4.3.2 which will not work!
GCC 4.1.2: ftp://gcc.gnu.org/pub/gcc/releases/gcc-4.1.2/gcc-4.1.2.tar.bz2
Binutils 2.19: ftp://gcc.gnu.org/pub/binutils/releases/binutils-2.19.tar.bz2
Newlib 1.17: ftp://gcc.gnu.org/pub/newlib/newlib-1.17.0.tar.gz
Insight 6.8: ftp://gcc.gnu.org/pub/insight/releases/insight-6.8.tar.bz2
For downloading in a shell we use wget
wget ftp://gcc.gnu.org/pub/gcc/releases/gcc-4.1.2/gcc-4.1.2.tar.bz2
wget ftp://gcc.gnu.org/pub/binutils/releases/binutils-2.19.tar.bz2
wget ftp://gcc.gnu.org/pub/insight/releases/insight-6.8.tar.bz2
Now extract the archives
tar -xjf gcc-4.1.2.tar.bz2
tar -xjf binutils-2.19.tar.bz2
tar -xzf newlib-1.17.0.tar.gz
tar -xjf insight-6.8.tar.bz2
We now have to use full path names and architecture names for which we will use variables. These variables wont work with sudo. Therefore we use all the following commands in a root shell.
sudo -s
export target=arm-elf
export prefix=/usr/local/$target
mkdir -p $prefix/bin
export PATH=$prefix/bin:$PATH
For compiling we prepare some build dirctories.
cd ~/temp/arm-elf
mkdir -p build/binutils-2.19 build/gcc-4.1.2 build/newlib-1.17.0 build/insight-6.8
Now we start with Binutils which contains the linker. The --disable-werror flag may be unneeded depending on GCC version, since Ubuntu has a default -Wformat=2 flag, but without the compile process may stop. If you want to be more clean you may have to use same patches, hints see here
cd build/binutils-2.19
../../src/binutils-2.19/configure --prefix=$prefix --target=$target --enable-interwork --enable-multilib --with-float=soft --disable-werror
make all install
Now it is GCC. We need libraries and headers (see above): libgmp3 libgmp3-dev libgmpxx4ldbl libmpfr libmpfr-dev
First we have to compile a GCC Bootstrap compiler to build a Newlib, then build the rest of GCC.
We have to do a change in GCC source files to be able to compile mixed ARM and Thumb code
cd ~/temp/arm-elf
vi src/gcc-4.1.2/gcc/config/arm/t-arm-elf
Search for the following two lines
MULTILIB_OPTIONS = marm/mthumb
MULTILIB_DIRNAMES = arm thumb
...and complete with
MULTILIB_OPTIONS = marm/mthumb mno-thumb-interwork/mthumb-interwork
MULTILIB_DIRNAMES = arm thumb normal interwork
...and save.
cd build/gcc-4.1.2
../../src/gcc-4.1.2/configure --target=$target --prefix=$prefix --enable-interwork --enable-multilib --with-float=soft --disable-werror --enable-languages="c,c++" --with-newlib --includedir=$HOME/temp/arm-elf/src/newlib-1.17.0/newlib/libc/include --disable-nls
make all-gcc install-gcc
Now for Newlib. Use --disable-newlib-supplied-syscalls be able to define Syscall functions in NG code.
cd ~/temp/arm-elf/build/newlib-1.17.0
../../src/newlib-1.17.0/configure --target=$target --prefix=$prefix --enable-interwork --enable-multilib --with-float=soft --disable-newlib-supplied-syscalls --disable-werror
make all install
Now the rest of GCC.
cd ~/temp/arm-elf/build/gcc-4.1.2
make all install
At last the Insight Debugger as graphical frontend to gdb. We need libx11-dev and libncurses5-dev.
cd ~/temp/arm-elf/build/insight-6.8
../../src/insight-6.8/configure --target=$target --prefix=$prefix --enable-interwork --enable-multilib --with-float=soft --disable-werror
make all install
References:
http://wiki.ubuntuusers.de/GNU_ARM-Toolchain
NG Source Code Development
This part describes the SVN download, compile and flash procedure.
For fashing you may use serial connection, but you will reach problems on version updates when the ARM memory block containing configuration section differs to much and the boot process hangs. So i recommend using a JTAG interface which allows erasing of the configuration block and is much, much fater in flashing. Applicable are
- Amontec JTAGkey-Tiny
- Olimex ARM-USB-Tiny
- OpenOCD USB Embedded Projects
I am using the last one, OpenOCD USB (interface type oocdlink). Therefor you need the openocd package
sudo apt-get install openocd
Further needed for compiling libusb-dev and sharutils
sudo apt-get install libusb-dev
sudo apt-get install sharutils
For SVN access you need subversion
sudo apt-get install subversion
Get the sources from the SVN server ( You need to have a developer account! )
mkdir -p ~/svn/trunk/
cd ~/svn/trunk/
svn --username [username] checkout https://dev.uavp.ch/pw/wolferl-ng/trunk/sources
If you already have a branch in the repository
mkdir -p ~/svn/branches/[branchname]/
cd ~/svn/branches/[branchname]/
svn --username [username] checkout https://dev.uavp.ch/pw/wolferl-ng/branches/[branchname]/sources
Edit a file myconfigure file in your home directory containing the following configure line. Never mind the --with-openocd-olimex-cfg and the --with-openocd-olimex-bin parameter are used for the OpenOCD-USB adapter - it works for us. --with-isp-port describes your serial device, if you are flashing serial.
./configure --with-openocd-olimex-cfg=openocd-lpc2148-oocdlink-unix.cfg --with-openocd-olimex-bin=/usr/bin/openocd --with-toolchaindir=/usr/local/arm-elf --with-isp-port=/dev/ttyUSB0
cd ~/svn/branches/[branchname]/sources/wolferl-ng/
~/myconfigure
make dev
For serial flashing use
sudo make fc-flash-serial
For JTAG flashing
sudo make fc-flash-jtag
As terminal program for NG console you may use minicom. For serial settings use 115200 8N1 no flow control.
