Man Linux: Main Page and Category List

NAME

       install_tools - .TH "install_tools" 3 "Thu Aug 12 2010" "Version 1.6.8"
       "avr-libc"

NAME

       install_tools - .PP This chapter shows how to build and install, from
       source code, a complete development environment for the AVR processors
       using the GNU toolset. There are two main sections, one for Linux,
       FreeBSD, and other Unix-like operating systems, and another section for
       Windows.

Building and Installing under Linux, FreeBSD, and Others

       The default behaviour for most of these tools is to install every thing
       under the /usr/local directory. In order to keep the AVR tools separate
       from the base system, it is usually better to install everything into
       /usr/local/avr. If the /usr/local/avr directory does not exist, you
       should create it before trying to install anything. You will need root
       access to install there. If you don't have root access to the system,
       you can alternatively install in your home directory, for example, in
       $HOME/local/avr. Where you install is a completely arbitrary decision,
       but should be consistent for all the tools.

       You specify the installation directory by using the --prefix=dir option
       with the configure script. It is important to install all the AVR tools
       in the same directory or some of the tools will not work correctly. To
       ensure consistency and simplify the discussion, we will use $PREFIX to
       refer to whatever directory you wish to install in. You can set this as
       an environment variable if you wish as such (using a Bourne-like
       shell):

       $ PREFIX=$HOME/local/avr
       $ export PREFIX

       Note:
           Be sure that you have your PATH environment variable set to search
           the directory you install everything in before you start installing
           anything. For example, if you use --prefix=$PREFIX, you must have
           $PREFIX/bin in your exported PATH. As such:

       $ PATH=$PATH:$PREFIX/bin
       $ export PATH

       Warning:
           If you have CC set to anything other than avr-gcc in your
           environment, this will cause the configure script to fail. It is
           best to not have CC set at all.

       Note:
           It is usually the best to use the latest released version of each
           of the tools.

Required Tools

       o GNU Binutils
          http://sources.redhat.com/binutils/
          Installation

       o GCC
          http://gcc.gnu.org/
          Installation

       o AVR Libc
          http://savannah.gnu.org/projects/avr-libc/
          Installation

Optional Tools

       You can develop programs for AVR devices without the following tools.
       They may or may not be of use for you.

       o AVRDUDE
          http://savannah.nongnu.org/projects/avrdude/
          Installation
          Usage Notes

       o GDB
          http://sources.redhat.com/gdb/
          Installation

       o SimulAVR
          http://savannah.gnu.org/projects/simulavr/
          Installation

       o AVaRICE
          http://avarice.sourceforge.net/
          Installation

GNU Binutils for the AVR target

       The binutils package provides all the low-level utilities needed in
       building and manipulating object files. Once installed, your
       environment will have an AVR assembler (avr-as), linker (avr-ld), and
       librarian (avr-ar and avr-ranlib). In addition, you get tools which
       extract data from object files (avr-objcopy), dissassemble object file
       information (avr-objdump), and strip information from object files
       (avr-strip). Before we can build the C compiler, these tools need to be
       in place.

       Download and unpack the source files:

       $ bunzip2 -c binutils-<version>.tar.bz2 | tar xf -
       $ cd binutils-<version>

       Note:
           Replace <version> with the version of the package you downloaded.

           If you obtained a gzip compressed file (.gz), use gunzip instead of
           bunzip2.

       It is usually a good idea to configure and build binutils in a
       subdirectory so as not to pollute the source with the compiled files.
       This is recommended by the binutils developers.

       $ mkdir obj-avr
       $ cd obj-avr

       The next step is to configure and build the tools. This is done by
       supplying arguments to the configure script that enable the AVR-
       specific options.

       $ ../configure --prefix=$PREFIX --target=avr --disable-nls

       If you don't specify the --prefix option, the tools will get installed
       in the /usr/local hierarchy (i.e. the binaries will get installed in
       /usr/local/bin, the info pages get installed in /usr/local/info, etc.)
       Since these tools are changing frequently, It is preferrable to put
       them in a location that is easily removed.

       When configure is run, it generates a lot of messages while it
       determines what is available on your operating system. When it
       finishes, it will have created several Makefiles that are custom
       tailored to your platform. At this point, you can build the project.

       $ make

       Note:
           BSD users should note that the project's Makefile uses GNU make
           syntax. This means FreeBSD users may need to build the tools by
           using gmake.

       If the tools compiled cleanly, you're ready to install them. If you
       specified a destination that isn't owned by your account, you'll need
       root access to install them. To install:

       $ make install

       You should now have the programs from binutils installed into
       $PREFIX/bin. Don't forget to set your PATH environment variable before
       going to build avr-gcc.

       Note:
           The official version of binutils might lack support for recent AVR
           devices. A patch that adds more AVR types can be found at
           http://www.freebsd.org/cgi/cvsweb.cgi/ports/devel/avr-
           binutils/files/patch-newdevices

GCC for the AVR target

       Warning:
           You must install avr-binutils and make sure your path is set
           properly before installing avr-gcc.

       The steps to build avr-gcc are essentially same as for binutils:

       $ bunzip2 -c gcc-<version>.tar.bz2 | tar xf -
       $ cd gcc-<version>
       $ mkdir obj-avr
       $ cd obj-avr
       $ ../configure --prefix=$PREFIX --target=avr --enable-languages=c,c++     --disable-nls --disable-libssp --with-dwarf2
       $ make
       $ make install

       To save your self some download time, you can alternatively download
       only the gcc-core-<version>.tar.bz2 and gcc-c++-<version>.tar.bz2 parts
       of the gcc. Also, if you don't need C++ support, you only need the core
       part and should only enable the C language support.

       Note:
           Early versions of these tools did not support C++.

           The stdc++ libs are not included with C++ for AVR due to the size
           limitations of the devices.

           The official version of GCC might lack support for recent AVR
           devices. A patch that adds more AVR types can be found at
           http://www.freebsd.org/cgi/cvsweb.cgi/ports/devel/avr-
           gcc/files/patch-newdevices

AVR Libc

       Warning:
           You must install avr-binutils, avr-gcc and make sure your path is
           set properly before installing avr-libc.

       Note:
           If you have obtained the latest avr-libc from cvs, you will have to
           run the bootstrap script before using either of the build methods
           described below.

       To build and install avr-libc:

       $ gunzip -c avr-libc-<version>.tar.gz | tar xf -
       $ cd avr-libc-<version>
       $ ./configure --prefix=$PREFIX --build=`./config.guess` --host=avr
       $ make
       $ make install

AVRDUDE

       Note:
           It has been ported to windows (via MinGW or cygwin), Linux and
           Solaris. Other Unix systems should be trivial to port to.

       avrdude is part of the FreeBSD ports system. To install it, simply do
       the following:

       # cd /usr/ports/devel/avrdude
       # make install

       Note:
           Installation into the default location usually requires root
           permissions. However, running the program only requires access
           permissions to the appropriate ppi(4) device.

       Building and installing on other systems should use the configure
       system, as such:

       $ gunzip -c avrdude-<version>.tar.gz | tar xf -
       $ cd avrdude-<version>
       $ mkdir obj-avr
       $ cd obj-avr
       $ ../configure --prefix=$PREFIX
       $ make
       $ make install

GDB for the AVR target

       GDB also uses the configure system, so to build and install:

       $ bunzip2 -c gdb-<version>.tar.bz2 | tar xf -
       $ cd gdb-<version>
       $ mkdir obj-avr
       $ cd obj-avr
       $ ../configure --prefix=$PREFIX --target=avr
       $ make
       $ make install

       Note:
           If you are planning on using avr-gdb, you will probably want to
           install either simulavr or avarice since avr-gdb needs one of these
           to run as a a remote target backend.

SimulAVR

       SimulAVR also uses the configure system, so to build and install:

       $ gunzip -c simulavr-<version>.tar.gz | tar xf -
       $ cd simulavr-<version>
       $ mkdir obj-avr
       $ cd obj-avr
       $ ../configure --prefix=$PREFIX
       $ make
       $ make install

       Note:
           You might want to have already installed avr-binutils, avr-gcc and
           avr-libc if you want to have the test programs built in the
           simulavr source.

AVaRICE

       Note:
           These install notes are not applicable to avarice-1.5 or older. You
           probably don't want to use anything that old anyways since there
           have been many improvements and bug fixes since the 1.5 release.

       AVaRICE also uses the configure system, so to build and install:

       $ gunzip -c avarice-<version>.tar.gz | tar xf -
       $ cd avarice-<version>
       $ mkdir obj-avr
       $ cd obj-avr
       $ ../configure --prefix=$PREFIX
       $ make
       $ make install

       Note:
           AVaRICE uses the BFD library for accessing various binary file
           formats. You may need to tell the configure script where to find
           the lib and headers for the link to work. This is usually done by
           invoking the configure script like this (Replace <hdr_path> with
           the path to the bfd.h file on your system. Replace <lib_path> with
           the path to libbfd.a on your system.):

       $ CPPFLAGS=-I<hdr_path> LDFLAGS=-L<lib_path> ../configure --prefix=$PREFIX

Building and Installing under Windows

       Building and installing the toolchain under Windows requires more
       effort because all of the tools required for building, and the programs
       themselves, are mainly designed for running under a POSIX environment
       such as Unix and Linux. Windows does not natively provide such an
       environment.

       There are two projects available that provide such an environment,
       Cygwin and MinGW/MSYS. There are advantages and disadvantages to both.
       Cygwin provides a very complete POSIX environment that allows one to
       build many Linux based tools from source with very little or no source
       modifications. However, POSIX functionality is provided in the form of
       a DLL that is linked to the application. This DLL has to be
       redistributed with your application and there are issues if the Cygwin
       DLL already exists on the installation system and different versions of
       the DLL. On the other hand, MinGW/MSYS can compile code as native Win32
       applications. However, this means that programs designed for Unix and
       Linux (i.e. that use POSIX functionality) will not compile as
       MinGW/MSYS does not provide that POSIX layer for you. Therefore most
       programs that compile on both types of host systems, usually must
       provide some sort of abstraction layer to allow an application to be
       built cross-platform.

       MinGW/MSYS does provide somewhat of a POSIX environment that allows you
       to build Unix and Linux applications as they woud normally do, with a
       configure step and a make step. Cygwin also provides such an
       environment. This means that building the AVR toolchain is very similar
       to how it is built in Linux, described above. The main differences are
       in what the PATH environment variable gets set to, pathname
       differences, and the tools that are required to build the projects
       under Windows. We'll take a look at the tools next.

Tools Required for Building the Toolchain for Windows

       These are the tools that are currently used to build WinAVR 20070525
       (or later). This list may change, either the version of the tools, or
       the tools themselves, as improvements are made.

       o MinGW/MSYS
          <http://downloads.sourceforge.net/mingw/MinGW-5.1.4.exe?use_mirror=superb-
         east>

         o Put MinGW-5.1.4.exe in it's own directory (for example:
           C:\MinGWSetup)

         o Run MinGW-5.1.4.exe

         o Select 'Download and install'

         o Select 'Current' package.

         o Select type of install: Full.

       o Install MSYS-1.0.10.exe package.
          <http://prdownloads.sf.net/mingw/MSYS-1.0.10.exe?download>

         o Default selections

         o Batch file will ask:

           o

           o

           o

           o

           o It will display some messages on the screen, then it will
             display: 'Press any key to continue . . .'. Press any key.

       o Edit c:\msys\1.0\msys.bat
          Change line (should be line 41):

               if EXIST rxvt.exe goto startrxvt

        to:

               rem if EXIST rxvt.exe goto startrxvt

        to remark out this line. Doing this will cause MSYS to always use the
       bash shell and not the rxvt shell.

       Note:
           The order of the next three is important. Install MSYS Developer
           toolkit before the autotools.

       o MSYS Developer Toolkit version 1.0.1

         o This is needed to build avr-libc in MinGW.

           o <http://downloads.sourceforge.net/mingw/msysDTK-1.0.1.exe?use_mirror=internap>

         o Single file installer executable. Install.

       o autoconf 2.59 from the 'MSYS Developer Toolkit' release

         o autoconf 2.59/2.60 is needed to build avr-libc in MinGW.

         o <http://downloads.sourceforge.net/mingw/msys-
           autoconf-2.59.tar.bz2?use_mirror=internap>

         o Extract to c:\msys\1.0

       o automake 1.8.2

         o automake 1.8/1.9 is needed to build avr-libc in MinGW.

         o <http://downloads.sourceforge.net/mingw/msys-
           automake-1.8.2.tar.bz2?use_mirror=internap>

         o Extract to c:\msys\1.0

       o Install Cygwin

         o Install everything, all users, UNIX line endings. This will take a
           *long* time. A fat internet pipe is highly recommended. It is also
           recommended that you download all to a directory first, and then
           install from that directory to your machine.

       Note:
           GMP is a prequisite for building MPFR. Build GMP first.

       o Build GMP for MinGW

         o Version 4.2.3

         o <http://gmplib.org/>

         o Build script:

               ./configure  2>&1 | tee gmp-configure.log
               make         2>&1 | tee gmp-make.log
               make check   2>&1 | tee gmp-make-check.log
               make install 2>&1 | tee gmp-make-install.log

         o GMP headers will be installed under /usr/local/include and library
           installed under /usr/local/lib.

       o Build MPFR for MinGW

         o Version 2.3.2

         o <http://www.mpfr.org/>

         o Build script:

               ./configure --with-gmp=/usr/local 2>&1 | tee mpfr-configure.log
               make         2>&1 | tee mpfr-make.log
               make check   2>&1 | tee mpfr-make-check.log
               make install 2>&1 | tee mpfr-make-install.log

         o MPFR headers will be installed under /usr/local/include and library
           installed under /usr/local/lib.

       o Install Doxygen

         o Version 1.5.6

         o <http://www.stack.nl/~dimitri/doxygen/>

         o Download and install.

       o Install NetPBM

         o Version 10.27.0

         o From the GNUWin32 project:
           <http://gnuwin32.sourceforge.net/packages.html>

         o Download and install.

       o Install fig2dev

         o Version 3.2 Patchlevel 5

         o From WinFig 2.2: <http://www.schmidt-web-berlin.de/winfig/>

         o Unzip the download file and install fig2dev.exe in a location of
           your choice.

       o Install MiKTeX

         o Version 2.7

         o <http://miktex.org/>

         o Download and install.

       o Install Ghostscript

         o Version 8.63

         o <http://www.cs.wisc.edu/~ghost/>

         o Download and install.

         o In the  subdirectory of the installaion, copy gswin32c.exe to
           gs.exe.

       o Set the TEMP and TMP environment variables to c:\temp or to the short
         filename version. This helps to avoid NTVDM errors during building.

Building the Toolchain for Windows

       All directories in the PATH enviornment variable should be specified
       using their short filename (8.3) version. This will also help to avoid
       NTVDM errors during building. These short filenames can be specific to
       each machine.

       Build the tools below in MSYS.

       o Binutils

         o Open source code pacakge and patch as necessary.

         o Configure and build in a directory outside of the source code tree.

         o Set PATH, in order:

           o <MikTex executables>

           o /usr/local/bin

           o /usr/bin

           o /bin

           o /mingw/bin

           o c:/cygwin/bin

           o <install directory>/bin

         o Configure

               CFLAGS=-D__USE_MINGW_ACCESS          ../$archivedir/configure             --prefix=$installdir             --target=avr             --disable-nls             --enable-doc             --datadir=$installdir/doc/binutils             --with-gmp=/usr/local             --with-mpfr=/usr/local             2>&1 | tee binutils-configure.log

         o Make

               make all html install install-html 2>&1 | tee binutils-make.log

         o Manually change documentation location.

       o GCC

         o Open source code pacakge and patch as necessary.

         o Configure and build in a directory outside of the source code tree.

         o Set PATH, in order:

           o <MikTex executables>

           o /usr/local/bin

           o /usr/bin

           o /bin

           o /mingw/bin

           o c:/cygwin/bin

           o <install directory>/bin

         o Configure

               CFLAGS=-D__USE_MINGW_ACCESS          ../gcc-$version/configure             --prefix=$installdir             --target=$target             --enable-languages=c,c++             --with-dwarf2             --enable-win32-registry=WinAVR-$release             --disable-nls             --with-gmp=/usr/local             --with-mpfr=/usr/local             --enable-doc             --disable-libssp             2>&1 | tee $package-configure.log

         o Make

               make all html install 2>&1 | tee $package-make.log

         o Manually copy the HTML documentation from the source code tree to
           the installation tree.

       o avr-libc

         o Open source code package.

         o Configure and build at the top of the source code tree.

         o Set PATH, in order:

           o /usr/local/bin

           o /mingw/bin

           o /bin

           o <MikTex executables>

           o <install directory>/bin

           o <Doxygen executables>

           o <NetPBM executables>

           o <fig2dev executable>

           o <Ghostscript executables>

           o c:/cygwin/bin

         o Configure

               ./configure             --host=avr             --prefix=$installdir             --enable-doc             --disable-versioned-doc             --enable-html-doc             --enable-pdf-doc             --enable-man-doc             --mandir=$installdir/man             --datadir=$installdir             2>&1 | tee $package-configure.log

         o Make

               make all install 2>&1 | tee $package-make.log

         o Manually change location of man page documentation.

         o Move the examples to the top level of the install tree.

         o Convert line endings in examples to Windows line endings.

         o Convert line endings in header files to Windows line endings.

       o AVRDUDE

         o Open source code package.

         o Configure and build at the top of the source code tree.

         o Set PATH, in order:

           o <MikTex executables>

           o /usr/local/bin

           o /usr/bin

           o /bin

           o /mingw/bin

           o c:/cygwin/bin

           o <install directory>/bin

         o Set location of LibUSB headers and libraries

               export CPPFLAGS="-I../../libusb-win32-device-bin-$libusb_version/include"
               export CFLAGS="-I../../libusb-win32-device-bin-$libusb_version/include"
               export LDFLAGS="-L../../libusb-win32-device-bin-$libusb_version/lib/gcc"

         o Configure

               ./configure             --prefix=$installdir             --datadir=$installdir             --sysconfdir=$installdir/bin             --enable-doc             --disable-versioned-doc             2>&1 | tee $package-configure.log

         o Make

               make -k all install 2>&1 | tee $package-make.log

         o Convert line endings in avrdude config file to Windows line
           endings.

         o Delete backup copy of avrdude config file in install directory if
           exists.

       o Insight/GDB

         o Open source code pacakge and patch as necessary.

         o Configure and build in a directory outside of the source code tree.

         o Set PATH, in order:

           o <MikTex executables>

           o /usr/local/bin

           o /usr/bin

           o /bin

           o /mingw/bin

           o c:/cygwin/bin

           o <install directory>/bin

         o Configure

               CFLAGS=-D__USE_MINGW_ACCESS          LDFLAGS='-static'         ../$archivedir/configure             --prefix=$installdir             --target=avr             --with-gmp=/usr/local             --with-mpfr=/usr/local             --enable-doc             2>&1 | tee insight-configure.log

         o Make

               make all install 2>&1 | tee $package-make.log

       o SRecord

         o Open source code package.

         o Configure and build at the top of the source code tree.

         o Set PATH, in order:

           o <MikTex executables>

           o /usr/local/bin

           o /usr/bin

           o /bin

           o /mingw/bin

           o c:/cygwin/bin

           o <install directory>/bin

         o Configure

               ./configure             --prefix=$installdir             --infodir=$installdir/info             --mandir=$installdir/man             2>&1 | tee $package-configure.log

         o Make

               make all install 2>&1 | tee $package-make.log

       Build the tools below in Cygwin.

       o AVaRICE

         o Open source code package.

         o Configure and build in a directory outside of the source code tree.

         o Set PATH, in order:

           o <MikTex executables>

           o /usr/local/bin

           o /usr/bin

           o /bin

           o <install directory>/bin

         o Set location of LibUSB headers and libraries

               export CPPFLAGS=-I$startdir/libusb-win32-device-bin-$libusb_version/include
               export CFLAGS=-I$startdir/libusb-win32-device-bin-$libusb_version/include
               export LDFLAGS="-static -L$startdir/libusb-win32-device-bin-$libusb_version/lib/gcc "

         o Configure

               ../$archivedir/configure         --prefix=$installdir         --datadir=$installdir/doc         --mandir=$installdir/man         --infodir=$installdir/info         2>&1 | tee avarice-configure.log

         o Make

               make all install 2>&1 | tee avarice-make.log

       o SimulAVR

         o Open source code package.

         o Configure and build in a directory outside of the source code tree.

         o Set PATH, in order:

           o <MikTex executables>

           o /usr/local/bin

           o /usr/bin

           o /bin

           o <install directory>/bin

         o Configure

               export LDFLAGS="-static"
               ../$archivedir/configure             --prefix=$installdir             --datadir=$installdir             --disable-tests             --disable-versioned-doc             2>&1 | tee simulavr-configure.log

         o Make

               make -k all install 2>&1 | tee simulavr-make.log
               make pdf install-pdf 2>&1 | tee simulavr-pdf-make.log