Electronic – arduino – Programming an ATtiny 85 with Arduino

arduinoattinyavrdude

I followed this tutorial and got the following error when trying to compile upload the attiny85 sketch:

avrdude: usbdev_open(): did not find any USB device "usb"

The attiny is already soldered on a circuit (with two leds, a buzzer, button and a brightness sensor). Can this cause the error?

Also, the attiny already has a program on it (that I want to overwrite) so I assume I don't need to install the bootloader?

I found two files with the attiny hardware files, one that adds ATtiny85 (w/ Arduino as ISP) and one that adds ATtiny 85 (internal 1Mhz clock) to the Board menu. When using the first one (Arduino as ISP) i can only compile the blink sketch when I add

#include <Arduino.h>
#include <wiring.h>

otherwise it says "OUTPUT" was not declared in this scope.

UPDATE: Tried it with setting programmer in the tools menu. I changed it to Arduino as ISP. The error is now a different one (with upload as well as upload using programmer):

avrdude: stk500_getsync(): not in sync: resp=0x00

– Board: ATtiny85 w/ Arduino as ISP
– Programmer as ISP
– COM port correct (I also tried the other one)

Sometimes I get this error (only with normal upload), which indicates a successful upload according to the tutorial, but the ATtiny still performs the program that was installed before.

avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
avrdude: stk500_program_enable(): protocol error, expect=0x14, resp=0x50
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

Best Answer

UPDATE 2

If the tiny is running a sketch then it must already have a bootloader.

I think there are a lot of factors to be wrong here because the tutorial was written pre arduino 1.0. I think the 1mhz one is a problem and best avoided for now. The tin85 w/ Arduino ISP sounds to be pre-arduino 1.0 and needs to compile correctly.

In a few days I will have some time so if you haven't fixed it by then I hope to give you some info.

First I will take 2 arduinos, one as ISP and one as normal arduino. We need to prove the ISP sketch is working correctly when uploading blink to a 2nd arduino.

Once the ISP is proven with arduino 1.0 we need to see why normal compile of the tiny85 fails. It might be there is an updated tiny85 hardware folder for arduino 1.0 on the web but if not then we can change the tiny85 hardware folder sources to use 1.0 instead (hopefully).

FYI: You mention the arduino.h, in versions earlier than arduino 1.0 the file was called wprogram.h, arduino 1.0 also expects a few other differences. If the tiny85 is including wprogram.h I think it will be a problem to also include arduino.h

IDEA

If you have some time spare why not go onto the arduino.cc and down load version 0023 of the arduino IDE. (All of the older version of arduino are available). Upload the Arduino ISP example to the UNO using 0023 then try the upload to the tiny85 (w/ arduino ISP) for the blink sketch. I would expect 0023 to work exactly like the video, so if it fails you can look to the wiring of the tiny85 for the problem. It it works we will know we need to update the tiny85 hardware folder to arduino 1.0 format

If it works in 0023 then you should follow Deans instructions above for Arduino 1.0.1.

UPDATE

The only way I can find to reproduce the error you see is if I attempt to "Upload using programmer" when the programmer is set to "AVRISP". If I upload the ISP sketch to an arduino and attempt to program an unconnected tinyxx I get different errors.

So sorry if these are time wasting questions but.. are you clicking "Upload" in the arduino ide or "Upload using programmer"? You should be clicking "Upload" after selecting the ATTiny (w/ Arduino ISP) as the board.

Info..

It is a bit confusing but the board definition for ATTiny xx (w/ Arduino ISP) forces the correct programmer settings for the normal arduino "Upload". In the arduino ide, the menu item "Upload using programmer" uses whichever programmer is selected on the "Tools>Programmer" menu, in this case probably AVRISP mkII which, if unconnected, will produce the error you have reported.