Go Down

Topic: Trying to use Arduino Uno R3 as ISP for ATTiny2313 (Read 3773 times) previous topic - next topic

gringle

Jan 20, 2013, 02:44 pm Last Edit: Jan 20, 2013, 06:39 pm by gringle Reason: 1
Hi,

I want to program a ATTiny2313 with a hex file and since I recently got myself an Arduino Uno, I am trying to use it as an ISP and upload the hex file with avrdude. I am working with OSX.

Mainly I have been following this tutorial: http://www.ernstc.dk/arduino/2313.htm
I also read (among many other stuff) this thread: (http://arduino.cc/forum/index.php/topic,84943.0.html)

According to the tutorial I connected the 2313 to the Arduino board.

Some things are not clear to me, hopefully someone can help me a bit. I do not want to program the 2313 using the Arduino IDE, I just want to upload an existing hex file with avrdude. Do I need to install the Tiny-core as explained in the tutorial for this? If so, I need some help with that as well. I tried to install it according to the ReadMe.txt but I can't get the new options to show up in the Tools->Board menu in the Arduino IDE. I extracted the Tiny-core into Documents/Arduino/libraries/hardware/ while the IDE was closed, but when I started it again I didn't have any new options.
I figured out how to install the Tiny-core. For anyone who might also have problems with this: Go to your application folder and Ctrl-Click the Arduino.app file and choose Show Package Contents. Then navigate to the Contents/Resources/Java/hardware folder and copy the tiny folder into it.

I uploaded the ArduinoISP sketch to the Arduino and tested it with an LED, which was fading on and off so I guess at least that worked.

Hopefully someone can give me a few pointers in the right direction.


Nick Gammon

OK, so you are using and Arduino as ISP and attempting to upload a sketch?

You should be able to use avrdude from the command line to do that.

Also I have a sketch that uploads .hex files without using avrdude at all (the wiring is slightly different). It should work for that chip but I haven't tested it.

Read more here:

http://www.gammon.com.au/forum/?id=11638

My main PC is being repaired so I can't give more details right now. Maybe someone else can.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Erni

#2
Jan 20, 2013, 10:12 pm Last Edit: Jan 20, 2013, 10:14 pm by Erni Reason: 1
I have no experience with OSX, but the principle should be the same.

Try doing an upload using the ArduinoISP to the Attiny2313, for example the blink sketch.

Enable verbose output: File->preference -> check the box: verbose during upload

You can now see how the Arduino IDE handles the upload.

On a Windows machine it looks something like this (stripped fot the path information)

avrdude -p t2313 -c arduino -P COM3 -b115200 -D -Uflash:w:Blink.hex:i

Now you can copy this line to a command line, and substitute the Blink.hex with the hex file you wnat to upload.

A guide to using Avrdude:

http://www.ladyada.net/learn/avr/avrdude.html

gringle

Thanks for your answers.

Nick, I had a look at your solution, it looks interesting but might be a bit too much for what I'm trying to do.

Thanks for the tip about the verbose output, Erni. Since I was able to install Tiny-core now, I'll give it a try. Maybe I tried the wrong avrdude command.

gringle

Ok, so I rechecked the wiring and did everything according to http://www.ernstc.dk/arduino/2313.htm.
I uploaded ArduinoISP and checked with an LED on pin 9. Then I unplugged the Arduino Board, connected the capacitor from Ground to Reset, plugged it in again, chose ATtiny2313@1MHz in the Board menu and tried to upload the Blink sketch.  This is what I got:
avrdude: stk500_getsync(): not in sync: resp=0xe0

I unplugged and replugged the Arduino again and tried the same with ATtiny@8Mhz: Same error.

This is all with AVR ISP chosen as programmer. When I try this with Arduino as ISP, I get a lot more avrdude: Send and avrdude: Recv messages but it ends with
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding

Any idea what I might be doing wrong?

Coding Badly


Erni

Quote
When I try this with Arduino as ISP


That is the correct option.
I have updated the tutorial in http://www.ernstc.dk/arduino/2313.htm



gringle

Thanks for the update, I will try this when I get home this evening.

@Coding Badly: I thought this was done with the 10 µF capacitor from reset to ground as it was mentioned in Ernis tutorial and also at http://arduino.cc/en/Tutorial/ArduinoISP. Do I also need a 120 Ohm resistor between 5V and Reset?

kf2qd

#8
Jan 22, 2013, 06:02 pm Last Edit: Jan 22, 2013, 06:04 pm by kf2qd Reason: 1
When I have used my Arduino as ISP I used a 120 ohm resistor and no capacitor. Programmed ATMega328s and ATtiny2313s.

I was developing an ATTiny2313 based Stepper Driver - http://arduino.cc/forum/index.php/topic,84809.15.html - if you look at reply 25 there is a picture of the board I made for programming 328s and 2313s. I put the resistor as part of the connector that plugs into the Arduino. I made a cable that goes to a 6 oin ISP plug that is done in a similar fashion.

As is always the rule when having problems - double check your wiring yet again.

Coding Badly

@Coding Badly: I thought this was done with the 10 µF capacitor from reset to ground as it was mentioned in Ernis tutorial and also at http://arduino.cc/en/Tutorial/ArduinoISP.


It is.

Quote
Do I also need a 120 Ohm resistor between 5V and Reset?


That is very very unlikely.

Coding Badly


Try this version of the ArduinoISP sketch...
http://arduino.cc/forum/index.php/topic,108797.msg824488.html#msg824488

gringle

Still the same result, I uploaded the different ArduinoISP sketch, unplugged the board, put the capacitor in, selected ATtiny2313@1Mhz and Ardunino as ISP and then clicked Upload with programmer.

programmer is not responding.

Coding Badly


The suggestion was meant to overcome this...
Quote
avrdude: stk500_getsync(): not in sync: resp=0xe0


I suggest posting verbose output from avrdude.  Please use [code] [/code] tags.

gringle

Oh, sorry, the "not in sync" error was due to the "AVR ISP" I had set as programmer. When I switched it to "Arduino as ISP" I only get the "programmer not responding" error. Here is the avrdude output:

Code: [Select]
avrdude: Version 5.11, compiled on Sep  2 2011 at 18:52:52
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/Users/gringle/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/tty.usbmodem1d11
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
         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
avrdude: Send: A [41] . [80]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [02]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [81]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [01]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [82]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [12]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [98]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
avrdude: Send: A [41] . [84]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [85]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [86]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [87]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [89]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: Send: A [41] . [81]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [01]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [82]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [12]
avrdude: Recv: . [10]
avrdude: Send: B [42] # [23] . [00] . [00] . [01] . [01] . [01] . [01] . [03] . [ff] . [ff] . [ff] . [ff] . [00]   [20] . [00] . [80] . [00] . [00] . [08] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: Send: E [45] . [05] . [04] . [d4] . [d6] . [01]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: Send: P [50]   [20]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding

Coding Badly


Your wiring is wrong.  Very likely a short-circuit brought about when the programmer (your Uno) attempts to enable programming mode on the target (the ATtiny2313).

I suggest you put 220 ohm (or higher) series resistors on the SPI and RESET connections between the programmer and the target before you damage one or both sides.

Go Up