CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

protect microcontroller against reading

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
CCS-Festina



Joined: 21 Feb 2012
Posts: 11

View user's profile Send private message MSN Messenger

protect microcontroller against reading
PostPosted: Tue Mar 20, 2012 2:21 pm     Reply with quote

hallow
With what method, I protect my program against reading ? ie I want to transfer a program to microcontroller, and in the program, which statement I make, so that will protect against miocrocontroller reading ?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 20, 2012 3:44 pm     Reply with quote

Use the PROTECT fuse.
CCS-Festina



Joined: 21 Feb 2012
Posts: 11

View user's profile Send private message MSN Messenger

protect
PostPosted: Wed Mar 21, 2012 3:04 pm     Reply with quote

PCM programmer wrote:
Use the PROTECT fuse.


ie I will write this code

Code:
#FUSES PROTECT
.
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Wed Mar 21, 2012 3:59 pm     Reply with quote

Depending on the exact PIC model, there may be other options (to change the memory areas protected etc.).

Verifying the chip once 'protected', needs to be done a special way:

Program the chip _without_this fuse set.
Verify it.
Then set just this fuse with your programmer.
Read the chip back. You will now get a data file that bears no resemblance at all to your code.
Store this.
Now program the chip _with your original code, with the protect fuse set_. Then verify the chip against the file you read back.

The scrambled return file, will always be the same for a correctly programmed chip, but will not work if programmed into a chip.

Remember that with protect on, you can't use a bootloader, and you can't use low voltage programming (only a high voltage 'erase', clears the fuse to allow the chip to be re-written).

Best Wishes
CCS-Festina



Joined: 21 Feb 2012
Posts: 11

View user's profile Send private message MSN Messenger

is this formula is just
PostPosted: Thu Mar 22, 2012 9:31 am     Reply with quote

I repeat the question, is this formula is just to protect the microcontroller against reading

Code:
#fuses protect
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Thu Mar 22, 2012 9:53 am     Reply with quote

As I said before:

"Depending on the exact PIC model, there may be other options (to change the memory areas protected etc.). ".

You have not told us what PIC....

On most of the simpler PIC's, 'yes'.

Remember certain things though - if you are using 'DEBUG', or compiling in MPLAB under DEBUG mode, this fuse will be automatically turned _off_, since otherwise debugging cannot be done. You need to be compiling a run time version.

Best Wishes
CCS-Festina



Joined: 21 Feb 2012
Posts: 11

View user's profile Send private message MSN Messenger

16f877A
PostPosted: Thu Mar 22, 2012 1:33 pm     Reply with quote

Ttelmah wrote:


You have not told us what PIC....


my PIC is : 16f877A
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Mar 22, 2012 3:20 pm     Reply with quote

You can see all the valid FUSES as well as predefined defines in the 'header' file located in the devices folder.

16f877a.h

//////// Fuses: LP,XT,HS,RC,NOWDT,WDT,NOPUT,PUT,PROTECT,DEBUG,NODEBUG
//////// Fuses: NOPROTECT,NOBROWNOUT,BROWNOUT,LVP,NOLVP,CPD,NOCPD,WRT_50%
//////// Fuses: NOWRT,WRT_5%,WRT_25%

9th item in the 1st row....PROTECT.... !

hth
jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Thu Mar 22, 2012 4:27 pm     Reply with quote

I wonder if the poster is misunderstanding what happens?.
You do realise the chip will still 'read', but what comes back is unuseable. It can't be disassembled to see what code is in the chip, and can't be programmed into another chip.
It's like looking at a book of text after it has been fed through a shredder, and then blended in a mixer. It is still paper, and still has printing on it, but putting it back together, would involve years of work.

Best Wishes
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Mar 22, 2012 5:02 pm     Reply with quote

Actually if Microchip haven't altered their 'protection' algorithm from the 16C84 days, it's kinda easy to 'reconstruct' the data read back from the PIC into the actual code that was originally stored.
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Fri Mar 23, 2012 11:08 am     Reply with quote

I thought they did... I think it comes back all zeros or some such, doesn't it?

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group