Arduino Mega2560 as ISP to program another Arduino Mega2560

Hi,

I'm trying to use an Arduino Mega2560 as ISP to program another Arduino Mega2560.

After reading a lot of info about, I tried several different ways to connect the arduinos but it didn't work. So, I tell you my attempts in case you can help me. Even I tried to use an Arduino Uno to work as ISP or to upload the code to it, but it didn't work either.

First of all, I upload to one of them (Arduino Mega2560) the ArduinoISP example, and select programmer 'Arduino as ISP'. Select the right board to upload the code and the port.

1- I connect as in the Arduino ISP example (http://arduino.cc/es/Tutorial/ArduinoISP) but optimized for the Mega.
MISO (50) - MISO (50)
MOSI (51) - MOSI (51)
SCK (52) - SCK (52)
SS (53) - Reset (30)

2- I tried to connect the wires in the opposite way.
MISO (50) - MOSI (51)
MOSI (51) - MISO (50)
SCK (52) - SCK (52)
SS (53) - Reset (30)

3- Also with Arduino Uno, I changed to fix the wires to Arduino Uno pin configuration.
MISO (50) - MISO (12)
MOSI (51) - MOSI (11)
SCK (52) - SCK (13)
SS (53) - Reset (7)

4- And the other way, Arduino Uno as ISP.
MISO (12) - MISO (50)
MOSI (11) - MOSI (51)
SCK (13) - SCK (52)
SS (7) - Reset (30)

I can't do anything. I read about plug a 10 uF capacitor between 'reset' and 'gnd' after upload Arduino ISP, but this didn't work either.

Could any help me?? It's important to solve this problem.

  • I'm working under Ubuntu environment, with Arduino IDE 1.0.

Thanks!

Here is Nick Gammon's bootloader page, it is written for Uno but, it may work for Mega. Note that the SS pin on the Uno is (10). You may have to change the pin to 52 or use 10 on the Mega instead. It does not require a capacitor across reset. Link is below.

Use this wire scheme:
Programmer Target
MISO (50) - MISO (50)
MOSI (51) - MOSI (51)
SCK (52) - SCK (52)
SS (53) - Reset (30)
5V - 5V
GND - GND

Then use the program from this page:

Couple more things:

  1. What exactly do you mean by "It didn't work"? Be specific about what exactly you saw on the bottom terminal of the Arduino IDE window and on the LEDs of the ISP-side board.

  2. Look at the page linked by cyclegadget but also this tutorial:
    http://www.instructables.com/id/How-to-use-Arduino-Mega-2560-as-Arduino-isp/

  3. You can use either the Mega board or the Uno board as your ISP board. Both should work equally effectively, as long as you make sure to first do a standard sketch upload of the "ArduinoISP" sketch to your chosen ISP board.

  4. A note: Remember, SS from the ISP board -> Reset pin of the TARGET board always. If you look at the tutorials, you'll understand why the target's reset pin is used.

  5. For your target, are you trying to program the chip on an Arduino Mega board or just onto your self-made/barebones Atmega2560 circuit?

  6. If you are using an Arduino Mega board as the target, be sure to connect to the pin labeled "RESET" on the board.

Ok, first of all, thanks!!

I'll try to be more explicit.

  1. I mean that when I try to upload the code, I follow next steps:
  • Check Port.
  • Check target board (Arduino Mega2560).
  • Check programmer (Arduino as ISP).
  • With an Arduino Mega2560 and the ArduinoISP code uploaded, I program the target board. I see how Tx & Rx leds of programmer board blink, but in the target board I don't see anything.
  • In the bottom terminal of the IDE it is all right, so I understand the proccess worked fine.
  1. Maybe I have done a mistake with Reset pin, I connect the SS pin (53) to the 'Reset' labeled one in the target board (I thinked is pin 30 in microcontroller).

  2. At the moment, I'm only trying to use an Arduino Mega2560 as ISP to program another Arduino Mega2560 board.

I'm going to continue working on this issue, but if you could help it woul be great!

Thanks again!

you cannot program a mega properly. for me it sais upload completed but no led is blinking. Burning the bootloader also doesnt work well for me. its works but it sais "error content mismatch" at the end. you can use the lufa avr mkii to create your own icsp on a 32u4 for example. burn it with the arduino as isp. this works, because the 32u4 is not that big like the 2560.

Yolco:
1- I connect as in the Arduino ISP example (http://arduino.cc/es/Tutorial/ArduinoISP) but optimized for the Mega.
MISO (50) - MISO (50)
MOSI (51) - MOSI (51)
SCK (52) - SCK (52)
SS (53) - Reset (30)

This is the right way but you must add 5V and GND pins.
There are some lock bits you have to deal before programming the Mega. You have to deal with some avr dude commands. Installing WIN AVR on windows is easy but I don't know how is it done on Linux.

so is this an issue of the arduino ide or the avr isp sketch? The connection is 100% connect, i know what i am doing here.
uploading sketches is sucessfull but the program isnt actually loaded by the mega. burning bootloader works, but its gives a verification error. For 328 and 32u4 it works fine.

With my lufa avr isp mkII i can reprogram my mega successfull without any errors, but only on IDE 1.0.5, none of the newer versions

There is so little information about this problem online. And i can also not answer to any Stackexchange post because i dont have the reputation :confused:

So i found out that the mega uses stk500v2 for sure. But is this a problem of the .hex file, the arduino .ino sketch or the mega chip itself? I am confused that burning still works with ide 1.0.5 even with a content mismatch. But the blink doesnt work.

I am searching for possible fixes to upload sketches and burn bootloader. Ive got a workaround for the bootloader to burn the fixed .hex file. But how can i upload normal sketches like this? Do i need to implement stk500v2 for the .ino or is this a problem of what the ide generates or maybe both??

Please, can someone explain me this a bit better? :blush:

How is that Arduino stuff Staff designed this troubleboard? I've read a lot of comments with this same problem.
Nico the best solution is the one I found I guess. Check it out.

(i dont get your first sentence)

But how does it help me?
The 1st command is crap.

The 2nd (you are probably talking about) is only a solution for Arduino Uno. I read in the optiboot post that the mega needs v2 because it is so big. But i still dont understand where the problem is. If its the pc that trys to send v2 (but its set to 1?) if its the precompiled hex file or the .ino sketch. This still doesnt help me. Ive no idea if the fuses are compatible with mega and what this should help me if the mega is not v1 compatible?

The 3rd post uses a usb device. I've got a AVRMKII clone running here but i want to integrate this Arduino as ISP to the 16u2 bootloader, thatswhy i am asking if one can get this working.

The "upload appears to work, but verification fails" appears to be the result of the memory on the 2560 being too large. The communications protocol used by ArduinoISP actually only supports 16 bits worth of address - 64k words or 128k bytes of program.
I think that AVRDUDE figures this out and uses a "raw SPI command" form for the actual programming, but it doesn't do anything similar for the read-back of flash that it does for verification. As a result, it ends up reading back the end of the first 128k of memory, which is NOT where the bootloader got put.

A lot of programmers have the same problem. We need a version of ArduinoISP that supports stk500v2.

Bootloader: the verification mismatch problem is solved, it was an avrdude bug. If you change the aduino avrdude to the last version you do not have this message.
Another important thing is that the error was only on verification, the bootloader normally work also whit the old version.

Programming: You use the Upload by programmers command under File tab ?
On the Uno after programming, and after a manual reset, the Blink work, on the Mega it is necessary change the RST Fuse. I do not know why this difference, I working on it for an exlanation.
I have a Guide, in italian, in my sign

So it is possible bootload and program via ISP the Mega :slight_smile:

Thy for the answers! This gives me a better impression.

I am using the Arduino IDE for everything. I select the mega, Arduino as ISP and burn bootloader or upload via Programmer.

I am still a bit confused. If the v1 cannot burn the bootloader to the right place, why does it still work?
Or maybe the sketch is actually v2 compatible?

Here is the AVR Dude error (with IDE up to 1.5.6):

avrdude: verification error, first mismatch at byte 0x1e000
         0xff != 0x0d
avrdude: verification error; content mismatch

With IDE 1.5.7 i can burn the Bootloader sucessfull and very fast!!! Thx for this hint!
The normal uploading is still successfull but the sketch doesnt start!

So how can we fix normal sketch uploading? Still confused about v1 and v2 and why burning still works.

The 100nF capacitor isnt needed i think. I know the 16u2 bootloader source and it seems the uploading doesnt trigger the DTR line. Maybe thats new and the documentation is old?

all version, v1 and v2 also, burn the bootloader to the right memory space, the mismatch verification is not a problem of the ArduinoISP sketch but an AvrDude bug. Infact the bootloader work also when you receive the verification error.

You do not need the capacitor on reset, it is tip for other kind of error, if your burning process finish with successfull you do not need of capacitor.
I repeat my tips for you second question, is it possible using Upload via Programmer on a Mega, but you need change your fuses for starting the program. Simply the sketch will correctly burn, but it do not run.

and what do you recommend to fix this fuse problem? Should someone fix the bug in the IDE or is it possible to add something to the sketch?

what fuses needs to be changed? ive never dealt with fuses before. I know what it is, but i never wanted to change something to not break things :wink:

Nobody know why on UNO it is not necessary change the fuses and on the MEGA it is necessary. (or at least i do not know anyone that have an answer).

for now the only way is change the fuses, the Bootrst is your target, but please study the datasheet and understand what you do, because it is possible brick the chip if you make error whit the fuse.

It would be nice of some can figure it out how this works. The you could program any Arduino with the 16u2.

See this and this:
https://groups.google.com/a/arduino.cc/forum/#!msg/developers/V_T-Uvj8hSs/h9xlGyM9cJoJ

interesting the hoodloader, i sent you a pm.
i can write a new virtualboard for resolve the "Not Run Mega problem"

we fixed the problem. fuse BootRST must be set to 1. to execute the program. Somehow its not needed for an uno.
stay tuned on further hoodloader releases :wink:

NicoHood:
we fixed the problem. fuse BootRST must be set to 1. to execute the program. Somehow its not needed for an uno.
stay tuned on further hoodloader releases :wink:

Great.