I have a sketch on a board and I'd like to review it. How do I download it from the board?
The simple answer is, you can't.
You can pull out the hex file that the code was compiled into, but you won't be able to read it.
There are disassemblers that can turn that back into assembly code if you know how to read that.
There are even de-compilers that can get you back to something sort of readable, but it won't look like the original code.
But you can't get back to the original code that was used. It doesn't exist on the chip.
Thanks, that is what I suspected.
Hi,
Not sure what the situation is, but if you are uncertain of the code you have put on the controller you can do this in hindsight.
In the setup part of the code place;
Serial.begin(9600);
Serial.println("*** Sketch Name_Sketch Verison ***");
Then each time you boot your code
This will appear on your IDE Monitor.
*** Sketch Name_Sketch Verison ***
So you will now the sketch name and version that has been loaded.
Also as you write your code keep saving as you go, with updated version numbers.
Tom..
Hello mtnclmbr
Addtional, you might add this line to the setup() function to see which source code file has been used.
Serial.println(__FILE__);
Have a nice day and enjoy coding in C++.
I put this function into every sketch:
void PrintFileNameDateTime() {
Serial.println( F("Code running comes from file ") );
Serial.println( F(__FILE__) );
Serial.print( F(" compiled ") );
Serial.print( F(__DATE__) );
Serial.print( F(" ") );
Serial.println( F(__TIME__) );
}
right in setup()
void setup() {
Serial.begin(115200);
Serial.println( F("Setup-Start") ) ;
PrintFileNameDateTime();
FILE
DATE
TIME
are so called macros. The macros are replaced by what the name says in the moment you compile the code.
My filenames end with a upcounting number
watering-automat-001
watering-automat-002
watering-automat-003
So I can roll back to an earlier version.
Another thing is in the Arduino-IDE you can archive a sketch.
All the code is zipped into a zip-file with date-time-stamp.
best regards Stefan
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.