2025-03-20 12:29 AM
Hi,
I'm using B-L4S5I-IOT01A board, Unable to program the board using stm32cubeprogrammer. Got Error: failed to erase memory. Tried to mass erase the chip, got Error: Mass erase operation failed.Please verify flash protection
here is the stm32cubeprogrammer CLI log for STM32_Programmer_CLI.exe -c port=SWD -ob displ command
C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin>STM32_Programmer_CLI.exe -c port=SWD -ob displ
-------------------------------------------------------------------
STM32CubeProgrammer v2.18.0
-------------------------------------------------------------------
ST-LINK SN : 0673FF3134354D5043061550
ST-LINK FW : V2J45M31
Board : STM32L4S5I-DK
Voltage : 3.20V
SWD freq : 4000 KHz
Connect mode: Normal
Reset mode : Software reset
Device ID : 0x470
Revision ID : Rev W
Device name : STM32L4Rxxx/STM32L4Sxxx
Flash size : 2 MBytes
Device type : MCU
Device CPU : Cortex-M4
BL Version : 0x95
Debug in Low Power mode enabled
UPLOADING OPTION BYTES DATA ...
Bank : 0x00
Address : 0x40022020
Size : 20 Bytes
██████████████████████████████████████████████████ 100%
Bank : 0x01
Address : 0x40022044
Size : 16 Bytes
██████████████████████████████████████████████████ 100%
OPTION BYTES BANK: 0
Read Out Protection:
RDP : 0xAA (Level 0, no protection)
BOR Level:
BOR_LEV : 0x1 (BOR Level 1, reset level threshold is around 2.0 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 independent 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)
BFB2 : 0x0 (Dual-bank boot disable)
DBANK : 0x0 (Single bank mode with 128 bits data read width)
nBOOT1 : 0x1 (Boot from system memory when BOOT0=1)
SRAM2_PE : 0x1 (SRAM2 parity check disable)
SRAM2_RST : 0x1 (SRAM2 is not erased when a system reset occurs)
nSWBOOT0 : 0x1 (BOOT0 taken from PH3/BOOT0 pin)
nBOOT0 : 0x1 (BOOT0 = 0, boot from system memory when nSWBOOT0=1 and main flash is empty,otherwise, boot from main flash memory)
PCROP Protection (Bank 1):
PCROP1_STRT : 0x0 (0x8000000)
PCROP1_END : 0x0 (0x8000000)
PCROP_RDP : 0x0 (PCROP zone is kept when RDP is decreased)
Write Protection (FLASH_WRP1AR):
WRP1A_STRT : 0xFF (0x81FE000)
WRP1A_END : 0xFF (0x81FE000)
Write Protection (FLASH_WRP2AR):
WRP2A_STRT : 0x0 (0x8100000)
WRP2A_END : 0x0 (0x8100000)
OPTION BYTES BANK: 1
PCROP Protection (Bank 2):
PCROP2_STRT : 0x0 (0x8100000)
PCROP2_END : 0x0 (0x8100000)
Write Protection (FLASH_WRP1BR):
WRP1B_STRT : 0x0 (0x8000000)
WRP1B_END : 0x0 (0x8000000)
Write Protection (FLASH_WRP2BR):
WRP2B_STRT : 0x0 (0x8100000)
WRP2B_END : 0x0 (0x8100000)
Can someone guide me to disable the write protection in option bytes
Thank you in advance
2025-03-21 1:31 AM
Hello @tpate.17
Try setting every WRPXY_STRT to 0xFF and every WRPXY_END to 0x0. That should disable all flash write protection.
Hope this helps !
Aziz
2025-03-21 4:02 AM
Hi @Aziz BRIGUI ,
Thanks for the reply.
Tried setting WRP1A_STRT, WRP2A_STRT, WRP1B_STRT, WRP2B_STRT to 0xFF and every WRP1A_END, WRP2A_END, WRP1B_END, WRP2B_END to 0x0 and applied, Option bytes programming was successful. (I have attached image for your reference).
But tried to Mass erase the chip which failed with error: ERROR: Mass erase operation failed. Please verify flash protection. (I have attached image for your reference).
RDP is set to AA (Level 0).
Anything else to be done?
2025-03-21 4:49 AM
Hi @tpate.17
I don't see anything wrong with the OB config now (PCROP addresses shouldn't matter since PCROP is not enabled).
Could you try powering off then on the MCU, connecting via CubeProgrammer, setting RDP to 0xBB and then resetting RDP to 0xAA and retrying the chip erase ?
PS: Please make sure to NOT put RDP to 0xCC otherwise you'll lose your device.
Aziz
2025-03-21 10:01 AM - last edited on 2025-03-24 2:36 AM by Andrew Neil
Merged from separate thread.
Hi i am using b-l4s5i-iot01a i am unable to Mass Erase the chip i am using latest version of STM32CubeProgrammer and Latest Version of ST-Link
I tried these things
1. WRP1A_STRT, WRP2A_STRT, WRP1B_STRT, WRP2B_STRT to 0xFF and every WRP1A_END, WRP2A_END, WRP1B_END, WRP2B_END to 0x0 and applied,
Option bytes programming was successful
But tried to Mass erase the chip which failed with error: ERROR: Mass erase operation failed. Please verify flash protection. (I have attached image for your reference).
RDP is set to AA (Level 0).
2. setting RDP to 0xBB and then resetting RDP to 0xAA and retrying the chip erase
error: ERROR: Mass erase operation failed. Please verify flash protection.
3. RDP level we tried to change 0xAA and 0xBB
but still we are unable to mass erase can suggest any other hardware or software method so that i can Erase
2025-03-21 10:13 AM
2025-03-21 10:13 AM - edited 2025-03-21 10:16 AM
Dear @avinpat_8 ,
Can you try to do simple "Pages" Erase, one by one, and all at a time, without Mass erase to see if it works ? and have logs. if successful, it might be a timing issue to investigate.
Hope it helps,
STOne-32.
2025-03-21 10:58 AM
2025-03-21 11:05 PM
Hi i have tried by erasing sector wise still unable to erase is there any hardware method to recover this because we have tried all possible case by software
2025-03-22 4:12 AM
@avinpat_8 wrote:we have tried all possible case by software
"we" ?
So are you and @tpate.17 working together on the same issue?