Arduino · 27 October 2012 0

How to update the AVR toolchain to the last 3.4.1 (Linux)

The Gnu AVR toolchain is a set of executables and libraries that are necessary to create programs for the Atmel microcontrollers. The toolchain that is included with the Arduino IDE 1.0.1 is out of date and has a known issue: it cannot generate functioning sketches bigger than 64 kwords (128 kB) due to a bug of the included compiler, avr-gcc 4.3.2.

Atmel periodically releases an updated version of the toolchain that also contains specific patches that fix some common bugs of the tools distribuited by Gnu. Unfortunately, you cannot use this toolchain with the Arduino IDE as it, but, with a few steps, we can replace the latter with it.

Warning. The following steps are only valid for Linux users.
For Windows, you can follow this guide.

Here are the simple steps to follow:

  • first of all, you have to get the last 3.4.1 toolchain, that Atmel released on 2012/08/29. To do this, go to this page and download the toolchain that is compatible with your OS’s architecture, 32- or 64-bits. Please remember that to reach the download link you have to register to the Atmel’s site and give a valid e-mail address, at which you’ll receive the direct link to get the files. After you have downloaded the package, uncompress it in a folder.
  • Now we have to replace the toolchain provided by the IDE with the one you have downloaded. To do so, go into the folder where you have the Arduino IDE and navigate to /hardware/tools. Inside it you’ll find another folder called /avr, that contains the toolchain: rename it in /avr.old if, for any reason, you’ll want to to roll back to the old version of the toolchain.
  • Now create a new folder called /avr and copy inside it the content of the folder /binaries that you find in the folder where you have uncompressed the toolchain you have downloaded from Atmel.

If you use the core Tiny, you have to do another step:

  • go in /hardware/tiny/cores/tiny and edit the file wiring.h. Around at line #136 comment the line that starts with #define round(x) so that at the end it will appear like this: //#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
    This modification (that you should replicate with the files wiring.h of all the others cores you have, too) is necessary to fix a bug with the management of this mathematical function, due to the fact that is replicated in delay.h for the inclusion of the math library that is present in this file.

Now the last step:

  • download the package that you find at the end of this article: it contains some files to replace/overwrite the same ones included in the Arduino IDES into the folder /arduino-1.0.1/hardware/arduino/cores/arduino. Warning: they are valid only for the version 1.0.1 of the Arduino IDE.

If you followed the above steps correctly, you’ll have on your computer the new Atmel toolchain. To check if everything is OK try to compile a sketch of yours and look for any error messages. This toolchain has the advantage to generate code that is smarter than the one created using the IDE toolchain.

Mod files to use with the new Atmel toolchain 3.4.1
10.1 KiB
1464 Downloads
Details...