Is it possible to copy a sketch from another microcontroller to your pc to edit
Sort of, but not really. Given enough effort you can get the binary machine code off the chip and into a PC editor, but (A) it won't be easy, and (B) it won't be pretty.
What you're asking for is the equivalent of saying "here's a cake; how can I get the eggs back out".
Getting the machine code back out is easy with atmel studio or avrdude if you have an isp programmer. There's no way to get the c code back though
Thank you for the replays
What you're asking for is the equivalent of saying "here's a cake; how can I get the eggs back out".
I like that one a lot.
Lefty
magagna:
What you're asking for is the equivalent of saying "here's a cake; how can I get the eggs back out".
Not really - he doesn't want the eggs, he wants the cake recipe.
modeller:
magagna:
What you're asking for is the equivalent of saying "here's a cake; how can I get the eggs back out".Not really - he doesn't want the eggs, he wants the cake recipe.
But his is the funnier sound bite.
retrolefty:
modeller:
magagna:
What you're asking for is the equivalent of saying "here's a cake; how can I get the eggs back out".Not really - he doesn't want the eggs, he wants the cake recipe.
But his is the funnier sound bite.
True, true ...
So is there a tutorial somewhere on how I can use atmel studio or avrdude to read the data from a chip? I'm really interested in seeing if I can reverse engineer things like that...
GDH5:
So is there a tutorial somewhere on how I can use atmel studio or avrdude to read the data from a chip? I'm really interested in seeing if I can reverse engineer things like that...
Just grab a .hex file from any old sketch and start from there...after that you can move onto unknown sketches.
Take a look at6 the AVRDude tutorial here
http://www.ladyada.net/learn/avr/avrdude.html
Example:
This will copy the hexfile from arduino to the file test.hex
avrdude -pm328p -Pcom20 -carduino -D -U flash:r:test.hex:i
@GDH5,
You might be better off compiling a known sketch, then look at the .hex file that was created and see if you can work backwards from there.
There are decompiler programs such as this
https://www.hex-rays.com/products/decompiler/index.shtml
You can search for an 8-bit AVR version, some links here maybe:
Thanks for all the advice guys... So if I understand this correctly, I will be able to read the code from the chip, and create a hex file with its contents.
Then I should be able to use that hex file to program a new board, right? And assuming all the hardware is wired up the same, it will be an exact copy?
Also, once I have the hex file, can I convert it to C, so I can read its contents?
Then I should be able to use that hex file to program a new board, right?
Yes, in the example above you could do something like this:
avrdude -pm328p -Pcom20 -carduino -D -U flash:w:test.hex:i
r - read from flash
w - write to flash
Ofcource you will have to ensure that the fuses are the same
GDH5:
Also, once I have the hex file, can I convert it to C, so I can read its contents?
No.
Windows Vista/Win7/?Win8? copy script:
http://forum.arduino.cc/index.php?topic=177898.msg1320206#msg1320206
@ Mr Burnette... I feel as if I was back in elementary school... However Thank You Mr Burnette... Too
Doc
I feel as if I was back in elementary school...
Oops... Is this a good thing?
There are days where I wish I were back in elementary school: In my time, the CK722 transistor was the hot electronic item... if you could get one. I saved my lawn cutting money for a month to order one. That was early 1960's and the CK722 was less than 10 years old... just a year younger than I. Imagine the electronic toys 50 years from now. Wow.
If there are any questions regarding the elementary copy script, I will gladly answer. If, on the other hand, I have completely exasperated you with such a simple script, my apologies. I find myself copying chips more often than I like so I devoted a few minutes to the archaic Windows batch processor.
- Ray