Arduino Uno R3 as a true ISP programmer for any AVR

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:

that teaches 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.

Edit: April 23, 2015

There is now a quite useful tutorial that answers well my question. It can be found at this link:
Arduino Uno R3 as a true ISP programmer for any Attiny and Atmega AVR

If it happens you find this topic on the net just click the address of the tutorial and follow its steps.

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...

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

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:

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

I'm not totally sure I understand the original question, but I have a sketch here that lets one Arduino program another:
Gammon Forum : Electronics : Microprocessors : Atmega bootloader programmer
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

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.

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!

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:

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.

simplex:
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.

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

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:

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?

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 :wink:

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

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.

spcomputing:
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.

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.

simplex:
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?

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.

simplex:
I wanted to make sure that my Atmega328p is set indeed for an external 16MHz crystal and not an internal oscillator.

The fuses tell you what it is set to. I don't understand what you are trying to do, except waste time.

What has any of this got to do with:

Arduino Uno R3 as a true ISP programmer for any AVR

Nothing you have said is anything to do with the Uno R3.

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?

Yeah, 7cm is pretty long for the connection to a crystal... On pretty much all of the real Arduinos I've used, the traces to the crystals are less than 1cm.

I'm with Nick in being confused. Where are you at this point? Are things working or not? Is the only issue remaining unexplained behavior that was solved by fiddling with the oscillator cap/wires/etc. And we're well beyond the thread title, right?

westfw:
I'm with Nick in being confused. Where are you at this point? Are things working or not?

Yes, my Atmega328p on the breadboard is working now. My post from "October 06, 2012, 01:20:29 PM" with the output generated by avrdude should have told you that, as long as I received the device signature and read the fuses.

[quote author=Nick Gammon link=topic=125248.msg947390#msg947390 date=1349601537]

simplex:
I wanted to make sure that my Atmega328p is set indeed for an external 16MHz crystal and not an internal oscillator.

The fuses tell you what it is set to. I don't understand what you are trying to do, except waste time.[/quote]

I am not familiar with avrdude. I launched it for the first time around 1 Oct. 2012.
A command like this:
c:>avrdude -P COM3 -b 19200 -c avrisp -p m328p -n
outputs a lot of text out of which a large majority proved to be taken from a configuration file on the PC, not directly from the Atmega328p on the breadboard.

I did four tests:

  1. Crystal connected with 22 pF capacitors both of them having one terminal grounded (the classical oscillator). avrdude output something.
  2. Crystal with capacitors disconnected from the ground (removed from the circuit). avrdude output something different compared with what I had gotten at point (1).
  3. Crystal removed from the circuit. avrdude displayed same thing as at point (1).
  4. Arduino Uno R3 with ISP sketch loaded but not connected to the breadbord with Atmega328p. avrdude displayed same thing as per point (1).

So only point (2) was different, despite the fact the external resonator was in an unusual configuration, which told me that this might be the working case. Normally (1) should have been the only situation in which Atmega328p on the breadbord should have worked, not two.

I did not waste my time as long as I narrowed down the problem to the external oscillator.

Regarding the fuses, it is not self evident from the output of avrdude what is the frequency of the crystal connected to Atmega328p on the breadboard. I had to use an internet calculator, a thing that I finally did when I found out about the existence of such a tool, this is after my problem with the external oscillator had been already fixed.

Nothing you have said is anything to do with the Uno R3.

I use an Arduino Uno R3 as an ISP programmer. I confirm this 100%.