Arduino Forum

Using Arduino => Installation & Troubleshooting => Topic started by: HoMeR on Feb 21, 2011, 10:22 am

Title: Retrieve a sketch from an Arduino
Post by: HoMeR on Feb 21, 2011, 10:22 am
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 !
Title: Re: Retrieve a sketch from an Arduino
Post by: pluggy on Feb 21, 2011, 10:37 am
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........
Title: Re: Retrieve a sketch from an Arduino
Post by: mowcius on Feb 21, 2011, 11:56 am
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.
Title: Re: Retrieve a sketch from an Arduino
Post by: floresta on Feb 21, 2011, 03:31 pm
Quote
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
Title: Re: Retrieve a sketch from an Arduino
Post by: pluggy on Feb 21, 2011, 04:59 pm
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 ;)
Title: Re: Retrieve a sketch from an Arduino
Post by: Nishant_Sood on Feb 22, 2011, 10:39 am
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.
Title: Re: Retrieve a sketch from an Arduino
Post by: floresta on Feb 22, 2011, 12:07 pm

... 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
Title: Re: Retrieve a sketch from an Arduino
Post by: Nishant_Sood on Feb 22, 2011, 02:56 pm


  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.
Title: Re: Retrieve a sketch from an Arduino
Post by: floresta on Feb 22, 2011, 03:46 pm
Quote
He said he needs to "Replicate the same stuff" over the newer chips he buys

And where did he say this?

Don
Title: Re: Retrieve a sketch from an Arduino
Post by: Nishant_Sood on Feb 22, 2011, 07:27 pm


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.
Title: Re: Retrieve a sketch from an Arduino
Post by: floresta on Feb 22, 2011, 08:38 pm
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
Title: Re: Retrieve a sketch from an Arduino
Post by: Nishant_Sood on Feb 23, 2011, 03:58 am
Why don't you just help him for which you should be there irrespective of Quoting my facts
Title: Re: Retrieve a sketch from an Arduino
Post by: floresta on Feb 23, 2011, 01:35 pm
Quote
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
Title: Re: Retrieve a sketch from an Arduino
Post by: mrtaylor on Feb 24, 2011, 02:23 am
@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.

Title: Re: Retrieve a sketch from an Arduino
Post by: floresta on Feb 24, 2011, 10:48 pm
@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
Title: Re: Retrieve a sketch from an Arduino
Post by: mrtaylor on Feb 25, 2011, 02:10 am
@floresta
A little is better then nothing