cancel
Showing results for 
Search instead for 
Did you mean: 

permanently unprotect write protect and debug protect

shangdawei1
Associate II
Posted on November 30, 2005 at 12:16

permanently unprotect write protect and debug protect

3 REPLIES 3
shangdawei1
Associate II
Posted on November 30, 2005 at 09:14

see : STR7 FAMILY FLASH PROGRAMMING REFERENCE MANUAL

3.4 PERMANENT UNPROTECTION

You can permanently unprotect a protected sector (write protect), or protected Flash Module

(debug protect). You may need to use this feature under certain circumstances, for example to

analyze rejects. Debug protection can be disabled by programming the PDSx bits in the

FLASH_NVAPR1 register. If the DBGP bit is programmed to 0,

 

disabling the protection by programming the PDSx bits can be done only by a program executed from the Flash Module.

 

The user software design can ensure that this is accessible only to authorized users.

3.6 SET PROTECTION EXAMPLES

Example 1: Enable Write Protection of sectors B0F3-0 of Bank 0 in the Flash Module.

FLASH_CR0 |= 0x01000000; /*Set SPR in FLASH_CR0*/

FLASH_AR = 0x0010DFB0; /*Load Add in FLASH_AR*/

FLASH_DR0 = 0xFFFFFFF0; /*Load Data in FLASH_DR0*/

FLASH_CR0 |= 0x80000000; /*Operation start*/

Example 2: Enable Debug Protection.

FLASH_CR0 |= 0x01000000; /*Set SPR in FLASH_CR0*/

FLASH_AR = 0x0010DFB8; /*Load Add in FLASH_AR*/

FLASH_DR0 = 0xFFFFFFFD; /*Load Data in FLASH_DR0*/

FLASH_CR0 |= 0x80000000; /*Operation start*/

 

Example 3: Disable Debug Protection permanently.

 

FLASH_CR0 |= 0x01000000; /*Set SPR in FLASH_CR0*/

FLASH_AR = 0x0010DFBC; /*Load Add in FLASH_AR*/

FLASH_DR0 = 0xFFFFFFFE; /*Load Data in FLASH_DR0*/

FLASH_CR0 |= 0x80000000; /*Operation start*/

Example 4: Re-Enable Debug Protection permanently, after having disabled it.

FLASH_CR0 |= 0x01000000; /*Set SPR in FLASH_CR0*/

FLASH_AR = 0x0010DFBC; /*Load Add in FLASH_AR*/

FLASH_DR0 = 0xFFFEFFFE; /*Load Data in FLASH_DR0*/

FLASH_CR0 |= 0x80000000; /*Operation start*/

Note You can disable and re-enable the Debug Protection permanently (as shown in

examples 3 and 4) a maximum of 16 times.

Note These examples can only be done by code which is fetched from RAM.

Now i have a question:

 

does program code execute from the Flash Module or fetch from RAM ?

shangdawei1
Associate II
Posted on November 30, 2005 at 09:27

The protection registers are not directly accessible for writing. They can be programmed using

a set protection operation and writing them as a normal write operation.

Note When accessing protection registers, a write operation of bit to ‘1’ is not considered

as a write operation to a bank. This means that writing ‘1’ to the protection registers

can be done even if the code is fetched from the Flash.

Writing to ‘0’ instead can be executed from all the internal or external memories except from the Flash bank 0.

 

This because the protection operation corresponds to a write into the system

memory (located in bank 0) and it is not possible to read and to write at the same

time the same bank.

... ...

3.4 PERMANENT UNPROTECTION

You can permanently unprotect a protected sector (write protect), or protected Flash Module

(debug protect). You may need to use this feature under certain circumstances, for example to

analyze rejects.

Debug protection can be disabled by programming the PDSx bits in the FLASH_NVAPR1 register.

If the DBGP bit is programmed to 0, disabling the protection

by programming the PDSx bits can be done only by a program executed from the Flash Module.

i have a question, executed from the Flash Module or not ?

shangdawei1
Associate II
Posted on November 30, 2005 at 12:16

3.4 PERMANENT UNPROTECTION

You can permanently unprotect a protected sector (write protect), or protected Flash Module

(debug protect). You may need to use this feature under certain circumstances, for example to

analyze rejects.

Debug protection can be disabled by programming the PDSx bits in the FLASH_NVAPR1 register.

But how to permanently unprotect a protected sector (write protect)?