avr-gcc 4.5.1 and avr-libc 1.7.0 for windows

Deprecated! This has now been superceded by gcc-4.7.0 and avr-libc 1.8.0. Click here to go to my article that describes how to upgrade.

The version of gcc included with WinAVR-20100110 is 4.3.3. If you’d like to update to avr-gcc 4.5.1 with avr-libc 1.7.0 then you’ve come to the right place.

Supported MCU names

Device support is considerably enhanced over 4.3.3. I have applied the latest patches to ensure that you get access to all these MCU’s.

AVR options:
  -mmcu=[avr-name] select microcontroller variant
            [avr-name] can be:
            avr1  - classic AVR core without data RAM
            avr2  - classic AVR core with up to 8K program memory
            avr25 - classic AVR core with up to 8K program memory
                    plus the MOVW instruction
            avr3  - classic AVR core with up to 64K program memory
            avr31 - classic AVR core with up to 128K program memory
            avr35 - classic AVR core with up to 64K program memory
                    plus the MOVW instruction
            avr4  - enhanced AVR core with up to 8K program memory
            avr5  - enhanced AVR core with up to 64K program memory
            avr51 - enhanced AVR core with up to 128K program memory
            avr6  - enhanced AVR core with up to 256K program memory
            or immediate microcontroller name.
  -mall-opcodes    accept all AVR opcodes, even if not supported by MCU
  -mno-skip-bug    disable warnings for skipping two-word instructions
                   (default for avr4, avr5)
  -mno-wrap        reject rjmp/rcall instructions with 8K wrap-around
                   (default for avr3, avr5)

Known MCU names:

avr1 avr2 avr25 avr3 avr31 avr35 avr4 avr5 avr51 avr6 at90s1200 attiny11
attiny12 attiny15 attiny28 at90s2313 at90s2323 at90s2333 at90s2343
attiny22 attiny26 at90s4414 at90s4433 at90s4434 at90s8515 at90c8534
at90s8535 attiny13 attiny13a attiny2313 attiny2313a attiny24 attiny24a
attiny4313 attiny44 attiny44a attiny84 attiny25 attiny45 attiny85
attiny261 attiny261a attiny461 attiny861 attiny861a attiny87 attiny43u
attiny48 attiny88 at86rf401 ata6289 at43usb355 at76c711 atmega103
at43usb320 attiny167 attiny327 at90usb82 at90usb162 atmega8u2 atmega16u2
atmega32u2 atmega8 atmega48 atmega48a atmega48p atmega88 atmega88a
atmega88p atmega88pa atmega8515 atmega8535 atmega8hva atmega4hvd
atmega8hvd atmega8c1 atmega8m1 at90pwm1 at90pwm2 at90pwm2b at90pwm3
at90pwm3b at90pwm81 atmega16 atmega16a atmega161 atmega162 atmega163
atmega164a atmega164p atmega165 atmega165p atmega168 atmega168a
atmega168p atmega169 atmega169a atmega169p atmega169pa atmega16hva
atmega16hvb atmega16c1 atmega32 atmega323 atmega324a atmega324p
atmega324pa atmega325 atmega325p atmega3250 atmega3250p atmega328
atmega328p atmega329 atmega329p atmega329pa atmega3290 atmega3290p
atmega32hvb atmega406 atmega64 atmega640 atmega644 atmega644a atmega644p
atmega644pa atmega645 atmega645a atmega645p atmega649 atmega649p
atmega649a atmega6450 atmega6450a atmega6450p atmega6490 atmega6490a
atmega6490p atmega64hve atmega16hva atmega16hva2 atmega16hvb atmega32hvb
at90can32 at90can64 at90pwm216 at90pwm316 atmega32c1 atmega64c1
atmega16m1 atmega32m1 atmega64m1 atmega16u4 atmega32u4 atmega32u6
at90usb646 at90usb647 at90scr100 at94k atmega128 atmega1280 atmega1281
atmega1284p atmega128rfa1 at90can128 at90usb1286 at90usb1287 m3000f
m3000s m3001b atmega2560 atmega2561

Additional Patches

Bug fix #29141 is patched in this release. The presence of this fix is one of the steps necessary to fixing the global constructor bug in gcc.

Release notes

This gcc suite was compiled using mingw on Windows 7 x64. The binaries are 32-bit standalone Win32 executables, that is they do not depend on any other package being installed on your computer.

I have removed the warning “only initialized variables can be placed into program memory area” from this compilation of avr-gcc. Previously you would get this whenever you use the PSTR() macro to place strings into flash memory. It was highly annoying and totally bogus so it’s gone. Now you can compile your projects with the strict -Werror -Wall settings.

Download it

Click here to go to the downloads page. Download and install the setup package. Just in case you miss it, there is a warning on the setup package welcome screen that discourages you from choosing an installation directory that has spaces in it, such as Program Files. Please heed this warning, Unix tools such as gcc do not like directory or file names that contain spaces.

Configuring Eclipse to use your new installation

It’s simple to get Eclipse to use the new installation. You just need to change two configuration items. Select Window->Preferences and then AVR->Paths from the options on the left. Highlight “AVR-GCC” from the main list in the center and select Edit…. You will get a screen that looks like this one.

Use the Browse… button or type in the location of the bin directory that contains avr-gcc.exe. It is directly below your installation directory so if you installed to the default of c:\avr-gcc4.5.1 then you need to enter c:\avr-gcc4.5.1\bin.

Go back and do the same with the AVR Header Files path. This time you need to point it to the avr\include directory. So if you accepted the default installation location then your correct setting is c:\avr-gcc\4.5.1\avr\include. When you’re done, you would have settings that look similar to this:


Click image to magnify it.

Finally you need to make a small change to the toolchain in Eclipse. The final build step displays the size of your hex file so you can keep an eye on how much flash memory you are consuming. You need to change the output format because the default avr format is not supported.

Right-click on any AVR project in Eclipse and choose Properties or press Alt-Enter. Expand C/C++ Build and choose Settings. Click on Print Size -> General down at the bottom and change the Size Format to be Berkeley Format. It looks like this:


Click image to magnify it.

Configuring for non-Eclipse users

WinAVR will add it’s bin directory to your system PATH environment variable. Use the Windows control panel to change this to the bin directory in your new installation. If your makefiles set up INCLUDE and LIB directories then you’ll need to make similar changes there.

Documentation

The official GNU documentation is included in the html subdirectory. The setup program will create shortcuts in your start menu that point to these.