This guide also works on Debian GNU/Linux 7 Wheezy, when applying the following:
- replace 'sudo su -c'
- replace 'sudo'
Concerning the step 'Install native gnat-4.7', as the native Debian gcc does not contain ada, you will need to use gnatgcc instead, but doing the following
$ export CC=gnatgcc
This is based on http://arduino.ada-language.com/building-avr-gnat-for-avr-ada.html and has been updated to match Ubuntu 12.04 and to avoid building software with root priviledge.
$ sudo apt-get install build-essential libc6-dev gnat gnat-4.6 libgmp-dev bison flex libmpfr-dev libmpc-dev git texinfo zlib1g-dev
$ mkdir avrada-build
$ cd avrada-build
create file native_build_env.sh containing the content above
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
create file cross_build_env.sh containing the content above
1 2 3 4 | |
make them executable
$ chmod +x native_build_env.sh cross_build_env.sh
$ . ./native_build_env.sh
$ wget ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-4.7.0/gcc-4.7.0.tar.gz
$ tar zxf gcc-4.7.0.tar.gz
$ mkdir gcc-obj-470
$ cd gcc-obj-470
$ ../gcc-4.7.0/configure --enable-languages=c,ada --prefix=$DEST_GNAT_HOST --disable-multilib
$ make bootstrap
$ sudo su -c " . ../native_build_env.sh && make install"
$ cd ..
Create a /opt/gnat-4.7/bin/gcc-4.7 file containing the following. Replace i386-linux-gnu with the output of dpkg-architecture -qDEB_HOST_MULTIARCH
1 2 | |
Create a /opt/gnat-4.7/bin/g++-4.7 file containing the following. Replace i386-linux-gnu with the output of dpkg-architecture -qDEB_HOST_MULTIARCH
1 2 | |
Create a /opt/gnat-4.7/bin/c++-4.7 file containing the following. Replace i386-linux-gnu with the output of dpkg-architecture -qDEB_HOST_MULTIARCH
1 2 | |
Create a /opt/gnat-4.7/bin/cpp-4.7 file containing the following. Replace i386-linux-gnu with the output of dpkg-architecture -qDEB_HOST_MULTIARCH
1 2 | |
Add executable rights
$ sudo chmod +x /opt/gnat-4.7/bin/gcc-4.7 /opt/gnat-4.7/bin/g++-4.7 /opt/gnat-4.7/bin/c++-4.7 /opt/gnat-4.7/bin/cpp-4.7
$ export CC="gcc-4.7" CXX="c++-4.7" CPP="cpp-4.7"
$ . ./cross_build_env.sh
$ wget http://ftp.uni-kl.de/pub/gnu/binutils/binutils-2.20.1a.tar.bz2
$ tar jxf binutils-2.20.1a.tar.bz2
$ git clone git://git.code.sf.net/p/avr-ada/code avr-ada-code
$ cd binutils-2.20.1
$ for a in ../avr-ada-code/patches/binutils/2.20.1/*.patch;do patch -p0 < $a || fail "avr-binutils: patch $a" ; done
$ cd ..
$ mkdir binutils-obj
$ cd binutils-obj
$ ../binutils-2.20.1/configure --target=avr --program-prefix=avr- --disable-shared --disable-nls --enable-commonbfdlib=no --disable-werror --prefix=$DEST_GNAT_CROSS
$ make
$ sudo su -c ". ../cross_build_env.sh && make install"
$ cd ..
$ . ./native_build_env.sh
$ . ./cross_build_env.sh
$ mv gcc-4.7.0 gcc-4.7.0-native
$ tar zxf gcc-4.7.0.tar.gz
$ cd gcc-4.7.0
$ for a in ../avr-ada-code/patches/gcc/4.7.0/*.patch;do patch -p0 < $a;done
$ cd ..
$ mkdir avr-gcc-obj
$ cd avr-gcc-obj
$ ../gcc-4.7.0/configure --target=avr --program-prefix=avr- --disable-shared --disable-nls --disable-libssp --with-system-zlib --disable-libada --enable-languages=ada,c,c++ --enable-cpp --with-dwarf2 --enable-version-specific-runtime-libs --prefix=$DEST_GNAT_CROSS
$ sed -i -e 's/$(STAMP)/echo timestamp >/' ../gcc-4.7.0/gcc/config/avr/t-avr
$ make
$ sudo su -c ". ../native_build_env.sh && . ../cross_build_env.sh && make install"
$ cd ..
$ . ./cross_build_env.sh
$ unset CC ; unset CXX ; unset CPP
$ wget http://download.savannah.gnu.org/releases/avr-libc/avr-libc-1.8.0.tar.bz2
$ tar jxf avr-libc-1.8.0.tar.bz2
$ cd avr-libc-1.8.0
$ ./configure --host=avr --prefix=$DEST_GNAT_CROSS
$ make
$ sudo su -c ". ../cross_build_env.sh && make install"
$ cd ..
Update the path to your native gprconfig and gprbuild binaries on the corresponding make commands
$ cd avr-ada-code
$ ./configure
$ make GPRCONFIG=/opt/gnat2013/bin/gprconfig GPRBUILD=/opt/gnat2013/bin/gprbuild
$ sudo su -c ". ../native_build_env.sh && . ../cross_build_env.sh && make install_rts GPRCONFIG=/opt/gnat2013/bin/gprconfig GPRBUILD=/opt/gnat2013/bin/gprbuild"
$ cd avr/avr_lib
$ sed -i -e 's/stamp-libs: $(thread_libs)/stamp-libs:/' Makefile
$ make
$ cd ../..
$ sudo su -c ". ../cross_build_env.sh && make install_libs"
Some errors can be found during make stage. Remove the "-Werror" (warnings treated as errors) flag in avr-ada-code/avr/threads_lib.gpr.
Execute the following to setup your cross build environment:
export PATH=/opt/avrada/bin:/opt/gnat-4.7/bin:$PATH
export ADA_PROJECT_PATH=/opt/avrada/avr/lib/gnat:$ADA_PROJECT_PATH
For Arduino 2009, make the following changes in all the avr examples Makefiles (see line numbers)
35 MCU := atmega328p
46 MFLAGS = -aL/opt/avrada/avr/lib/gnat/avr_lib/$(MCU)/lib -XMCU=$(MCU) -p -P$(GPR)
61 AVRDUDE_PROGRAMMER = stk500v1
65 AVRDUDE_PORT = /dev/ttyUSB0
85 AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -b 57600
Create the file /etc/udev/rules.d/99-avrdude-usb.rules containing the following
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", SYMLINK+="ttyUSB0", GROUP="plugdev", MODE="0660"
then
$ sudo service udev restart
Make sure the current user is in the plugdev group
$ grep plugdev /etc/group
if the user is not listed, then add him
$ sudo addgroup user plugdev
Unplug (if needed), and plug the USB device, test it by doing :
$ ls -al /dev/ttyUSB0
crw-rw---- 1 root plugdev 188, 0 Aug 1 23:05 /dev/ttyUSB0
http://arduino.ada-language.com/building-avr-gnat-for-avr-ada.html