Offline
Full Member
Karma: 0
Posts: 109
|
 |
« on: October 01, 2012, 06:01:52 pm » |
Arduino Uno R3 as a true ISP programmer for any AVRIs 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/ArduinoISPhttp://arduino.cc/en/Tutorial/ArduinoToBreadboardthat 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
God Member
Karma: 13
Posts: 632
|
 |
« Reply #1 on: October 01, 2012, 06:14:08 pm » |
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
Melbourne, Australia
Offline
Shannon Member
Karma: 218
Posts: 13896
Lua rocks!
|
 |
« Reply #2 on: October 01, 2012, 06:26:03 pm » |
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=11635If 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=11638Then you just move the SD card to your computer, and copy across the new bootloader when you want to program it.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Full Member
Karma: 0
Posts: 109
|
 |
« Reply #3 on: October 01, 2012, 07:29:29 pm » |
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=11635If 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
Faraday Member
Karma: 78
Posts: 5453
Strongly opinionated, but not official!
|
 |
« Reply #4 on: October 01, 2012, 07:34:24 pm » |
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
Full Member
Karma: 0
Posts: 109
|
 |
« Reply #5 on: October 02, 2012, 02:01:00 pm » |
Using an Arduino and Avrdude to Program an AVRsee: http://www.sparkfun.com/tutorials/2001) 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
Full Member
Karma: 0
Posts: 109
|
 |
« Reply #6 on: October 06, 2012, 03:12:49 am » |
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.
|
|
|
|
« Last Edit: October 06, 2012, 03:14:20 am by simplex »
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 218
Posts: 13896
Lua rocks!
|
 |
« Reply #7 on: October 06, 2012, 04:07:52 am » |
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
God Member
Karma: 13
Posts: 632
|
 |
« Reply #8 on: October 06, 2012, 10:15:36 am » |
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
Full Member
Karma: 0
Posts: 109
|
 |
« Reply #9 on: October 06, 2012, 01:20:29 pm » |
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?
|
|
|
|
|
Logged
|
|
|
|
|
California
Offline
God Member
Karma: 13
Posts: 632
|
 |
« Reply #10 on: October 06, 2012, 10:17:22 pm » |
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 http://www.gammon.com.au/forum/?id=11633
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 218
Posts: 13896
Lua rocks!
|
 |
« Reply #11 on: October 06, 2012, 11:33:18 pm » |
I think the 8 MHz clock signal is described on this page: http://www.gammon.com.au/forum/?id=11638I 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
Full Member
Karma: 0
Posts: 109
|
 |
« Reply #12 on: October 07, 2012, 03:23:44 am » |
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.htmlProduct 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=atmega328pfuse 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
Melbourne, Australia
Offline
Shannon Member
Karma: 218
Posts: 13896
Lua rocks!
|
 |
« Reply #13 on: October 07, 2012, 03:49:56 am » |
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
Full Member
Karma: 0
Posts: 109
|
 |
« Reply #14 on: October 07, 2012, 04:10:57 am » |
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
|
|
|
|
|
|