Give Them No Quarter: Preventing PIC Microcontroller Code from Being Duplicated

Copying, from all understandings, seems like a disingenuous and sub-par strategy for any solution you need; from taking a test in school, to catching up with your friends, it is rare to find a moment where you would be rewarded for simply copying a message or answer. Imitating, on the other hand, is an encouraged practice in most professional industries - follow the guidelines and roadwork laid out before you so as to avoid the tedious work of reinventing the wheel for any given task. If copying is punished, and imitating is rewarded, then what’s the difference between the two and how do you protect yourself from incurring future punishments?

From my understanding, imitating is a practice which is there to help you get to a point where you can develop your own strategies, habits, and ideas - not to keep you within certain parameters forever, but to give you an easier understanding of the professional world that you are working in.

But while you are concerned over the debate between copying and imitating and the ethics of each, there are others who may be less concerned about this problem. Take pirates for example. A pirate’s life may not be the life for you, but that won’t stop one from stealing treasured code from your electronics. If you have an electronics product that is strong or selling well, code copying is a hard reality that you need to address with your product. Especially within electronics industries, code piracy from an unscrupulous competitor will hurt your business. Give no quarter to your competitors, and learn how to protect your code.

Don't Ignore the Parrot: Use PIC Microcontroller Code Protection

A great part of my engineering career involved designing with PIC microcontrollers. Protecting my code from being copied had not been a priority until I started a design business; there’s simply too much that goes into the process of PCB design and manufacturing for me to have been concerned over one part of this process being compromised. But, after I listened to horror stories of how some electronics businesses suffered huge losses due to piracy issues, I said scupper that and began taking preventative measures in protecting my products.

Reading an unprotected firmware from a PIC microcontroller is relatively simple. You just need to ensure the microcontroller is connected to the programming header and the raw code can be extracted to a computer via the programming adapter. The resulting file is a hex file that can be easily injected into duplicated hardware. But there are many ways to which you can add protection to this code which will heave any would-be pirate.

No reason for not turning on the code protection bit

Want to Protect Your Code? Install More Cannons!

Code protection should be one of your design priorities from the start. There are various ways to protect your code in your final products and varying accompanying degrees of difficulty to break. Here are a few:

Enable Code Protection Bit: In the PIC microcontroller, there is a code protection bit that will prevent read operation on the program memory when it is asserted. Turning on this code protection feature is as simple as including a directive in the program before it is being compiled and downloaded to the microcontroller. This is the easiest way of code protection but there are suggestions that there are illegitimate methods that may bypass the security features.

Unique ID Authentication: Instead of preventing the code from being read, this method requires the application to verify itself against a unique ID before launching the main program. It usually requires manual insertion of a secret identification number during the first startup before storing the unique ID from an external device to a secured storage. In the case of the code being copied to another hardware, the firmware will not be able to function without the stored unique ID and the secret identification number.

Epoxy Coated: In products where there is no need to update the firmware of the microcontroller, the epoxy coating can be used to physically prevent access to the microcontroller. This is an effective way to not only prevent code piracy but also any attempt to copy and re-engineer the hardware itself. The downside is that the product has limited serviceability if it experienced failure after a period of time.

Self-Destructing Circuit: Just like in certain movies where the characters turn kamikaze mode to protect secrets being tortured out of them, self-destructing circuitry can be used in sensitive applications. I’ve worked in a highly sensitive industry changing design where the client insists on a self-destructing circuit to prevent any attempt of piracy at all. It uses sensors to detect any illegal attempt to access the hardware and connect the microcontroller to a high voltage source. This is a drastic measure to take and the system may accidentally activate the self-destruct mode if the sensor malfunctions.