Skip to main content
Graduate
April 5, 2025
Solved

Disabling write protection fails on STM32F401RE

  • April 5, 2025
  • 2 replies
  • 719 views

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

    This topic has been closed for replies.
    Best answer by STOne-32

    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 . 

    IMG_2318.jpeg



    let us know ,

    STOne-32

    2 replies

    Technical Moderator
    April 5, 2025

    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.

    Graduate
    April 5, 2025

    Here is the device marking on top of the package as requested.

    packagepackage

    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.

     

    STOne-32Answer
    Technical Moderator
    April 5, 2025

    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 . 

    IMG_2318.jpeg



    let us know ,

    STOne-32

    Graduate
    April 5, 2025

    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!