ArduinoISP and AtTiny2313 try with no success

Hello all,

I’m trying to use the arduino (Duelmilanove with AtMega328) loaded with ArduinoISP sketch and program a AtTiny2313.

I made the wiring as shown here : http://arduino.cc/en/Tutorial/ArduinoISP

The AtTiny2313 is stand alone and I have NOT connected a crystal to it.

I’m running GNU/Linux and using this arguments to avrdude to program the AtTiny2313 :

avrdude -c avrisp -p attiny2313 -P /dev/ttyUSB0 -b 19200 -v -U flash:w:blink.hex

The blink code is :

#define F_CPU 1000000UL //Define the speed the clock is running at.  Used for the delay.h functions

#include <avr/io.h>     //Include the headers that handles Input/Output function for AVR chips
#include <util/delay.h> //Include the headers that allow for a delay function

//Prototypes
void Delay_ms(int cnt);
void init_io(void);

//Functions
void Delay_ms(int cnt)
{
  while(cnt-->0) _delay_ms(1);
}

void init_io(void)
{
  DDRB = (1 << PB0)|(1<< PB1)|(1 << PB2)|(1 << PB3)|(1 << PB4); // Set LED pins as outputs
}

//Main Function
int main(void)
{
  init_io(); //Set up the pins that control the LEDs
  int i;     //Initialize variable to count through each LED
  for (;;)   //Loop forever
  {
    for (i=2; i<8; i++)
    {
      PORTB |= (1 << i);  //Turn on LED i
      Delay_ms(1000);        //Wait 1 second
      PORTB = 0;          //Turn off all LEDs
    }
  }
}

which I found on instructables. The problem now is the following,

When I try only to erase the chip (using the -e command line argument) I get an “avrdude done. Thank you.” and the erase cycle completes successfully (or does it?). The problem is that when I add the argument for flashing the AtTiny2313 (-U flash:w:blink.hex) I get this :

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.12s

avrdude: Device signature = 0x1e910a
avrdude: safemode: lfuse reads as 64
avrdude: safemode: hfuse reads as DF
avrdude: safemode: efuse reads as FF
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 "blink.hex"
avrdude: input file blink.hex auto detected as Intel Hex
avrdude: writing flash (190 bytes):

[b]Writing |                                                    | 0% 0.00s
avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x11
avrdude: stk500_cmd(): programmer is out of sync[/b]

It doesn’t even want to start programing the chip.

Has anyone encountered this kind of a problem before and what is its solution ?

Regards,
Aleks

Needing a crystal or not depends on fuse programming on the AVR to be programmed. Factory Default options would indicate Crystal is needed.

In my opinion, it's really much simpler and cheaper to build an STK200 programmer and the free PONYPROG software to program the other AVR chips.

http://www.lancos.com/prog.html

Factory Default options would indicate Crystal is needed

The factory default is 8 MHz internal oscillator divided by 8. An external clock is not needed.

Other than the ArduinoISP, is anything connected to the 2313?

Try adding "-v -v -v" to the command-line when you run AVRDUDE.

I agree with pwillard. A dedicated programmer is worth the money. I really like this one... http://www.pololu.com/catalog/product/1300

The factory default is 8 MHz internal oscillator

I blame age and bad memory... ;-)

If that's the most "important" thing you can't remember, you're doing well! :)

Needing a crystal or not depends on fuse programming on the AVR to be programmed. Factory Default options would indicate Crystal is needed.

In my opinion, it's really much simpler and cheaper to build an STK200 programmer and the free PONYPROG software to program the other AVR chips.

http://www.lancos.com/prog.html

I know that a dedicated programer is the best think, but I'm doing this for PoC and for the sake of doing and I think its the fastest solution.

Anyhow, just a random question, does PONYPROG work under GNU/Linux ?

The factory default is 8 MHz internal oscillator divided by 8. An external clock is not needed.

Other than the ArduinoISP, is anything connected to the 2313?

Try adding "-v -v -v" to the command-line when you run AVRDUDE.

I have connected only one led through a 2k2 resistor to PB0 so I can see if the program is running.

Here is the output of the command with the "-v -v -v" arguments :

avrdude -c avrisp -p attiny2313 -P /dev/ttyUSB0 -b 19200 -v -v -v -U flash:w:blink.hex

avrdude: Version 5.10, compiled on Apr  3 2010 at 18:48:10
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/etc/avrdude.conf"
         User configuration file is "/home/aleks/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyUSB0
         Using Programmer              : avrisp
         Overriding Baud Rate          : 19200
         AVR Part                      : ATtiny2313
         Chip Erase delay              : 9000 us
         PAGEL                         : PD4
         BS2                           : PD6
         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        128    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      2048   32     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 : STK500
         Description     : Atmel AVR ISP
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.12s

avrdude: Device signature = 0x1e910a
avrdude: safemode read 1, lfuse value: 64
avrdude: safemode read 2, lfuse value: 64
avrdude: safemode read 3, lfuse value: 64
avrdude: safemode: lfuse reads as 64
avrdude: safemode read 1, hfuse value: df
avrdude: safemode read 2, hfuse value: df
avrdude: safemode read 3, hfuse value: df
avrdude: safemode: hfuse reads as DF
avrdude: safemode read 1, efuse value: ff
avrdude: safemode read 2, efuse value: ff
avrdude: safemode read 3, efuse value: ff
avrdude: safemode: efuse reads as FF
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 "blink.hex"
avrdude: input file blink.hex auto detected as Intel Hex
avrdude: writing flash (190 bytes):

Writing |                                                    | 0% 0.00s
avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x11
avrdude: stk500_cmd(): programmer is out of sync

I have connected only one led through a 2k2 resistor to PB0 so I can see if the program is running.

In series? Have you tried with the LED removed?

In series? Have you tried with the LED removed?

Yes in series and yes I have tried without it.

Latest that I have tried is connecting a 8MHz crystal with 2 27pF capacitors on my breadboard to the AtTiny2313 and I still get the same error.

Any clues to what might be going on ?

Regards, Aleks

This is from the 0019 programmers.txt file…

arduinoisp.name=Arduino as ISP
arduinoisp.communication=serial
arduinoisp.protocol=stk500v1
arduinoisp.speed=19200

Try this…

avrdude -c stk500v1 -p attiny2313 -P /dev/ttyUSB0 -b 19200 -v -v -v -U flash:w:blink.hex

The same problem :(

avrdude -c stk500v1 -p attiny2313 -P /dev/ttyUSB0 -b 19200 -v -v -v -U flash:w:blink.hex

avrdude: Version 5.10, compiled on Apr  3 2010 at 18:48:10
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/etc/avrdude.conf"
         User configuration file is "/home/aleks/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyUSB0
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
         AVR Part                      : ATtiny2313
         Chip Erase delay              : 9000 us
         PAGEL                         : PD4
         BS2                           : PD6
         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        128    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      2048   32     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 : STK500
         Description     : Atmel STK500 Version 1.x firmware
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.12s

avrdude: Device signature = 0x1e910a
avrdude: safemode read 1, lfuse value: 64
avrdude: safemode read 2, lfuse value: 64
avrdude: safemode read 3, lfuse value: 64
avrdude: safemode: lfuse reads as 64
avrdude: safemode read 1, hfuse value: df
avrdude: safemode read 2, hfuse value: df
avrdude: safemode read 3, hfuse value: df
avrdude: safemode: hfuse reads as DF
avrdude: safemode read 1, efuse value: ff
avrdude: safemode read 2, efuse value: ff
avrdude: safemode read 3, efuse value: ff
avrdude: safemode: efuse reads as FF
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 "blink.hex"
avrdude: input file blink.hex auto detected as Intel Hex
avrdude: writing flash (190 bytes):

Writing |                                                    | 0% 0.00s
avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x11
avrdude: stk500_cmd(): programmer is out of sync

Maybe it's something to do with the .hex file ?