2025-04-05 2:46 AM
My board is stuck with all write protection Bytes enabled.
Please help thank you.
Running the following command fails to deactivate write protection.
STM32_Programmer_CLI -c port=swd -ob WRP0=0
-------------------------------------------------------------------
STM32CubeProgrammer v2.19.0
-------------------------------------------------------------------
ST-LINK SN : 066DFF3632524B3043204154
ST-LINK FW : V2J46M31
Board : NUCLEO-F401RE
Voltage : 3.24V
SWD freq : 4000 KHz
Connect mode: Normal
Reset mode : Software reset
Device ID : 0x433
Revision ID : Rev Z
Device name : STM32F401xD/E
Flash size : 512 KBytes
Device type : MCU
Device CPU : Cortex-M4
BL Version : 0xD1
UPLOADING OPTION BYTES DATA ...
Bank : 0x00
Address : 0x40023c14
Size : 8 Bytes
[==================================================] 100%
PROGRAMMING OPTION BYTES AREA ...
Bank : 0x00
Address : 0x40023c14
Size : 8 Bytes
[==================================================] 100%
UPLOADING OPTION BYTES DATA ...
Bank : 0x00
Address : 0x40023c14
Size : 8 Bytes
[==================================================] 100%
OPTION BYTE PROGRAMMING VERIFICATION:
Error: Expected value for Option Byte "wrp0": 0x0, found: 0x1
Error: Option Byte Programming failed Or modified by application after OB_LAUNCH
Time elapsed during option Bytes configuration: 00:00:00.054
Solved! Go to Solution.
2025-04-05 8:44 AM
Dear @themarcman ,
This may help , indeed that bit for PCRoP feature is a bit special and to reset it , and RDP change is required on same time . Can you try using the STM32CubeProgrammer GUI instead and use unitary operations .
let us know ,
STOne-32
2025-04-05 3:52 AM
Dear @themarcman ,
Can you please provide the device marking on top of the package and also confirm if other Erase/programming operations on the flash are working fine? so only sector write protection, or/and any modification of options bytes is also not working?
Let us know
STOne-32.
2025-04-05 5:50 AM - edited 2025-04-05 6:11 AM
Here is the device marking on top of the package as requested.
package
I am unable to reprogram the MCU with cubeide.
I also cannot mass erase :
STM32_Programmer_CLI -c port=SWD -e all
-------------------------------------------------------------------
STM32CubeProgrammer v2.19.0
-------------------------------------------------------------------
ST-LINK SN : 066DFF3632524B3043204154
ST-LINK FW : V2J46M31
Board : NUCLEO-F401RE
Voltage : 3.23V
SWD freq : 4000 KHz
Connect mode: Normal
Reset mode : Software reset
Device ID : 0x433
Revision ID : Rev Z
Device name : STM32F401xD/E
Flash size : 512 KBytes
Device type : MCU
Device CPU : Cortex-M4
BL Version : 0xD1
Mass erase ...
Error: Mass erase operation failed.
Please verify flash protection
I am able to change RDP (Read out Protection) from AA to BB an back, but SPRMOD is set and I am not able to disable it as well.
Thanks again for your help.
2025-04-05 8:44 AM
Dear @themarcman ,
This may help , indeed that bit for PCRoP feature is a bit special and to reset it , and RDP change is required on same time . Can you try using the STM32CubeProgrammer GUI instead and use unitary operations .
let us know ,
STOne-32
2025-04-05 9:55 AM
Thank you so much this solved it.
I remember reading around this area but I stopped right before because it did not seem relevant.
I first changed RDP to level 1.
Then in one go changed RDP to 0, SPRMOD to 0 and all RPx to 0.
My understanding is operations on RPx can only be done during this specific transition of the state machine.
I then switched SPRMOD to 1 again because I could not flash code otherwise and this fixed my problem.
Not sure if I could've simply switched RPx to 0 during that transition without SPRMOD, I'm still don't fully understand this.
Thanks again!