2560 Mega - Copy to another

I have Mega 2560 with a sketch uploaded that I need to duplicate to another blank Mega 2560.

I've looked at the forum and the many topics - the solutions have pointed at using AVRDUDE and/or an Arduino ISP programmer. Most of these are related to the Uno. When I get in-depth into the solution, it will say it doesn't work with the 2560's.

Could anyone give me hope and say if AVRDUDE would work on the 2560?

From what I've read, the solution should be connecting via USB the 2560 and opening cmd (after installing AVRDUDE)

To read the 2560:

avrdude -c arduino -P com20 -p atmega328p -Uflash:r:d:\hexfiles\test.hex:i

Then disconnect it and connect the blank 2560.

To write it to the blank one:

avrdude -c arduino -P com20 -p atmega328p -Uflash:w:d:\hexfiles\test.hex:i

From this, some say there's a need to use a ISP programmer. Others say it's not needed...

Lastly, what is the difference between the avrdude under hardware>tools>avr>bin compared to the one that can be downloaded off the website?

That should work fine and there is no need for an ISP programmer. However, you need to modify the commands a little. The download command should look like this:

avrdude -c wiring -P com20 -p atmega2560 -Uflash:r:d:\hexfiles\test.hex:i

the upload command should look like this:

avrdude -c wiring -P com20 -p atmega2560 -Uflash:w:d:\hexfiles\test.hex:i

You need to change the "com20" part to match the COM port of the Mega boards (it will be shown in the Arduino IDE's Tools > Port menu. Each of your Mega boards may have a different COM port, so check it each time.

joaco09:
what is the difference between the avrdude under hardware>tools>avr>bin compared to the one that can be downloaded off the website?

Arduino has made some modifications to avrdude to support all their boards and programmers. You should be able to use either version of avrdude for this project, but since you already have it installed with the Arduino IDE, you might as well just use that one. Much more simple that way.

I tried implementing those lines but with failure:

C:\Users\jbh2844>avrdude -c wiring -P com13 -p atmega2560 -U flash:r:d:\hexfiles
\test.hex:i
avrdude: can't open config file "": Invalid argument
avrdude: error reading system wide configuration file ""

I have not found the cause of these two errors. I tried:

  1. using avrdude from the official website
  2. changing the folder of the save to
  3. changing ports

Haven't found anything useful online...

You need to specify the location of avrdude.conf via the -C option of avrdude. If you're using the version of avrdude that comes with the Arduino IDE, the location of avrdude.conf is at {Arduino IDE installation folder}/hardware/tools/avr/etc/avrdude.conf

A nice trick for learning how to use avrdude is to enable File > Preferences > Show verbose output during > Upload in the Arduino IDE, do an upload, then examine the contents of the black console window at the bottom of the Arduino IDE window to see the avrdude command that was generated by the Arduino IDE. The upload doesn't actually need to be successful, you only want the command.

pert:
A nice trick for learning how to use avrdude is to enable File > Preferences > Show verbose output during > Upload in the Arduino IDE, do an upload, then examine the contents of the black console window at the bottom of the Arduino IDE window to see the avrdude command that was generated by the Arduino IDE. The upload doesn't actually need to be successful, you only want the command.

You are awesome, Pert.
This trick is what I needed.

I hope this helps someone else in the future.

You're welcome. I'm glad if I was able to be of assistance. Enjoy!
Per