Building gcc 3.4.6 to compile USBtinyISP firmware

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Seems to have been asked a number of times, how to build the firmware for a USBtinyISP. I wanted to increase the current it would draw from the USB port so this is how I built built binutils, gcc and avr-libc and then USBtinyISP.

Useful for *nix people that can't use a old version of winavr.

I also have the firmware building with binutils 2.22, gcc 4.5.1, avr-libc 1.8.0 so will post details once written them up.

Although you could just run the following shell script recommend you *DO NOT* as it is for my system. Run the commands one by one after downloading the software.

# Builds gcc 3.4.6 so usbtinyisp firmware can be built.
#
# need the following......
#
# binutils-2.16.1a.tar.bz2
#     wget -q http://ftp.gnu.org/gnu/binutils/binutils-2.16.1a.tar.bz2
# gcc-3.4.6.tar.bz2
#     wget -q http://gcc-uk.internet.bs/releases/gcc-3.4.6/gcc-3.4.6.tar.bz2
# avr-libc-1.4.4.tar.bz2
#     wget -q http://download.savannah.gnu.org/releases/avr-libc/avr-libc-1.4.4.tar.bz2
#

wheretoinstall="/usr/local/avr-3.4.6"

# Make sure we are in a known state
LDFLAGS="-Wl,-rpath -Wl,${wheretoinstall}/lib"
PATH=$PATH:/usr/local/${wheretoinstall}/bin
export LDFLAGS PATH

echo building binutils

# build binutils

bzip2 -cd binutils-2.16.1a.tar.bz2 | tar xf -
mkdir binutils-2.16.1-build
cd binutils-2.16.1-build
../binutils-2.16.1/configure --prefix=${wheretoinstall} --target=avr
make all install
cd ..

echo finished building binutils-2.16.1a. press enter to continue.
read
echo patching gcc

# now gcc

bzip2 -cd gcc-3.4.6.tar.bz2 | tar xf -

# okay, gcc 3.4.6 does not support attiny2313 so need to install a
# patch.  Thanks to the people at freebsd for the patch including Joerg
# Wunsch and Anatoly Sokolov and I'm sure others.
# See http://www.freebsd.org/cgi/cvsweb.cgi/ports/devel/avr-gcc/files/Attic/patch-newdevices for more details.

wget -qO gcc-3.4.6-AVR-Support.patch 'http://www.freebsd.org/cgi/cvsweb.cgi/~checkout~/ports/devel/avr-gcc/files/Attic/patch-newdevices?rev=1.12;content-type=text%2Fplain'

patch -p1 -d ./gcc-3.4.6 < gcc-3.4.6-AVR-Support.patch
# patching file ./gcc/config/avr/avr.c
# patching file ./gcc/config/avr/avr.h
# patching file ./gcc/config/avr/t-avr

echo finished patching gcc-3.4.6. press enter to continue.
read
echo building gcc

mkdir gcc-3.4.6-build
cd gcc-3.4.6-build
../gcc-3.4.6/configure --prefix=${wheretoinstall} --target=avr \
    --enable-languages="c,c++" --disable-nls
make all install
cd ..

echo finished building gcc-3.4.6. press enter to continue.
read
echo building avr-libc

# you can confirm its been installed / patched correctly

# avr-gcc --target-help
# [...]
#  attiny13 *attiny2313* atmega603 atmega103 at43usb320 at43usb355 at76c711
# [...]

# avr-libc

bzip2 -cd avr-libc-1.4.4.tar.bz2 | tar xf -
mkdir avr-libc-1.4.4-build
cd avr-libc-1.4.4-build
../avr-libc-1.4.4/configure --build=`./config.guess` --host=avr \
    --prefix=${wheretoinstall}
make install
cd ..
unset LDFLAGS

echo finished building avr-libc-1.4.4. press enter to continue.
read
echo building usbtiny

# Build the firmware downloaded from Ladyada.net.
#
# http://www.ladyada.net/make/usbtinyisp/download.html

unzip -q 'usbtiny v2.0 firm.zip'
cd usbtinyisp/spi
mv main.hex main.hex.orig
make clean
make

# we just produced an identical firmware image to the one included in
# the file downloaded!

# ls -al main.hex*
# -rw-r--r-- 1 root root 5782 Jan 11 13:41 main.hex
# -rw-r--r-- 1 root root 5782 Aug 16  2007 main.hex.orig
md5sum main.hex*
# e2193820174973295ca87bbcb0d38e44  main.hex
# e2193820174973295ca87bbcb0d38e44  main.hex.orig

# Now go and edit the source as needed and rebuild it.....

echo
echo Finished.
echo
echo best to remove the source and build directories to save space
echo run....
echo     rm -fr binutils-2.16.1-build binutils-2.16.1
echo     rm -fr gcc-3.4.6-build gcc-3.4.6
echo     rm -rf avr-libc-1.4.4-build avr-libc-1.4.4