Building gcc 3.4.6 to compile USBtinyISP firmware

1 post / 0 new
  • 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
# gcc-3.4.6.tar.bz2
#     wget -q
# avr-libc-1.4.4.tar.bz2
#     wget -q


# Make sure we are in a known state
LDFLAGS="-Wl,-rpath -Wl,${wheretoinstall}/lib"

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.
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 for more details.

wget -qO gcc-3.4.6-AVR-Support.patch ';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.
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.
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 \
make install
cd ..

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

# Build the firmware downloaded from

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

# 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 Finished.
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