Uploaded code on arduino

Is there a way to read the code uploaded on an arduino board? and if yes, is there a way to protect my code?

This is a subject that comes up once in a while so there are threads that deal with the subject that can be found with a search (for example "arduino protect code). Here is a thread found with that search.

And always the question - why do you want to "protect my code"? :cold_sweat:

elshoraamira:
Is there a way to read the code uploaded on an arduino board? and if yes, is there a way to protect my code?

Yes, it is possible to read the compiled binary version of your sketch out of an Arduino. The program to do it comes with the Arduino IDE and is called 'avrdude'. It would take a lot of work to create an Arduino sketch that produces the equivalent binary.
To prevent reading the binary there are lock bits to prevent the reading and writing of FLASH and EEPROM. Once the memories are locked, the only programming that can be do is to clear both memories: Chip Erase. To recover use of the chip you will need a special high-voltage programmer to do the Chip Erase.

"High Voltage" is a 12V pulse on th reset line.

Nick Gammon has it worked out here

The reading back from the chip is binary code.
You can work back to get it looking like machine code (see the instruction set commands in the '328P datasheet)
and another step to look llike C code.
You won't get your comments, it doesn't undo the compiler optimizations.
Once step is decompiling, the other I'm drawing a blank on what it is called.

That's assuming the lock bits aren't set.
And if they are, folks can still de-lid the chip, and access the memory and read it. That's a bit advanced tho.

CrossRoads:
Once step is decompiling, the other I'm drawing a blank on what it is called.

Binary to Assembler is called "disassembly".

And to make it more interesting, you can't tell the constants, strings, ints, etc, from actual instructions.

Paul

I knew there was a name for it, just couldn't pull it out of the old memory.

And sometimes programmer put fake code sections in their programs to stop people from doing what you ask.

Paul

34 hours and counting on a "one-hit wonder", I am thinking this thread is dead! :roll_eyes:

And buried. :grinning:

Sometimes people don't like the truth and will look elsewhere for someone who will give them an answer that they prefer. A lesson learned recently when trying to help someone with spraying a boot lid at home. He ignored everything I told him, went to an off topic forum and started asking the same questions there. The mess resulting was a joy to behold. :wink:

AJLElectronics:
The mess resulting was a joy to behold. :wink:

Most satisfying I trust. :grinning: