Protecting Microcontroller Code

Status
Not open for further replies.

haxan

New Member
Hi, Can anyone guide me how to protect code in a microcontroller from being copied by others?

Also is it possible to get the code back from HEX file?
 
1. You set the code protection bits in the config location. Actual bits depend on the actual chip.
2. You can get a disassembly listing.

Mike.
 
Yes, both things are possible
you can protect code in a microcontroller from being copied by others
and you can get the code back from HEX file

to protect the code: you need to enable lock bits (I am talking about 89s51)
and to get code from Hex file you need assembler, once i have converted using batronix but the converted code was hard to understand...
 
I am using PIC18F series. If i lock the code, i wont be able to read correct? Also will i be able to reburn code onto it?
 
I am using PIC18F series. If i lock the code, i wont be able to read correct? Also will i be able to reburn code onto it?

You can't read it back, but you can erase the chip and re-write to it.

Unless it's a sensitive and valuble application it's best not to read-protect it though - and even then, if it's valuable enough, it can be read by various nefarious means.
 
While going through the compiler help file, I see that there are Code Protection blocks in PIC18F4520.

If i lock all the 4 (CP0 - CP3) blocks, and leave the Configuration Register Write Protection bit to disable, can someone change my Code protection blocks by writing on the configuration register?
 

No, in order to change them you have to erase the chip (which is done as part of programming it).
 
Note that as Nigel already said, there are other means of reading code back. Microchip have improved in this area recently.

Have a read of some of these links if you are interested:

Breaking copy protection in microcontrollers (mostly historical)
**broken link removed** (historical)
**broken link removed** (search their site for "Microchip" to find teardowns)

As I already said, many of these things have been improved to the point that the attacks won't work any longer. But it proves the point that you cannot rely 100% on code protection and therefore should not feel like it is protecting your intellectual property. It's just putting another (arguably large) barrier in the way.

There was a really interesting site with detailed pictures of the Microchip code protection fuses and how to erase them with UV by exposing the dye with acid. But I don't appear to have it bookmarked. Edit: it's here: **broken link removed**
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…