Pages: [1]   Go Down
Author Topic: how to download the current code from an arduino board?  (Read 1301 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hello arduino forum,

my question seems to be a basic principle - but i nowhere found the answer so far:

is it possible to download the current code from an arduino board to the pc – is there a workaround?
(i lost the code i uploaded some time ago and i need a exact copy of the existing for a
second installation)

thanks and best

Offline Offline
Edison Member
Karma: 19
Posts: 1041
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, look up avrdude. You'll want to use something like this (it worked on my computer, but you'll have to change the ports and probably some other stuff.)

You open up cmd (assuming windows; essentially same for linux and mac though), then type
"C:\arduino-1.0\hardware\tools\avrdude -p m328p -C C:\arduino-1.0\hardware\tools\avrdude.conf -c arduino -D -P COM5 -U flash:r:output.bin:r"

changing each of the "C:\arduino-1.0"s to where your arduino is located (it should work on multiple versions) and changing "output.bin" to where you want the output going.

The small problem is that it's not in C++ anymore, it's in machine code. Meaning you can't* edit it

*conditional can't

There is no way to get the C++ out of it, save disassemblers and stuff.

Global Moderator
Melbourne, Australia
Online Online
Brattain Member
Karma: 511
Posts: 19351
Lua rocks!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Agreed. To get the "binary data" off the chip do something along these lines:

avrdude -c usbtiny -p m328p -U flash:r:myfile.hex:i

Then attach the other board and do:

avrdude -c usbtiny -p m328p -U flash:w:myfile.hex

The "r" version reads the flash memory, the "w" writes it.

You will need something like USBtinyISP to connect to do this.

As WizenedEE said this will not give you back the sketch (in C++) but you can make another board behave the same as the first one.


Please post technical questions on the forum - not to me by personal message. Thanks a lot.

Pages: [1]   Go Up
Jump to: