Pages: [1] 2   Go Down
Author Topic: Unable to program attiny45 with arduino IDE  (Read 1521 times)
0 Members and 1 Guest are viewing this topic.
Estonia
Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, I have tried very many different solutions but simply cannot get arduino IDE to program attiny45 or attiny85 with USBtinyISP v3.0

I have the following:
Have tried these things on both Arduino 1.0.1 and 1.0.3
attiny library both from http://hlt.media.mit.edu/?p=1695 and http://code.google.com/p/arduino-tiny/
have the latest USBtinyISP drivers for win7 64bit from http://www.ladyada.net/make/usbtinyisp/download.html

I have tried two different USBtinyISP programmers, 4 attiny45-s and one attiny85 - to rule out bad chip theory
Connetion between USBtinyISP and chip I have tried two methods - connectors soldered to perfboard and connected with wire and 6 pin connector to 8 pin chip connector connected with short loose wire.

I do have selected the correct board from tools - board menu. I have tried both tools - burn bootloader and avrdude with the help of fusecalculator on http://www.engbedded.com/fusecalc/

Outcome:
Arduino IDE always gives me error when comparing data written to chip with compiled program. Address is always different but not bigger than 0x0200 or so.
Code:
avrdude: verification error, first mismatch at byte 0x0100
         0xd0 != 0xc8

The strange thing is that I can upload this same file using command line and avrdude with no problem. Compare is always OK. (using the instruction on http://www.ladyada.net/learn/avr/avrdude.html)

Program behaviour:
When programming with Arduino I have seen only once that blink program started working, all other times - no function

When using avrdude from command line, simple programs work. e.g. servo8bit controls servo OK. I hoped to get software serial to get working this way with no luck. all i get is gibberish from serial.(I have double checked the baud rates in serial monitor and in progarm)

MAIN QUESTION:
How to configure Arduino IDE so I can upload programs to attiny45/85 and make them work?
« Last Edit: March 07, 2013, 03:59:29 am by Amigone » Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 178
Posts: 12288
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The strange thing is that I can upload this same file using command line and avrdude with no problem. Compare is always OK. (using the instruction on http://www.ladyada.net/learn/avr/avrdude.html)

Post the command line and output.  If you are using Windows, from the system menu you can click Edit, Select All, Edit, Copy to copy the contents of the command shell window.  Please use [code] [/code] tags.
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 178
Posts: 12288
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Arduino IDE always gives me error when comparing data written to chip with compiled program. Address is always different but not bigger than 0x0200 or so.
Code:
avrdude: verification error, first mismatch at byte 0x0100
         0xd0 != 0xc8

Post the verbose output.  Please use [code] [/code] tags.
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 119
Posts: 4594
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Arduino IDE always gives me error when comparing data written to chip with compiled program. Address is always different but not bigger than 0x0200 or so.
Code:
avrdude: verification error, first mismatch at byte 0x0100
         0xd0 != 0xc8

I've seen that when I have other things connected to the I/O pins when uploading. Try disconnecting everything except the programmer.
Logged

No, I don't answer questions sent in private messages...

Estonia
Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is the verbose output of arduino IDE

I have chip in socket, directly connected to USBtinyISP, nothing else in the circuit.

Code:
Binary sketch size: 3 232 bytes (of a 4 096 byte maximum)
C:\Users\tanels\Desktop\arduino-1.0.1\hardware/tools/avr/bin/avrdude -CC:\Users\tanels\Desktop\arduino-1.0.1\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -pattiny45 -cusbtiny -Uflash:w:C:\Users\tanels\AppData\Local\Temp\build4990552546878447088.tmp\serialtest.cpp.hex:i

avrdude: Version 5.11, compiled on Sep  2 2011 at 19:38:36
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Users\tanels\Desktop\arduino-1.0.1\hardware/tools/avr/etc/avrdude.conf"

         Using Port                    : lpt1
         Using Programmer              : usbtiny
avrdude: usbdev_open(): Found USBtinyISP, bus:device: bus-0:\\.\libusb0-0001--0x1781-0x0c9f
         AVR Part                      : ATtiny45
         Chip Erase delay              : 4500 us
         PAGEL                         : P00
         BS2                           : P00
         RESET disposition             : possible i/o
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65     6     4    0 no        256    4      0  4000  4500 0xff 0xff
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           flash         65     6    32    0 yes      4096   64     64  4500  4500 0xff 0xff
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           calibration    0     0     0    0 no          2    0      0     0     0 0x00 0x00

         Programmer Type : USBtiny
         Description     : USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/
avrdude: programmer operation not supported

avrdude: Using SCK period of 10 usec
CMD: [ac 53 00 00] [ff fe 53 00]
avrdude: AVR device initialized and ready to accept instructions

Reading | CMD: [30 00 00 00] [00 30 00 1e]
CMD: [30 00 01 00] [00 30 00 92]
################CMD: [30 00 02 00] [00 30 00 06]
################################## | 100% 0.00s

avrdude: Device signature = 0x1e9206
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
CMD: [a0 00 fc 00] [00 a0 00 ff]
CMD: [a0 00 fd 00] [00 a0 00 ff]
CMD: [a0 00 fe 00] [00 a0 00 ff]
CMD: [a0 00 ff 00] [00 a0 00 ff]
avrdude: erasing chip
CMD: [ac 80 00 00] [00 ac 80 00]
avrdude: Using SCK period of 10 usec
CMD: [ac 53 00 00] [00 ac 53 00]
avrdude: reading input file "C:\Users\tanels\AppData\Local\Temp\build4990552546878447088.tmp\serialtest.cpp.hex"
avrdude: writing flash (3232 bytes):

Writing | CMD: [4c 00 00 00] [00 4c 00 00]
CMD: [4c 00 20 00] [12 4c 00 20]
#CMD: [4c 00 40 00] [20 4c 00 40]
#CMD: [4c 00 60 00] [ec 4c 00 60]
#CMD: [4c 00 80 00] [d0 4c 00 80]
#CMD: [4c 00 a0 00] [e0 4c 00 a0]
#CMD: [4c 00 c0 00] [85 4c 00 c0]
#CMD: [4c 00 e0 00] [23 4c 00 e0]
#CMD: [4c 01 00 00] [56 4c 01 00]
#CMD: [4c 01 20 00] [93 4c 01 20]
#CMD: [4c 01 40 00] [83 4c 01 40]
#CMD: [4c 01 60 00] [86 4c 01 60]
#CMD: [4c 01 80 00] [5d 4c 01 80]
#CMD: [4c 01 a0 00] [f0 4c 01 a0]
#CMD: [4c 01 c0 00] [91 4c 01 c0]
#CMD: [4c 01 e0 00] [91 4c 01 e0]
#CMD: [4c 02 00 00] [00 4c 02 00]
#CMD: [4c 02 20 00] [f4 4c 02 20]
#CMD: [4c 02 40 00] [96 4c 02 40]
#CMD: [4c 02 60 00] [91 4c 02 60]
#CMD: [4c 02 80 00] [e0 4c 02 80]
#CMD: [4c 02 a0 00] [4f 4c 02 a0]
#CMD: [4c 02 c0 00] [95 4c 02 c0]
#CMD: [4c 02 e0 00] [17 4c 02 e0]
#CMD: [4c 03 00 00] [2f 4c 03 00]
#CMD: [4c 03 20 00] [e0 4c 03 20]
#CMD: [4c 03 40 00] [93 4c 03 40]
#CMD: [4c 03 60 00] [92 4c 03 60]
#CMD: [4c 03 80 00] [1d 4c 03 80]
#CMD: [4c 03 a0 00] [91 4c 03 a0]
#CMD: [4c 03 c0 00] [2f 4c 03 c0]
#CMD: [4c 03 e0 00] [96 4c 03 e0]
#CMD: [4c 04 00 00] [05 4c 04 00]
#CMD: [4c 04 20 00] [bf 4c 04 20]
#CMD: [4c 04 40 00] [b7 4c 04 40]
#CMD: [4c 04 60 00] [73 4c 04 60]
#CMD: [4c 04 80 00] [2b 4c 04 80]
#CMD: [4c 04 a0 00] [92 4c 04 a0]
#CMD: [4c 04 c0 00] [91 4c 04 c0]
#CMD: [4c 04 e0 00] [bf 4c 04 e0]
#CMD: [4c 05 00 00] [01 4c 05 00]
#CMD: [4c 05 20 00] [94 4c 05 20]
#CMD: [4c 05 40 00] [08 4c 05 40]
#CMD: [4c 05 60 00] [93 4c 05 60]
#CMD: [4c 05 80 00] [94 4c 05 80]
#CMD: [4c 05 a0 00] [e0 4c 05 a0]
#CMD: [4c 05 c0 00] [2f 4c 05 c0]
#CMD: [4c 05 e0 00] [17 4c 05 e0]
#CMD: [4c 06 00 00] [f0 4c 06 00]
#CMD: [4c 06 20 00] [48 4c 06 20]
#CMD: [4c 06 40 00] [00 4c 06 40]
# | 100% 5.98s

avrdude: 3232 bytes of flash written
avrdude: verifying flash memory against C:\Users\tanels\AppData\Local\Temp\build4990552546878447088.tmp\serialtest.cpp.hex:
avrdude: load data flash data from input file C:\Users\tanels\AppData\Local\Temp\build4990552546878447088.tmp\serialtest.cpp.hex:
avrdude: input file C:\Users\tanels\AppData\Local\Temp\build4990552546878447088.tmp\serialtest.cpp.hex contains 3232 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 4.81s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0100
         0xd0 != 0xc8
avrdude: verification error; content mismatch

avrdude done.  Thank you.

and the sketch itself
Code:
#include <SoftwareSerial.h>

SoftwareSerial mySerial(0, 1); // RX, TX

void setup()  
{
  // set the data rate for the SoftwareSerial port
  mySerial.begin(1200);
  mySerial.println("Hello, world?");
}

void loop() // run over and over
{
    mySerial.write("tere");
    delay(100);
}

when using avrdude from command line I use:
Code:
C:\Users\tanels\AppData\Local\Temp\build4990552546878447088.tmp>avrdude -c usbtiny -p t45 -U flash:w:serialtest.cpp.hex

The picture of the used hardware for connecting attiny to USBtinyISP. USB A socket on perfboard is for extra power from another USB port, this didn't change a thing. Capacitor is 0,1 uF for supply voltage stability (it was recommended on one forum) the perfboard has both male and female connector, so it can be connected directly to USBtinyISP or to the cable (the other USBtinyISP had its connector oriented so that cable had to be used)
« Last Edit: March 07, 2013, 05:22:21 am by Amigone » Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 119
Posts: 4594
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It has to be a wiring problem. Double-check it all with a multimeter. Trust nothing.

I've seen that exact error when the MISO wire wasn't working properly.

Logged

No, I don't answer questions sent in private messages...

Estonia
Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If this is wiring problem, how do you explain the fact that using avrdude from commandline works? I can go over all the connections one more time, just fur fun of it =)

EDIT
one more round with my fluke multimeter and all the connections are solid from chip to chip.

Just for infromation, the results of command line:
Code:
C:\Users\tanels\AppData\Local\Temp\build4990552546878447088.tmp>avrdude -c usbti
ny -p t45 -U flash:w:serialtest.cpp.hex

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9206
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed

         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "serialtest.cpp.hex"
avrdude: input file serialtest.cpp.hex auto detected as Intel Hex
avrdude: writing flash (3232 bytes):

Writing | ################################################## | 100% 6.08s



avrdude: 3232 bytes of flash written
avrdude: verifying flash memory against serialtest.cpp.hex:
avrdude: load data flash data from input file serialtest.cpp.hex:
avrdude: input file serialtest.cpp.hex auto detected as Intel Hex
avrdude: input file serialtest.cpp.hex contains 3232 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 4.95s



avrdude: verifying ...
avrdude: 3232 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.
« Last Edit: March 07, 2013, 06:13:43 am by Amigone » Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 119
Posts: 4594
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Doesn't look to me like you're verifying the data from the command line.

It's the verifying that's the problem, which is why I pointed the finger at MISO. Even if the multimeter shows a connection there might be a weird wire or solder joint.

What's the resistance, exactly from ISP to MISO pin? Is there any voltage on the chip socket if you remove the ATtiny?

Logged

No, I don't answer questions sent in private messages...

Estonia
Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
avrdude: verifying flash memory against serialtest.cpp.hex:
avrdude: load data flash data from input file serialtest.cpp.hex:
avrdude: input file serialtest.cpp.hex auto detected as Intel Hex
avrdude: input file serialtest.cpp.hex contains 3232 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 4.95s



avrdude: verifying ...
avrdude: 3232 bytes of flash verified

I can't read out of this anything else but the fact that flash is read back and verified against the serialtest.cpp.hex file.

I did the measurements and all pins had resistance of 0,35 to 0,4 ohm on my work Fluke multimeter that is calibrated yearly. (leads connected resistance was 0,15) I measured the resistance from the socket for attiny to the component on the USBtinyISP.

When removing attiny from socket, i remove the cable from USBtinyISP first.

Still with no clue, but thankful for your time.

EDIT

for instance, I have a tiny sketch to output serial data - print Hello World. If i upload it using Arduino IDE, I get nothing on the serial line. If I do the same thing on command line with avrdude, I do get gibbrish on serial line "Heìlÿ‹×ªwor¶ôý" - this is supposed to be "Hello World?", so Arduino IDE fails to program the chip and it seems, also fails to compile the program correctly.
« Last Edit: March 07, 2013, 08:28:20 am by Amigone » Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 119
Posts: 4594
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I dunno...it's weird.

If command line is working then maybe it's using a different SPI speed than the IDE. That's about the only thing left.



Logged

No, I don't answer questions sent in private messages...

Denmark
Offline Offline
Edison Member
*
Karma: 35
Posts: 1029
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If you look at the verbose output you will see this error:

Code:
        Description     : USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/
avrdude: programmer operation not supported

If you google that error you will get a lot of results from others using USBTiny as programmer, maybe some of them has the answer.
Logged

Denmark
Offline Offline
Edison Member
*
Karma: 35
Posts: 1029
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


I can replicate your error if I use a USBAsp programmer, and a fresh Attiny85
It is possible because i have not updated the firmware like described in this thread

http://arduino.cc/forum/index.php/topic,149668.0.html

If I set the fuses to 8MHZ, it works.

Furthermore you could check the avrdude version
When I use Arduino IDE it uses version 5.11, and if I use the command line version 5.10 is used.

So maybe you have different versions too, that you use without knowing.
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 119
Posts: 4594
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you look at the verbose output you will see this error:

Code:
        Description     : USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/
avrdude: programmer operation not supported

If you google that error you will get a lot of results from others using USBTiny as programmer, maybe some of them has the answer.

No, that's completely normal. I get it on every upload.
Logged

No, I don't answer questions sent in private messages...

Estonia
Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I do have different avrdude versions, as I installed WinAVR in the process of debugging. Command line version is 5.10 and arduino uses 5.11. So newer version can't handle it?

Also I have tried to change the fuses both with arduino IDE and with avrdude, as specified in my first post - with no success.

My guess is that arduino IDE either mishandles avrdude, giving it wrong parameters, or doesn't take into account the speed or other specific parameters of the attiny chip - problem in some config files?
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 178
Posts: 12288
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

My guess is that arduino IDE either mishandles avrdude, giving it wrong parameters, or doesn't take into account the speed or other specific parameters of the attiny chip - problem in some config files?

Easy enough to prove.  Copy the avrdude command line from the Arduino IDE status window and paste it into a command shell.
Logged

Pages: [1] 2   Go Up
Jump to: