The AVR GCC Toolchain

From AVR-Eclipse

Revision as of 20:36, 17 September 2009 by 127.0.0.1 (Talk)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
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

[edit] 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.

[edit] 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.

[edit] 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).

[edit] 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.

[edit] Debian and Ubuntu

Ubuntu LTS 8.04 (Hardy), the current Ubuntu 8.10 (Intrepid) and the upcoming 9.04 (Jaunty) [1] include only the outdated Eclipse 3.2.2. As AVR plugin requires Eclipse 3.3 or greater, you need to download and install the Eclipse IDE for C/C++ Developers yourself. Because Eclipse is self contained (does not require an installation) this is easy - just download the package and unpack it in any directory.


Then 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.

In Ubuntu if you receive the error message:

avrdude: usb_open(): cannot read serial number "error sending control message: Operation not permitted"

This means that your permission settings to access the programmer are probably wrong. Setup a new rule in by typing:

sudo gedit /etc/udev/rules.d/41-atmega.rules

and entering the following into the new text file:

# JTAGICE mkII
SUBSYSTEM=="usb_device", SYSFS{idVendor}=="03eb", SYSFS{idProduct}=="2103", GROUP="users", MODE="0666", GROUP="dialout"
# AVRISP mkII
SUBSYSTEM=="usb_device", SYSFS{idVendor}=="03eb", SYSFS{idProduct}=="2104", GROUP="users", MODE="0666"
# Dragon
SUBSYSTEM=="usb_device", SYSFS{idVendor}=="03eb", SYSFS{idProduct}=="2107", GROUP="users", MODE="0666" 

This should allow you to programme the uC.

[edit] 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

[edit] 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

[edit] Suse

Open

[edit] 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.

[edit] MacOSX

Here are some sources for prebuild toolchains:

AVR MacPack Last release: March 2009

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

[edit] 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: November 2008

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: September 2009

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: November 2008

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

[edit] 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