How can I modify STM32F401CE's option byte by UART(bootloader)?
- May 9, 2023
- 1 reply
- 2047 views
Hi,
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.
Kirby
