How to lock code in Arduino?

Submitted by AllenTrage on

Hi I have a program running on Arduino UNO. I found that it is possible to extract the code out of the controller and use it on other Arduino boards ... and clone it... 

How do I prevent this from happening? Basically I do not want people to be able to copy my code from my Arduino board. 

There is something known as Fuse Bits & Lock BIts in any AVR microcontroller. You can alter those to enable Maximum protection,

Let me explain a bit, most of AVR device contains two lock bits. LB1 and LB2. Programming these (to 0, low) will add protection for the Flash and EEPROM memories according to the datasheet.

1.jpg

 

 

 

 

 

 

 

 

 

 

As you can see from the above table there are three modes of protection mode 1 bing the list secure and mode 3 being the most secure.

Please keep in mind that the AVR allows changing "high" bits to "low", but not the other way around. It's not possible to change a low lock bit too high which means one the lock bits are enabled you cannot program the chip anymore.

The only way to reprogram them is to make a complete Chip Erase. and for that, you need a "High Voltage Parallel Programmer".

For extreme protection, you can also disable SPI.

​you can flash the lock bits with avrdude. the command will be avrdude -c usbasp -P usb-p m328 -U lock:w:0xc0:m -v "This is just an example you need to calculate the lock bits according to your needs".

  Joined December 02, 2019      117
Monday at 10:02 PM

jaksonlee

Permalink

Connect the signal pin of the relay to pin 10 on the Arduino and the lock's VCC and GND to 5V and GND on the Arduino. Then on the other end of the relay, connect the negative of the battery to the common on the relay and the NO (Normally open) on the relay to one side of the lock.First of all, we will include the libraries for the 4X4 keypad, LCD, and a library for storing the password. The EEPROM library is used to store the password. The default password stored in it is ‘1234’.In the loop function, the key pressed will be stored in the ‘key_pressed’ variable and it will be compared with the other keys. If the pressed key is ‘#’, then the change function will be called and it will ask for the new password.The keys pressed are stored in the ‘password’ variable and these are shown on the LCD when the keys are pressed. Then these keys will be matched with the initial password stored in the EEPROM. If the keys that were pressed match the initial password, then the lock will get open and “Pass accepted” will be printed on the LCD. If the password does not match, then it will ask to enter the password again.

  Joined November 07, 2019      124
Thursday at 04:25 PM

Connect the signal pin of the relay to pin 10 on the Arduino and the lock's VCC and GND to 5V and GND on the Arduino. Then on the other end of the relay, connect the negative of the battery to the common on the relay and the NO on the relay to one side of the lock.

  Joined February 27, 2020      55
Thursday at 11:08 AM