Pages: [1] 2 3 4   Go Down
Author Topic: Arduino Uno R3 as a true ISP programmer for any AVR  (Read 30148 times)
0 Members and 3 Guests are viewing this topic.
Offline Offline
Full Member
***
Karma: 0
Posts: 109
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Arduino Uno R3 as a true ISP programmer for any AVR

Is there a driver that can be loaded in Arduino Uno R3 and turn this board into a pure ISP programmer for any AVR or at least for a few Attiny and Atmega which are used frequently?

I know, there is a tutorial, see:
http://arduino.cc/en/Tutorial/ArduinoISP
http://arduino.cc/en/Tutorial/ArduinoToBreadboard
that teach people how to program stand alone ATmega168 or ATmega328 controllers, using Arduino Uno R3, but the operation is complicated involving two steps:
1) Writing a boot-loader to the stand alone AVR.
2) Removing the Atmega from Arduino Uno R3, changing the wiring required for (1) and finally writing the stand alone AVR with the desired hex file.

Is there a way to program a stand alone AVR in one step, by just connecting it to Arduino Uno R3, with the help of a few wires, without writing the boot-loader first?

It looks like this is possible, the only thing missing being the driver that transform Arduino Uno R3 into a real ISP programmer.
Logged

California
Offline Offline
God Member
*****
Karma: 14
Posts: 629
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

There is no reason you have to write the bootloader unless you want serial programming (FTDI/Atmega16u2 etc).  You can hook up the SPI of the Arduino as ISP and connect the SPI pins of the target and upload away...
Logged


Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm not totally sure I understand the original question, but I have a sketch here that lets one Arduino program another:

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

If you make up the cable I describe all you have to do is plug it in to program.

Or if you are changing the bootloader (eg. testing it) you can use this one to upload any file from an SD card:

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

Then you just move the SD card to your computer, and copy across the new bootloader when you want to program it.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 109
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I'm not totally sure I understand the original question, but I have a sketch here that lets one Arduino program another:
http://www.gammon.com.au/forum/?id=11635
If you make up the cable I describe all you have to do is plug it in to program.
Your post seems to answer my question.
This is want I want to do, to program AVRs that have nothing to do with Arduino Uno R3 and the boot-loader on its Atmega328, and use them in various boards. 

I will try to compile and upload, on my Arduino Uno R3 board, the sketch http://gammon.com.au/Arduino/Atmega_Board_Programmer.zip you indicated and follow the instructions on your site.
If I have supplemental questions I will come back.
Thank you
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 124
Posts: 6651
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, that will work fine.  Any random hex file into any random avr is logically equivalent to burning the bootloader into an Arduino chip, except that you'll have to learn to use avrdude and fuses and such, instead of using the simple "burn bootloader" button in the arduino IDE.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 109
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Using an Arduino and Avrdude to Program an AVR
see: http://www.sparkfun.com/tutorials/200

1) Upload ArduinoISP to the Arduino
2) Connect the Arduino to the Target Board's ISP signals
3) Generate the hex file to be loaded onto the Target Board
4) Use avrdude to send the hex file to the Arduino, which will program the Target Board

It was so simple!
« Last Edit: October 02, 2012, 02:02:40 pm by simplex » Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 109
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have tried to follow the steps from here ( http://arduino.cc/en/Tutorial/ArduinoToBreadboard ) to burn a bootloader in an identical controller (Atmega328p already configured for a 16 MHz crystal) as the one used by Arduino Uno R3, the board that I have.

First, I did not use avrdude but just Arduino 1.0.1. No bootloader can be loaded in the Atmega328p on the breadboard. I get the message "Invalide device signature".

Reading more carefully the instructions in the tutorial, I noticed that it says:
"Note that these techniques only work with the Arduino Duemilanove w/ an ATmega328, not the Arduino Uno (or older Arduino boards w/ an ATmega168)."
which I guess means Arduino Uno R3 can simply not be configured by Arduino 1.0.1 as an ISP programmer and no bootloader can be uploaded in controllers on breadboards.

It is a bit puzzling but it looks like this is the reality.

If I use avrdude I get the same error message:

Code:
c:\>avrdude -P COM3 -b 19200 -c avrisp -p m328p -n

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.30s

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

avrdude done.  Thank you.

Same message I get if I try to use avrdude without connecting Arduino Uno R3 to the breadboard.

It looks like the connections between Arduino Uno R3 and the Atmega328p on the breadboard are not good but I checked them many times and they are ok.

« Last Edit: October 06, 2012, 03:14:20 am by simplex » Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

which I guess means Arduino Uno R3 can simply not be configured by Arduino 1.0.1 as an ISP programmer and no bootloader can be uploaded in controllers on breadboards.

No. Of course it can, and of course you can upload bootloaders.

You have a wiring issue or something like that. Post a clear photo please.
Logged

California
Offline Offline
God Member
*****
Karma: 14
Posts: 629
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Also, you need to change the programmer type in the command line (this case, Arduino as ISP):

c:\>avrdude -P COM3 -b 19200 -c avrisp arduino -p m328p -n
Logged


Offline Offline
Full Member
***
Karma: 0
Posts: 109
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I disconnected from the ground the two 22pF capacitors connected to the 16MHz Crystal, which means that they no longer exist in the circuit.

Now, with both options -c avrisp and -c arduino, I get the following output:

Code:
c:\>avrdude -P COM3 -b 19200 -c avrisp -p m328p -n -v

avrdude: Version 5.10, compiled on Jun  4 2012 at 14:16:26
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Program Files\Atmel\AVR Tools\AVR Toolchain\bin\avrdude.conf"

         Using Port                    : COM3
         Using Programmer              : avrisp
         Overriding Baud Rate          : 19200
         AVR Part                      : ATMEGA328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         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     5     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    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.23s

avrdude: Device signature = 0x1e950f
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as D6
avrdude: safemode: efuse reads as 5

avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as D6
avrdude: safemode: efuse reads as 5
avrdude: safemode: Fuses OK

avrdude done.  Thank you.

If I pull out the Crystal, from the breadboard, I get the message:

"Device signature = 0x000000
avrdude: Yikes!  Invalid device signature."


It seems that this is a oscillator related problem. The 16 MHz crystal is connected to the Atmega328p on the breadboard with a pair of 7 cm long wires. Could these wires act as capacitors at 16 MHz and replace somehow the two 22pF capacitors?
Logged

California
Offline Offline
God Member
*****
Karma: 14
Posts: 629
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I think your Atmega is still running at 1 MHz (factory default).  If you use Nick's programmer and the 8MHz signal from the D9 pin, you will crack that chip smiley-wink
http://www.gammon.com.au/forum/?id=11633
Logged


Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I think the 8 MHz clock signal is described on this page:

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

I also think I altered the other sketches to output it (but maybe didn't describe it on the page).

I recently got an Atmega32U4 to program, and didn't have any luck until I slowed down the programming rate, and then it turned out it had the "divide by 8" fuse set.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 109
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think your Atmega is still running at 1 MHz (factory default).
This is the Atmega I bought:
see: http://www.abra-electronics.com/products/A000048-Arduino-ATMega328-Microcontroller.html
Product Description
The A000048 is a Arduino ATMega328 Microcontroller in a DIP package, pre-loaded with the Arduino UNO (16MHz) Bootloader.
 

It is clear that my chip on the breadboard is a 16MHz ATMega328p with bootloader preloaded.

Quote
I recently got an Atmega32U4 to program, and didn't have any luck until I slowed down the programming rate, and then it turned out it had the "divide by 8" fuse set.
Using this
http://www.frank-zhao.com/fusecalc/fusecalc.php?chip=atmega328p
fuse calculator but in reverse, I get that my Atmega328p does not have the "divide by 8" fuse set and runs at 16 MHz.
This is the information I obtain if I introduce, in the line just above the black line of Frank Zhao's calculator, the values of fuses lfuse = FF, hfuse = D6, efuse = 5 which I read with avrdude from Atmega328p.
« Last Edit: October 07, 2012, 03:52:05 am by simplex » Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If I pull out the Crystal, from the breadboard, I get the message:

"Device signature = 0x000000
avrdude: Yikes!  Invalid device signature."


If you pull out the crystal it doesn't work. What do you expect, exactly?
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 109
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you pull out the crystal it doesn't work. What do you expect, exactly?
I wanted to make sure that my Atmega328p is set indeed for an external 16MHz crystal and not an internal oscillator.

In the meantime I read that breadbords do not work well above 10 MHz because of stray capacitors in the range of 2-20 pF that appear everywhere. The two 22 pF capacitors connected to the Crystal are in the order of magnitude of the stray capacitors so it looks like I had too much capacitance around the crystal, which was connected to the ground by the two 22 pF capacitors and to the uC by other, this time unwanted capacitors. Removing the two 22 pF capacitors somehow liberated the Crystal and made it to oscillate which it did not do before.

Logged

Pages: [1] 2 3 4   Go Up
Jump to: