Flash writing problem.

Started by lenux22 August 2, 2004
There is 2 flash blocks on Motorla DG128: Flash Block 0 and Flash.
Block 1. For Flash Block 1 i had set the security byte(0xFF0F) to 0xFE (security disabled) and set protection byte of block 0 (0xFF0D) to protect range 0xF000-0xFFFF (contains my bootrom and flash protections bytes). All working fine. But now I need to write flash block 1. But, then i erasing last address range of block 1, byte at address 0xFF0F also changed to 0xFF. What wrong whith it? changing. The byte at 0xFF0F can't be changed, becouse: 1) I writing flash 1, not flash 0. 0xFF0F address contained in flash
0. 2) Full 0xF000-0xFFFF range is protected. No bytes from it can not
changing.



Flash Block 0 corresponds to Pages 3C - 3F and Flash Block 1 corresponds to
Pages 38 - 3B (counter intuitive than can be expected).
Check figure 3-1 of:
http://www.freescale.com/files/microcontrollers/doc/ref_manual/S12FTS128KV2.pdf

This explains why the protection doesn't work as you expect it. You need to
protect the same address range in Flash Block 0 (rather than Block 1). In
order to protect the $F000 - FFFF range, you need to write the appropriate
protection byte to $FF0D instead of $FF0C.

Hope this helps,
Doron
Nohau Corporation
HC12 In-Circuit Emulators
www.nohau.com/emul12pc.html At 16:29 02/08/2004 +0000, you wrote:
>There is 2 flash blocks on Motorla DG128: Flash Block 0 and Flash.
>Block 1. For Flash Block 1 i had set the security byte(0xFF0F) to >0xFE (security disabled) and set protection byte of block 0 (0xFF0D) >to protect range 0xF000-0xFFFF (contains my bootrom and flash >protections bytes). All working fine. But now I need to write flash >block 1. But, then i erasing last address range of block 1, byte at >address 0xFF0F also changed to 0xFF. What wrong whith it? changing. >The byte at 0xFF0F can't be changed, becouse: >1) I writing flash 1, not flash 0. 0xFF0F address contained in flash
>0. >2) Full 0xF000-0xFFFF range is protected. No bytes from it can not
>changing.





Hello, Doron! Thank you for answer. I forget to say, i program flash in special
mode. Yes, i know about protection: 0xFF0C is protection byte for Flash Block 1 0xFF0D is protection byte for Flash Block 0. But I can't understand why secure byte changed (location 0xFF0F). Then I erasing Flash Block 1 (Flash Block 0 area 0xF000 is
protected!), the byte 0xFF0F (this area in not banked!) is changed to 0xFF. And
this is catastrophic for me - after this i need execute unprotection
procedure described in AN2400/D. Maybe I do something wrong: I erase flash in Special mode and using in erasing procedure instead
of: *((unsigned int *)(FLASH_ADDR)) = DUMMY_BYTE; FCMD = FLASH_ERASE;

this code: FADDR = FLASH_ADDR; FDATA = DUMMY FCMD = FLASH_ERASE;

In DG64 Flash Guide registers FADDR, FDATA mentioned as reserved
registers. But all my erasing/writing procedures (in special mode!)
of DG128's FLash Block 0 working fine for a year.
--- In , Doron Fael <doronf@n...> wrote: > Flash Block 0 corresponds to Pages 3C - 3F and Flash Block 1
corresponds to > Pages 38 - 3B (counter intuitive than can be expected).


> Check figure 3-1 of:


>
http://www.freescale.com/files/microcontrollers/doc/ref_manual/S12FTS1
28KV2.pdf >


> This explains why the protection doesn't work as you expect it. You
need to > protect the same address range in Flash Block 0 (rather than Block
1). In > order to protect the $F000 - FFFF range, you need to write the
appropriate > protection byte to $FF0D instead of $FF0C.


>


> Hope this helps,


> Doron


> Nohau Corporation


> HC12 In-Circuit Emulators


> www.nohau.com/emul12pc.html


>


>


> At 16:29 02/08/2004 +0000, you wrote:


> >There is 2 flash blocks on Motorla DG128: Flash Block 0 and Flash.


> >Block 1. For Flash Block 1 i had set the security byte(0xFF0F) to


> >


> >


> >0xFE (security disabled) and set protection byte of block 0
(0xFF0D) > >


> >


> >to protect range 0xF000-0xFFFF (contains my bootrom and flash


> >


> >


> >protections bytes). All working fine. But now I need to write flash


> >


> >


> >block 1. But, then i erasing last address range of block 1, byte
at > >


> >


> >address 0xFF0F also changed to 0xFF. What wrong whith it?
changing. > >


> >


> >The byte at 0xFF0F can't be changed, becouse:


> >


> >


> >1) I writing flash 1, not flash 0. 0xFF0F address contained in
flash > >0.


> >


> >


> >2) Full 0xF000-0xFFFF range is protected. No bytes from it can not


> >changing.


>


>


>



Location 0xFF0F is part of Flash Block 1 - not Flash Block 0.

In other words:

You need to protect Flash Block 1 - not Flash block 0, in order to protect
location 0xFF0F from being erased.

Doron
Nohau Corporation
HC12 In-Circuit Emulators
www.nohau.com/emul12pc.html

At 08:36 03/08/2004 +0000, you wrote:
>Hello, Doron!
>
>Thank you for answer. I forget to say, i program flash in special
>mode. Yes, i know about protection:
>
>0xFF0C is protection byte for Flash Block 1
>
>0xFF0D is protection byte for Flash Block 0.
>
>But I can't understand why secure byte changed (location 0xFF0F).
>
>Then I erasing Flash Block 1 (Flash Block 0 area 0xF000 is
>protected!),
>
>the byte 0xFF0F (this area in not banked!) is changed to 0xFF. And
>this is catastrophic for me - after this i need execute unprotection
>procedure described in AN2400/D. Maybe I do something wrong:
>
>I erase flash in Special mode and using in erasing procedure instead
>of:
>
> *((unsigned int *)(FLASH_ADDR)) = DUMMY_BYTE;
> FCMD = FLASH_ERASE;
>
>this code:
>FADDR = FLASH_ADDR;
>FDATA = DUMMY
>FCMD = FLASH_ERASE;
>
>In DG64 Flash Guide registers FADDR, FDATA mentioned as reserved
>registers. But all my erasing/writing procedures (in special mode!)
>of DG128's FLash Block 0 working fine for a year.





Maybe i stupid, but I can't understand how it can be. Text on page 15
of FTS 128K User guide is describe Flash Block 0 holding protection
bytes for all other Flash blocks. And security byte is one for all
blocks. And it's located at Flash Block 0.
Page 15. Text under Table 3.1 :
Security information that allows the MCU to prevent intrusive access
to the Flash module is stored in the Flash Protection/Options field of
Flash block 0 as described in Table 3-1.
--- In , Doron Fael <doronf@n...> wrote: > Location 0xFF0F is part of Flash Block 1 - not Flash Block 0.


>


> In other words:


>


> You need to protect Flash Block 1 - not Flash block 0, in order to
protect > location 0xFF0F from being erased.


>


> Doron


> Nohau Corporation


> HC12 In-Circuit Emulators


> www.nohau.com/emul12pc.html


>


> At 08:36 03/08/2004 +0000, you wrote:


> >Hello, Doron!


> >


> >Thank you for answer. I forget to say, i program flash in special


> >mode. Yes, i know about protection:


> >


> >0xFF0C is protection byte for Flash Block 1


> >


> >0xFF0D is protection byte for Flash Block 0.


> >


> >But I can't understand why secure byte changed (location 0xFF0F).


> >


> >Then I erasing Flash Block 1 (Flash Block 0 area 0xF000 is


> >protected!),


> >


> >the byte 0xFF0F (this area in not banked!) is changed to 0xFF. And


> >this is catastrophic for me - after this i need execute
unprotection > >procedure described in AN2400/D. Maybe I do something wrong:


> >


> >I erase flash in Special mode and using in erasing procedure
instead > >of:


> >


> > *((unsigned int *)(FLASH_ADDR)) = DUMMY_BYTE;


> > FCMD = FLASH_ERASE;


> >


> >this code:


> >FADDR = FLASH_ADDR;


> >FDATA = DUMMY


> >FCMD = FLASH_ERASE;


> >


> >In DG64 Flash Guide registers FADDR, FDATA mentioned as reserved


> >registers. But all my erasing/writing procedures (in special
mode!) > >of DG128's FLash Block 0 working fine for a year.


>


>


>



I am sorry. My mistake.
My email from yesterday contained the right information. The email from
today was wrong (I got confused between Block 1 and Block 0).

Which S12DG128 mask set are you using? I believe early mask sets (0L85D)
did not have Flash protection and security fully working. Maybe this is the
source of your problem.

Hope this helps,
Doron
Nohau Corporation
HC12 In-Circuit Emulators
www.nohau.com/emul12pc.html

At 10:39 03/08/2004 +0000, you wrote:
>Maybe i stupid, but I can't understand how it can be. Text on page 15
>of FTS 128K User guide is describe Flash Block 0 holding protection
>bytes for all other Flash blocks. And security byte is one for all
>blocks. And it's located at Flash Block 0.
>Page 15. Text under Table 3.1 :
>Security information that allows the MCU to prevent intrusive access
>to the Flash module is stored in the Flash Protection/Options field of
>Flash block 0 as described in Table 3-1.





Yes, i have 0L85D mask. :( But Freescale web-site on DG128 page
provide erratas only for mask sets 0L40K. :(

--- In , Doron Fael <doronf@n...> wrote: > I am sorry. My mistake.


> My email from yesterday contained the right information. The email
from > today was wrong (I got confused between Block 1 and Block 0).


>


> Which S12DG128 mask set are you using? I believe early mask sets
(0L85D) > did not have Flash protection and security fully working. Maybe this
is the > source of your problem.


>


> Hope this helps,


> Doron


> Nohau Corporation


> HC12 In-Circuit Emulators


> www.nohau.com/emul12pc.html


>





Hi,

Using the Freescale keyword search for 0L85D I got:
http://www.freescale.com/files/microcontrollers/doc/errata/MSE9S12DT128B_0L85D.pdf

They keep shuffling things around...

Hope this helps
Steve Russell
Nohau Emulators

At 05:40 AM 8/3/2004, lenux22 wrote:
>Yes, i have 0L85D mask. :( But Freescale web-site on DG128 page
>provide erratas only for mask sets 0L40K. :( >
>
>--- In , Doron Fael <doronf@n...> wrote: > > I am sorry. My mistake. > > My email from yesterday contained the right information. The email
>from > > today was wrong (I got confused between Block 1 and Block 0). > > > Which S12DG128 mask set are you using? I believe early mask sets
>(0L85D) > > did not have Flash protection and security fully working. Maybe this
>is the > > source of your problem. > > > Hope this helps, > > Doron > > Nohau Corporation > > HC12 In-Circuit Emulators > > www.nohau.com/emul12pc.html > >Yahoo! Groups Links >
>