13 Feb 2013

Problems programming ATtiny85 from Arduino IDE

After several successful firmware uploads from the Arduino IDE via Arduino Uno as ISP programmer to an ATtiny85 it suddenly stopped to work.

I have not figured out why this happens, a friend of mine has the same problem and couldn't find what caused it neither.

Long story short, the work around is to use Arduino IDE to compile the sketch and avrdude directly to do the uploading.

Compiling

Compiling code for ATtiny85/45 in Arduino IDE requires that the hardware definitions of these chips are installed in Arduino IDE:

Once the code is compiled it can be found in /tmp/build[0-9]*.tmp/*.hex on a *nix platform (C:\Windows\temp\... probably on windows, check the Arduino IDE manual).

Once the location of the hex file is known, I copy it to a safe place (data in the temp folder are purged occasionally).

Arduino as ISP

I am using Arduino Uno as programmer. For this wot work the arduino must be flashed with an already available sketch called: ArduinoISP (found under Examples).

Once this sketch is uploaded, the Arduino Uno works as In System Programmer and can be hooked up to your ATtiny device. The Arduino Uno is the used as "bridge" between your USB port on the computer and the tiny, as well as power supply.


Uploading

Using avrdude with the following parameters worked out of the box for me on a virgin ATTiny85 from linux:
$ avrdude -P /dev/ttyACM0 -p t85 -c avrisp -b 19200 \
          -v -F -U flash:w:pulse_in.cpp.hex