MC9S12DT128 - Flash security

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MC9S12DT128 - Flash security

3,990 Views
ramabh
Contributor I
Hey All
 
I am working on hcs12(MC9S12DT128) and i am using cosmic compiler and zap debugger.
 
From the datasheet i understood that setting the value 0xff or 0xfd or oxfc at address FFOE will secure my controller.
 
But whats happenening is by default the debugger is placing 0xFE(Unsecured mode) and when through program when i try to change this byte its giving me an error "error while programming the memory location 0x3fbf0e" .And when i try to program the controller again its not happening.
I have to unsecure the device and then i have to program
 
i gone thruogh all the posts in this forum there are few people who faced similar type of problem but it seems that there problem was solved by writing FC instead of FF and i too tried all the ways still not able to solve the problem. 
 
--
Alban Edit: part number to be shwon in subject line
 


Message Edited by Alban on 2007-05-07 10:20 AM
Labels (1)
0 Kudos
14 Replies

783 Views
Alban
Senior Contributor II
Hello,

The best way is to use the default when you are debugging and then integrate the security in your software so it is programmed in the same time as the rest of the software.
If it is in the S-Record you program, the debugger default will not apply.

Code:
const tU08 FlashSecure @ 0xFF0E = 0x00; 

Up to you to translate this to COSMIC, I don't use it.

Cheers,
Alban.
0 Kudos

783 Views
ramabh
Contributor I
Hey Alban
 
I am doing the same thing what u mentioned.
 
while programming that memory location only i am getting that error"error while programming ".
 
 
0 Kudos

783 Views
Alban
Senior Contributor II
Hello,

In this case, I would cross check with another device.
And also check that the right device is selected from the list.

Alban.
0 Kudos

783 Views
ramabh
Contributor I
Hi alban
 
the same code that i am using for HCS12 i checked with hcs08.For Hcs08 its working as expected but for hcs12 only i am facing this problem.
 
 
0 Kudos

783 Views
Alban
Senior Contributor II
Hello,

S08 and S12 are different.
If the code was written for S08, you need to modify it to run on S12.

Memory map and/or flash programing algorithm are probably wrong, explaining why it cannot program what it wants where it wants.

Change the software to fit S12 memory map,
Change the compiler and linker to use S12 map and instructions,
Use a debugger able to program S12.

Alban.
0 Kudos

783 Views
ramabh
Contributor I
hi
 
I am using both HCS12 and Hcs08 and i know what to change in memory and in linker files and i changed all the required minor changes and even in s19 files tha data is there......
0 Kudos

783 Views
JohnnyP
Contributor III
Hi. I just finished porting my HC11 assembly code to the MC9S12C32. I'm using CW12 V3.1 with P&E USB BDM pod. To secure the processor, do I add an equate to my assembly code, like: FSEC EQU $FC Thanks
0 Kudos

783 Views
ramabh
Contributor I
hi
 
we cannot eauate a value to FSEC.
 
After every reset this FSEC register takes the value from memory location FFOF and so writing to FSEC makes no sense and even its not allowed only .check the datasheet
0 Kudos

783 Views
Alban
Senior Contributor II
Yes, FSEC should be declared as being at $FFOF for this to work.
or if FSEC is not an existing declaration.
You can declare a byte start (Org $FFOF).
Alban.

0 Kudos

783 Views
Alban
Senior Contributor II
Hi,

The equates should be OK as it would create the equivalent of the "const", I would think.
You can check that it does the good linking by looking at your generated S-Record.
You would be able to read 0xFC at the address $FSEC.

Alban.
0 Kudos

783 Views
JohnnyP
Contributor III
Alban:

I don't know the format.

I tried:

ORG $101 ; FSEC register here
Secure EQU $FC ; Secure the flash
FDB Secure

This compiles, but the loader times out part way through.
0 Kudos

783 Views
Alban
Senior Contributor II
As Ramabh says you cannot work from $0101. It is a copy from $FF0F.
Change the "org" to declare your value in the Flash $FF0F, instead of the register area.

Alban.
0 Kudos

783 Views
JohnnyP
Contributor III
Hooray:

ORG $FFOF ; FSEC register loads from here
Secure EQU $FC ; Secure the flash
FDB Secure

TrueTime loads this. After reset, TrueTime debugger fails to load, giving a BDM speed warning, saying processor may be secure.

Had a scare with the P&E Unsecure 12, though. It wouldn't communicate the first time. Second time, it went through the unsecure process.

Thanks for the help guys.

See my project here (scroll down for pic):
http://www.jandssafeguard.com/8ChannelVampire/J&S_Vampire_Brochure.html
0 Kudos

783 Views
ramabh
Contributor I

Hi

this message is for the people who are using cosmic and zap debugger.

Zap prevents writting 0xFF at location FFOF

we can restrict ZAP not to do this by overwriting the contents of file "pflash.sr" with contents of "PFLASH_BDM_Lock_Allowed.sr" when we donot want this we just have to over write the contents with PFLASH_default.sr

0 Kudos