Installation/FromScratch

From PaparazziUAV
Jump to navigation Jump to search

As with all Wiki pages, also this page is a work in progress. try to be a big help to the Paparazzi project and improve this page whenever you can. If you have a distribution different from Ubuntu which doesn't satisfy any other dependency and have instructions about compiling it, packaging it, feel free to add any reference on how to do that on this wikipage.

Intro

The goal of this page is to clarify about which version of each piece of software has to be compiled, where to find that software, patches needed to make it compile on Linux 64Bit. This includes compiling all paparazzi-dev, paparazzi-arm7 and paparazzi-bin software on a 64Bit machine, running an Ubuntu Lucid Lynx or later Linux distribution or maybe even OSX. The Text below has it's origins from http://paparazzi.enac.fr/w/index.php?title=User:Roirodriguez and the OpenUAS internal Wiki.

Paparazzi-dev packages

For Ubuntu users, you can install the following packages from standard repository. You can just copy the line(s) and paste into your terminal. But do not copy the $ sign, this symbol is just added on this page to show that it is to be pasted at a normal terminal prompt.

Ocaml and libraries

Ocaml, short for Objective Caml is the most popular variant of the Caml language. The Paparazzi GCS and some of it's tools are crafted in this language.

  • ocaml, ocaml-camlimages-devel, ocaml-lablgtk2-devel, ocaml-xml-light-devel
$ sudo aptitude install ocaml libcamlimages-ocaml lablgtk2-ocaml libxml-light-ocaml

Boa

Lightweight and high performance web server, a single-tasking HTTP server.

$ sudo aptitude install boa

Gnome canvas Library

The GnomeCanvas is an engine for structured graphics that offers a rich imaging model, high performance rendering, and a powerful, high level API. This widget can be used for flexible display of graphics and for creating interactive user interface elements.

$ sudo aptitude install libgnomecanvas2-0 libgnomecanvas2-dev

USB Library

The libusb project aims to create a library for use by user level applications to access USB devices regardless of OS. http://www.libusb.org

$ sudo aptitude install libusb-dev

Ocaml PCRE

This OCaml-library interfaces the PCRE (Perl-compatibility regular expressions) C library. it can be used for matching regular expressions which are written in Perl style.

$ sudo aptitude install libpcre-ocaml libpcre-ocaml-dev

Glade Library

Libglade is a library that performs a similar job to the C source output routines in the GLADE user interface builder. Whereas GLADE's output routines create C source code that must be compiled, libglade builds the interface from an XML file (GLADE's save format) at runtime. This can allow modifying the user interface without recompiling.

$ sudo aptitude install libglade2-0 libglade2-dev

Make

GNU Make is an utility which controls the generation of executables and other target files of a program from the program's source files.

$ sudo aptitude install make

Build essential

$ sudo aptitude install build-essential

Subversion Client

Subversion, also known as SVN, is a version control system. Version control systems allow many individuals to collaborate on the paparazzi source code. This is needed to retrieve the latest sourcecode from various packages and Paparazzi sourcecode itself.

$ sudo aptitude install subversion

GNU Plot

A command-line driven interactive plotting program. Unknow if it is used

$ sudo aptitude install gnuplot

ImageMagick

ImageMagick is a software suite to create, edit, and compose bitmap images. It can read, convert and write images in a variety of formats. Use ImageMagick to translate, flip, mirror, rotate, scale, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves. This pacage is needed for ?

$ sudo aptitude install imagemagick

Optional on an older OS

If you have an older OS distribution it never hurts to install the following...

$ sudo aptitude install libx11-6 libx11-dev texinfo flex bison libncurses5 libncurses5-dev libncursesw5 libncursesw5-dev zlibc

Building the ARM cross-toolchain

The goal of this part is to building an ARM cross-toolchain with binutils gcc newlib and gdb from source. This is needed so we can compile the code that ends up onto the autopilot board. Newlib is a C library intended for use on embedded systems. It is a conglomeration of several library parts, all under free software licenses that make them easily usable on embedded products. Enter the following on your command prompt

$ cd ~
$ nano paparazzi_from_scratch.sh

Then copy the part below (CTRL+C) and go to your terminal window again and use CTRL+SHIFT+V to paste the text into the nano editor. Afterther save the file with CTRL+X and answer Y

#!/bin/sh

# ******************************************************************************
#
# Goal: Get the ARM cross compiler, tools and libraries installed and all 
#       working on 64Bit (Linux) computer system like they should
# Version:  1.6 
# Copyright: 2010 LGPL OpenUAS http://www.openuas.org/
# Date: 20100808 00:41
# Usage: $ sh ./paparazzi_from_scratch.sh 2>&1 | tee buildlog.txt  
#        
# I want to improve this script, what can I do?
#
#  IMPR: with automatic log filename appending date like "date +%y%j%H%M%S"
#  IMPR: Set MAJOR and MINOR GCC verion in make parameter automatically
#  IMPR: Add all commands from this wikipage also to the script, so we have a 
#        full paparazzi from scratch in one script!
#
# Useful links:
# http://fun-tech.se/stm32/gcc/index.php
# http://only.mawhrin.net/~alexey/prg/lpc2103/toolchain/
# http://gcc.gnu.org/install/configure.html
# http://wiki.ubuntuusers.de/GNU_arm-toolchain
# http://gcc.gnu.org/onlinedocs/gcc-4.5.0/gcc/ARM-Options.html#ARM-Options
# http://www.hermann-uwe.de/blog/building-an-arm-cross-toolchain-with-binutils-gcc-newlib-and-gdb-from-source
# http://mcuprogramming.com/forum/arm/gnu-arm-toolchain-installer/
# http://code.google.com/p/hobbycode/source/browse/trunk/gnu-arm-installer
# http://www.ethernut.de/en/documents/cross-toolchain-osx.html
# http://paparazzi.enac.fr/w/index.php?title=User:Roirodriguez
# http://chdk.wikia.com/wiki/Gcc433
# http://chdk.wikia.com/wiki/Compiling_CHDK_under_Linux
#
# http://gcc.gnu.org/faq.html#multiple
# https://wiki.kubuntu.org/CompilerFlags
#
# Older compiler http://ubuntu-virginia.ubuntuforums.org/showthread.php?t=91596
# Replaced O_CREAT for S_IRWXU in the files where you get gcc-3.4.4/gcc/collect2.c
#
# The eBook "Definitive guide to GCC" may come in handy
#
# And if all went well, a command
#  $ arm-elf-gcc -print-multi-lib
#
# Should give the following 
#
# .;
# thumb;@mthumb
# interwork;@mthumb-interwork
# thumb/interwork;@mthumb@mthumb-interwork
#
# ******************************************************************************

# In case you want to recompile, and if you do not want to re-download the files
# to save time and bandwith set CLEANUPDOWNLOADS to N
CLEANUPDOWNLOADS="N"

TARGET=arm-elf  #Or use  TARGET=arm-none-eabi or arm_non_eabi the pararazzi makefile will figure it out
PREFIX=$HOME/arm-elf-paparazzi # Install location of the final toolchain, change this to your liking

# If you have a good reason to compile other versions, ONLY then change the version data below
BINUTILS_VERSION=2.16.1
GCC_VERSION=3.4.4
NEWLIB_VERSION=1.13.0
GDB_VERSION=6.8

#Just in case for some reason you want the latest versions a just values here
# and some more 3.4 in the rest of the script
#TARGET=arm-elf
#PREFIX=$HOME/arm-elf-latest # Install location of the final toolchain, change this to your liking
#BINUTILS_VERSION=2.20.1
#GCC_VERSION=4.4.4
#NEWLIB_VERSION=1.18.0
#GDB_VERSION=7.1

# ******************************************************************************
# * No need to change anything below this line, exept improvements             *
# ******************************************************************************

# On multicore Processor this value can speedup the compilation
if grep -q "processor" /proc/cpuinfo || grep -q "siblings" /proc/cpuinfo
then
  SPEEDUPCOMPILATION="-j "$(($( grep "processor" /proc/cpuinfo | sort -u | wc -l ) * $( grep "siblings" /proc/cpuinfo | tail -1 | cut -d: -f2 )))
else
  SPEEDUPCOMPILATION=""
fi

# Install texinfo tool
sudo apt-get install texinfo

# A GCC v3.4 64Bit install to avoid issues whil compiling the crosscompiler, native compile use would be much better
# Or, get debian packages from here http://www.openuas.org/pub/ubuntu/pool/universe/g/gcc-3.4/ or http://es.archive.ubuntu.com/ubuntu/pool/universe/g/gcc-3.4/
wget -N -c http://archive.ubuntu.com/ubuntu/pool/universe/g/gcc-3.4/gcc-3.4-base_3.4.6-8ubuntu2_amd64.deb
wget -N -c http://archive.ubuntu.com/ubuntu/pool/universe/g/gcc-3.4/cpp-3.4_3.4.6-8ubuntu2_amd64.deb
wget -N -c http://archive.ubuntu.com/ubuntu/pool/universe/g/gcc-3.4/gcc-3.4_3.4.6-8ubuntu2_amd64.deb 
# Must be installed in this order
sudo dpkg -i gcc-3.4-base_3.4.6-8ubuntu2_amd64.deb
sudo dpkg -i cpp-3.4_3.4.6-8ubuntu2_amd64.deb
sudo dpkg -i gcc-3.4_3.4.6-8ubuntu2_amd64.deb
if [ "${CLEANUPDOWNLOADS}" != "N" ]
then
  rm *.deb
fi

BINUTILS=binutils-$BINUTILS_VERSION
GCC=gcc-$GCC_VERSION
NEWLIB=newlib-$NEWLIB_VERSION
GDB=gdb-$GDB_VERSION

mkdir $PREFIX

# ** Now set the gcc and tools to be used in environment
echo 'export PATH='$PREFIX'/bin:$PATH' >> ~/.bashrc
source ~/.bashrc

rm -drf build
mkdir build

# Get and compile the BinUtils
wget -N -c http://ftp.gnu.org/gnu/binutils/$BINUTILS.tar.bz2
tar xfvj $BINUTILS.tar.bz2 
cd build
unset CFLAGS && unset LDFLAGS && unset CPPFLAGS && unset CXXFLAGS &&
CC=gcc-3.4
CXX=g++-3.4
../$BINUTILS/configure -v --target=$TARGET --prefix=$PREFIX --enable-interwork --enable-multilib --enable-shared --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-checking --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=$TARGET
make $SPEEDUPCOMPILATION CC=gcc-3.4 CXX=g++-3.4 
make CC=gcc-3.4 CXX=g++-3.4 install
cd ..
rm -rf build/* $BINUTILS
if [ "${CLEANUPDOWNLOADS}" != "N" ]
then
  rm $BINUTILS.tar.bz2
fi

# ** Get and compile GCC stuff
wget -N -c ftp://ftp.gnu.org/gnu/gcc/$GCC/$GCC.tar.bz2
tar xfvj $GCC.tar.bz2

# Set correct MULTILIB options in GCC config, by patching
ONTHFLYPATCHFILE='gcc_thumb_interwork_settings.patch'
rm -f $ONTHFLYPATCHFILE #Just to make sure
echo '--- t-arm-elf	2003-09-30 12:21:41.000000000 +0200' >> $ONTHFLYPATCHFILE
echo '+++ t-arm-elf	2010-08-07 19:17:47.000000000 +0200' >> $ONTHFLYPATCHFILE
echo '@@ -26,8 +26,8 @@' >> $ONTHFLYPATCHFILE
echo ' # MULTILIB_DIRNAMES   += 32bit 26bit' >> $ONTHFLYPATCHFILE
echo ' # MULTILIB_EXCEPTIONS += *mthumb/*mapcs-26*' >> $ONTHFLYPATCHFILE
echo ' # ' >> $ONTHFLYPATCHFILE
echo '-# MULTILIB_OPTIONS    += mno-thumb-interwork/mthumb-interwork' >> $ONTHFLYPATCHFILE
echo '-# MULTILIB_DIRNAMES   += normal interwork' >> $ONTHFLYPATCHFILE
echo '+MULTILIB_OPTIONS    += mno-thumb-interwork/mthumb-interwork' >> $ONTHFLYPATCHFILE
echo '+MULTILIB_DIRNAMES   += normal interwork' >> $ONTHFLYPATCHFILE
echo ' # MULTILIB_EXCEPTIONS += *mapcs-26/*mthumb-interwork*' >> $ONTHFLYPATCHFILE
echo ' # ' >> $ONTHFLYPATCHFILE
echo ' # MULTILIB_OPTIONS    += fno-leading-underscore/fleading-underscore' >> $ONTHFLYPATCHFILE
patch $GCC/gcc/config/arm/t-arm-elf < $ONTHFLYPATCHFILE
rm -f $ONTHFLYPATCHFILE
cd build

# IMPR "../$GCC/gcc/collect2.c" ajust the line in this file to prevent compiler error for older gcc to "redir_handle = open (redir, O_WRONLY | O_TRUNC | O_CREAT, S_IRWXU);"
unset CFLAGS && unset LDFLAGS && unset CPPFLAGS && unset CXXFLAGS &&
CC=gcc-3.4
CXX=g++-3.4
../$GCC/configure -v --enable-languages=c --prefix=$PREFIX --infodir=$PREFIX"/share/info" --mandir=$PREFIX"/share/man" --enable-interwork --enable-multilib --enable-shared --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-checking --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=$TARGET
make $SPEEDUPCOMPILATION CC=gcc-3.4 CXX=g++-3.4  all
make CC=gcc-3.4 CXX=g++-3.4 install
cd ..
# NOTE: We do not delete GCC temporary build yet, we need it once more later in this script

if [ "${CLEANUPDOWNLOADS}" != "N" ]
then
  rm $GCC.tar.bz2
fi

# Now get and compile NewLib, note that sometimes this server is to busy serving the files,
# try to get the files via an FTP client with good resume if it happens
wget -N -c --waitretry=20 http://www.openuas.org/pub/newlib/$NEWLIB.tar.gz
tar xfvz $NEWLIB.tar.gz
cd build
unset CFLAGS && unset LDFLAGS && unset CPPFLAGS && unset CXXFLAGS &&
CC=gcc-3.4
CXX=g++-3.4
../$NEWLIB/configure -v --target=$TARGET --prefix=$PREFIX --enable-interwork --enable-multilib --enable-shared --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-checking --build=x86_64-linux-gnu --host=x86_64-linux-gnu
make $SPEEDUPCOMPILATION CC=gcc-3.4 CXX=g++-3.4 
make CC=gcc-3.4 CXX=g++-3.4  install
cd ..
rm -rf build/* $NEWLIB 
if [ "${CLEANUPDOWNLOADS}" != "N" ]
then
  rm -rf $NEWLIB.tar.gz
fi

# GCC needs to be build again including the real newlib now
cd build
unset CFLAGS && unset LDFLAGS && unset CPPFLAGS && unset CXXFLAGS &&
CC=gcc-3.4
CXX=g++-3.4
../$GCC/configure -v --target=$TARGET --prefix=$PREFIX --enable-interwork --enable-multilib --enable-languages="c,c++" --with-newlib --enable-shared --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --build=x86_64-linux-gnu --host=x86_64-linux-gnu --infodir=$PREFIX"/share/info" --mandir=$PREFIX"/share/man"

make $SPEEDUPCOMPILATION CC=gcc-3.4 CXX=g++-3.4 all-gcc
make CC=gcc-3.4 CXX=g++-3.4 install-gcc
cd ..
rm -rf build/* $GCC
rm -rf build

# We need a symlink to arm-elf-gcc in /usr/bin/ the way the current paparazzi AP compile script works
# We need a better solution here then symlinks, any clues...plz improve
# Yes, helping with a better use of shell by using arm-elf wild-cards is appreciated 
PREFIXBINDIR=$PREFIX/bin
OURBINDIR=/usr/bin
#Remove old symlinks
for x in $OURBINDIR/arm-elf*; do if [ -L $x ]; then sudo rm $x; fi ; done
#Make fresh symlinks so arm tools ar found by paparazzi center
sudo ln -s $PREFIXBINDIR/arm-elf-gcc $OURBINDIR/arm-elf-gcc
sudo ln -s $PREFIXBINDIR/arm-elf-size $OURBINDIR/arm-elf-size
sudo ln -s $PREFIXBINDIR/arm-elf-objcopy $OURBINDIR/arm-elf-objcopy
sudo ln -s $PREFIXBINDIR/arm-elf-objdump $OURBINDIR/arm-elf-objdump
sudo ln -s $PREFIXBINDIR/arm-elf-nm $OURBINDIR/arm-elf-nm
sudo ln -s $PREFIXBINDIR/arm-elf-addr2line $OURBINDIR/arm-elf-addr2line
sudo ln -s $PREFIXBINDIR/arm-elf-ar $OURBINDIR/arm-elf-ar
sudo ln -s $PREFIXBINDIR/arm-elf-as $OURBINDIR/arm-elf-as
sudo ln -s $PREFIXBINDIR/arm-elf-c++filt $OURBINDIR/arm-elf-c++filt
sudo ln -s $PREFIXBINDIR/arm-elf-cpp $OURBINDIR/arm-elf-cpp
sudo ln -s $PREFIXBINDIR/arm-elf-gcc $OURBINDIR/arm-elf-gcc
sudo ln -s $PREFIXBINDIR/arm-elf-gcc-3.4.4 $OURBINDIR/arm-elf-gcc-3.4.4
sudo ln -s $PREFIXBINDIR/arm-elf-gccbug $OURBINDIR/arm-elf-gccbug
sudo ln -s $PREFIXBINDIR/arm-elf-gcov $OURBINDIR/arm-elf-gcov
sudo ln -s $PREFIXBINDIR/arm-elf-ld $OURBINDIR/arm-elf-ld
sudo ln -s $PREFIXBINDIR/arm-elf-nm $OURBINDIR/arm-elf-nm
sudo ln -s $PREFIXBINDIR/arm-elf-objcopy $OURBINDIR/arm-elf-objcopy
sudo ln -s $PREFIXBINDIR/arm-elf-objdump $OURBINDIR/arm-elf-objdump
sudo ln -s $PREFIXBINDIR/arm-elf-ranlib $OURBINDIR/arm-elf-ranlib
sudo ln -s $PREFIXBINDIR/arm-elf-readelf $OURBINDIR/arm-elf-readelf
sudo ln -s $PREFIXBINDIR/arm-elf-size $OURBINDIR/arm-elf-size
sudo ln -s $PREFIXBINDIR/arm-elf-strings $OURBINDIR/arm-elf-strings
sudo ln -s $PREFIXBINDIR/arm-elf-strip $OURBINDIR/arm-elf-strip

# If you also a want to add the debugger, Uncomen the lines here. Configure could need parameter "--disable-werror" in some cases
#wget -N -c ftp://ftp.gnu.org/gnu/gdb/$GDB.tar.bz2
#tar xfvj $GDB.tar.bz2
#cd build
#../$GDB/configure --target=$TARGET --prefix=$PREFIX --enable-interwork --enable-multilib
#make $SPEEDUPCOMPILATION
#make install
#cd ..

#rm -rf build $GDB
#if [ "${CLEANUPDOWNLOADS}" != "N" ]
#then
#  rm $GDB.tar.bz2
#fi

echo "Misterious as this scripts progress might have looked, everything is now done, hopefully without any issue"

Then run the script in a terminal window via:

$ sh ./paparazzi_from_scratch.sh 2>&1 | tee buildlog.txt

Rest of code needed

To install the rest we make a special directory "develop". You can give it another name ofcourse.

$ mkdir ~/develop

LPC21ISP

LPC21ISP is an in-circuit programming (ISP) tool for the microcontroller used on the Paparazzi autopilot boards. The lpc21isp project is hosted on sourceforge and one can find the source packages at http://sourceforge.net/projects/lpc21isp/

Get the SVN version via

$ mkdir ~/develop/lpc21isp
$ cd ~/develop/lpc21isp
$ svn co https://lpc21isp.svn.sourceforge.net/svnroot/lpc21isp lpc21

To compile go into the source directory and then do

$ cd lpc21
$ make -f Makefile clean all

To install

$ sudo cp lpc21isp /usr/bin/

IVY

IVY is a simple protocol and a set of open-source libraries and programs that allows applications to broadcast information through text messages, with a subscription mechanism based on regular expressions. The project can be found at: http://www2.tls.cena.fr/products/ivy/

In the paparazzi project, Ivy is used to send telemetry data to where ever you want.

NOTE: Do not confuse this IVY with the Apache Ivy project.

Ivy-python

The ivy-python package makes it possible to use the IVY libraries from within the Python programming language. The ivy-python package is architecture independent, so it can be downloaded from the Ubuntu or Debian paparazzi repository. However since this is the from scratch page we will to download it from the official source repository via

$ mkdir ~/develop
$ mkdir ~/develop/ivy-python/
$ cd ~/develop/ivy-python/
$ svn co http://svn.tls.cena.fr/svn/ivy/ivy-python/trunk

Now we can build and install

$ cd ~/develop/ivy-python/trunk
$ sudo ./setup.py install

Ivy-c

To be able to use IVY-c, the libraries need to be installed. Source packages of ivy-c can be downloaded via:

$ mkdir ~/develop/ivy-c
$ cd ~/develop/ivy-c
$ svn co http://svn.tls.cena.fr/svn/ivy/ivy-c/trunk

To compile

$ cd ~/develop/ivy-c/trunk/src
$ make

It is possible you get errors of the test module when compiling, just ignore the messages, it is not important for the Paparazzi project. Contact the IVY team to help them also to resolve also the testing makefile issue.

Now install the compiled libraries

$ sudo make install

Ivy-OCAML

The Ivy-ocaml is a Library that make it possible to use Ivy via de Ocaml language.

$ mkdir ~/develop
$ mkdir ~/develop/ivy-ocaml
$ cd ~/develop/ivy-ocaml/
$ svn co http://svn.tls.cena.fr/svn/ivy/ivy-ocaml/trunk

NOTE: If the above SVN repository does not work due ti API incompatibilities get the ivy-ocaml source via

$ wget http://paparazzi.enac.fr/ubuntu/dists/lucid/main/binary-i386/ivy-ocaml_1.1-10.tar.gz 

Now we need to compile the source via

$ cd ~/develop/ivy-ocaml/trunk
$ make

Compilation that doesn't work on 64bit systems, if you just run 'make'

/usr/bin/ld: civyloop.o: relocation R_X86_64_32 against `timer_cb' can not be used when making a shared object; recompile with -fPIC

That's solved by just editing the Makefile. Change the line containing

.c.o:
        $(CC) -Wall -c $(OCAMLINC) $(GLIBINC) $<

to

.c.o:
       $(CC) -Wall -c -fPIC $(OCAMLINC) $(GLIBINC) $<


TODO: File a defect to the ivy-ocam development team: A proper patch for the original sources would be one that checks if the system is a 64bit system, and if so set FPIC env variable. The following code at the beginning of the Makefile needs to be added just as it is done in the ivy-c Makefile

PERHAPS64:= $(shell uname -m | perl -ne "print /64/? '64' : ;")
ifeq ($(PERHAPS64), "64")
        FPIC=
else
        FPIC=-fPIC
endif

And then let the rule to compile all .c and .o files be like the following:

.c.o:
        $(CC) -Wall -c $(FPIC) $(OCAMLINC) $(GLIBINC) $<

Paparazzi Main sourcecode

To run the Ground control station and to be able to create airborne code for the Autopilot board and more one needs to get the Paparazzi source via

$ svn co svn://svn.savannah.nongnu.org/paparazzi/paparazzi3/trunk paparazzi3

Compilation

If you enter the sources directory and simply run make you will get the following error in an amd64 system:

cd sw/ground_segment/multimon; make PAPARAZZI_SRC=/home/roi/Codigo/paparazzi-dev/lenny_versions/paparazzi/temp PAPARAZZI_HOME=/home/roi/Codigo/paparazzi-dev/lenny_versions/paparazzi/temp
CC hdlc.c
hdlc.c:1: error: CPU you selected does not support x86-64 instruction set

This is because the code in sw/ground_segment/multimon/filter-i386.h which contains optimizations for some functions gets included and it doesn't work on amd64. filter.h says that filter-i386.h gets included if:

#ifdef ARCH_I386
#include "filter-i386.h"
#endif /* ARCH_I386 */

If we take a look to the Makefile (sw/ground_segment/multimon/Makefile):

CFLAGS          =-Wall -Wstrict-prototypes -I/usr/X11R6/include -I `ocamlc -where`
ifeq ($(DEBUG),y)
CFLAGS          +=-g -O -march=i486 -falign-loops=2 -falign-jumps=2 \
                 -falign-functions=2 -DARCH_I386
else
CFLAGS          +=-O3 -march=i486 -falign-loops=2 -falign-jumps=2 \
                 -falign-functions=2 -DARCH_I386
endif

We'll have to change it to not define ARCH_I386, not optimize for i486 and add -fPIC. So we need to leave the above lines like:

CFLAGS          =-Wall -fPIC -Wstrict-prototypes -I/usr/X11R6/include -I `ocamlc -where`
ifeq ($(DEBUG),y)
CFLAGS          +=-g -O -falign-loops=2 -falign-jumps=2 \
                 -falign-functions=2
else
CFLAGS          +=-O3 -falign-loops=2 -falign-jumps=2 \
                 -falign-functions=2
endif

Note that leaving the sources like this won't apply the optimizations if now you take the modified source and compile it in a 32bit system...

Now it will compile. run paparazzi and test it with a simulation via

$ ./paparazzi

NOTES: See also the main installation page

TIP: If you get the File "pprz.mli", line 149, characters 78-89: Error: Unbound type constructor Ivy.binding ...this happens when IVY libraries are not yet installed. How to do this, read the part on installing IVY on this page

Set the UDev rules

To be able to access the Hardware attached to your PC later on, rules must be set in your OS. By setting the correct rules a regular user can access USB and other devices, otherwise restricted for only the root user.

Cut an paste the text below


#BUS=="usb", SYSFS{serial}=="*_fbw", NAME="test_fbw", SYMLINK="paparazzi/%s{serial}", MODE="0666"

# MaxStream xbee pro box
BUS=="usb", SYSFS{product}=="MaxStream PKG-U", KERNEL=="ttyUSB*", SYMLINK+="paparazzi/xbee", GROUP="plugdev"

# bare FTDI chip without EEPROM
BUS=="usb", SYSFS{idVendor}=="0403", SYSFS{idProduct}=="6001", KERNEL=="ttyUSB*", SYMLINK+="paparazzi/serial", GROUP="plugdev"

# all (fake VID 0x7070) LPCUSB devices (access through libusb)
BUS=="usb", SYSFS{idVendor}=="7070", GROUP="plugdev"

# FTDI 2232 parallel converter / Amontec JTAG-Tiny (access through libftdi)
BUS=="usb",  SYSFS{idVendor}=="0403", SYSFS{idProduct}=="cff8", GROUP="plugdev"

# make joysticks/gamepads readable on event interface (writeable for force feedback), see input_event.sh
KERNEL=="event*", IMPORT{program}="input_event.sh %p", NAME="input/%k", GROUP="plugdev", MODE="0640"
ENV{FF_DEVICE}=="1", MODE="0660"

# FTDI UBlox direct on USB
BUS=="usb", SYSFS{idVendor}=="1546", SYSFS{idProduct}=="01a5", KERNEL=="ttyACM*", SYMLINK+="paparazzi/acm", GROUP="plugdev"

Now in a terminal

$ sudo nano /etc/udev/rules.d/91-paparazzi.rules

Past the text via CTRL+SHIFT+V and save the file via CTRL+X , that's it

The depriciated -mapcs-32 option

The option "-mapcs-32" is only available with very old tool chain versions e.g. GCC-3.3.x. More recent tool chains will either require "-mabi=apcs-gnu" (non-EABI-compliant) or "-mabi=aapcs-linux" (EABI-compliant). To have an overview of all flags go here

http://ecos.sourceware.org/docs-1.3.1/ref/gnupro-ref/arm/ARM_COMBO_ch01.html

By changing -mapcs-32 with -Wa,-mapcs-32 compilation will work with more recent compilers and we have backward compatibility with the old flag for older compilers. The option -Wa,-mapcs-32 is doing the following: -Wa,option : Pass option as an option to the assembler. If option contains commas, it is split into multiple options at the commas.

The -mapcs-32 option generates code for a processor running with a 32-bit program counter and conforming to the function calling standards for the APCS 32-bit option. If interested in depth what APCS is read the following: http://www.openuas.org/site/APCS.txt

The gcc flag -mapcs-32 was deprecated since gcc-3.4.0 and finally removed in gcc-4.0.0 which unconditionally generates 32bit ARM code. You should not need to pass this flag to the assembler either but it might not hurt for backwards compatibility with older compilers, so it's best to leave it in with the -Wa, option metho

Useful links

http://svn.savannah.gnu.org/svn/paparazzi/paparazzi3/trunk/conf/Makefile.stm32

http://wiki.ubuntuusers.de/GNU_arm-toolchain

http://gcc.gnu.org/onlinedocs/gcc-4.5.0/gcc/ARM-Options.html#ARM-Options

http://mcuprogramming.com/forum/arm/gnu-arm-toolchain-installer/

http://code.google.com/p/hobbycode/source/browse/trunk/gnu-arm-installer

http://www.ethernut.de/en/documents/cross-toolchain-osx.html

http://paparazzi.enac.fr/w/index.php?title=User:Roirodriguez

http://www.hermann-uwe.de/blog/building-an-arm-cross-toolchain-with-binutils-gcc-newlib-and-gdb-from-source