Copy code from one Arduino Mega to another

I have two Ardunio Megas, one that is programed already and one that is blank. I would like to clone the programed board onto the blank one. I am running Mac OS on my computer, is there a fairly straight forward way to do this? I have no interest in editing the code, just copying it.


This is the Batch FilesI use to clone an Arduino UNO

For this example create directories on the C drive as follows: C:x\z\

This will create the following files in the z directory backup_flash.hex backup_hfuse.hex backup_lfuse.hex backup_efuse.hex

It does this by reading reading from the chip directly using avrdude check to see if this file is located here: C:\PROGRA~2\Arduino/hardware/tools/avr/etc/avrdude.conf The avrdude .exe should be here: C:\PROGRA~2\Arduino\hardware\tools\avr\bin\avrdude.exe if it isn't edit the batch files to match also note this is configured for the ATMEGA328P MPU you will need to change the batch files for your chip details are found in the avrdude.conf file that may help you change the name.

I use a USBASP programmer that connects through the iscp connector on the UNO I would place these batch files in the C:x/ folder you just created

The Copy Batch File: c.bat:

prompt $G
CD C:\PROGRA~2\Arduino\hardware\tools\avr\bin
ECHO CTRL+C to abort OR PRESS Any key to begin copy...
pause >nul
ECHO Creating hexadecimal binary files of ATmel328P contents...
avrdude -CC:\PROGRA~2\Arduino/hardware/tools/avr/etc/avrdude.conf -c usbasp -P usb -p ATMEGA328P  -U flash:r:c:\x\z\backup_flash.hex:i
ECHO flash has been SAVED to backup_flash.hex

avrdude -CC:\PROGRA~2\Arduino/hardware/tools/avr/etc/avrdude.conf -c usbasp -P usb -p ATMEGA328P  -U hfuse:r:c:\x\z\backup_hfuse.hex:i
ECHO hfuse has been SAVED to backup_hfuse.hex

avrdude -CC:\PROGRA~2\Arduino/hardware/tools/avr/etc/avrdude.conf -c usbasp -P usb -p ATMEGA328P  -U lfuse:r:c:\x\z\backup_lfuse.hex:i
ECHO lfuse has been SAVED to backup_lfuse.hex

avrdude -CC:\PROGRA~2\Arduino/hardware/tools/avr/etc/avrdude.conf -c usbasp -P usb -p ATMEGA328P  -U efuse:r:c:\x\z\backup_efuse.hex:i
ECHO efuse has been SAVED to backup_efuse.hex

ECHO Hexadecimal files created.

cd c:\x

Now that I've backed up the Arduino UNO

I can load it again and again into other Arduino UNO's with this batch file

The Load Batch File: x.bat

CD C:\PROGRA~2\Arduino\hardware\tools\avr\bin
ECHO Creating hexadecimal binary files of ATmel328P contents...
avrdude -CC:\PROGRA~2\Arduino/hardware/tools/avr/etc/avrdude.conf -c usbasp -P usb -p ATMEGA328P -b 115200 -U flash:w:c:\x\z\backup_flash.hex:i
avrdude -CC:\PROGRA~2\Arduino/hardware/tools/avr/etc/avrdude.conf -c usbasp -P usb -p ATMEGA328P -b 115200 -U hfuse:w:c:\x\z\backup_hfuse.hex:i
avrdude -CC:\PROGRA~2\Arduino/hardware/tools/avr/etc/avrdude.conf -c usbasp -P usb -p ATMEGA328P -b 115200 -U lfuse:w:c:\x\z\backup_lfuse.hex:i
avrdude -CC:\PROGRA~2\Arduino/hardware/tools/avr/etc/avrdude.conf -c usbasp -P usb -p ATMEGA328P -b 115200 -U efuse:w:c:\x\z\backup_efuse.hex:i
cd c:\x

Don’t some versions of the USBAsp firmware not work correctly with the Mega?

If you have a USBAsp and the firmware is one that works right with the mega, you can just use eXtremeBurner AVR, connect the ASP to one board, to “read all”, then connect to the other, and do “write all” :wink: That’s how I clone boards.

Note that if the source of the board doesn’t want you copying it, there’s a bit they can set to prevent you from reading it without first erasing it.

DrAzzy can you provide a link to the origional eXtremeBurner AVR software i'm getting several sites with garbage

I don't remember, google it. First hit on google looks right?