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 support@ccsinfo.com

Is my eeprom protected and how to

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



Joined: 30 Apr 2007
Posts: 64

View user's profile Send private message

Is my eeprom protected and how to
PostPosted: Wed Mar 11, 2009 1:54 pm     Reply with quote

Hello i am working on a project with a PIC 16F687. In this PIC i store on its eeprom some values that represent credits for water consumption charging. I wanted to ask if it is possible someone to load credits to the eeprom so he can <<hacks>> the memory without paying for these credits. This thing is crucial so i can see if there is any security for my system. Thank you.
Ttelmah
Guest







PostPosted: Wed Mar 11, 2009 3:48 pm     Reply with quote

You need to enable two fuses. The first, 'CPD', prevents a programmer from accessing the EEPROM. The second, is 'PROTECT', which does the same for the main memory. This is essential, since otherwise, it is possible to bypass the protection, by updating parts of your code...
To write the chips, write one with the protection _off_. Verify it. Then enable both protection bits. If you now read the chip, you will get a encrypted version of the contents. Store this. Then blow future chips from your master code, with the protection on, and verify these against the contents to the file you stored.
Basically, if anyone turns these bits off with a programmer, the corresponding section of the chip, is completely erased. The 'read' encrypted code, cannot be written into another chip (won't work), but will always be the same, from a chip containing the identical code. Hence it works for verification.

Best Wishes
jojos



Joined: 30 Apr 2007
Posts: 64

View user's profile Send private message

PostPosted: Thu Mar 12, 2009 2:00 am     Reply with quote

Thank you Ttelmah for your response. I tried to Protect the chip and it worked. Mainly I made this post because i can remember that in the past it worked with some atmel chips it was possible to load only eeprom data in hex format without reprogramming the flash memory. Is this possible to me made on a PIC because if it is there goes security. I see in the configuration bits that is a Data Read Protect bit. Does this prevent an outside write of the eeprom (of course if it is possible)?
Ttelmah
Guest







PostPosted: Thu Mar 12, 2009 4:10 am     Reply with quote

This is down to why the fuses are implemented 'inverted'.
On a PIC, you can clear a location during programming, without using an erase, but to _set_ a location, you have to perform an erase on the block involved. So to turn off the fuse protecting the EEPROM, you have to erase the configuration memory part covering both fuses. This implies that the code protection fuse also gets turned off at the same time. Each of these fuses, autoatically erases the memory it covers, if it is disabled. So you use a programmer, and turn off the EEPROM protection, and immediately, you have lost both the EEPROM contents, _and_ the program as well. You can then write whatever you want to the EEPROM, but you have no code to talk to it. Obviously you can write code back, but without the unencrypted code, you will have to write your own complete version, to give the right replies.
This though is why the code should contain hidden checks, so that when the proper system talks to it, you can verify that this is the 'real' code...
Smile

Best Wishes
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