The goal of this guide is to demonstrate how to download, build, and install the GNU tool chain for the AVR family of microcontroller on a Microsoft Windows XP system.
The following is assumed
Basic knowledge of Unix shell commands
Windows knowledge like setting PATH environment variables, creating shortcuts etc.
Since the build process depends on tools which are available on every Linux system, but not on Windows, the following tools will provide some sort of Unix emulation on Windows:
A free open source GCC compiler for Windows that allow one to produce native Windows programs that do not rely on any 3rd-party C runtime DLLs
Download MinGW Setup (MinGW-4.1.0.exe) from http://mingw.org Install MinGW (the installer will automatically download the required packages)
A Minimal SYStem to provide POSIX/Bourne configure scripts the ability to execute and create a Makefile used by make
Download MSYS-Setup (MSYS-1.0.10.exe) from http://mingw.org Install MSYS and follow the instructions. When the installers asks for a install location, select C:\MSYS instead of the default C:\MSYS\1.0 After the installation you should have a shortcut to MSYS on your desktop. Right-click on this MSYS shortcut and select edit. Now Notepad opens, add the following statement at the top of the file after the comment lines (rem): PATH=C:\MSYS\bin;C:\MINGW\bin;C:\AVRGCC\bin save the file and close Notepad.
Flex is a fast lexical analyzer generator, used to build the GCC compiler
Download Flex (flex-2.5.4a-1-bin.zip) from http://gnuwin32.sourceforge.net/packages/flex.htm Copy the file flex.exe to C:\mingw\bin
Finally, create a directory to store the AVR tool chain source files
download the following source files:
http://ftp.gnu.org/gnu/binutils/binutils-2.16.1.tar.bz2
http://ftp.gnu.org/gnu/gcc/gcc-3.4.5/gcc-core-3.4.5.tar.bz2
http://ftp.gnu.org/gnu/gcc/gcc-3.4.5/gcc-g++-3.4.5.tar.bz2
http://savannah.nongnu.org/download/avr-libc/avr-libc-1.4-2.tar.bz2
http://savannah.nongnu.org/download/avr-libc/avr-libc-user-manual-1.4.2.tar.bz2
download the following patches to support newer AVR devices:
http://www.freebsd.org/cgi/cvsweb.cgi/ports/devel/avr-binutils/files/
-> download patch-newdevices and save as binutils-patch-newdevices.txt
http://www.freebsd.org/cgi/cvsweb.cgi/ports/devel/avr-gcc/files/
-> download patch-newdevices and save as avrgcc-patch-newdevices.txt
Copy the downloaded files into the directory C:\MSYS\[username]. This is the home directory of the MSYS shell.
Click on the MSYS icon on the desktop to open a MSYS shell window. All the below commands need to be entered into this MSYS shell window.
cd bunzip2 binutils-2.16.1.tar.bz2 tar -xvf binutils-2.16.1.tarApply the patches to support newer AVR devices
cd binutils-2.16.1 patch -p1 < ../binutils-patch-newdevices.txtNow we can start building binutils
cd cd binutils-2.16.1 configure --target=avr --prefix=/c/avrgcc --disable-nls make make install
cd bunzip2 gcc-core-3.4.5.tar.bz2 bunzip2 gcc-g++-3.4.5.tar.bz2 tar -xvf gcc-core-3.4.5.tar tar -xvf gcc-g++-3.4.5.tarApply the patches to support newer AVR devices
patch -d gcc-3.4.5/gcc/config/avr avr.c ../../../../avrgcc-patch-newdevices.txtchange the following two files manually, otherwise the build process fails for some reason:
File: gcc-3.4.5/gcc/config/avr/t-avr USE_COLLECT2= <--- ADD THIS LINE at end of the file
File: gcc-3.4.5/gcc/fixinc/mkfixinc.sh
case $machine in
alpha*-dec-*vms* | \
arm-semi-aof | \
avr-*-* | \ <-- ADD THIS LINE (no space allowed after '\' )
hppa1.1-*-osf* | \
hppa1.1-*-bsd* | \
i370-*-openedition | \
Now we can start building avr-gcccd gcc-3.4.5 mkdir objavr cd objavr ../configure --target=avr --prefix=/c/avrgcc --with-dwarf2 --enable-languages=c,c++ --disable-nls make -> when the build process terminates with error messages, see below make install
The following generated Makfile in the gcc subdirectory (gcc-3.4.5/objavr/gcc/Makefile) has to be changed manually to continue the build process, either remove the red marked characters from the below line with an editor which does not replace tabs with spaces
INCLUDES = -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \
or change this Makefile using the following commands:
mv gcc/Makefile gcc/Makefile.orig sed "s/\-I\$(@D)//" gcc/Makefile.orig >gcc/Makefile
Now enter the following commands to continue the build
make make installVerify the installation of avr-gcc and binutils:
avr-as --version avr-as --target-help avr-gcc --version avr-gcc --target-help
Uncompress, extract and build avr-libc
cd bunzip2 avr-libc-1.4.2.tar.bz2 tar -xvf avr-libc-1.4.2.tar cd avr-libc-1.4.2 ./configure --build=`./config.guess` --host=avr --prefix=/c/avrgcc make make install
cd strip /c/avrgcc/bin/*.exe strip /c/avrgcc/libexec/gcc/avr/3.4.5/*.exe
Since the standard installation script only installs the GNU info format, which is not readable on a Windows system without special tools, the following command convert into HTML documents:
cd mkdir /c/avrgcc/html cd gcc-3.4.5/gcc/doc makeinfo --html --no-split -Iinclude cpp.texi makeinfo --html --no-split -Iinclude gcc.texi cp cpp.html /c/avrgcc/html cp gcc.html /c/avrgcc/html
cd cd binutils-2.16.1/binutils/doc makeinfo --html --no-split binutils.texi cp binutils.html /c/avrgcc/html
cd cd binutils-2.16.1/gas/doc makeinfo --html --no-split as.texinfo cp as.html /c/avrgcc/html
The AVR-libc documentation is already available in HTML format and just need to be extracted into the destination directory
cd cp avr-libc-user-manual-1.4.2.tar.bz2 /c/avrgcc/html cd /c/avrgcc/html bunzip2 avr-libc-user-manual-1.4.2.tar.bz2 tar -xvf avr-libc-user-manual-1.4.2.tar rm avr-libc-user-manual-1.4.2.tar
The installed GNU info and man pages can be deleted, since these infos are now available as HTML pages.
cd /c/avrgcc rm -Rf info rm -Rf manAdd the following Windows shortcut using Windows Explorer:
The final avr-gcc is now available in the directory c:\avrgcc. Add
c:\avrgcc\bin to your PATH environment variable.
In order to build with make, either add C:\msys\bin
to your PATH environment variable, or copy make.exe, sh.exe
and rm.exe to C:\avrgcc\bin.
Please remove \Winavr\bin from your PATH environment variable.
GCC Home Page
GNU Binutils Home Page
AVR Libc Home Page
Building GNU-Toolchain
on Windows systems
Compiling_AVR-GCC - Uwes Wiki
J�rg Wunsch's binutils patches
J�rg
Wunsch's avr-gcc patches
� Copyright 2006 Peter Fleury e-mail
[email protected] home page:
http://jump.to/fleury