View Full Version : extracting code from robot
Jeff 801
10-08-2007, 13:20
I know this is answered some where but i cant find it is it possible to extract the code from the robot if we don't have it any where else thanks
jtdowney
10-08-2007, 13:28
Unfortunately no, what is transfered to the robot is a form of the code translated into a language the Microcontroller understands. You could in theory disassemble a dump of the PIC and sort through it for the logic you used but you will never be able to reconstruct the code as you saw it in MPLAB.
Alan Anderson
10-08-2007, 15:15
Device Reader Ver1.0.1 (http://www.ifirobotics.com/docs/device-reader.zip) (found on the IFI FRC Robot Controller (RC) (http://www.ifirobotics.com/rc.shtml) page) will allow you to retrieve the ones and zeroes from the RC, so you can save them somewhere and put them back later.
Getting from the compiled binary file to usable source code is likely to be a lot harder than rewriting the code from scratch, even if you don't know how to program and have to learn it in the process.
Jeff 801
10-08-2007, 15:59
Device Reader Ver1.0.1 (http://www.ifirobotics.com/docs/device-reader.zip) (found on the IFI FRC Robot Controller (RC) (http://www.ifirobotics.com/rc.shtml) page) will allow you to retrieve the ones and zeroes from the RC, so you can save them somewhere and put them back later.
Getting from the compiled binary file to usable source code is likely to be a lot harder than rewriting the code from scratch, even if you don't know how to program and have to learn it in the process.
will this be the hex
aaeamdar
12-08-2007, 00:53
If, and this is a significant if, If jtdowney is correct in his assertion (good word, eh?) that the code is translated into a format designed for the Microcontroller, then NO, this will not be the hex. While it might be a reversible process, the logic would be way more complex - I've spent a lot of time (for my job) parsing text files, and even fairly simple formats have challenges involved.
So, again, if jtdowney is correct, then I don't believe Mr. Anderson's approach will give you the original hex file (though he would be the best person to ask about that). Whether the binary (which is of course easily convertible to a hex, if not THE hex that you put in originally) is helpful to you or not is up to you, though I would bet that it's not, unless you have a few months on your hands to write a parser. If you do, toss it out onto the GNU :) !
-Paul
jtdowney
12-08-2007, 06:23
The format for the microcontroller I was speaking of is the .hex. IIRC the C18 compiler takes the code and compiles it to a COF (common object format) file which is then linked into a .hex file. Since that is what you send to the RC you should be able to dump it from the RC using the tool Alan provided. That will allow you to get the current .hex file which you can save in case you ever need it again. The executable format the microcontroller uses probably has a disassembler somewhere if not the format is generally not to bad from my experience working with Linux ELF files. Once disassembled you will have the original code in assembly language which will show you the logic you used assuming you have someone who knows PIC18 assembly.
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.