One of my Arduino Megas contains a compiled sketch that I would like to copy to another identical Arduino Mega. Is there a way to do this (even if it involves downloading the executable to a PC from the original Mega and then uploading it from the PC to a new Mega)?
ronart:
even if it involves downloading the executable to a PC from the original Mega and then uploading it from the PC to a new Mega)?
That's exactly what you'd need to do. You can't do this via the Arduino IDE but you can use the AVRDUDE tool that comes with the Arduino IDE. You'll need an ISP programmer to download the program from the Mega. If you don't have one you can turn your extra Mega into an "Arduino as ISP" and use that. Then you will need to use AVRDUDE to upload the downloaded file to the other Mega. You can do this over the USB cable since you don't need to use an ISP programmer to upload.
What pert wrote works only if the programmer of the source Mega didn't prohibit the readout of the program code by setting the corresponding fuses.
Thank you, pert and pylon. pylon, how are the "corresponding fuses" set to prohibit the readout of the program code. My goals are to be able to do both, download a sketch and upload it to a similar Arduino, AND to keep someone from downloading certain sketches. So pert addressed my first requirement; and pylon, the second, but are there indicators in the compiler that need to be set? If so, which and to what? Or are physical jumpers needed on the board? TIA, -- Ron
Forgive me, I asked before researching. I then searched "arduino fuses" and found the "Serial Programming downloading (SPI) enabled; [SPIEN=0]" reference. My apologies again and thanks again for the help! -- Ron
Look at the Lock Byte in boards.txt.
Usually set to 0x3F, indicating nothing locked.
Other values will lock things up, such that you may need a High Voltage programmer (12V) to perform a chip erase and clear them back to unlocked.