This tutorial explains step by step how to install AVR-Ada on a Linux system. This tutorial was tested on a 64 Bit Ubuntu 9.10 system. The steps for building AVR-Ada on a Windows system are essentially the same. The prerequisits are more demanding as you need MSYS, MinGW, Cygwin, the Atmel Toolsuite (as part of the Atmel Studio) and gprconfig and gprbuild (provided by Adacore's GNAT). See [BuildScript] for further details.
For building the AVR-Ada cross compiler you have to download the following packages:
binutils-2.20.1.tar.bz2 gcc-4.7.1.tar.bz2 avr-libc-1.8.0.tar.bz2 avr-ada-1.2.0.tar.bz2
For building an Ada compiler you will need a working Ada compiler on your system because the Ada front-end of gcc is written in Ada. Therefore on an Ubuntu and other Debian systems you need to have the package gnat installed. On Windows you have to build a native gcc including Ada support first. MinGW currently (Summer 2012) provides gcc-4.6 which does not work.
Further check that you have the packages flex and bison installed.
On Ubuntu and Debian systems the normal gcc is built without Ada support. The gcc with Ada support is called gnatgcc. Take care you are using a gcc with Ada support for building an Ada cross compiler. You can force using the gnatgcc by setting the CC environment variable.
export CC=gnatgcc
Extract the binutils and the avr-ada packages into your working directory.
tar xvfj binutils-2.20.1.tar.bz2 tar xvfj avr-ada-1.2.0p.tar.bz2
This will create the binutils-2.20.1 and avr-ada-1.2.0 directories.
First you have to apply the AVR-Ada patches to the Binutils:
cd binutils-2.20.1 patch --verbose --strip=0 --input=../avr-ada-1.2.0/patches/binutils/2.20.1/10-binutils-2.19-sprintf-format.patch patch --verbose --strip=0 --input=../avr-ada-1.2.0/patches/binutils/2.20.1/50-binutils-2.19-xmega-autoconf.patch
Now run the configure script:
./configure --prefix=/opt/avr --target=avr
If you don't set the prefix option the default prefix will be /usr/local. So you will find the avr-as under /usr/local/bin/. Ensure that you use the same prefix for all packages.
Than you can compile and install the whole package
make sudo make install
This last step can be omitted if you have installed your AVR-Binutils into a standard path like /usr/local/bin. Otherwise you have to add the directory of the installation to your PATH environment variable.
export PATH=$PATH:/opt/avr/bin
To permanently add this path to your PATH variable on an Ubuntu system you have to edit the file /etc/environment.
Now your AVR-Binutils are working.
Go back to your working directory and extract the GCC Compiler package
tar xvfj gcc-4.7.1.tar.bz2
This will create the gcc-4.7.1 subdirectory.
Apply the AVR-Ada patches to the GCC package:
cd gcc-4.7.1 patch --verbose --strip=0 --input=../avr-ada-1.2.0/patches/gcc/4.7.1/22-gcc-4.7-ada-xgnatugn.patch ...
Now create a new directory build
mkdir build cd build
Creating this build directory is very important because it is not possible to compile GCC within its root directory like most other projects. If you do so compiling will fail with strange error messages.
Now run the configure script:
../configure --prefix=/opt/avr --target=avr --enable-languages=c,c++,ada --with-dwarf2 --disable-nls --disable-libssp --disable-libada
Than you can compile and install the whole package
make sudo make install
Go to your working directory and extract the AVR-Libc package
tar xvfj avr-libc-1.8.0.tar.bz
For compiling the AVR-Libc you have to use the avr-gcc compiler. This is achieved by setting the CC environment variable
export CC=avr-gcc
Than you can configure, compile and install the AVR-Libc:
cd avr-libc-1.8.0 ./configure --prefix=/opt/avr --build=`./config.guess` --host=avr make sudo make install
Note: If you installed everything into /opt/avr (for example), which is probably not already referenced in your PATH variable, now is the time to correct this. Check where your avr-gcc is being referenced now:
$ type avr-gcc
avr-gcc is /opt/avr/bin/avr-gcc
If it doesn't report your installed avr-gcc (as above) then you need to adjust your PATH. On Debian installations, you might prefer to just uninstall their C-only versions of the avr software to avoid mixing them up.
In any case, you need to put /opt/avr/bin in your PATH:
$ PATH="/opt/avr/bin:$PATH"
According to the build scripts supplied with AVR-Ada under the directory avr-ada-1.1.0/tools/build/ the installation process should work this way:
cd avr-ada-1.2.0 ./configure --prefix=/opt/avr make build_rts sudo make install_rts make build_libs sudo make install_libs
Unfortunately compiling stopped with an error message that attiny167 is only supported in assembly language. As I do not use this processor I just removed its directory from the avr_lib directory:
rm -r avr/avr_lib/attiny167
But this is just a quick and dirty solution.
Another error message I received when just calling make without any target. Compiling stopped when compiling a library for the at90can processor. In this case you can just call make install and than go on with make for building the missing libraries. If you do the two step build with make build_rts and make build_libs you shall not run into this error.
A similar problem occurred for avr6 (yet attiny167 didn't):
gnat1: error: MCU 'avr6' supported for assembly only make[1]: *** [s-bitops.o] Error 1
I found that if you just edit the top-level Makefile and comment out the offending architecture (avr6):
ARCH_LIST := avr2 avr25 avr3 avr35 avr4 avr5 # avr6
You can get it to build successfully doing:
$ make clean $ make build_rts
All the previous steps are automated in the build script '''build-avr-ada-gcc-4.3.x.sh'''. See the [BuildScript] of usage. The scripts includes an automated download of the required source packages and it also checks out the current set of patches from WinAVR. Be sure to set the paths and directories suitable for your environment in the top part of the script.
Up to date version of this script & build procedure can be found on the [Build_From_Ubuntu_Lucid_Or_Debian_Squeeze].
If you find that the version of the avr-ada package you installed is missing a contributed Ada library that
you'd like to use, this section will save you some time in getting that included.
The first thing to do is to acquire a copy of the software package source code from the avr-ada git repository.
Add the name ''pkgdir'' to that list. For example, if you were interested in the crc and slip contributed packages, then add "crc slip" to the list, so that it reads as follows:
libraries := debug lcd sensirion onewire crc slip
As of this writing, there are the following optional Ada packages that may not be in your downloaded AVR-Ada distribution:
Wiki: BuildScript
Wiki: CRC
Wiki: Fatfs
Wiki: Home
Wiki: MCP4922
Wiki: MIDI
Wiki: Slip