My question is a bit deliciously weird. Some weeks ago I uploaded a sketch(code) into the Arduino’s micro-controller. Now I need the code but i cannot remember and find the file in my PC.
I know that was the last code I uploaded and it is in there.
Is there a way to take it out?
This is a good question. I would be interested in knowing the answer to this as well.
You can take it out but it's post compiled, ie unintelligible.
The closest you can get is the disassembled machine code, which looks like this:
f2d4: 85 e1 ldi r24, 0x15 ; 21
f2d6: 92 ee ldi r25, 0xE2 ; 226
f2d8: 60 e0 ldi r22, 0x00 ; 0
f2da: 0f 94 c2 f1 call 0x3e384 ; 0x3e384
f2de: c8 01 movw r24, r16
f2e0: aa 27 eor r26, r26
f2e2: bb 27 eor r27, r27
f2e4: 0f 94 11 f2 call 0x3e422 ; 0x3e422
f2e8: bb 27 eor r27, r27
f2ea: a1 2f mov r26, r17
f2ec: 90 2f mov r25, r16
f2ee: 8f 2d mov r24, r15
f2f0: 0f 94 11 f2 call 0x3e422 ; 0x3e422
f2f4: 8e 2d mov r24, r14
Not particularly useful unless you are an assembler guru.
I would be doing a “find files” for files ending in .pde or .ino and see if you can find that file.
what kind of method is used to reach the machine code? i mean basically.
Assuming you are using the USBtinyISP programmer (if not, modify to suit):
avrdude -c usbtiny -p m328p -U flash:r:myfile.hex:i
avr-objdump -j .sec1 -d -m avr3 myfile.hex > myfile.asm
That reads in the flash memory to myfile.hex, and the second line disassembles it into myfile.asm.