Instructables

How to program a AVR (arduino) with another arduino

Picture of How to program a AVR (arduino) with another arduino
attiny2313_burning_fuses.jpg
atmega_rbbb1.jpg
This instructables is usefull if:

* you've got your arduino with atmega168 and you bought an atmega328 at you local electronics store. It doesn't have an arduino bootloader

* you want to make a project that doesn't use arduino - just a regular AVR chip (like the USBTinyISP) - you have a clean attiny2313/attiny48 etc that you want to burn firmware on.

Normally  you would have to have an ISP (In System Programmer) like USBTinyISP to program your new chip.  Having the arduino you can teach it to be a programmer thank to a great work done by Randall Bohn. He created Mega-ISP - an arduino sketch that works like a programmer.
 
Remove these adsRemove these ads by Signing Up

Step 1: What do you need ?

* a working Arduino (or a clone - i'm using the BBB - BareBonesBoard and a RBBB - RealBareBonesBoard by ModernDevices)
* a chip that you want to program (tested with atmega8,atmega168,atmega368, attiny2313, attiny13)
* a breadboard or a board with ISP header
* 3 leds + 3 resistors
* breadboard wires
1-40 of 46Next »
KarolisL2 years ago
Hi,

can you help me?
PC doesnt see my programmer. Everything is ok with wiring. I think i did something bad with firmware burning.

As i understood i should insert hex from spi folder only or I should compile makefiles in 1 hex from all folder?

Can u upload hex which you used?
phenoptix2 years ago
Thanks for the ibble! Found it very useful for information programming an ATTiny85 (with slightly different board layout). Steps were largely the same. Cheers!
Hi kabturek, I'm a little confused on this part. I'm not quite sure through what you're sending the commands to upload firmware onto the ATTINY2313. Are you using the Arduino as an AVR programmer to upload the firmware or are you using a USBTinyISP that you bought to upload it? And after this, don't you still need the hardware support files to upload an Arduino sketch onto the ATTINY2313? Help on this section would be much appreciated.
jcbed3 years ago
for the bit about burning the tiny usb isp chip ummmmm... what pullup didu use if anney and do you have a fritzing image of it or any more info .
btw great indestrustiabel
hello,
Great Instructables, thank you very much for this. very informative. In your poist you mention you could use this method to program attiny13 chips. How do you go about wiring it up? the image you show is an atmega chip i believe which has more pins.

Sorry for the noob question. This is my first attempt at programming a standalone chip!

Any help would be appreciated.
Thank you.
kabturek (author)  meyer_lanski3 years ago
Hey,
thanks!
Look at the attiny13 datasheet:
http://www.atmel.com/dyn/products/product_card.asp?part_id=3175
On page 2 you've got te pinout for an atmega. You need these signals :
13 - SCK
12 - MISO
11 - MOSI
10 - RST (Reset)

on attiny13 they are on pins::
SCK is pin 7
MISO - pin 6
MOSI - pin 5
RESET - pin 1
GND is pin 4 and VCC pin 8
Connect them like this and you should be ready to go. Look at step 2.

Hope that helps.
shanakaplus3 years ago
um looking for elevator avr program. Do you have example program ?
andrew1014 years ago
AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH!!!!11!!!!

ONE FRIGGIN WIRE!!!!!!!!

(sorry)

I spent quite a while at this wondering where i went wrong (followed diagrams to the pin)

I didn't realize the reset resistor was supposed to be pull up, not pull down. Please fix the diagram.

Havne't gotten it working (yet) but made progress :)
kabturek (author)  andrew1014 years ago
Really sorry about that, i uploaded the new version some time ago but didnt include it in the instructable.

Whats your actual problem ?
Well its been fixed now, but the chip was in an eternal state of resetting with a pulldown resistor instead of a pullup one

I used the method in this video:
http://www.youtube.com/watch?v=7LskShrK4vQ

plus I used your tutorial for the actual programmer and stuff.
I wanted to use this to upload to an ATMEGA168p from Windows 7.

Using a Pro Mini as the programmer and the Ardunio menu option to burn the bootloader I got an error.

avrdude: Expected signature for ATMEGA168 is 1E 94 06
Double check chip, or use -F to override this check.

I had to drop to a dos prompt and run the command by hand. I copied the hex file and conf file into the dir with avrdude to make things easy.

C:\>avrdude -p m168 -c avrisp -b 19200 -P com4 -F -U flash:w:ATmegaBOOT_168_diecimila.hex

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.05s

avrdude: Device signature = 0x1e940b
avrdude: Expected signature for ATMEGA168 is 1E 94 06
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 "ATmegaBOOT_168_diecimila.hex"
avrdude: input file ATmegaBOOT_168_diecimila.hex auto detected as Intel Hex
avrdude: writing flash (16294 bytes):

Writing | ################################################## | 100% 2.50s

avrdude: 16294 bytes of flash written
avrdude: verifying flash memory against ATmegaBOOT_168_diecimila.hex:
avrdude: load data flash data from input file ATmegaBOOT_168_diecimila.hex:
avrdude: input file ATmegaBOOT_168_diecimila.hex auto detected as Intel Hex
avrdude: input file ATmegaBOOT_168_diecimila.hex contains 16294 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 22.43s

avrdude: verifying ...
avrdude: 16294 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done. Thank you.

I still need to test if it worked properly since I only have the pro-mini and some loose 168p chips.

By the way, I omited the external oscilator. So it's not mandatory for these chips.
P.S. if you need to burn the fuses on an atmega128 and you are using and external resonator:

avrdude -p m168 -c avrisp -b 19200 -P com4 -F -U lfuse:w:0xff:m -U hfuse:w:0xdd:m

If you don't burn any fuses your chip will run at 1mhz. You can tell because 1. The blink program will take 16 seconds to blink the light AND you can't program from the arduino IDE.

If you burn the wrong fuses, you can ruin your chip until you can get it into a high power (12v) programmer, so be sure before you burn fuses.
heh, still having problems. You can to burn the lock bits to keep from overwriting the bootload with the sketch. I haven't got that working yet... Moral of the story: atmega169p is $3.30, but problematic with Ardunio, just buy the pre-burned ones for $5.
Fast Eddy4 years ago
I think I may be just being thick but ... I have two ATMEGA8-16PC chips that I want to put a bootloader on. I successfully execute this step (using "m8" instead of "m168") but how do I upload the bootloader correctly. I am confuse (as they say).
Derin4 years ago
In Arduino 0017 the avrdude.conf flie does not have anything like this:
id    = "avrisp";
  desc  = "Atmel AVR ISP";
  baudrate = 115200;    # default is 115200
  type  = stk500;

kabturek (author)  Derin4 years ago
When i wrote the guide 0017 was the actual version and im sure it was there. search the file for "avrisp"
esbit4 years ago
Hi!

First of all: Great project :-)

You said, all we need is the chip, 3 leds and 3 resistors (and the arduino of course).
I understand the additional 10kΩ resistor to prevent the chip of resetting, but what are the two capacitors at pin 9 and 10 for? Can I omit them? If I need them, what value should I use for the capacitors?

Bye from Bavaria :-)
kabturek (author)  esbit4 years ago
hey,
Thanks.
the two capacitors are 22p for the crystal oscilator. it will probably work without them but its a good design to include them. You do need the 16mhz oscilator if you're going to program the chip on a breadboard.

If you have a Ceramic oscillator (this one has 3 legs) you don't need them cause ceramic oscilator has them built in.

the 16mhz oscilator (with the 22p caps) and reset resistor is used on the second soon-to-be arduino (Its the minimal number of needed components on an arduino)


esbit kabturek4 years ago
Ahh, okay, this explains something :-) I didn't see the oscillator on the Fritzing-Graphic...
Because I get my oscillators not until friday, I tried without the caps and clock crystal, but when I try to test my attiny2313 with avrdude the heartbeat-led freezes and I get an "The programmer is not responding"-error. Same with attiny45 and atmega168...

Do all of the atmel chips (esp: attiny2313 and attiny25/45/85) work with an 16MHz oscillator?
kabturek (author)  esbit4 years ago
Most of them work with 16mhz. but you don't have to use exactly 16mhz - its only used on the arduino after the fuses are burnt. when you only upload programs to attiny it runs with the internal oscilator (8mhz divided by 8). The important thing is to match the oscillator to the fuses that you burned

HTH
esbit esbit4 years ago
Hey, I might have found (can I say this in English :-p "might have found" sounds strange in german-school-english-ears ?!) the mistake, though I didn't test it, yet:

On the Fritzing-Graphic the Reset-Pin of the ic is connected (over the 10kΩ) to the ground -> the chip is nonstop resetting... Instead it should be pulled high to to the 5V, shouldn't it?

Well I will test it tomorrow and give feedback...

cya
kabturek (author)  esbit4 years ago
Hey, thanks! You're right, on my breadboard the gnd and 5v rails are switched and i wired it the other way in Fritzing.
I'll update the drawings when ill be back home
esbit esbit4 years ago
And I'm keeping replying to myself ;-)

Well I couldn't wait until tomorrow and gues what: I was right :-)! just connect the 10kΩ resistor to 5V instead of ground and everything is working fine!
But thanks to this mistake I learned myself a lot by reading all arduino sites in the web to solve the error ;-)
34nanana4 years ago
Great stuff you did there with fritzing sketch.

Nevertheless it looks like the Atmega168 on the bread board is shifted on dot too far to the left. 
According to Atmega168 pinout, power should connect to pin 20(AVCC)
SCK to 19  (in your fritzing sketch  20)
MISO to 18 (in your fritzing sketch  20)
MOSI to 17 (in your fritzing sketch  20)

Apart from RESET connecting to pin 1 all the other are shifted as well.

*!&^# .. I wish I'd seen your comment 2 hours earlier...
kabturek (author)  ivancho4 years ago
sorry for the confusion ivancho, hope your chips are ok :)
they heated up quite a bit, but I don't think there's permanent damage... eventually I made it to the 328 datasheet and started counting..

In any case, thanks for the instructable
kabturek (author)  34nanana4 years ago
ups, sorry for the mixup, these things are hard to catch up with all the work. the images are updates with the correction. thanks 34nanana
TOCO4 years ago
You can simply buy several atmega chips and pop them into your arduino and program them. Then you simply follow a breadboard arduino instructable. Granted this only works with a few types of chips that work in the specific arduino. This is a very good instructable though!

Sorry if that sounded mean I only wanted to say that to someone.
kabturek (author)  TOCO4 years ago
hmm Are you sure thats possible ? to burn the arduino bootloader on the chip you need a programmer (look in tools->burn bootloader menu for a list of supported programmers from the ide). the other way around is bit-banging with the serial/ftdi-usb interdace)

np. every comment is welcome:)
TOCO kabturek4 years ago
You can buy them online for like $5.50 with the boot loader already installed.
ivancho TOCO4 years ago
I think paying people $2.42 extra to flash your chips is, well, wrong
is is possible to program a Arduino Duemilanove with an Arduino Mega?  Would it work in the same way?
kabturek (author)  andy.parksie4 years ago
yeah it should work ok, nothing specific in the sketch. Just change the pins if necessery (dont have a mega so can't help much) do write if you succeed.
or just use digital 1/0 and 5v. you will have to press reset before upload
kabturek (author)  devicemodder4 years ago
i'm not sure what are you refering to :)
i don't think you can flash a bootloader  or program another avr chip that way:)
the boot loader is already programmed just use the blink sketch
i did it and it worked with a atmega 328/168 with bootloader
This looks really handy for integrated projects!
brunoxyz4 years ago
I wish I had found this earlier! thanks
1-40 of 46Next »