cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103RET6 can't disable read out protection

Czukuczan
Associate

Hey,

I am using STM32F103RET6 MCU in my own project and program it via SWD through Nucleo F446RE's ST-Link.

Since I activated CAN peripherial I can't load a project to the MCU. I don't know if CAN is the problem.

When I try to load a program through ST-Link Utility I receive messages and I am disconnected immadietly:

17:52:11 : ST-LINK SN : 066DFF504955657867124523

17:52:11 : V2J33M25

17:52:11 : Connected via SWD.

17:52:11 : SWD Frequency = 1,8 MHz.

17:52:11 : Connection mode : Connect Under Reset.

17:52:11 : Debug in Low Power mode enabled.

17:52:11 : Device ID:0x414 

17:52:11 : Device flash Size : 512KBytes

17:52:11 : Device family :STM32F10xx High-density

17:52:12 : Disconnected from device.

17:52:12 : Connection to device is lost: check power supply and debug connection.

17:52:12 : If the target is in low power mode, please enable "Debug in Low Power mode" option from Target->settings menu.

The same thing holding 'RESET' button on Nucleo: (allows me to connect to the board):

17:53:43 : Memory-Loader error

17:53:43 : Error occured during erase operation!

17:53:45 : Disconnected from device.

17:53:45 : Connection to device is lost: check power supply and debug connection.

17:53:45 : If the target is in low power mode, please enable "Debug in Low Power mode" option from Target->settings menu.

So I decided to load almost empty project to the MCU also holding 'RESET':

17:55:07 : Read out protection is activated.

17:55:12 : Could not disable Read Out Protection!

17:55:15 : Internal command error

17:55:15 : Error occured during erase operation!

17:55:15 : Can not connect to device!

17:55:17 : Disconnected from device.

So I tried to disable Read Out Protection through Option Bytes and I receive a message:

---------------------------

Error

---------------------------

Could not set Option bytes!

Please reset the target and retry.

---------------------------

OK  

---------------------------

As far as I can see, there is no choice of Level 0,1 and 2 or RDP. Only 'Enabled' and 'Disabled'. No message that enabling will result in permament writing of MCU and can not be reversable.

Therefore where is the problem? How can I set Option Bytes without ST-Link? Is it possible through SWD or bootloader?

Thanks in advance,

Szymon

2 REPLIES 2

Do you actually connect NRST to the ST-LINK, or not? If you don't "Connect under Reset" doesn't really work as intended.

I would suggest setting BOOT0 High and resetting, this will run the code in ROM, rather than yours, and likely permit you to connect to the device.

Your code additions might interfere with normal use of PA13/PA14 by the debugger.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Czukuczan
Associate
  • Do you actually connect NRST to the ST-LINK, or not? If you don't "Connect under Reset" doesn't really work as intended.

It is connected properly.

  • I would suggest setting BOOT0 High and resetting, this will run the code in ROM, rather than yours, and likely permit you to connect to the device.

It might be impossible in my project. I will give it a try but is there any other option?

  • Your code additions might interfere with normal use of PA13/PA14 by the debugger.

They do interfere. PA13, PA15 and SPI are in conflict when I try to enable SWD debugging in CubeMX. When projecting is it neccessary to leave them free for debugging through SWD? Are there other guidelines for projecting and leaving space for debug in SWD?

 It is interesting because I was able to load a project onto the MPU before enabling CAN interface.

Thanks for the answer.