The AVR GCC Toolchain

From AVR-Eclipse

Jump to: navigation, search

Within the context of the AVR Eclipse plugin the word AVR-GCC toolchain is used quite liberally for all tools and files required to develop and deploy applications for AVR processors with this Plugin. Actually these tools come from seperate sources, of which the real avr-gcc is only one.

Contents

Toolchain components

These are the items that make up the AVR-GCC toolchain:

gcc The actual C/C++ Compiler
binutils A collection of tools, including the assembler, linker and some other tools to manipulate the generated binary files.
libc-avr A subset of the standard C Library with some additional AVR specific functions. The libc-avr package also includes the AVR specific header files.
gdb The debugger. See the Debugging section for more information about this.
avrdude A Programm to download/upload/manipulate the ROM and EEPROM of an AVR MCU.

At the core of the avr-gcc toolchain and absolutely required to build AVR applications, are the compiler, the binutils collection and the libc library. While the last one is a dedicated project, the first two (and gdb) are part of the GNU Project.

Patches

Since the GNU Project serves a much greater community than just the AVR folks and its stability is critical to the stability of the entire open software community, the avr-gcc developers have elected to publish AVR specific bugfixes and improvements as patches to the baseline distributions of gnu tools. Some of these patches are integrated into the gnu tools at some point, some are not. So to get the latest toolchain, it is advisable to include the patches.

Most of these patches are maintained as part of the FreeBSD ports collection.

For some platforms sedulous members of the AVR community have assembled packages containing pre-build toolchains, the best known of which is winAVR for the Windows platform.

Windows

Download and install WinAVR, which includes the AVR-GCC toolchain together with some other useful tools for programming the AVR processor series. WinAVR is actively maintained and has the latest patches as well as some improvements of its own (like the --format=avr option for the avr-size tool).

Linux

Most Linux distributions have an AVR-GCC toolchain. For instructions about installing AVR-GCC for your particular distribution, see the instructions below. However, the AVR-GCC toolchains packaged for the various distributions tend to be very much out of date. If you need the latest toolchain (e.g. if you are targeting one of the newer AVR processors) you probably have to build the toolchain yourself.

The same goes for Eclipse. Most Linux distributions are usually a bit, sometimes severely, behind the Eclipse release schedule. So it is probably best to grab the latest Eclipse IDE for C/C++ Developers from eclipse.org, unpack it any directory and run it.

Debian and Ubuntu

Install the following packages with your favorite package manager:

Or directly from the shell:

sudo apt-get install gcc-avr binutils-avr gdb-avr avr-libc avrdude

The avr-gdb in the Ubuntu 8.04 does not allow jtag debugging. See the known issues Known Issues page for details.

If the standard packages are too old you can find an up-to-date .deb package here based on the latest build scripts by bingo600 (see below for a link to the build scripts)

"Operation not permitted" error

see Known Issues#"Operation not permitted" error

RedHat

The directive same as Free BSD

  1. yum install avr-gcc
  2. yum install avr-binutils
  3. yum install avr-libc
  4. yum install avr-gdb
  5. yum install avrdude

Fedora

The directive same as Free BSD

  1. yum install avr-gcc
  2. yum install avr-binutils
  3. yum install avr-libc
  4. yum install avr-gdb
  5. yum install avrdude
  6. yum install eclipse
  7. yum install eclipse-cdt

Suse

Open

FreeBSD

The AVR-GCC toolchain is part of the FreeBSD ports system and is, as it is the main source for patches, always up-to-date (except for patches from winAVR).

See here on how to install programs from the Ports collection.

MacOSX

Here are some sources for prebuild toolchains:

AVR MacPack Last release: January 2010

Maintained by Objective Development in Austria, this package is actively supported and includes the latest patches from winAVR.

Build from Sources

If you do not have access to a prebuild - up to date - toolchain you will have to build it yourself. If you search the internet, you will find many sites on how to build the avr-gcc toolchain, most of which are very much dated. However, as the basic principle is always the same you can still use them as a guideline on how to build the toolchain.

Here are some links to recent build instructions. Please feel free to add others:

Linux Bingo600's Build Scripts Last Update: June 2010

You need to register with AVRFreaks to actually download the scripts.
These scripts are actively maintained and popular.

Linux, MacOSX, Windows FemtoOS Toolchain Builder Last Update: February 2010

The FemtoOS project includes a x-platform toolchain builder to build the avr toolchain.
It is a Bash script found in the FemtoOS download as Install_Scripts/install_toolchain.

Linux, FreeBSD, and Others avr-libc user manual Last Update: June 2010

Instructions on how to build the various components of the AVR toolchain by the folks who maintain the avr-libc code. They do not include instructions for the latest patches, but a good alternative if you have problems with the other scripts.

Mac OSX OSX-AVR Last Update: September 2006

Toolchain Bundles

Especially with the mess on Linux, where you have to build the toolchain yourself to get a somewhat recent version, I thought it might be a good idea to wrap a pre-build toolchain into an Eclipse Bundle (basically a plugin) and have the AVR Eclipse Plugin use it. This has currently not a high priority on my to do list. But if you are really interested in this, i could reprioritize :-) Be aware that I only would supply the Plugin integration. The actual bundeling has to be done by someone else who would be willing to maintain the toolchain bundle. Please comment at the Feature Request or write me a mail

Personal tools