Software installation (binutils, avr-gcc, avr-libc, avrdude)

Post here about your arduino projects, get help & ideas, etc!

Moderators: arduwino, adafruit

Software installation (binutils, avr-gcc, avr-libc, avrdude)

Postby niksun » Tue Aug 19, 2008 12:15 am

So I had problems uploading programs to my AVRs using both the Arduino Diecimila and the BoArduino. I did have success using the USBtinyISP, but I did want to get my boards to work (with the bootloaders of course). It turns out that a bunch of small issues compounded to create my rather huge problem. Ultimately, I had success! I recorded my progress as I went along (all the while enjoying an ice-cold Beck's :P); here goes:

In setting up my Ubuntu 8.04 (Hardy) system for programming AVRs using avrdude, I ran into problems (even with ladyada's tutorial). So, I jotted down the steps I took to successfully install everything. Here it is in case you are having problems. If it helps you, great!

First, some prelimiaries to make sure the build process goes fine (hopefully):

Code: Select all
sudo apt-get install build-essential make tar wget patch libusb-dev libusb-0.1-4 libc6-dev


Create and navigate to an applicable source directory:

Code: Select all
cd ~
mkdir src
cd src


Fetch and build binutils; we have to get the latest snapshot (> v2.18!) so that avr-gcc can later compile correctly without the 'illegal opcode movw for mcu avr3' error (use the password 'anoncvs' when prompted):

Code: Select all
mkdir binutils-cvs-snapshot
cd binutils-cvs-snapshot
cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src login
cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src co binutils
cd src/
./configure --target=avr --program-prefix="avr-"
make
sudo make install
cd ../..


Fetch and build avr-gcc (make sure to enable c++ so the Arduino IDE (installed later) doesn't complain). Note: don't use the '-no-cpp-precomp' option when "make"ing as specified in other tutorials; it's deprecated:

Code: Select all
wget http://gcc.releasenotes.org/releases/gcc-4.3.1/gcc-4.3.1.tar.bz2
tar jxfv gcc-4.3.1.tar.bz2
mkdir avr-gcc-4.3.1
cd avr-gcc-4.3.1/
../gcc-4.3.1/configure --target=avr --enable-languages=c,c++ --disable-libssp
make CC="cc"
sudo make install
cd ..


Fetch and build avr-libc:

Code: Select all
wget http://download.savannah.gnu.org/releases/avr-libc/avr-libc-1.6.2.tar.bz2
tar jxfv avr-libc-1.6.2.tar.bz2
cd avr-libc-1.6.2/
./configure --host=avr
make
sudo make install
cd ..


Fetch and build avrdude (also applying the Arduino/BoArduino patch which fixes the invalid device signature bug and ensures DTI gets cleared when the port is closed):

Code: Select all
wget http://download.savannah.gnu.org/releases/avrdude/avrdude-5.5.tar.gz
tar xfv avrdude-5.5.tar.gz
wget http://www.artificial-stupidity.com:4352/avrdude-arduino.patch
patch -p0 < avrdude-arduino.patch
cd avrdude-5.5/
./configure
make
sudo make install
cd ..


Edit avrdude's configuration to add the Arduino Diecimila and the BoArduino to its programmer list:

Code: Select all
sudo vim /usr/local/etc/avrdude.conf


Add the following:

Code: Select all
programmer
  id    = "arduino";
  desc  = "Arduino Serial Bootloader";
  type  =  stk500;
  reset = 7;
  baudrate = 19200;
;

programmer
  id    = "boarduino";
  desc  = "BoArduino Serial Bootloader";
  type  =  stk500;
  reset = 7;
  baudrate = 19200;
;


Now run avrdude and have fun! For example:

Code: Select all
avrdude -V -c arduino -p m168 -P /dev/ttyUSB0


Optionally, fetch and run the Arduino IDE:

Code: Select all
wget http://www.arduino.cc/files/arduino-0011-linux.tgz
tar xfv arduino-0011-linux.tgz
cd arduino-0011
./arduino


You may need to apply a patch here (for the IDE) also for the DTR bug as mentioned above; if you do, see timv's post.

Optionally, remove sources:

Code: Select all
cd ~/src
rm binutils-cvs-snapshot gcc-4.3.1 gcc-4.3.1.tar.bz2 avr-gcc-4.3.1 avr-libc-1.6.2 avr-libc-1.6.2.tar.bz2 avrdude-5.5 avrdude-5.5.tar.gz arduino-0011-linux.tgz avrdude-arduino.patch


If you have problems; for example:

avrdude: stk500_recv(): programmer is not responding


You may want to reload the Arduino Diecimila (also BoArduino) bootloader using a USBtinyISP as follows (make sure to connect the USBtinyISP to the Arduino Diecimila or the BoArduino and that you have an ATMEGA168 AVR in the socket):

Code: Select all
cd ~/src
wget http://www.artificial-stupidity.com:4352/ATmegaBOOT_168_diecimila.hex
sudo avrdude -V -c usbtiny -p m168 -U flash:w:ATmegaBOOT_168_diecimila.hex


Then remove the USBtinyISP, connect the Arduino Diecimila or BoArduino and test again:

Code: Select all
avrdude -V -c arduino -p m168 -P /dev/ttyUSB0


If it works so far, then you can try to upload the "Hello World" of uCs:

Code: Select all
wget http://www.artificial-stupidity.com:4352/Blink.hex
avrdude -V -c arduino -p m168 -P /dev/ttyUSB0 -U flash:w:Blink.hex


An LED connected to pin 13 and GND should blink on/off every second or so.

Hope it works for you like it did for me!
Niksun

If you thought before that science was certain--well, that is just an error on your part. -- Richard Feynman
User avatar
niksun
 
Posts: 202
Joined: Sun Jul 27, 2008 8:59 pm

Ubuntu install - well done

Postby dugie » Sat Sep 13, 2008 8:04 pm

Thanks
Just joined this board. Installing arduino on Ubuntu Hardy had been driving me crazy with Java problems. Too many incomplete directions floating around the net. So I tried this method and my install went like clock work after I set up all the Java with Synaptic.
Thanks
Larry

wget http://www.arduino.cc/files/arduino-0011-linux.tgz
tar xfv arduino-0011-linux.tgz
cd arduino-0011
./arduino
Larry
dugie
 
Posts: 1
Joined: Sat Sep 13, 2008 7:47 pm
Location: Lakefield


Return to Arduino

Who is online

Users browsing this forum: Google [Bot] and 0 guests

Stuff to buy from the Adafruit store and links to product documentation!