Showing results for 
Search instead for 
Did you mean: 

How can I modify STM32F401CE's option byte by UART(bootloader)?



I'm recently working on an iOS app that communicates with an STM32F401 via Bluenrg-lp using UART. The goal is to update the STM32F401 firmware through the Bluenrg-lp with a mobile phone. I've encountered some issues with the F401 and I was wondering if there is anyone who is more familiar with this area that could help me out.

The main problem is that if unexpected power loss or reset occurs during the transmission process, the STM32F401 may enter a protected state, and it won't be able to erase/program the F401 again. I've tried sending the bootloader commands 0x73 Write Unprotect and 0x92 Readout Unprotect, but it didn't help.

I've used a USB to UART tool to connect to the computer and used STM32CubeProgrammer to check the F401. The RDP is 0xAA, but the SPRMOD is 1 (refer to 1.png). When I uncheck the SPRMOD through the software and then apply, it only shows an error message (refer to 2.png).

I've also tried using ST-Link, but I still couldn't disable SPRMOD in STM32CubeProgrammer. The only way to recover the F401 is to use STM32 ST-LINK Utility and click Target->Option Bytes, then disable the Flash sectors protection at the bottom. However, I don't understand the difference between these two software programs, one works and the other doesn't.

Is there any way to solve this? I hope to handle it under the UART bootloader transmission method, so that the IC can erase/program again. Otherwise, if an update fails, I would have to connect it to a computer to clear it, which defeats the purpose of OTA.

Thanks for any help.


ST Employee

Hi @KHuan.9​ ,

Sorry to come back late to your question.

Could you please try following steps using STM32CubePorgrammer and let me know if it works properly or not:

1- As RDP value is AA, please change it to BB.

2- Uncheck SPRMOD OB and re-set RDP to AA (in one shot) then click the Apply button.


To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hi @Amel NASRI​ ,

1- As RDP value is AA, please change it to BB.

Should I click Apply button after set RDP to BB?

I have already tried the following steps:

  1. Changed the RDP to BB (with SPRMOD checked) and clicked the "Apply" button.
  2. Clicked "Connect," but it showed that the STM32F401 is protected.
  3. Checked the "Read Unprotect (MCU)" option and clicked "Connect" again.
  4. However, the OB still displayed RDP = AA, and SPRMOD remained checked.

I also attempted these steps using ST-Link, and they were successful. However, I specifically need them to work with UART.