Development Toolchain for Ubuntu 10.04 with GCC 4.1.2 and newlib 1.17.0
Contents
-
Development Toolchain for Ubuntu 10.04 with GCC 4.1.2 and newlib 1.17.0
- Ready to use VMware Guest OS with Ubuntu Linux & Toolchains
- OS Installation
- The arm-elf- Toolchain
-
NG Source Code Development
- Preparations for Fashing the FC Controller
- Getting the Source
- Compiling the FC Source
- Flashing the FC Controller
- Using a Terminal Programm to communicate to Shell
- Compiling the RC Source
- Flash the RC Controller
- Compiling the SB Source
- Flash the RC Controller
- Netbeans IDE
- Prepare ng-tools and qngctrl
Attention: For the ARM Toolchain the most recent working combination of binutils, gcc and newlib is the following used. We tested newer gcc and newlib versions, both could be compiled but resulting in non working NG code.
This manual is written to reproduce the steps to build an ARM/AVR Tool Chain. It applies to Ubuntu 10.04 Desktop Edtion. A ready to use VM working with VMware Player will also be availabel soon.
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]
Ready to use VMware Guest OS with Ubuntu Linux & Toolchains
You may download a Virtual Machine running with VMware Workstation 7.x or VMware Player 3.x from here: http://www2.fh-rosenheim.de/ralf.hager/ng/NG-DEV.zip
Username: ng
Password: uavp
It is ready to checkout source code, develop, compile. Flashing to the NG with USB serial or USB JTAG devices works too. Even the graphical configurarion tool "gngctrl" is slow but working.
If you want to do it all on your own, follow the instructions.
OS Installation
Install a clean Ubuntu 10.04 Desktop Edition using ubuntu-10.04-desktop-i386.iso
Logon to GUI
Open Shell Window
Ubuntu Lucid has the window buttons to the top left. If you like to change the window buttons to the top right use the command
gconftool-2 --type string --set /apps/metacity/general/button_layout "menu:minimize,maximize,close"
Update the Ubuntu System
sudo apt-get update sudo apt-get dist-upgrade
If you are using VMware Workstation 7 VM VMware display drivers should be already installed. If not, install the Open 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 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 sudo apt-get install libmpc-dev sudo apt-get install libelfg0-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.
GCC 4.1.2: ftp://ftp.gnu.org/pub/gnu/gcc/gcc-4.1.2/gcc-4.1.2.tar.bz2
Binutils 2.19.1: ftp://ftp.gnu.org/pub/gnu/binutils/binutils-2.19.1.tar.gz
Newlib 1.17: ftp://sources.redhat.com/pub/newlib/newlib-1.17.0.tar.gz
Insight 6.8: ftp://sourceware.org/pub/insight/releases/insight-6.8-1.tar.bz2
For downloading in a shell we use wget
wget ftp://ftp.gnu.org/pub/gnu/gcc/gcc-4.1.2/gcc-4.1.2.tar.bz2 wget ftp://ftp.gnu.org/pub/gnu/binutils/binutils-2.19.1.tar.gz wget ftp://sources.redhat.com/pub/newlib/newlib-1.17.0.tar.gz wget ftp://sourceware.org/pub/insight/releases/insight-6.8-1.tar.bz2
Now extract the archives
tar -xjf gcc-4.1.2.tar.bz2 tar -xzf binutils-2.19.1.tar.gz tar -xzf newlib-1.18.0.tar.gz tar -xjf insight-6.8-1.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.1 build/gcc-4.1.2 build/newlib-1.17.0 build/insight-6.8-1
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 ~/temp/arm-elf/build/binutils-2.19.1 ../../src/binutils-2.19.1/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 ~/temp/arm-elf/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 make 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-1 ../../src/insight-6.8-1/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 automake autoconf indent libusb-dev sharutils subversion avrdude gcc-avr avr-libc
Preparations for Fashing the FC Controller
For fashing you may use serial connection, but it is the slowest method (5 min). Also you may flash via JTAG Interface, which is much faster (15 - 40 sec). Third method is flashing through USB connection on the header board (8 - 15 sec), see below. Applicable JTAG interfaces 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.4.0/openocd-0.4.0.tar.gz tar xf openocd-0.4.0.tar.gz cd openocd-0.4.0 ./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 script for flashing FC code serial and with JTAG and for flashing the Bootloader serial and with JTAG.
./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-amir-ng --enable-ctrl-pt1 --enable-rc-s3d-dsl --enable-rc-mlink
Configure script for flashing FC code through USB
./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-amir-ng --enable-usb-bootloader --enable-usb-bootloader-switch --enable-ctrl-pt1 --enable-rc-s3d-dsl --enable-rc-mlink
Configure and make
chmod 755 ~/myconfigure cd ~/svn/branches/[branchname]/sources/ngos/ ~/myconfigure make all
Next time you compile you only need to do "make dev".
Flashing the FC Controller
For serial flashing use this. Adjust jumper for serial Bootstrap.
sudo make fc-flash-serial
For JTAG flashing use this.
sudo make fc-flash-jtag
For USB flashing use this. Adjust jumper for USB bootstrap. Bootloader for USB has to flashed to LPC by serial Interface before once.
sudo make bl-flash-serial
sudo make fc-flash-usb
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]/sources/rc-controller/ ./configure --enable-rc-s3d-dsl --enable-rc-mlink 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]/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 default-jre sudo sh ./netbeans-6.9.1-ml-cpp-linux.sh
Start Netbeans and import the sources
File -> New Project -> C/C++ -> Next -> Specify the folder that contais existing sources: ~/svn/branches/ralf/sources/ngos -> Finish
Do this also for
~/svn/branches/[branchname]/trunk/sources/rc-controller
~/svn/branches/[branchname]/trunk/sources/sb-controller
Prepare ng-tools and qngctrl
One possibility to configure and monitor the NG is to use the graphical application gngctrl. You have to build ng-tools to have qngctrl available. The libraries libQtOpenGL, libqwt-qt4, libSDL, lib3ds from Ubuntu and libGLC built from source are needed.
sudo apt-get install libqt4-dev libqt4-opengl-dev libqwt5-qt4-dev libsdl-image1.2-dev lib3ds-dev cd ~/temp wget http://downloads.sourceforge.net/project/glc-lib/glc-lib/GLC_lib_2.0.0/GLC_lib_src_2.0.0.zip unzip GLC_lib_src_2.0.0.zip cd GLC_lib_src_2.0.0/glc_lib qmake make all sudo make install
Using qngctrl
/usr/local/bin/qngctrl
