14

I'm using an Arduino UNO to program a pre-compiled hex image to an ATTINY45, using the avrdude in the Arduino IDE directory, on Windows 7. The Uno has the ISP sketch loaded from the examples directory and that works- the heartbeat LED pulses nicely.

On the hardware side I have this setup, except the ATTINY is surface-mount, soldered to a surfboard with all its pins verified-soldered with a voltmeter. I use a header-pin strip, held by hand to get the pins touching the surfboard, to get the signals from the Uno to the ATTINY.

Here are the command lines, which I took from looking at the IDE's debugging output:

REM set the fuse for 8MHz, so the ISP programmer can work
C:\Progra~1\Arduino\hardware\tools\avr\bin\avrdude -CC:\Progra~1\Arduino\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -pattiny45 -cstk500v1 -P\\.\COM7 -b19200 -e -Uefuse:w:0xff:m -Uhfuse:w:0xdf:m -Ulfuse:w:0xe2:m 
REM load the program
C:\Progra~1\Arduino\hardware\tools\avr\bin\avrdude -CC:\Progra~1\Arduino\hardware/tools/avr/etc/avrdude.conf -v -pattiny45 -cstk500v1 -P\\.\COM7 -b19200 -Uflash:w:firefly.hex:i
REM set fuse for 1MHz, as the project requires
C:\Progra~1\Arduino\hardware/tools/avr/bin/avrdude -CC:\Progra~1\Arduino\hardware/tools/avr/etc/avrdude.conf -v -pattiny45 -cstk500v1 -P\\.\COM7 -b19200 -e -Uefuse:w:0xff:m -Uhfuse:w:0xdf:m -Ulfuse:w:0x62:m 

-I try running those separately, but always get this error:

avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
     Double check connections and try again, or use -F to override
     this check.

but sometimes the number is ff0000 or ffff00 or ffffff

I read that "Arduino uses a slightly modified version of avrdude to upload sketches to the Arduino board. The standard version queries for the board's device signature in a way not understood by the bootloader, resulting in this error." Does this mean that using the Arduino avrdude with a new ATTINY chip, no bootloader on it, would also cause that same error? In other words, is the modified avrdude incapable of querying a non-Arduino-bootloaded AVR chip?

Or does that error simply mean I don't have a good contact between all my programmer pins and the ATTINY?

And, are the fuse settings truly needed, can the Uno program the flash into an attiny running at 1MHz and thus save me some steps?

(I would just buy a "real" programmer, but need to get this code in the next two days, and am in a rural part of Nova Scotia)

5
  • Try setting the programmer to -c avrisp. I think you can program it at 1 MHz without problems.
    – user2973
    Aug 14, 2014 at 11:05
  • 1
    When I upload from the arduino IDE and set the programmer to "Arduino as ISP" it uses -carduino not the stk500. Just try uploading the blink program to the attiny from the IDE. That way you can see the correct commandline at the bottom, if you enable "verbose output" in the settings.
    – Gerben
    Aug 14, 2014 at 11:22
  • Did you upload the ArduinoISP sketch first?
    – PhillyNJ
    Aug 14, 2014 at 11:33
  • Phil, I did load the ArduinoISP sketch into the Uno before these steps, it succeeded, and I see the green "heartbeat" LED in pin 9 pulse. Gerben/user2973, I did try "-carduino", I will try "-c avrisp" next. Thanks.
    – Yary
    Aug 14, 2014 at 11:59
  • This looks like an ISP<->target connection issue. Anything in your circuit which could be loading the lines? Are the ATtiny fuses still set for internal clock, or are you providing an external one? Are you sure you have all four signal wires and ground connected, and in the right order? Perhaps you should tack solder a setup just to verify it is not your hand-held method (though I've also used that) Aug 14, 2014 at 15:20

3 Answers 3

12

I soldered wires to pads to be sure the connection was good, and used those wires for programming from the Uno. Then the programmer worked, without any edits to the command lines as posted in the question. I ran a few variations and was able to answer all my questions, and a few more besides:

  1. The "Yikes! Invalid device signature" error was being caused by poor contact between the programmer (Uno) and the ATTINY pins.

  2. It had nothing to do with the bootloader not being on the new microcontroller. The new ATTINY45 chip doesn't need a bootloader for the in-circuit programmer to work.

  3. The Uno can program the ATTINY45 configured to either of its speeds, 1MHz or 8MHz. The factory settings are fine, and don't require changing the fuses.

  4. Both avrdude versions worked for programming- the 6.1 from the author's site, and the modified one from the Arduino IDE.

  5. avrdude can program via the Uno using any of -c avrisp, -c arduino, or -c stk500v1, it doesn't matter which.

One little question I wasn't able to answer, was what speed the Uno programs at (communication speed between the Arduino I/O pins & microcontroller being flashed). Is it related to the serial port speed? But it turned out to be not pertinent to answering this problem. Someone else can ask it if curious enough.

1
  • 2
    ArduinoISP sets the SPI interface to clock/128, so for a 16 MHz Uno the connected AVR is programmed at 16 MHz / 128 = 125 kbit/s. But the limiting factors are the serial speed and when PROG_FLICKER is set, 30 ms delays added for each page commit.
    – user2973
    Aug 16, 2014 at 7:46
4

I had exactly this problem. If the ATtiny is set for external clock, then the ArduinoISP will not be able to program it without an external crystal. Connected a 16 MHz crystal and 2 capacitors and worked perfectly.

(I was then able to set ATtiny to internal clock, remove the crystal, and then worked perfectly without the crystal.)

1

Add the board and their fuse description from what is already set and it will work.

For adding just C:\Program Files\Arduino\hardware\arduino\avr\boards.txt and add the board description.

########
############ Definitions for ATmega 8MHz 
##############################################################
atmega16-8.name=Atmega16 (internal 8MHz clock)

atmega16-8.upload.tool=avrdude

atmega16-8.upload.protocol=stk500v1

atmega16-8.upload.maximum_size=14336
atmega16-8.upload.speed=19200

atmega16-8.bootloader.low_fuses=0xE8
atmega16-8.bootloader.high_fuses=0x99

atmega16-8.build.mcu=atmega16
atmega16-8.build.f_cpu=8000000L
atmega16-8.build.core=arduino:arduino
atmega16-8.build.variant=mega16

##############################################################
############################

I used it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.