[SOLVED] programming ATtiny85 with avrdude and AVR-C using Arduino as ISP.

Dear comrades,

Lately I've been having a lot of fun with my Arduinos, and now I'm trying to program an ATtiny85 chip directly using AVR-C/avrdude on the Ubuntu command line, bypassing the Arduino IDE. I'm just trying to make an LED blink on and off.

I started by programming the ATtiny85 chip using the Arduino IDE. First I installed the ATtiny suport files, following the instructions from High-low tech here. I uploaded the “ArduinoISP” sketch to the board and I made the circuit below:

Next, in the “Tools” menu of the Arduino IDE, I set “board” to “ATtiny”, “processor” to “ATtiny85”, “Clock” to “8 MHz (internal)”, “port” to “/dev/ttyACM0 (Arduino Uno)” and programmer to “Arduino as ISP”. Then I clicked “Burn Bootloader”.

After this, I put the AVR-C code below in the Arduino IDE and clicked upload.

This worked great, the LED started blinking happily.

Next, I wanted to do the exact same thing, using the avrdude on the command line, replicating the instructions here. I put the AVR-C code in a text file.

#include <avr/io.h>
#include <util/delay.h>

int main (void){
    DDRB |= 8;    
        PORTB ^= 8;

Then I turned the blink.c code into a hex-file using these 3 commands.

user@ubuntu$ avr-gcc -Os -DF_CPU=8000000 -mmcu=attiny85 -c blink.c
user@ubuntu$ avr-gcc -DF_CPU=8000000 -mmcu=attiny85 -o blink.elf blink.o
user@ubuntu$ avr-objcopy -O ihex blink.elf blink.hex

Next, I tried to flash the ATtiny85 using avrdude with the following command, which gave an error.

user@ubuntu$ avrdude -c arduino -p attiny85 -P /dev/ttyACM0 -U flash:w:blink.hex

avrdude: stk500_recv(): programmer is not responding
avrdude done. Thank you.

I removed the capacitor, because the instructables tutorial doesn't use one either. Then I got the following reply/error.

user@ubuntu$ avrdude -c arduino -p attiny85 -P /dev/ttyACM0 -U flash:w:blink.hex

avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f
avrdude: Expected signature for ATtiny85 is 1E 93 0B
Double check chip, or use -F to override this check.

avrdude done. Thank you.

And nothing happened, the LED stayed off. :confused: I did some testing and it just doesn't upload anything.

Could somebody help me with this? Why isn't it uploading any code to the ATtiny85?

This should work.
Put the cap back, 0x1e950f is the signature for the 328p.
-c stk500v1
-b 19200

Hi da_big_fella

I work on Windows, so this may not help ...

Following the steps you described, I tried uploading a program to an ATtiny using a Uno with "Arduino as ISP". In preferences, I set verbose messages on for upload.

The call to avrdude was this:

C:\Arduino_1_6_5\hardware\tools\avr/bin/avrdude -CC:\Arduino_1_6_5\hardware\tools\avr/etc/avrdude.conf -v -pattiny85 -cstk500v1 -PCOM5 -b19200 -Uflash:w:C:\Users\Ray\AppData\Local\Temp\build4712359377930323958.tmp/BareMinimum.cpp.hex:i

Even allowing for different paths, the arguments passed to avrdude are different from the ones you posted.

Maybe you could try the same thing when uploading from the IDE and compare the results.



Awesome guys! I put the capacitor back in and added the arguments you both suggested:

user@ubuntu$ avrdude -c stk500v1 -p attiny85 -P /dev/ttyACM0 -b 19200 -U flash:w:blink.hex

Worked like a charm! The LED started blinking correctly :smiley: I'm very happy with this, now I can continue learning.