Development Toolchain for Ubuntu 9.10
Contents
This manual is written to reproduce the steps to build an ARM/AVR Tool Chain. It applies to Ubuntu 9.10 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.10 Desktop Edition using ubuntu-9.10-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
If you are using VMware Workstation 7 you may alternatively use the VMware Tools that come with VMware. They install cleanly as well.
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 builds
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 (should already be installed, see above): libgmp3c2 libgmp3-dev libgmpxx4ldbl 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.
Packages needed for download and compilation libusb-dev and sharutils and subversion and avrdude (you need to have at least Version 5.8 to have ATmega328 Support) and gcc-avr and avr-libc.
sudo apt-get install libusb-dev
sudo apt-get install sharutils
sudo apt-get install subversion
sudo apt-get install avrdude
sudo apt-get install gcc-avr
sudo apt-get install avr-libc
Preparations for Fashing the FC Controller
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 faster 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 compiled from source. Get libfdti-dev and download OpenOCD Source Package and compile it.
sudo apt-get install libftdi-dev
cd ~/temp/arm-elf/src
wget http://downloads.sourceforge.net/project/openocd/openocd/0.3.1/openocd-0.3.1.tar.gz
tar xf openocd-0.3.1.tar.gz
cd openocd-0.3.1
./configure --enable-ft2232_libftdi --enable-usbprog --enable-oocd_trace
make all
sudo make install
Getting the Source
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
Compiling the FC Source
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-ftdi-unix.cfg --with-openocd-olimex-bin=/usr/local/bin/openocd --with-toolchaindir=/usr/local/arm-elf --with-isp-port=/dev/ttyUSB0 --enable-ctrl-wolferl --enable-ctrl-bh --enable-ctrl-amir --enable-ctrl-test
cd ~/svn/branches/[branchname]/trunk/sources/wolferl-ng/
~/myconfigure
make all
Next time you compile you only need to do "make dev".
Flashing the FC Controller
For serial flashing use
sudo make fc-flash-serial
For JTAG flashing
sudo make fc-flash-jtag
==== Using a Terminal Programm to communicate to Shell ====
As terminal program for NG console you may use minicom. For serial settings use 115200 8N1 no flow control.
Compiling the RC Source
cd ~/svn/branches/[branchname]/trunk/sources/rc-controller/
./configure
make all
Flash the RC Controller
I am using an USBprog from Embedded Projects as flashing device. Also supported is AVR Dragon. For USBprog you have to flash the fuses off the ATmega644p once. Than you flash the binaries.
sudo make rc-flash-fuses-usbprog
sudo make rc-flash-usbprog
Compiling the SB Source
cd ~/svn/branches/[branchname]/trunk/sources/sb-controller/
./configure
make all
Flash the RC Controller
I am using an USBprog from Embedded Projects as flashing device. Also supported is AVR Dragon. For USBprog you have to flash the fuses off the ATmega644p once. Than you flash the binaries.
sudo make sb-flash-fuses-usbprog
sudo make sb-flash-usbprog
Netbeans IDE
A useful tool for editing the source code Netbeans IDE. Download the needed Version from http://netbeans.org/downloads/. C/C++ Support is required. Also needed is Sun Java.
sudo apt-get install sun-java6-jre
sudo sh ./netbeans-6.8-ml-cpp-linux.sh
Start Netbeans and import the sources
File -> New Project -> C/C++ -> Next -> Specify the folder that contais existing sources: /home/ng/svn/branches/ralf/sources/wolferl-ng -> Finish
Do this also for
/home/ng/svn/branches/[branchname]/trunk/sources/rc-controller
/home/ng/svn/branches/[branchname]/trunk/sources/sb-controller
Compile ng-tools
sudo apt-get install libqt4-opengl-dev
sudo apt-get install libsdl-image1.2-dev
sudo apt-get install lib3ds-dev
mkdir ~/temp/qwt
cd ~/temp/qwt
svn co https://qwt.svn.sourceforge.net/svnroot/qwt/branches/qwt-5.2
cd qwt-5.2
qmake
make
sudo make install
mkdir ~/temp/GLC
cd ~/temp/GLC
wget http://downloads.sourceforge.net/project/glc-lib/glc-lib/GLC_lib_1.2.0/GLC_lib_src_1.2.0.zip
unzip GLC_lib_src_1.2.0.zip
cd GLC_lib_src_1.2.0/glc_lib
qmake
make
sudo make install
cd ~/svn/branches/[branchname]/trunk/sources/ng-tools/
./configure
