-
Notifications
You must be signed in to change notification settings - Fork 0
avr
Atmel AVR is a mature microcontroller platform that has exploded in popularity with hobbyists since the release of the Arduino, which uses an AVR. There is a complete assortment of simulators and debuggers and a GNU toolchain.
These instructions are adapted from http://www.nongnu.org/avr-libc/user-manual/install_tools.html to work with newer library versions and host systems.
Create a combined build tree. The order in which the trees are combined is important!
mkdir combined
cd combined
ln -sf path/to/gdb-7.12.1/* .
ln -sf path/to/binutils-2.28/* .
ln -sf path/to/gcc-6.3.0/* .
cd ..
Create a build directory and configure the toolchain. The toolchain supports C and C++.
mkdir combined-build
cd combined-build
../combined/configure \
--prefix=$HOME/.local/share/cross \
--target=avr \
--with-system-zlib \
--with-system-readline \
--with-gmp=$HOME/.local/share/cross \
--with-mpc=$HOME/.local/share/cross \
--with-mpfr=$HOME/.local/share/cross \
--with-isl=SHOME/.local/share/cross \
--disable-libssp \
--with-dwarf2 \
--enable-languages=c,c++ \
--enable-version-specific-runtime-libs \
--disable-multilib \
--enable-host-shared \
--enable-shared \
--with-{stage1,boot}-ldflags="-Wl,-rpath=$HOME/.local/share/cross/lib"
cd ..
Build and install just the host tools for the toolchain. The target libraries need avr-libc to be available.
cd combined-build
make -j8 all-host
make install-host
cd ..
Build and install avr-libc. There are A LOT of components for each supported chip.
mkdir avr-libc-build
cd avr-libc-build
../avr-libc-2.0.0/configure \
--prefix=$HOME/.local/share/cross \
--host=avr \
--enable-debug-info=dwarf-2
make -j8
make install
cd ..
Build and install the target libraries for the toolchain. Again, lots of invidually tailored libraries.
cd combined-build
make -j8
make install
cd ..
Build and install AVRDUDE, an AVR programmer.
cd avrdude-build
../avrdude-6.3/configure \
--prefix=$HOME/.local/share/cross \
--target=avr
make -j8
make install
Patch, build, and install AVaRICE, an application that can debug AVR targets connected to a couple of different programmers. AVaRICE needs access to libbfd
from the toolchain but cannot find it by itself, so we add the necessary flags to locate it. New versions of libbfd
require some arbitrary flags to be defined to compile, so we add those as compile flags too.
cd avarice-2.13
patch -p1 path/to/avarice-gcc5.patch
cd ..
mkdir avarice-build
cd avarice-build
../avarice-2.13/configure \
--prefix=$HOME/.local/share/cross \
--enable-target-programming \
CPPFLAGS="-I$HOME/.local/share/cross/x86_64-pc-linux-gnu/avr/include -DPACKAGE='avarice' -DPACKAGE_VERSION='2.13'" \
LDFLAGS="-L$HOME/.local/share/cross/x86_64-pc-linux-gnu/avr/lib -Wl,-rpath=$HOME/.local/share/cross/x86_64-pc-linux-gnu/avr/lib"
make -j8
make install
cd ..
Patch, build, and install SimulAVR, an AVR simulator target for GDB. The needed patch is apparently related to the level of standards compliance observed by newer versions of GCC, and GCC suggests the change all by itself when compiling without.
cd simulavr-1.0.0
sed -e 's/resize(this->size()+1);/this->resize(this->size()+1);/' -i src/systemclock.cpp
cd ..
mkdir simulavr-build
cd simulavr-build
../simulavr-1.0.0/configure \
--prefix=$HOME/.local/share/cross \
--with-bfd=$HOME/.local/share/cross/x86_64-pc-linux-gnu/avr
make -j8
make install
cd ..
That's it! You should have a working avr
toolchain, programmer, simulator, and debugger now. I've yet to personally start working with this family of chips, but at least I have the tools ready.
Info
Host Libraries
Targets