how do i stop someone from reading the code/sketch that is loaded into my arduino leonardo/pro micro? want to give it to somebody for testing but dont want them to read the sketch/source code of of it. how can i stop it using software methods ?
Program using ICSP and set the lock bit after program.
The bootloader will be unavailable and USB-Serial programming will be disabled.
If it becomes necessary to rewrite the chip after locking, chip erase is performed.
This cleans up all programs and lock bits and allows new programs to be written.
There are fuses that can be burned out to prevent the code from being copied by just about anyone. I think you can only do this once though and it's not an absolute guarantee.
If you're writing for Arduino you should participate in the open-source nature of this environment.
You should also be aware of the copyright laws covering Arduino and its libraries.
oh,but then wont usb communication be stopped aswell ? i want the board to be able to communicate over usb as a joystick
once black box testing is over i am going to open the code to editing. just want a fellow software engineer buddy to test it without trying to mess with it and go around things .
It does not prevent the program from using USB.
It means you need a ICSP programmer to transfer and lock sketches.
The AVR lock bit is released by chip erase.
Return to the raw chip to erase all the ROM contents.
It may be possible to melt the chip mold and perform surgery on the silicon die to unlock the lock bit, but this is probably not possible for the normal user.
that makes sense. thanks for the advice.
The source code is not stored on the Arduino! The compiled code is, and this is not really usable by humans to change things!
The Arduino doesn't contain your C++ source code. The compiler converts it to machine language (hex code). Machine language can be disassembled to assembly language but this is not something that can be done casually and you need to know assembly language for the AVR.
And there might be a de-compiler for the Arduino, A de-compiler might make an "equivalent" C++ program but again the chip doesn't contain any of your variable names or comments.
It's probably easier to reverse-engineer your code by figuring-out what it's doing and re-creating it from scratch rather than going-through any of this.
It's the same on your computer. Your EXEs & DLLs contain machine code, not "human readable" code in a high-level language. For open source programs you can download the source code but otherwise you don't have it.
The program written to ROM is machine language.
It can be read by anyone who can read the assembler code.
No, its machine code. That's really a difference. Assembler language is human readable, it contains comments, variable names and labels. All this is not contained in the machine code in ROM. And you cannot distinguish between constant data and executable code in ROM - if you read it back, it looks all the same - simply a lot of bytes.
You have to do reverse engeneering of the ROM contents - the hard way. I think only few people can do that and are willing to do that. It's very time consuming. As already mentioned, it is easier to rewrite a sketch from scratch that behaves the same way.
It doesn't make sense to protect the ROM for these blind tests.
It's one of my fun hobbies, so I recommend it to you.
I've shown how to protect the ROM from reading and what possible to after read the ROM, and it's the OP not me wants the ROM protection.
I did that a lot many years ago. Now I know how to spend my time with other things .
Of course, at he end the OP has to decide if it's worth to protect the ROM.
Yes. If it’s worth stealing, it will be stolen.
[Reverse engineering] is one of my fun hobbies, so I recommend it to you.
Me too. The lengths to which ppl who really want your IP will go is astonishing. Google it.
So the OP’s friend is unlikely to go to the trouble.
Or just burn the fuse and be 99.44 % sure.
So did I. It was in the 1980s. Methodically re-wrote/ debugged FLEX09 for the 6809 using the disassembler after shrinking a BASIC09. May even have disassembled the disassembler!
A good interactive disassembler facilitating (dynamic) mapping of the code segments and labels makes it relatively easy.
I'm with Steve G. - I like assembler. Well, I used to when I used it.
The such a plural old soldiers' words means there are a many users who can disassemble, so finally decision the OP should protect the ROM!
People call that "selection bias".
lol its not worth that much trouble,its a simple button box.
Your "buddy" won't be able to "mess" with your C++ code unless you give it to them. If they really are a buddy, they won't be reading and disassembling the ROM, they would just ask you for the source...
that person is anyways getting the source after testing it and knows that.just wanted to know how i could lock the code.
Op's friend will be getting the source anyways so.