Retrieve a sketch from an Arduino

Hi,

I have an Arduino with a sketch that works great. I want to use it for another project but I wouldn't want to lose the sketch (my original got lost in an harddrive crash).
Is there a way to get it "out" of the Arduino ? It would be a lot of work to program it again from scratch.....

Thanks !

Not as such. You may be able to retrieve the code as machine code so it can be reloaded. Compilation is a one way process, Microsoft's business model depends on it........

Try using the search bar.

The simple answer is no - if you want the complex answer then I and many others have written it many times - go look for it.

Compilation is a one way process, Microsoft's business model depends on it........

Not that I want to defend Microsoft's business model - but I don't think you can pin this one on them.

Don

I don't hold Microsoft responsible for compiling being a one way process. but they do take advantage of the fact. Dyed in the wool Linux nerd here :wink:

you can make a paraellel programmer or Serial Programmer(I recommend it) so you can do it in home so will definitely save you money and then use the PONYPROG's latest environment and extract the INTEL HEX out of it, this is cheapest or else use the AVR programmer to extract the program.

Nishant:
... and extract the INTEL HEX out of it...

And with the proper disassembler or a lot of work he could then come up with an uncommented assembly language version of the program code. What would he do next to accomplish his objective of retrieving his original sketch?

Don

floresta:

Nishant:

What would he do next to accomplish his objective of retrieving his original sketch?
Don

He said he needs to "Replicate the same stuff" over the newer chips he buys so that need to write the cumbersome program is Eliminated ,he can achieve that with the solution.

He said he needs to "Replicate the same stuff" over the newer chips he buys

And where did he say this?

Don

HoMeR:
I have an Arduino with a sketch that works great. I want to use it for another project but I wouldn't want to lose the sketch (my original got lost in an harddrive crash).

did you get that? He just not want to loose the actual thing in it and use it as it is currently loaded and working on it.

You don't seem to understand the concepts of quotation marks any more than you understand the concept of recovering a sketch (program). There's a big difference between recovering the object code and recovering the source code.

Don

Why don't you just help him for which you should be there irrespective of Quoting my facts

Why don't you just help him ...

Because there is nothing that can be done. This was correctly stated in the first two replies.

Don

@HoMeR
Since you don't want to modify the original sketch here a place to start.

First I upload the example blink sketch to Arduino Uno.

(Your sketch is already uploaded, I did this for testing. DON'T DO THIS STEP )
Then I executed the following command. It copies the flash memory and writes it to a file called blink.hex
avrdude -C ./avrdude.conf -patmega328p -cstk500v1 -P /dev/ttyACM1 -Uflash:r:blink.hex:i

Then I uploaded another sketch that did not cause the led to blink. My intent was to erase the blink sketch from memory.

I then reload the blink sketch back into memory using the following command
avrdude -C ./avrdude.conf -patmega328p -cstk500v1 -P /dev/ttyACM1 -Uflash:w:blink.hex:i

It is working fine. If your sketch uses eeprom memory, read up on avrdude to see if you can copy it to a file. You will have to change some of the avrdude option to fit your system.

@mrtaylor

I repeat: There's a big difference between recovering the object code and recovering the source code. He asked about recovering his sketch which is the source code.

Don

@floresta
A little is better then nothing