View previous topic :: View next topic |
Author |
Message |
younder
Joined: 24 Jan 2013 Posts: 53 Location: Brazil
|
Help with Fuses to protect code from reading |
Posted: Wed Oct 07, 2015 7:05 pm |
|
|
Hello everyone,
I was looking at the fuses.txt and also to some other related threads but I'm still a bit confused about this fuse. The point is that CCS uses different names when comparing with datasheet, which turns it even more complicated sometimes to understand the fuses.
Well, I just need to know which fuse should I use to protect the entire code from been read ?
And Finally, say that I want to update the firmware later, can I erase the chip and write the code again once I've included such fuse?
Some related fuses you'll find inside "fuses.txt" in the compiler directory:
CPB Boot Block Code Protected
CPD Data EEPROM Code Protected
DPROTECT Protect EE memory
EBTR Memory protected from table reads
EBTRB Boot block protected from table reads
NOWRT Program memory not write protected
NOWRTD Data EEPROM not write protected
NOWRTB Boot block not write protected
NOWRTC Configuration registers not write protected
PROTECT Code protected from reads
PROTECT_5% Protect 5% of ROM
PROTECT_50% Protect 50% of ROM
PROTECT_75% Protect 75% of ROM
PROTECT_88% Protect 88% of ROM
WRT Program Memory Write Protected
PROTECTS Standard Code protection
PROTECTH High Code protection
SSSS Standard protection for secure segment
SSSH High protection for secure segment
RBS Boot Segment RAM code Protection
For the above mentioned reading protect + write not protect I was thinking in maybe:
Code: |
#fuses PROTECT,NOWRT,NOWRTD,NOWRTB,NOWRTC
|
Edit: I tried to compile the fuses above with DSPic30F4012 (CCS 5.049), but it only worked with:
Code: |
#fuses PROTECT,NOWRT
|
Any help would be appreciated!
Thanks in advance
Hugo _________________ Hugo Silva
Last edited by younder on Wed Oct 07, 2015 8:09 pm; edited 3 times in total |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Wed Oct 07, 2015 7:38 pm |
|
|
You need to now that 'fuses' are specific to a particular PIC so you can't just use a handful of them on a 'PIC' and expect it to work for you.
Hopefully the compiler will complain if you select a fuse that your PIC doesn't have BUT there could be a bug in the compiler so you should post which PIC you're using.
As for reusing a PIC, yes, whenever you totally erase a PIC you're starting 'fresh' so you will lose your program,EEPROM contents as well as the old 'fuses'. The important word here is 'totally' erase. Newer PIC do allow sections of memory to be 'protected' so you must read the datasheet for the PIC you're using.
Jay |
|
|
younder
Joined: 24 Jan 2013 Posts: 53 Location: Brazil
|
|
Posted: Wed Oct 07, 2015 8:05 pm |
|
|
Jay, my mistake, I just forget to mention which pic I was using, I've already edited the original post.
So as long as I can 'totally' erase it and reprogram I will be fine...I did not test it because I was thinking it may not allow me to write chip again once I enable the fuse. However, should I include PROTECT and NOWRT or just PROTECT?
Thanks Buddy
Hugo _________________ Hugo Silva |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Thu Oct 08, 2015 12:57 am |
|
|
Look at the file 'fuses.txt' in the directory with the compiler.
This is second only to the readme, in terms of 'vital data'. It gives the description of what each CCS fuse name means.
Depends who you want to protect against. If you turn off the ability to do table reads, this will stop quite a few compiler functions that do things like access constant arrays from working, but if the code is only protected from reads, and not writes, if this is left on, then somebody could write a new small bootblock into the chip, and this could then contain code to read the rest of the chip....
So generally, protect the chip from external reads, and from writing, which then leaves your code able to work, but can't be overwritten without erasing the chip. |
|
|
younder
Joined: 24 Jan 2013 Posts: 53 Location: Brazil
|
|
Posted: Sat Oct 10, 2015 9:04 am |
|
|
I've tried to include just:
Code: |
#fuses PROTECT,NOWRT
|
But after that I was not able to re-write the chip again...I'm using Pickit 3 to load the HEX into the chip. Even after erase the chip, I was not able to write it again.
How to perform a 'totally erase' and reuse it again?
Thanks guys
Hugo _________________ Hugo Silva |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Sat Oct 10, 2015 10:27 am |
|
|
That's the whole point of the protection....
There is a tick box for the Pickit, that should say 'erase all before programming'. It'll only erase, if the supply voltage is >4.5v. The chip will do a normal erase down to 3v, but bulk erase (which is what is needed to turn off the protection), requires 4.5v minimum.
This is why some boards have a jumper to disconnect the processor from the board supply, and you can then use the programmer to supply the chip. If however you have other circuitry on the board that can't accept this voltage, you are stuck.. |
|
|
younder
Joined: 24 Jan 2013 Posts: 53 Location: Brazil
|
|
Posted: Sat Oct 10, 2015 10:54 am |
|
|
I see Ttelmah, I will try then to use a different board to erase it. For sure this must be the issue (supply voltage <4,5v).
Thanks Buddy
Hugo _________________ Hugo Silva |
|
|
|