Skip to main content
Associate
July 24, 2025
Solved

STM32C031 Flash Memory Protection Fail to Reconnect

  • July 24, 2025
  • 3 replies
  • 287 views

Hi All,

 

Using STM32CubeProgrammer with the ST-LINK in SWD mode.

If the RDP flag is set to 0xBB (level 1) and programmed the programmer can no longer connect to the device.

How can I reconnect to the device to set it back to 0xAA?

 

_Carl_

Best answer by Bugfarmer

Solved! (I think)

Make sure nBOOT0, nBOOT1 and nBOOT_SEL are all set. Make sure BOOT_LOCK is clear.

Setting the Read Protection to 0xBB works as before. However, it is possible to connect to the device again and restore it to 0xAA.

This would appear to be contrary to the description given in RM0490 Rev 3. From what I can work out: ultimately, it was the BOOT_LOCK bit that was the problem.

 

The next problem is how to mark this thread as solved.

3 replies

Andrew Neil
Super User
July 24, 2025

Do a full chip erase?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
TDK
Super User
July 24, 2025

Holding BOOT0 high during reset may let you connect with SWD, do a full chip erase, and recover the chip.

You should be able to connect under RDP1 unless it's actively modifying option bytes, erasing flash, going into low power modes, or reassigning SWD pins.

"If you feel a post has answered your question, please click ""Accept as Solution""."
BugfarmerAuthor
Associate
July 25, 2025

Hi TDK,

BOOT0 is SWCL. Therefore I cannot control it. It is under the control of the STM32CubeProgrammer. Unless, there is a setting in that to help?

BugfarmerAuthorBest answer
Associate
July 25, 2025

Solved! (I think)

Make sure nBOOT0, nBOOT1 and nBOOT_SEL are all set. Make sure BOOT_LOCK is clear.

Setting the Read Protection to 0xBB works as before. However, it is possible to connect to the device again and restore it to 0xAA.

This would appear to be contrary to the description given in RM0490 Rev 3. From what I can work out: ultimately, it was the BOOT_LOCK bit that was the problem.

 

The next problem is how to mark this thread as solved.

Andrew Neil
Super User
July 25, 2025

@Bugfarmer wrote:

The next problem is how to mark this thread as solved.


https://community.st.com/t5/community-guidelines/help-others-to-solve-their-issues/ta-p/575256 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.