Setup the AVR toolchain

From Tuxisalive

Jump to: navigation, search

Setup the AVR tool chain to compile the firmware

If you want to develop the embedded firmware, you'll have to setup a complete tool chain for the AVR processor before you can compile the firmware.

Contents

Install the AVR tool chain

You want to compile from Linux a software for the AVR processors. Therefore you need to install a complete development environment for the AVR processors. The AVR has a very good support from the open source community. There's a complete GNU Tool Chain and a very good C library called AVR Libc. There are multiple ways to get it working, so follow what suits you.


The manual way

To install the GNU tool chain, follow the instructions given at http://www.nongnu.org/avr-libc/user-manual/install_tools.html

Notes:

  1. read the firsts paragraphs about the prefix, don't blindly use 'PREFIX=$HOME/local/avr' unless you haven't root access to your computer;
  2. use the latest GCC-4.1.1 as that's the version we're using for the firmware;
  3. both binutils and GCC have now support for the ATmega88 that we use, there's no need to apply the patches for recent AVR devices;
  4. the dwarf2 implementation of GCC is currently broken, there's a patch at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26504 but dwarf2 is only used by AVRStudio on Windows, under Linux you don't really have any use of dwarf2 so simply drop the '--with-dwarf2' option there;
  5. you don't need uisp, avrdude, GDB and AVaRice, those tools are to be used with AVR programmers and debuggers; Tux Droid has it's own uploader called tuxup to bootload new firmware;
  6. I don't think there's any use of Simulavr neither as it doesn't support the ATMega88
  7. if you used 'PREFIX=/usr/local/avr', you will need to update the path and manpages path in your profile. Just add the following to your /etc/profile or ~/.bashrc

Check with 'echo $PATH' that you have '/usr/local/avr/bin' in your path

export PATH="/usr/local/avr/bin:$PATH"
export MANPATH="/usr/local/avr/man:$MANPATH"
  • Depending on your distro, there are maybe other things to do to get everything compiling:
    • Ubuntu users will have to install build-essential: 'sudo apt-get install build-essential'

At this point, you should now have a complete AVR tool chain. You can test it with the examples given by avr-libc. Just try to compile them to know if everything works fine. Check with 'echo $PATH' that you have '/usr/local/avr/bin' in your path, otherwise start a new terminal window or re-login (or source /etc/profile or your .bashrc file). Then copy the demo example and try to compile it.

cd
cp -r /usr/local/avr/share/doc/avr-libc-*/examples/demo .
cd demo
make

You shouldn't get any error if you did it right.

The script way

There's a script to download, patch and compile all necessary tools of the AVR GNU tool chain. It's in a sticky post at AVR freaks in the AVR GCC Forum: Script for building AVR-GCC 4.1.1 on Linux. I didn't try it but it should work. You need an account on avrfreaks to download it though, but anybody who wants to do AVR dev should have one anyway.

The distro way

Some distros should have binaries of the AVR tool chain packaged. If you got it working that way, please add a comment or a post on the forum to tell us how you did and we'll add this information here.

  • Gentoo users should be able to emerge avr-libc though I couldn't get crossdev to compile a toolchain based on GCC-4.1.1, I always got 3.4.6. If someone can get it that way, please send me the details.
  • Debian, Ubuntu, Knoppix, SELinux users can use apt as root (or sudo) to get the following packages: (not tested!)
apt-get install gcc-avr
apt-get install avr-libc
apt-get install gdb-avr
  • Red Hat based systems like Fedora Core, SuSe, Mandrake can use YUM as root: (not tested!)
yum install avr-gcc
yum install avr-binutils
yum install avr-libc
yum install avr-gdb


Originaly written by David Bourgeois for www.tuxisalive.com on the documentation section.

Personal tools
information strucure
development tools
miscellaneous