Install the software

On GNU/Linux you need to install some packages on top of a standard developer's environment. They are:

The trick

It took me some time to realize that avr-binutils and avr-gcc are not separate projects. They are the source packages of GNU binutils and gcc, exactly the same tar balls you would use for a PC target, but you compile them for the avr target.

Binary or source

You might find binary packages or install targets named avr-xxx for your Linux distribution. It should work without problems.

However, it is no big deal to compile the programs yourself once you have the source tarballs. I will describe installing the AVR environment from source.

Download

At time of the third review of this text (August 2010), the sources are available for download from the following locations:

Your university's mirror might also be satisfactory.

These are the project home pages:

The usual details

In below command line examples, you obviously have to replace the version numbers with those you downloaded.

If you downloaded a .tar.gz package, use `tar xvzf' instead of `tar xvjf'.

If you already have an older version of any of the avr packages installed, it might cause some confusion. For example, the command `avr-gcc' might still call an older version, and the newer version's command would be something like `avr-gcc-3.4'. For clarity, try to get rid of older versions before calling `make install'.

Note that avr-libc has to be compiled with your avr-gcc. You may need to make sure that you compiled the avr-libc with the same avr-gcc you are using.

If you do not have write access to /usr/local/... or you don't want to mess with your packaging tool's structures, you can install the programs in your home directory. Simply add another parameter

 --prefix=$HOME

to every command calling a `configure' script. For example:

../binutils-2.15.90.0.3/configure --target=avr --prefix=$HOME

You might need root access to install the programs (for compiling them, you don't). If you need root access, instead of `make && make install', use the commands

make
sudo make install

and enter your password when prompted.

Compile and install

Here are the commands needed to compile and install above packages.
Be sure to compile and install them in the order shown here.

You may need to install a few other things before you can build your AVR compilation suite.

(Note that ubuntu does have pre-compiled binary packages gcc-avr, binutils-avr, avr-libc and avrdude, so no need to compile from source, really.)

avr-binutils

tar xjf binutils-2.20.1.tar.bz2 
mkdir build-binutils-2.20.1
cd build-binutils-2.20.1/
../binutils-2.20.1/configure --target=avr
make
sudo make install

avr-gcc

tar xjf gcc-4.5.1.tar.bz2 
mkdir build-gcc-4.5.1
cd build-gcc-4.5.1
../gcc-4.5.1/configure --target=avr --enable-languages=c
make
sudo make install

avr-libc

tar xjf avr-libc-1.6.7.tar.bz2 
mkdir build-avr-libc-1.6.7
cd build-avr-libc-1.6.7/
../avr-libc-1.6.7/configure --host=avr
make
sudo make install

avrdude

tar xzf avrdude-5.10.tar.gz 
mkdir build-avrdude-5.10
cd build-avrdude-5.10/
../avrdude-5.10/configure 
make
sudo make install

Problems

If you encounter any problems, try other versions of the programs, or try to find out stuff in documentation or mailing lists of the programs. For example, gcc-3.3.3 is known not to work for the avr target.

I had the problem that avr-gcc could compile for an older ATMEL chip but not for any of the ATMEGAs. That was because I had different versions floating around, and had ignorantly built the avr-libc with a different avr-gcc version than the one I was using.

So again, make sure the right programs are used, and were used for compilation:

~$ avr-gcc --version
avr-gcc (GCC) 4.5.1
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Next section]
login 2012-12-16 21:04