cancel
Showing results for 
Search instead for 
Did you mean: 

Option Byte Programming failed upon trying to modify option bytes

breynard
Associate II

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!

18 REPLIES 18

hello @breynard ,

I have tried on nucleo board because I don't have Black pill board, and no issue come up on my side.

What I suggest is to modify both OPT RDP and PCROP SPRMOD byte the first time to see if you've always got the same message :

1/

MikaelM_0-1695028298039.png

On my side this work fine.

2/ but by modifying all it works as well :

MikaelM_2-1695028481611.png

When you connect the first time you should have this message when RDP=0xFF, and others set to 1 :

MikaelM_1-1695028405616.png

indicating your memory is protected. But you can always program OPTION bytes

Best regards

Mikael

If you feel a post has answered your question, please click Accept as Solution.

Hi @MikaelM,

Thank you so much for your prompt and detailed reply! I attempted to modify this through the GUI to no avail, same error. I then ran it through the CLI with the command like this:

sudo ./STM32_Programmer_CLI -c port=swd -ob RDP=170 SPRMOD=0 WPR0=0 WPR1=0 WPR2=0 WPR3=0 WPR4=0 WPR5=0 WPR6=0

That produced the same error. I wrote the output to a file, and it is as follows:

      -------------------------------------------------------------------
                        STM32CubeProgrammer v2.14.0                  
      -------------------------------------------------------------------

ST-LINK SN  : B55B5A1A0000000053E8EE01
ST-LINK FW  : V2J39S7
Board       : --
Voltage     : 3.27V
SWD freq    : 4000 KHz
Connect mode: Normal
Reset mode  : Software reset
Device ID   : 0x431
Revision ID : Rev A
Device name : STM32F411xC/E
Flash size  : 512 KBytes (default)
Device type : MCU
Device CPU  : Cortex-M4
BL Version  : 0x0


UPLOADING OPTION BYTES DATA ...

  Bank          : 0x00
  Address       : 0x40023c14
  Size          : 8 Bytes

[==================================================] 100% 



PROGRAMMING OPTION BYTES AREA ...
Warning: Option Byte: wpr0, does not exist
Warning: Option Byte: wpr1, does not exist
Warning: Option Byte: wpr2, does not exist
Warning: Option Byte: wpr3, does not exist
Warning: Option Byte: wpr4, does not exist
Warning: Option Byte: wpr5, does not exist
Warning: Option Byte: wpr6, does not exist

  Bank          : 0x00
  Address       : 0x40023c14
  Size          : 8 Bytes



UPLOADING OPTION BYTES DATA ...

  Bank          : 0x00
  Address       : 0x40023c14
  Size          : 8 Bytes

[==================================================] 100% 
[==================================================] 100% 


OPTION BYTE PROGRAMMING VERIFICATION:

Error: Expected value for Option Byte "sprmod": 0x0, found: 0x1
Error: Expected value for Option Byte "rdp": 0xAA, found: 0xFF
Error: Option Byte Programming failed Or modified by application after OB_LAUNCH

Time elapsed during option Bytes configuration: 00:00:01.734

One thing I did notice is that my ST-LINK firmware is version V2J39S7, while yours in the screenshot is V2J36M26. I don't know if that is significant, and I also don't know how to update the firmware should I need to. I realize as I'm typing this that I misspelled the WRP option bytes, but the RDP and SPRMOD bytes still failed in the same fashion.

Thank you so much for your continued support in solving this; I must be getting annoying by now!

Best regards,

breynard

MikaelM_12-1695109468505.png

to upgrade STLink fw :

MikaelM_0-1695108889726.png

 

MikaelM_1-1695108951502.png

 

MikaelM_2-1695108969649.png

MikaelM_3-1695109000698.png

(close your programmer and power on/off your target if needed) then 

MikaelM_4-1695109077441.png

 

MikaelM_5-1695109155292.png

MikaelM_6-1695109226958.png

 

MikaelM_11-1695109407713.png

 

MikaelM_7-1695109250571.png

then come back to level 0 :

MikaelM_8-1695109322001.png

MikaelM_10-1695109378757.png

I did this with a nucleo board with STM32F401 chip but it must be the same with a STM32F411 chip.

But as I don't use "Black pill" board, maybe I suggest you to try the same with a nucleo board to keep away STlink issues, because I suppose that you use an "external" STLink" ?

Best regards

Mikael

PS you can also access Programmer data sheet here :

MikaelM_13-1695109813497.png

and select "Document"

 

 

 

 

 

 

 

 

 

If you feel a post has answered your question, please click Accept as Solution.

Hi @MikaelM,

I successfully updated the firmware on the STLINK, but still no luck with the issue; same error. I do not have a Nucleo board on hand, and would rather not spend the money unless absolutely necessary. However, I can return and rebuy either/both the board and the STLINK, free of charge. Which would be the better one to try a new one, and is this even something I should do?

Best regards,

breynard

Hello @breynard 

so I recommend you to get a nucleo with the same series and with an STM32F411 chip like this board (not very expensive, less than 14$ : https://estore.st.com/en/nucleo-f411re-cpn.html

With this nucleo you can use of course the embedded stlink but you can as well use an external STlink by shunting the embedded through jumper, solder,...
You also select one of our distributors : https://www.st.com/content/st_com/en/contact-us.html

Moreover I warn you about using BlackPill board as stated in the following web site :

https://stm32-base.org/boards/

"The official Nucleo, Discovery, and Eval development boards manufactured and sold by STMicroelectronics are available from official ST distributors around the world.

The Chinese development boards are available from webshops like Ebay, AliExpress, Wish, Taobao, and many more. It may be hard to find the specific board you are looking for, since many of these boards do not have a clear unique name. Also, availability of these boards changes over time. Be aware of counterfeit STM32F103C8T6 devices when ordering from China. These specific devices are mostly used on the Blue Pill and Black Pill boards."

Maybe counterfeit can as well be on other series. Maybe your issue might be due to your card. (be carefull as well where you by your STlink, some of them are counterfeit too.

NOTE about the website : "This is the STM32-base project website. Learn more about the STM32-base project or check out this project on Github. The STM32-base project is in no way affiliated with STMicroelectronics."

 

Nevertheless, I recommend you to work with STMicroelectronics boards to avoid struggling with issues that could came from counterfeit. 

This will help you to save your time and money. You probably have lost more than 14$ since the beginning of our exchange.

Best regards,

Mikael

If you feel a post has answered your question, please click Accept as Solution.

Hi @MikaelM,

Thank you for your time in putting together a detailed post. I suspect it's my STLink that is causing issues, as the sample blinking program pre-installed on the board was working just fine. I agree that Nucleo boards are the more reputable and consistent option, though. The Nucleo board you suggested will not work for my project, as I need the small form factor. I'm planning on ordering a Nucleo L432KC as well as a new STLink V3, both from Digikey. I think that should hopefully have a higher chance of working contrary to the parts I have now, which I ordered on Amazon. This is a personal project, so time is less of a factor, but still, thank you for your insightful help.

Best regards,

breynard

Hello @breynard 

We are always happy to help people to succeed in their technical projects.
I wish you to succeed in your project.

ST will be happy to answer your questions if any to help you to succeed.

Best regards

Mikael

 

If you feel a post has answered your question, please click Accept as Solution.
breynard
Associate II

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

SandeepBajaniya
Associate

Try using

"STM link utility"

Target>Option byte>Flash protection mode

Screenshot 2024-07-10 111516.png