2025-09-21 10:51 AM - edited 2025-09-21 10:51 AM
I wanted to do a full chip erase using STM32Programmer (I am trying to debug a custom bootloader) but kept getting the error "Mass erase operation failed. Please verify flash protection".
I sent the following option byte screenshot to ChatGPT....
ChatGPT said...
In your PCROP Protection section:
PCROP1_STRT = 0xFFFF
PCROP1_END = 0x0000
PCROP_RDP is enabled
This is an invalid PCROP range: start at 0xFFFF, end at 0x0.
That effectively protects a huge chunk of flash against erase/program.
So even though WRP and RDP are fine, PCROP is blocking your erase.
In STM32CubeProgrammer → Option Bytes → PCROP:
Set PCROP1_STRT = 0xFF
Set PCROP1_END = 0xFF
Uncheck PCROP_RDP unless you specifically need PCROP linked to readout protection.
Apply changes (Program Option Bytes → Reset).
Retry Full Chip Erase with ST-Link.
I did the suggested fix but it obviously didnt work.
But worse still, I cant even change the option bytes back to as they were because I get the following error....
18:45:49 : UPLOADING OPTION BYTES DATA ...
18:45:49 : Bank : 0x00
18:45:49 : Address : 0x40022020
18:45:49 : Size : 20 Bytes
18:45:49 : OPTION BYTE PROGRAMMING VERIFICATION:
18:45:49 : Error: Expected value for Option Byte "PCROP1_END": 0x0, found: 0xFF
18:45:49 : Error: Expected value for Option Byte "PCROP1_STRT": 0xFFFF, found: 0xFF
18:45:49 : Error: Option Byte Programming failed Or modified by application after OB_LAUNCH
I cant program or debug in STMCubeIDE either so Im worried my board is bricked.
Is it recoverable and if so how ?
2025-09-21 11:02 AM - edited 2025-09-21 11:02 AM
connect your boot PIN to VCC then power your board, now you should be able to erase the chip.
2025-09-21 11:29 AM
I connected BOOT0 pin to +3.3V and did a reset.
Then connected to STM32Programmer via STLINK and tried a full chip erase, but still got the same error "Mass erase operation failed. Please verify flash protection".
I also tried a power reset but the result is the same