cancel
Showing results for 
Search instead for 
Did you mean: 

How to permanently unprotect a protected Flash Module(debug protect) ?

shangdawei1
Associate II
Posted on January 22, 2006 at 10:32

How to permanently unprotect a protected Flash Module(debug protect) ?

8 REPLIES 8
shangdawei1
Associate II
Posted on January 12, 2006 at 06:44

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.

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

anis2
Associate II
Posted on January 13, 2006 at 05:25

Hello,

You right, its a mistake on the STR7 Flash programming reference manual:

- The write protection can not be disabled in a permanent way, it can be disabled only in a temporary way. The code to Enable/Disable the write protection can be fetched either from RAM or Flash.

- The Debug protection can be Enabled with code fetched either from RAM or FLASH.

- The Debug protection can be disabled with code fetched only from FLASH.

A new version of the STR7 FLASH PROGRAMMING MANUAL will be available on the STMCU website.

Regards.

shangdawei1
Associate II
Posted on January 13, 2006 at 05:52

Quote:

On 13-01-2006 at 09:55, Anonymous wrote:

Hello,

- The Debug protection can be disabled with code fetched only from FLASH.

To be disabled Debug protection, PDSx has to be programmed to '0', you mean, i can program FLASH_NVAPR1 from BANK0 ?

BTW, my MSN is shangdawei AT 371.net, how can i contact you directly ?

shangdawei1
Associate II
Posted on January 13, 2006 at 06:23

Quote:

On 13-01-2006 at 09:55, Anonymous wrote:

Hello,

A new version of the STR7 FLASH PROGRAMMING MANUAL will be available on the STMCU website.

Regards.

When can i get it ? I need it urgent.

anis2
Associate II
Posted on January 13, 2006 at 10:41

yes you can can program FLASH_NVAPR1 from BANK0 and the new version of the STR7 Flash programming manual will be available next week.

Regards.

shangdawei1
Associate II
Posted on January 17, 2006 at 19:33

Now i downloaded newer FLASH PROGRAMMING REFERENCE MANUAL V3.

in FLASH PROGRAMMING REFERENCE MANUAL V3 :

WRITE PROTECTION

The Flash module provides a write protection, which can be independently activated for each

sector of each bank. When a sector is Write Protected, any attempt to program or erase will

result in a Protection Error.

A flash sector can be Write Protected by programming at 0 the related bit WyPx of the

FLASH_NVWPAR register.

Note The Write protection operation can be executed from all the internal/external

memories including Flash Bank 0 of the Flash module.

Q1: does it means Flash B0, Flash B1,RAM, Ext. mem ?

DEBUG PROTECTION

If bit DBGP of FLASH_NVAPR0 is programmed at 0, the device becomes Debug protected:

debug features JTAG pins and Flash SystemMemory mode are disabled.

Note The Debug protection operation can be executed from all the internal/external

memories except Flash Bank 0 of the Flash module.

Q2: does it means Flash B1,RAM, Ext. mem except Flash B0 ?

Temporary Unprotection - A write protected sector

A write protected sector can be temporarily unprotected by executing the set protection

operation and writing 1 in the associated WyPx bits of FLASH_NVWPAR. Refer to Section 3.5

for examples. The temporary unprotection write operation can be executed from all the

internal/external memories including Flash Bank 0 of the Flash module.

Q3: A write protected sector can be temporarily unprotected can be finished from internal RAM or Flash B0 or Flash B1 or Ext. Mem ?

Temporary Unprotection - The debug protected Flash

The debug protected Flash module can be temporarily unprotected by executing the set

protection operation and writing 1 into this DBGP bit but only if these instructions are executed

from the Flash Module.

Permanent Unprotection - The debug protected Flash

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.

Q4: debug protection can be temporarily or premanent unprotected only when a program executed from the Flash Module (B0 or B1) ?

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

 

 

where does a program executes from? Only Flash B1?

in FLASH PROGRAMMING REFERENCE MANUAL V2 Page 23 :

Trying to write into the Debug Protected Flash from internal RAM will be unsuccessful.

and in V3 it is removed. does it mean

Q6: the Debug Protected Flash can be wrote from internal RAM or Flash B0/B1 or Ext. Mem ?

anis2
Associate II
Posted on January 18, 2006 at 08:03

Hello,

Q1: does it means Flash B0, Flash B1,RAM, Ext. mem?

R1: Yes.

Q2: does it means Flash B1,RAM, Ext. mem except Flash B0 ?

R2: Yes.

Q3: A write protected sector can be temporarily unprotected can be finished from internal RAM or Flash B0 or Flash B1 or Ext. Mem ?

R3: The write protection can be temporarily unprotected form all the memory areas (internal RAM or Flash B0 or Flash B1 or Ext).

Q4: debug protection can be temporarily or premanent unprotected only when a program executed from the Flash Module (B0 or B1) ?

R4: Yes.

Q5: Re-Enable Debug Protection permanently, after having disabled it. where does a program executes from? Only Flash B1?

R5: from all the internal/external memories except Flash Bank 0 of the Flash module.

Q6: the Debug Protected Flash can be wrote from internal RAM or Flash B0/B1 or Ext. Mem ?

R6: Yes a Debug Protected Flash can be wrote from Internal RAM, or from Ext. Mem if enabled. Because when Debug protection is enabled the EMI is disabled automatically, but it can be enabled again if the user application allows it.

Best regards.

shangdawei1
Associate II
Posted on January 22, 2006 at 10:32

Thx Bouha, now all are clear !