I have a Uno board with the program in it, how to read it out
You can't do it, there is no source code inside the controller.
After compilation, a binary firmware file is loaded into the controller. The firmware has nothing common with the original sketch. Even if you can read it from the controller, there is no way to turn it back into program source code.
Hi, @kaojoy
Welcome to the forum.
Did you write and upload the code that is now on the UNO?
Thanks.. Tom..
The sourcecode that is written gets compiled.
Compiling means all the human-readable words are translated to machine-readable numbers.
There is not a single letter left. Just a huge pile of numbers.
like this.
You can see letters in this screenshot but this is just because the binary numbers
are easier to read if the binary numbers are converted to hexadecimal numbers
Plus... Every C++ statement is usually translated to several machine-language instructions and some of the program "structure" can change.
...There is a direct correlation-translation between machine code and assembly language (AKA "assembler") and disassemblers exist to convert the machine code to assembly. As far as I know there is no disassembler for the Arduino. It can be done "manually" but it would "take forever".
There are also decompilers, but again probably not for the Arduino. But it's not exactly-like translating from French-to-English, and then back to French. All of the original variable names and all comments) are lost and some of the program structure may be different so you basically get a different C++ program that does the same thing.
In the real world decompiling is rarely useful. It's usually easer to figure-out what the program is doing and "reverse-engineer" it and write your own code that does the same thing.
You can get a disassembly fairly easily. If you have the source you can even get it annotated. For example
Can you read out the existing compiled firmware binary to image out to clone to another board? I don’t need source, just multiple copies.
The previous answers ignore the fact that the lock bits in the 328P processor might have been set. If YOU did upload the code to the Uno via USB, that will not be the case; but if somebody else uploaded that code via ICSP, they might have set the lock bits and you will never be able to read it out.
Hi,
Until @kaojoy replies, we can only hope for more information the clear up the whys and wheres.
Tom...
Yes, provided the lock bits have not been set to prevent this.
Good to know. Can the ide via the usb set the bit(s) and what bit am I looking for?
no, it can't be set via usb
Background info: If a manufacturer sells a machine with a microcontroller and a program that took a lot of time to develop, he wants to block anyone else from reading his program. That’s what the lockbits are for.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.