Pages: [1]   Go Down
Author Topic: how to download the current code from an arduino board?  (Read 1258 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
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
sebastian
Logged

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
Code:
"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.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18810
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

Then attach the other board and do:

Code:
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.

http://www.ladyada.net/make/usbtinyisp/

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.

Logged


Pages: [1]   Go Up
Jump to: