cancel
Showing results for 
Search instead for 
Did you mean: 

How to fix: Error: Mass erase operation failed. / verify flash protection

Rena Z.
Associate II

After evaluating/flashing the SBSFU examples on the NUCLEO-G071RB evalboard it's not possible to erase full flash anymore. I get the error below. How to set factory defaults that erasing is possible again?

STM32_Programmer_CLI.exe -c port=SWD -e all

   -------------------------------------------------------------------

            STM32CubeProgrammer v2.12.0

   -------------------------------------------------------------------

ST-LINK SN : xxxxxxxxxxxxxxxxxxxxxxx

ST-LINK FW : V2J40M27

Board    : NUCLEO-G071RB

Voltage   : 3.21V

SWD freq  : 4000 KHz

Connect mode: Normal

Reset mode : Software reset

Device ID  : 0x460

Revision ID : Rev B

Device name : STM32G07x/STM32G08x

Flash size : 128 KBytes

Device type : MCU

Device CPU : Cortex-M0+

BL Version : 0xB2

Debug in Low Power mode enabled

Mass erase ...

Error: Mass erase operation failed.

Please verify flash protection

STM32_Programmer_CLI.exe -c port=SWD -ob displ

   -------------------------------------------------------------------

            STM32CubeProgrammer v2.12.0

   -------------------------------------------------------------------

ST-LINK SN : xxxxxxxxxxxxxxxxxxxxx

ST-LINK FW : V2J40M27

Board    : NUCLEO-G071RB

Voltage   : 3.21V

SWD freq  : 4000 KHz

Connect mode: Normal

Reset mode : Software reset

Device ID  : 0x460

Revision ID : Rev B

Device name : STM32G07x/STM32G08x

Flash size : 128 KBytes

Device type : MCU

Device CPU : Cortex-M0+

BL Version : 0xB2

Debug in Low Power mode enabled

UPLOADING OPTION BYTES DATA ...

 Bank     : 0x00

 Address    : 0x40022020

 Size     : 112 Bytes

██████████████████████████████████████████████████ 100%

OPTION BYTES BANK: 0

  Read Out Protection:

   RDP     : 0xAA (Level 0, no protection)

  BOR Level:

   BOR_EN    : 0x0 (Configurable brown out reset disabled, power-on reset defined by POR/PDR levels)

   BORR_LEV   : 0x3 (BOR rising level 4 with threshold around 2.9 V)

   BORF_LEV   : 0x3 (BOR falling level 4 with threshold around 2.8 V)

  User Configuration:

   nRST_STOP  : 0x1 (No reset generated when entering Stop mode)

   nRST_STDBY  : 0x1 (No reset generated when entering Standby mode)

   nRST_SHDW  : 0x1 (No reset generated when entering the Shutdown mode)

   IWDG_SW   : 0x1 (Software independant watchdog)

   IWDG_STOP  : 0x1 (IWDG counter active in stop mode)

   IWDG_STDBY  : 0x1 (IWDG counter active in standby mode)

   WWDG_SW   : 0x1 (Software window watchdog)

   RAM_PARITY_CHECK: 0x1 (SRAM parity check disable)

   nBOOT_SEL  : 0x1 (BOOT0 signal is defined by nBOOT0 option bit)

   nBOOT1    : 0x1 (Boot from Flash if BOOT0 = 0, otherwise system memory)

   nBOOT0    : 0x1 (nBOOT0=1)

   NRST_MODE  : 0x3 (Bidirectional reset: NRST pin configured in reset input/output mode (legacy mode))

   IRHEN    : 0x1 (Internal resets drives NRST pin low until it is seen as low level)

  PCROP Protection:

   PCROP1A_STRT : 0x0 (0x8000000)

   PCROP1A_END : 0x0 (0x8000200)

   PCROP_RDP  : 0x1 (PCROP zone is erased when RDP is decreased)

   PCROP1B_STRT : 0xFF (0x801FE00)

   PCROP1B_END : 0x0 (0x8000200)

  Write Protection:

   WRP1A_STRT  : 0x0 (0x8000000)

   WRP1A_END  : 0x0 (0x8000000)

   WRP1B_STRT  : 0x3F (0x801F800)

   WRP1B_END  : 0x0 (0x8000000)

  FLASH security:

   BOOT_LOCK  : 0x0 (Boot based on the pad/option bit configuration)

   SEC_SIZE   : 0x0 (0x8000000)

9 REPLIES 9
GwenoleB
ST Employee

Hello @Rena Z.​,

I'm seeing some PCROP and WRP are set. When a WRP or PCROP is set, mass erase is forbidden.

WRP or PCROP are enable when START_ADDRESS <= STOP_ADDRESS

 PCROP1A_STRT : 0x0 (0x8000000)

 PCROP1A_END : 0x0 (0x8000200)

WRP1A_STRT  : 0x0 (0x8000000)

WRP1A_END  : 0x0 (0x8000000)

First, disable PCROP and WRP protection, then proceed to the mass erase.

Let me know if it works.

Best Regards,

Gwénolé

Rena Z.
Associate II

seems that modifying PCROP1A_STRT does not work:

STM32_Programmer_CLI.exe -c port=SWD -ob PCROP1A_STRT=0x3F -ob displ

   -------------------------------------------------------------------

            STM32CubeProgrammer v2.12.0

   -------------------------------------------------------------------

ST-LINK SN : xxxxxxxxxxxxxxxxxxxxx

ST-LINK FW : V2J40M27

Board    : NUCLEO-G071RB

Voltage   : 3.22V

SWD freq  : 4000 KHz

Connect mode: Normal

Reset mode : Software reset

Device ID  : 0x460

Revision ID : Rev B

Device name : STM32G07x/STM32G08x

Flash size : 128 KBytes

Device type : MCU

Device CPU : Cortex-M0+

BL Version : 0xB2

Debug in Low Power mode enabled

UPLOADING OPTION BYTES DATA ...

 Bank     : 0x00

 Address    : 0x40022020

 Size     : 112 Bytes

██████████████████████████████████████████████████ 100%

PROGRAMMING OPTION BYTES AREA ...

 Bank     : 0x00

 Address    : 0x40022020

 Size     : 112 Bytes

██████████████████████████████████████████████████ 100%

Reconnecting...

 DBG enabled successfully

Reconnected !

UPLOADING OPTION BYTES DATA ...

 Bank     : 0x00

 Address    : 0x40022020

 Size     : 112 Bytes

██████████████████████████████████████████████████ 100%

OPTION BYTE PROGRAMMING VERIFICATION:

Error: Expected value for Option Byte "pcrop1a_strt": 0x3F, found: 0x0

Error: Option Byte Programming failed

GwenoleB
ST Employee

Hello @Rena Z.​,

Can you try to read and change Option Bytes through CubeProgrammer?

I'll investigate Programmer_CLI.

Another test could be to read the Option bytes register in debug mode.

Best Regards,

Gwénolé

Rena Z.
Associate II

0693W00000Y8ZH4QAN.pngsame issue with STM32CubeProgrammer.

>Another test could be to read the Option bytes register in debug mode.

how to read out in debug mode?

Here is an additional log where I have increased the verbosity level to 3:

---------------------------------------------------------------------------------------------------

 07:03:34:480 : r ap 0 @0x1FFF6FFE 0x00000004 bytes Data 0xFFFF00B2

 07:03:35:575 : r ap 0 @0x1FFF6FFE 0x00000004 bytes Data 0xFFFF00B2

 07:03:35:724 : Option byte command : -ob PCROP_RDP=1 PCROP1A_STRT=0xff 

 07:03:35:729 : PROGRAMMING OPTION BYTES AREA ...

 07:03:35:729 : Reading data...

 07:03:35:781 : r ap 0 @0x1FFF77DD 0x00000004 bytes Data 0xFFFFFFFF

 07:03:35:781 : Database: Config 0 is active.

 07:03:35:782 : Warning: Option Byte: PCROP_RDP, value: 0x1, was not modified.

 07:03:35:786 :  Bank     : 0x00

 07:03:35:786 :  Address    : 0x40022020

 07:03:35:787 :  Size     : 112 Bytes

 07:03:35:787 : OB buffer: aafeffffff000000000000803f0000003f000000ff00000000000000ffffffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

 07:03:35:788 : Buffer program...

 07:03:35:842 : halt ap 0 

 07:03:35:842 : w ap 0 reg 15 PC  (0x20000000)  

 07:03:35:895 : w ap 0 reg 17 MSP (0x20000500)  

 07:03:35:948 : w ap 0 reg 16 xPSR (0x01000000)  

 07:03:36:475 : w ap 0 @0x20000B20 : 0x00000200 bytes, Data 0x00000000...

 07:03:36:490 : w ap 0 @0x20000000 : 0x00000004 bytes, Data 0x0000BE00...

 07:03:38:106 : w ap 0 @0x20000004 : 0x000006F4 bytes, Data 0x4891B580...

 07:03:38:212 : w ap 0 @0x20000B20 : 0x00000070 bytes, Data 0xFFFFFEAA...

 07:03:38:212 : Loader write option bytes...

 07:03:38:212 : Init flashloader...

 07:03:38:237 : halt ap 0 

 07:03:38:303 : w ap 0 reg 0 R0  0x00000001

 07:03:38:356 : w ap 0 reg 1 R1  0x00000000

 07:03:38:410 : w ap 0 reg 2 R2  0x00000000

 07:03:38:463 : w ap 0 reg 3 R3  0x00000000

 07:03:38:516 : w ap 0 reg 4 R4  0x00000000

 07:03:38:569 : w ap 0 reg 5 R5  0x00000000

 07:03:38:622 : w ap 0 reg 6 R6  0x00000000

 07:03:38:676 : w ap 0 reg 7 R7  0x00000000

 07:03:38:729 : w ap 0 reg 8 R8  0x00000000

 07:03:38:782 : w ap 0 reg 9 R9  0x00000000

 07:03:38:835 : w ap 0 reg 10 R10 0x00000000

 07:03:38:888 : w ap 0 reg 11 R11 0x00000000

 07:03:38:941 : w ap 0 reg 12 R12 0x00000000

 07:03:38:994 : w ap 0 reg 13 SP  0x00000000

 07:03:39:048 : w ap 0 reg 14 LR  0x20000001

 07:03:39:101 : w ap 0 reg 15 PC  0x20000005

 07:03:39:155 : w ap 0 reg 16 xPSR 0x01000000

 07:03:39:207 : w ap 0 reg 17 MSP 0x20000AF4

 07:03:39:259 : w ap 0 reg 18 PSP 0x00000000

 07:03:39:259 : run ap 0 

 07:03:39:310 : halt ap 0 

 07:03:39:342 : r ap 0 reg 0 R0  0x00000001

 07:03:39:408 : w ap 0 reg 0 R0  0x40022020

 07:03:39:461 : w ap 0 reg 1 R1  0x00000070

 07:03:39:514 : w ap 0 reg 2 R2  0x20000B20

 07:03:39:567 : w ap 0 reg 3 R3  0x00000002

 07:03:39:620 : w ap 0 reg 4 R4  0x00000000

 07:03:39:673 : w ap 0 reg 5 R5  0x00000000

 07:03:39:726 : w ap 0 reg 6 R6  0x00000000

 07:03:39:779 : w ap 0 reg 7 R7  0x00000000

 07:03:39:833 : w ap 0 reg 8 R8  0x00000000

 07:03:39:886 : w ap 0 reg 9 R9  0x00000000

 07:03:39:939 : w ap 0 reg 10 R10 0x00000000

 07:03:39:992 : w ap 0 reg 11 R11 0x00000000

 07:03:40:045 : w ap 0 reg 12 R12 0x00000000

 07:03:40:098 : w ap 0 reg 13 SP  0x00000000

 07:03:40:151 : w ap 0 reg 14 LR  0x20000001

 07:03:40:204 : w ap 0 reg 15 PC  0x2000007D

 07:03:40:257 : w ap 0 reg 16 xPSR 0x01000000

 07:03:40:311 : w ap 0 reg 17 MSP 0x20000AF4

 07:03:40:364 : w ap 0 reg 18 PSP 0x00000000

 07:03:40:365 : run ap 0 

 07:03:40:415 : WriteOB function terminated with connection error due to OB_Launch

 07:03:40:428 : Reconnecting...

 07:03:41:530 : ST-LINK SN : xxxxxxxxxxxxxxxxxxxxx

 07:03:41:530 : ST-LINK FW : V2J40M27

 07:03:41:532 : Board    : NUCLEO-G071RB

 07:03:41:533 : Voltage   : 3.22V

 07:03:41:832 : SWD freq  : 15 KHz

 07:03:41:833 : Connect mode: Normal

 07:03:41:833 : Reset mode : Software reset

 07:03:41:864 : Device ID  : 0x460

 07:03:41:891 : Revision ID : Rev B

 07:03:41:918 : halt ap 0 

 07:03:41:935 : r ap 0 @0x4002103C 0x00000004 bytes Data 0x00000000

 07:03:41:953 : w ap 0 @0x4002103C 0x00000004 bytes Data 0x08000000

 07:03:41:954 : DBG enabled successfully

 07:03:41:970 : r ap 0 @0x40015808 0x00000004 bytes Data 0x00000000

 07:03:41:985 : w ap 0 @0x40015808 0x00000004 bytes Data 0x00001800

 07:03:41:987 : r ap 0 @0x40015804 0x00000004 bytes Data 0x00000000

 07:03:41:995 : w ap 0 @0x40015804 0x00000004 bytes Data 0x00000007

 07:03:41:996 : Reconnected !

 07:03:41:996 : Success with Time elapsed during Reconnect: 467 ms

 07:03:41:997 : Reading data...

 07:03:42:051 : r ap 0 @0x1FFF77DD 0x00000004 bytes Data 0xFFFFFFFF

 07:03:42:051 : Database: Config 0 is active.

 07:03:42:052 : UPLOADING OPTION BYTES DATA ...

 07:03:42:052 :  Bank     : 0x00

 07:03:42:053 :  Address    : 0x40022020

 07:03:42:053 :  Size     : 112 Bytes

 07:03:42:054 : Reading data...

 07:03:42:153 : r ap 0 @0x40022020 0x00000070 bytes Data 0xFFFFFEAA

 07:03:42:156 : OPTION BYTE PROGRAMMING VERIFICATION:

 07:03:42:156 : Error: Expected value for Option Byte "PCROP1A_STRT": 0xFF, found: 0x0

 07:03:42:213 : Error: Option Byte Programming failed

 07:03:42:250 : Reading data...

 07:03:42:263 : r ap 0 @0x1FFF77DD 0x00000004 bytes Data 0xFFFFFFFF

 07:03:42:264 : Database: Config 0 is active.

 07:03:42:265 : Time elapsed during option Bytes configuration: 00:00:06.482

 07:03:42:537 : r ap 0 @0x1FFF6FFE 0x00000004 bytes Data 0xFFFF00B2

 07:03:42:537 : UPLOADING OPTION BYTES DATA ...

 07:03:42:537 :  Bank     : 0x00

 07:03:42:537 :  Address    : 0x40022020

 07:03:42:537 :  Size     : 112 Bytes

 07:03:42:538 : Reading data...

 07:03:42:538 : r ap 0 @0x40022020 0x00000070 bytes Data 0xFFFFFEAA

 07:03:42:545 : r ap 0 @0x1FFF6FFE 0x00000004 bytes Data 0xFFFF00B2

Rena Z.
Associate II

What a pitty! All the nice CLI options to restore the option bytes are only available for STM32WL devices ???

STM32_Programmer_CLI.exe -c port=SWD -ob unlockchip

   -------------------------------------------------------------------

            STM32CubeProgrammer v2.12.0

   -------------------------------------------------------------------

ST-LINK SN : xxxxxxxxxxxxxxxxxxxxxxx

ST-LINK FW : V2J40M27

Board    : NUCLEO-G071RB

Voltage   : 3.21V

SWD freq  : 4000 KHz

Connect mode: Normal

Reset mode : Software reset

Device ID  : 0x460

Revision ID : Rev B

Device name : STM32G07x/STM32G08x

Flash size : 128 KBytes

Device type : MCU

Device CPU : Cortex-M0+

BL Version : 0xB2

Debug in Low Power mode enabled

UPLOADING OPTION BYTES DATA ...

 Bank     : 0x00

 Address    : 0x40022020

 Size     : 112 Bytes

██████████████████████████████████████████████████ 100%

Error: Only STM32WL devices are supported.

Error: Fail to unlock chip

STM32_Programmer_CLI.exe -c port=SWD -setdefaultob

   -------------------------------------------------------------------

            STM32CubeProgrammer v2.12.0

   -------------------------------------------------------------------

ST-LINK SN : xxxxxxxxxxxxxxxxxxxxxxx

ST-LINK FW : V2J40M27

Board    : NUCLEO-G071RB

Voltage   : 3.21V

SWD freq  : 4000 KHz

Connect mode: Normal

Reset mode : Software reset

Device ID  : 0x460

Revision ID : Rev B

Device name : STM32G07x/STM32G08x

Flash size : 128 KBytes

Device type : MCU

Device CPU : Cortex-M0+

BL Version : 0xB2

Debug in Low Power mode enabled

 Set default OB for STM32WL

Error: Only STM32WL devices are supported.

GwenoleB
ST Employee

Hello @Rena Z.​,

I'll provide you a quick script to reset the Option bytes by software.

I'm quite surprising about the behavior you faced.

Best Regards,

Gwénolé

Hello @Rena Z.​ ,

To reset the PCROP1 you need also to perform a transition from RDP1 to RDP0.

So it means:

1-Check PCROP_RDP and put RDP=BB (level 1 reed protection)

2-Put RDP=AA (level 0, no protection)

3- Your PCROP registers have the default values.

Just be careful to not put the circuit as RDP level 2 otherwise the circuit will be blocked for ever.

Best regards,

Simon

SAAD_ELF
Associate

I have a similar issue, can i have the script that put registers to default value ?