Matthew Beckler's Home Page

Home :: Blog :: General :: Software :: Hardware :: Microcontrollers :: Artsy

How To: Set up an AVR-GCC build environment from scratch.

Introduction: The main benefit of using Atmel's line of AVR microcontrollers is the well established avr-gcc toolchain, based on the free and open source gcc compiler. There is a nicely packaged distribution for Windows, but nothing nice for Linux users. Given that a compiler toolchain is fairly important, I thought I should try building my own. Reproduced below are my notes from installing all the components of the avr-gcc toolchain. It was based on the following guides and websites:

What You Get: You can either follow the guide at the bottom, or download the finished package below. Either way, you end up with a fully-functioning avr-gcc environment installed into /usr/local/avr, with the following tools:

Downloads: Click below to download the build notes or the finished toolchain package. If you find this to be useful, please send me an email. I'm always interested to know who's using my software.

Install Pre-Built Package: Here's how to install the pre-built package into /usr/local/avr:

  1. Download the package above (.tar.gz file) into your home directory.
  2. cd /usr/local
  3. sudo tar xvzf ~/avr_gcc_toolchain.tar.gz
  4. Be sure to add /usr/local/avr/bin to your path!

Build Instructions:

# avr-gcc toolchain build notes - version 1.2
# Last updated: January 9, 2010
# Matthew Beckler - matthew at mbeckler dot org
# Based on these guides:
# Used a fresh install of Ubuntu 9.10 Karmic (i686) in a virtual machine.
# --------------------------------------------------------------------
# If you have the usr_local_avr_toolchain.tar.gz and want to install that and
# not go to all the trouble of building these tools, do this:
# cd /usr/local
# sudo tar xvzf ~/usr_local_avr_toolchain.tar.gz
# Be sure to add /usr/local/avr/bin to your path!
# You probably want to install these to work with the wnl code:
# sudo apt-get install subversion scons python-pexpect

# general setup
cd ~
mkdir avr_build

# add /usr/local/avr/bin to PATH, by adding this line to ~/.bashrc
export PATH=$PATH:/usr/local/avr/bin
# you should also do this for the root user, since using sudo can
# reset your PATH to root's default PATH
source ~/.bashrc

# install newer versions of MPFR and GMP dev packages
# required to build newer versions of gcc (ubuntu packages)
# also should pull in 4.1 versions of gcc
# The texinfo package is used while building binutils.
sudo apt-get install libgmp3-dev libmpfr-dev texinfo

# binutils-2.19
cd ~/avr_build
tar xvzf binutils-2.19.tar.gz
cd binutils-2.19
mkdir build
cd build
export CC=gcc
../configure --target=avr --prefix=/usr/local/avr --disable-nsl --enable-install-libbfd --disable-werror
sudo make install
# to test binutils installation:
/usr/local/avr/bin/avr-as --help

# gcc-core-4.2.3
cd ~/avr_build
tar xvzf gcc-core-4.3.2.tar.gz
cd gcc-4.3.2
mkdir build
cd build
../configure --target=avr --prefix=/usr/local/avr --disable-nsl --enable-languages=c --disable-libssp
# sometimes there are PATH issues with "sudo make install",
# so you might try "sudo su" and then "make install".
# be sure to 'exit' from the root account before continuing!
sudo make install
# to test:
avr-gcc --version

# avr-libc-1.6.4
cd ~/avr_build
tar xvjf avr-libc-1.6.4.tar.bz2
cd avr-libc-1.6.4/
mkdir build
cd build
export CC=avr-gcc
../configure --build=`../config.guess` --host=avr --prefix=/usr/local/avr
# again, it might work best to "sudo su" then "make install"
# be sure to 'exit' from the root account before continuing!
sudo make install

# avrdude-5.8
sudo apt-get install flex byacc libusb-dev
cd ~/avr_build
tar xvzf avrdude-5.8.tar.gz
cd avrdude-5.8
export CC=gcc
./configure --prefix=/usr/local/avr
sudo make install
export CC=
# TODO add udev magic to fix usb permissions for non-root user using avrdude.

# gdb-6.8
sudo apt-get install libncurses5-dev
# the above install fixes a warning about "no termcap library found"
cd ~/avr_build
tar xvzf gdb-6.8.tar.gz
cd gdb-6.8
./configure --target=avr --prefix=/usr/local/avr --disable-werror
sudo make install

# simulavrxx
sudo apt-get install tcl-dev cvs autoconf libtool swig g++ zlib1g-dev
cd ~/avr_build
cvs -z3 co simulavrxx
cd simulavrxx
./configure --prefix=/usr/local/avr --with-bfd=/usr/local/avr
# remove both references to 'examples' in the Makefile. (see diff below)
vim Makefile
sudo make install

# other stuff to install for wnl dev:
sudo apt-get install subversion scons python-pexpect

matthew@karmic-fresh:~/avr_build/simulavrxx$ diff -u Makefile Makefile_orig 
--- Makefile    2009-11-20 13:22:03.394709782 -0500
+++ Makefile_orig       2009-11-20 13:19:26.630713617 -0500
@@ -75,7 +75,7 @@
        distdir dist dist-all distcheck
 ETAGS = etags
 CTAGS = ctags
-DIST_SUBDIRS = src doc regress
+DIST_SUBDIRS = src examples doc regress
 distdir = $(PACKAGE)-$(VERSION)
 top_distdir = $(distdir)
@@ -259,7 +259,8 @@
 top_builddir = .
 top_srcdir = .
-SUBDIRS = src doc regress
+EXAMPLES = examples
+SUBDIRS = src $(EXAMPLES) doc regress
 EXTRA_DIST = bootstrap make_tarball README.gdb SUPPORT \
  m4/README m4/avr_tcl.m4 m4/avr_swig.m4

Homepage Made with Vim! Validate HTML Email Me! Made with Inkscape! Validate CSS

Copyright © 2004 - 2024, Matthew L. Beckler, CC BY-SA 3.0
Last modified: 2010-01-29 10:17:54 PM (EST)