Skip to main content
Explorer II
September 10, 2023
Solved

Option Byte Programming failed upon trying to modify option bytes

  • September 10, 2023
  • 4 replies
  • 20517 views

Hello! I'm new to STM32 hardware, and I'm having some difficulties getting it running on my Black Pill board with an STM32F411CEU6. It has both Read and Write Protection enabled, and I am trying to disable them using STM32CubeProgrammer through an STLINK V2. However, upon trying change option bytes, it gives me a weird error.

For attempting to change read protection from value 0xFF to 0xAA it gives me this:

16:24:25:038 : Error: Expected value for Option Byte "RDP": 0xAA, found: 0xFF
16:24:25:044 : Error: Option Byte Programming failed Or modified by application after OB_LAUNCH

 

And similar story for trying to change the write protection values from true to false for all flash sectors:

 16:26:41:386 : Error: Expected value for Option Byte "WRP0": 0x0, found: 0x1
 16:26:41:391 : Error: Expected value for Option Byte "WRP1": 0x0, found: 0x1
 16:26:41:395 : Error: Expected value for Option Byte "WRP2": 0x0, found: 0x1
 16:26:41:399 : Error: Expected value for Option Byte "WRP3": 0x0, found: 0x1
 16:26:41:408 : Error: Expected value for Option Byte "WRP4": 0x0, found: 0x1
 16:26:41:416 : Error: Expected value for Option Byte "WRP5": 0x0, found: 0x1
 16:26:41:428 : Error: Expected value for Option Byte "WRP6": 0x0, found: 0x1
 16:26:41:436 : Error: Expected value for Option Byte "WRP7": 0x0, found: 0x1
 16:26:41:441 : Error: Option Byte Programming failed Or modified by application after OB_LAUNCH

I am on Linux, and the software recognizes the MCU type and ID, so I believe the connection is good. Any help would be appreciated!

    This topic has been closed for replies.
    Best answer by breynard

    Hello everyone,

    I ended up ordering two Nucleo L432KC boards and one new Black Pill board from Digikey. Given that Digikey's quality standards are higher than Amazon's, I figured it was a safe bet to order another one.

    I've had a chance to mess around with the new Black Pill and one of the Nucleo boards and they're both working perfectly with my old programmer (or a USB cable in the case of the Nucleo board). I don't believe the old Black Pill had a counterfeit chip, but it does seem to be bricked somehow.

    Thank you to @Issamos and @MikaelM for your help! I suppose the moral of the story is to order electronics off of a reputable seller rather than some random person on Amazon. I believe I will mark this as the solution, unless others have something to add.

    Many thanks,

    breynard

    4 replies

    Graduate II
    September 10, 2023

    Hello @breynard 

    This problem depends on different conditions (level of read protection,Proprietary code readout protection,...) that's why I suggest you to take a look at the parts 3.6.5, 3.6.4 et 3.6.3 of the RM0383. That will give you all details you need to now. I'm suspecting that the read protection is in level 2 and that's going to be impossible to change. 

    Best regards.

    II

    breynardAuthor
    Explorer II
    September 10, 2023

    Thank you for the prompt reply. I don't think it's in level 2 read protection, as the value reads 0xFF, not 0xCC. I remember seeing somewhere that anything but 0xAA and 0xCC is level 1 protection. Also, I don't think that will affect the ability to write to option bytes, but I could be mistaken. PCROP is enabled, and upon trying to disable it, I get the same error.

     17:40:06 : Error: Expected value for Option Byte "SPRMOD": 0x0, found: 0x1
     17:40:06 : Error: Option Byte Programming failed Or modified by application after OB_LAUNCH

    You know far more than I do though, and if it is truly unrecoverable (either on part of the MCU or the STLINK), I can still return either or both of them.

    Graduate II
    September 10, 2023

    Than, this post may be helpful for you.

    Best regards.

    II

    ST Employee
    September 11, 2023

    hello @breynard ,

    as suggested, you could read reference manual RM0383.
    You will find page 57/844 :
    "The deactivation of the SPRMOD and/or the unprotection of PCROPed user sectors can
    only occur when, at the same time, the RDP level changes from 1 to 0. If this condition is not
    respected, the user option byte modification is cancelled and the write error WRPERR flag
    is set. The modification of the users option bytes (BOR_LEV, RST_STDBY, ..) is allowed
    since none of the active nWRPi bits is reset and SPRMOD is kept active."

    Best regards

    Mikael

    breynardAuthor
    Explorer II
    September 14, 2023

    Hello @MikaelM 

    I interpret that to mean that I can only change protection option bytes at the same time I change RDP from Level 1 (which I think it is at right now with value FF) to Level 0. Upon changing this, the same error as before manifested itself:

     22:47:38 : Error: Expected value for Option Byte "RDP": 0xAA, found: 0xFF
     22:47:38 : Error: Expected value for Option Byte "SPRMOD": 0x0, found: 0x1
     22:47:38 : Error: Expected value for Option Byte "WRP0": 0x0, found: 0x1
     22:47:38 : Error: Expected value for Option Byte "WRP1": 0x0, found: 0x1
     22:47:38 : Error: Expected value for Option Byte "WRP2": 0x0, found: 0x1
     22:47:38 : Error: Expected value for Option Byte "WRP3": 0x0, found: 0x1
     22:47:38 : Error: Expected value for Option Byte "WRP4": 0x0, found: 0x1
     22:47:38 : Error: Expected value for Option Byte "WRP5": 0x0, found: 0x1
     22:47:38 : Error: Expected value for Option Byte "WRP6": 0x0, found: 0x1
     22:47:38 : Error: Expected value for Option Byte "WRP7": 0x0, found: 0x1
     22:47:38 : Error: Option Byte Programming failed Or modified by application after OB_LAUNCH

    Am I misinterpreting, or is my device bricked? Thank you so much for your time, both of you!

    ST Employee
    September 14, 2023

    hello @breynard 

    could you just connect, dump option bytes and send me the log file caontaining all option bytes values ?

    thanks

    Mikael

    breynardAuthorAnswer
    Explorer II
    October 1, 2023

    Hello everyone,

    I ended up ordering two Nucleo L432KC boards and one new Black Pill board from Digikey. Given that Digikey's quality standards are higher than Amazon's, I figured it was a safe bet to order another one.

    I've had a chance to mess around with the new Black Pill and one of the Nucleo boards and they're both working perfectly with my old programmer (or a USB cable in the case of the Nucleo board). I don't believe the old Black Pill had a counterfeit chip, but it does seem to be bricked somehow.

    Thank you to @Issamos and @MikaelM for your help! I suppose the moral of the story is to order electronics off of a reputable seller rather than some random person on Amazon. I believe I will mark this as the solution, unless others have something to add.

    Many thanks,

    breynard

    Visitor II
    July 10, 2024

    Try using

    "STM link utility"

    Target>Option byte>Flash protection mode

    Screenshot 2024-07-10 111516.png