Extract code from Arduino.

Hi all!
I'm presently in a crappy situation, basically, my computers crashed and I lost everything on it.
I had on it a program I downloaded into the Arduino, it's a very important one, for my final year project.

Do you know if it's possible to retrieve this program from the Arduino ?

Help! :-/

I assume you haven't set any fuses to stop you reading the program back (if this doesn't sound familiar, then you are almost certainly okay).

For most people, the practical answer is NO.

You can retrieve the result of compilation, which is the binary instructions of your program, and put that into another Arduino chip. That may be enough.

AVR Studio has an application for doing this if you have access to an In-Circuit-Serial Programmer.

What you'll get back is the binary code produced after compiling, assembling, linking and loading. That can be put straight into a 'raw' ATmega.

In general, it is very hard to recover even the assembler, but there may be an AVR dis-assembler. I think the Atmel tools include one.

If you can run a dis-assembler, that will get you back to assembly language, a programmer friendly printed form of the binary.

There will not be any program variables names, just memory location addresses.

It is extremely difficult to get back to anything close to Arduino program from this.

The assembler could be edited and a new program produced if you are familiar with assembler, and this may be enough to solve your problem.

Summary: If you must have an Arduino program, then No.
Further, even if you don't need an Arduino program, unless you really know what you are doing (e.g. everything I wrote above made sense), it's likely quicker to write it again.

HTH
GB

The assembler could be edited and a new program produced if you are familiar with assembler, and this may be enough to solve your problem.

I think if you are skilled enough for that then it would be easer to re write the program.

my computers crashed and I lost everything on it.

Are you sure? By "crash" what do you mean?

Depending on the kind of the "crash", what died, how it died, etc; might determine if there is some manner to recover. It may not be easy, you may not get everything (or anything) back, but there may be hope, too (provided you haven't done anything drastic with the drive yet, like reformatting it, or attempting a re-install, etc).

What OS were you using?

For example, if you were using Windows and something just went wildly wrong that wouldn't allow the OS to boot up, but it still seemed like it wanted to (say it will boot and load up so far, then hang); you might be able to disconnect it, throw it on a linux box (or use a live cd), and mount it, search through it for your code, and pull that (and anything else) off onto a USB thumbdrive.

I've seen recoveries done to certain drives that were defective by freezing them for a while, then running them long enough to copy the data.

Back in bad old days, sticking heads on the platters could be unstuck temporarily by dropping them flat six inches off a table.

But before you can try anything, you need to know and understand what and how the system crashed; your data may still be readable in some manner by another system, if it isn't something crazy that really fried the drive (depending on how valuable the data is, even a fried drive can be recovered, given enough time and money - sometimes it is only the controller board; if you can find the exact same drive with the same controller board, you might be able to recover it).

I wish I had a quid (circa $1.50 for the Yanks) for every time this subject has been brought up on here......

The answer is always no (slight embellishments, but in our heart of hearts we all know they want their sketch back). Its the same reason that Microsoft's source code isn't freely available on every shady website on the net. Compiling is a one way process.

cr0sh is right. If I were you, I'd try getting the data back from the harddrive first. Since if you were goign to extract code from Arduino, even if you are successful, you won't be getting your source code (it will be in assembly).

If the data is really important to you, I'd suggest that you consult a data recovery service first before trying to do anything on that crashed harddrive. If you haven't messed with the drive yet, the chances for successful recovery is quite good.

Good luck!

I think if you are skilled enough for that then it would be easer to re write the program.

Applying Pareto's principle, I, at least, 99.2% agree (only 20% of 20% of 20% are likely worth thinking about), it it may be more, or less, agreement if I understood what the program is, and what is needed.

I think I could do it. I would only do it, if:

  • there is no need for a Arduino (C/C++) program
  • the code only needs to be tweaked a little bit (I wouldn't want to maintain assembler)
  • it took more than a 4-5 days of solid work to write (unlikely, as program memory is a bit small), and just as hard to reproduce

There are some other threads on this topic Search program extract

I agree with cr0sh, look at recovering the machine.

GB

Thank you all for your replies :slight_smile:

cr0sh: I'm on mac OSX, and my partition was just corrupted, that's why I had to reinstall mac OSX, losing all of my data...

I think I will try to remember what I have done and do it again... That's really annoying, the code is working on my Arduino and I have to start to design it from the beginning...

Thanks gbulmer and the others!