2009年7月23日星期四

AVR - building avr toolchain under Linux

avr-gcc build notes:

host gcc version: 4.2.3

set default install path
- export prefix=~/tools/avr


1) build binutils
version: binutils-2.19.1

-- cd binutils-2.19.1
-- ./configure --target=avr --prefix=$prefix --disable-nls
-- make
-- make install


2) build avr-gcc
version: gcc-core-4.2.4

add path:
-- export PATH=$prefix/bin:$PATH

-- cd gcc-4.2.4
-- ./configure --target=avr --prefix=$prefix --disable-libssp --enable-language=c
-- make
-- make install

if build version gcc-core-4.4.0
we need lib "mpfr" and "gmp", the arithmetic libs

version: mpfr-2.4.1.tar.gz
source: http://www.mpfr.org/mpfr-current/#download

version: gmp-4.3.1.tar.gz
source: http://gmplib.org/#DOWNLOAD

-- tar -zxvf gcc-core-4.4.0.tar.gz
-- tar -zxvf mpfr-2.4.1.tar.gz
-- cp -R mpfr-2.4.1 gcc-4.4.0
-- cd gcc-4.4.0
-- mv mpfr-2.4.1 mpfr

-- tar -zxvf gmp-4.3.1.tar.gz
-- cp -R gmp-4.3.1 gcc-4.4.0
-- mv gmp-4.3.1 gmp

we must not configure directly under gcc-4.4.0 or any existing subfolders,
otherwise may get errors like:

"Makefile:144: ../.././gcc/libgcc.mvars: No such file or directory
make[2]: *** No rule to make target `../.././gcc/libgcc.mvars'. Stop. "

-- cd gcc-4.4.0
-- mkdir build
-- cd build
-- ../configure --target=avr --prefix=$prefix --disable-libssp --enable-language=c
-- make
-- make install


3) build avr-libc
version: avr-libc-1.6.7.tar.bz2
source: http://ftp.twaren.net/Unix/NonGNU/avr-libc/

-- tar -jxvf avr-libc-1.6.7.tar.bz2
-- cd avr-libc-1.6.7
-- ./configure --host=avr --prefix=$prefix
-- make
-- make install

if I follow the INSTALL guild:
-- ./configure --build='./config.guess' --host=avr --prefix=$prefix

I got the following error:
"Invalid configuration `./config.guess': machine `./config.guess' not recognized "


4) build avr-gdb
version: gdb-6.8.tar.gz
source: http://ftp.gnu.org/gnu/gdb/

-- tar -zxvf gdb-6.8.tar.gz
-- cd gdb-6.8
-- ./configure --target=avr --prefix=$prefix
-- make
-- make install


5) build avrdude
version: avrdude-5.8.tar.gz
source: http://ftp.twaren.net/Unix/NonGNU/avrdude/

It needs the following packages:
bison and flex

version: bison-2.4.1.tar.gz
source: http://ftp.gnu.org/gnu/bison/

version: flex-2.5.35.tar.gz
source: http://flex.sourceforge.net/

#install bison
-- tar -zxvf bison-2.4.1.tar.gz
-- cd bison-2.4.1
-- ./configure
-- make
-- sudo make install

#install flex
-- tar -zxvf flex-2.5.35.tar.gz
-- cd flex-2.5.35
-- ./configure
-- make
-- sudo make install

#install avrdude
-- tar -zxvf avrdude-5.8.tar.gz
-- cd avrdude-5.8
-- ./configure --prefix=$prefix
-- make
-- make install


6) build avarice
version: avarice-2.10.tar.bz2
source: http://sourceforge.net/projects/avarice/

-- tar -jxvf avarice-2.10.tar.bz2
-- cd avarice-2.10
-- ./configure --prefix=$prefix
-- make
-- make install

If it warns: "configure: error: You need to install libbfd.a from binutils."
the package "libbinutils2-devel" may be missing (me, Mandriva 2008)
install this package from Software Management


7) build simulavr
version: simulavr-0.1.2.6.tar.gz
source: http://savannah.nongnu.org/projects/simulavr/

-- tar -zxvf simulavr-0.1.2.6.tar.gz
-- cd simulavr-0.1.2.6
-- ./configure --prefix=$prefix
-- make
-- make install