Program origin and banks

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
User avatar
Coccoliso
Posts: 152
Joined: Mon Feb 17, 2014 10:34 am

Program origin and banks

Post by Coccoliso » Mon May 11, 2015 2:32 pm

Hello,
I need to protect the source, but read a part of the ROM containing some string constants.
I am aware of the configuration parameters to protect the individual banks and would like to know if and how I can position the origin of the program from a specific bank.
Thank you.

User avatar
octal
Registered User
Registered User
Posts: 586
Joined: Thu Jan 11, 2007 12:49 pm
Location: Paris IDF
Contact:

Re: Program origin and banks

Post by octal » Mon May 11, 2015 2:48 pm


Jerry Messina
Swordfish Developer
Posts: 1473
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: Program origin and banks

Post by Jerry Messina » Mon May 11, 2015 3:43 pm

but read a part of the ROM containing some string constants
Read the constants with what? Also, what device are you using? Different ones have different protections.
how I can position the origin of the program from a specific bank
Octal pointed you to the 'org_xxx' options for moving things around in ROM, but it sounds like
what you want is a little different.

Swordfish will locate all of your constants (both const strings and tables) in the lower portion
of memory after the reset and interrupt vectors, but it's not in it's own section... it could
be mixed in with some code.

The const data is considered as part of the code, so when you use the ORG options to move the code
it moves the const data along with it.

There's no easy way that I know of to leave the const data where it's at and only move the code.

User avatar
Coccoliso
Posts: 152
Joined: Mon Feb 17, 2014 10:34 am

Re: Program origin and banks

Post by Coccoliso » Mon May 11, 2015 5:34 pm

Hello,
with 18F2682 and below config I disable the code read from MPU..

Code: Select all

CP0 = On
CP1 = On
CP2 = On
CP3 = On
CP4 = On
CP5 = On
EBTR0 = On
EBTR1 = On
EBTR2 = On
EBTR3 = On
EBTR4 = On
EBTR5 = On
CPD = On
CPB = On 
.. but this also prevents the use of the TBLRD* and always returns 0.
So the idea was put only the constants allowing TBLRD* in the first bank then protect other banks.
I would do the same thing for 18F26K80.

Jerry Messina
Swordfish Developer
Posts: 1473
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: Program origin and banks

Post by Jerry Messina » Mon May 11, 2015 7:09 pm

Do you really need the table read protection?

User avatar
Coccoliso
Posts: 152
Joined: Mon Feb 17, 2014 10:34 am

Re: Program origin and banks

Post by Coccoliso » Tue May 12, 2015 7:14 am

Hello Jerry,
I had based on this post http://www.microchip.com/forums/m252258.aspx but rightly once you've set CPn and make sure the bootloader with CPB the FW can not be changed and read than a full erase right?
So EBTRn are superfluous :D and are those that prevent me from the TBLRD*.

Jerry Messina
Swordfish Developer
Posts: 1473
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: Program origin and banks

Post by Jerry Messina » Tue May 12, 2015 10:49 am

I've never used code protection and a bootloader. I'm not sure how all that would work.

It's my understanding that if you code protect the bootloader and write-protect the configuration registers (WRTC)
it makes it difficult to use a low-voltage block erase to modify the bootloader, so you're relatively safe.

That assumes you're using an encripted bootloader of some sort so that the user couldn't just download a small hex file
to dump out the contents.

Post Reply