How to protect code?

Hi, is possible to protect code that is in the chip against copy?

Yes! It is done by setting the appropriate Lock Bits (Fig-1) of the MCU (ATmega328P).


Figure-1:

3 Likes

With some define bits?

What Arduino do you have?

Arduino UNO R3

To protect the uploaded code, use an ISP programmer to set the fuses to block read access to program memory.

Consult the ATmega328P data sheet, "memory programming" section, for the details.

Why would you want that… I have not seen a program running on a UNO that could not be rewritten easily by a skilled engineer… so unless you patent your idea,…

Also the AVR fuse are not foolproof. If someone really wants your binary they will manage to get to it.

2 Likes

Is a program for a company, is not problem if rewrite the chip or erase, i want that cant be copied to another chip.

What does that mean?
To prevent the flash memory from being read by others, are we not setting the Lock Bits and NOT the Fuse Bits?

Arduino UNO fuse can be bypassed. (I used fuse as a general term)

3 Likes

The chip will be placed at PCB without Arduino after write the code, but then i can deduce that can be possible bypass the fuse bits and open the code if some stole the PCB and place in arduino.
Correct?

What copying methods can there be or which pins must be used for a copy?
I made a program that can be used for any code in the arduino IDE that protects the entire code from the microcontroller.

What do you mean by "open the code" ?

If you are worried that someone may get to see your sketch then forget it because the sketch will no longer exist, only the compiled binary code

1 Like

Yes i know, but if can access to the binary, then can extract as hex to copy in another chip, and this is that i want to evade.

As has previously been pointed out, given the details of what the program does, a skilled engineer could write a program to do the same

2 Likes

Yes - there are various glitching schemes / fault attacks that have been reported.

If it runs on a naked at mega thief’s will just rewrite the code from your ideas… it’s probably easier (although you can find companies offering attack services…)

2 Likes

hm how about adding any kind of chip that has a unique number that is inbuild through the manufacturing process of the chip and to read out this unique number. Reading this number after a varying time that depends on that unique number.
If the number does not fit to the code-version you know: illegal copy code stops in a while(true)-loop.

Omg, the eeprom register the passwords, i need to explain more about i need to protect the code against copy?

And leaving aside the possibility that the hacker from Swordfish or any other movie where they break codes appears, is it possible to protect it against copying or not?

And even if you protect copying the binary, the source code and the final f/w image created is subject to all the various s/w licenses.
At a minimum LGPL v2.1 will apply if Arduino is involved.
(There can be multiple licenses involved since libraries don't all use LGPL v2.1)
It is section 6 of the LGPL that is extremely difficult if not impossible to comply with for firmware that is created using Arduino.
Oh and if you use any GPL v3 code - like say a library, you agree to forfeit patent licensing/royalties for any patents involved in the entire f/w image.

@miguelyx if you are trying to create a product that you want be closed source, and it involves Arduino and Arduino libraries, you really need to understand ALL the license agreements involved.
i.e. GPL/LGPL is not freeware there are various requirements and restrictions that come with using that code.
I would advise you to seek legal council.

For a closed source product, one of the most difficult it not impossible to comply with when using Arduino is section 6(b) of LGPL 2.1 which requires that your provide a mechanism for a user of this code to be able to replace the any of LGPL code in the image with updated or modified versions of that LGPL code. So the user must be able to rebuild, relink and re burn the firmware image.
i.e. if I have your product and I want to replace the digitalRead() function in the firmware image, you have provide me the ability to replace the core library in the firmware image with my version.
With Arduino, that is pretty much impossible to do without providing source code so the user can re-build the image.

If you used an Arduino library that is GPL v3, then forget it. You can't make the image close source since using a GPL v3 library requires that everything in the entire image be open source.
i.e. the cost of using GPL v3 code is making your code open source.

--- bill

6 Likes

Those kind of dongle protections s are easily fooled…

@miguelyx
If you want more security you need to look at more modern processors with a Secure Enclave and on board crypto capabilities

But if you use anything related to the arduino world, @bperrybap comment stands… look at the licensing terms for anything you use.

3 Likes