[SOLVED] STM32F103C8T Flash Protect

Post Reply
Posts: 18
Joined: Thu Oct 08, 2015 5:44 am

[SOLVED] STM32F103C8T Flash Protect

Post by jbforrer » Thu Nov 19, 2015 5:50 pm


I was playing around with a home-made (Blue Pill) ST-Link adapter with Arduino also CooCox under XP. The target being another Blue Pill.
Downloading seemed to have worked a few times, then something abruptly stopped downloads.
BMP or ST-Link downloads did not seem to work, though serial downloads with DFU bootloader still worked.
Normally I would use BMP for downloads but I have not yet figured out how to make that work with CooCox ... ST_Link works fine there.

Trying to find the propblem, "st-util" indicated Flash Protection was enabled on the target. This seems to be the reason why BMP or ST-Link was prevented from downloading into flash.

The ST-DEMO utility came to the rescue where one could do a complete erase of the MCU and restore the usual download procedures.

Any ideas where I went wrong to end up with Flash Protection enabled on the target?

Thanks much.
Last edited by jbforrer on Fri Nov 20, 2015 4:11 am, edited 1 time in total.

User avatar
Posts: 7693
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia

Re: STM32F103C8T Flash Protect

Post by RogerClark » Thu Nov 19, 2015 9:02 pm

The only software which I know enables Protection is the STLink firmware its self.

So if you got the STlink bin from the web, ( its not publicly released by STM but it is on various Russian websites), and flashed it, your device would be read protected after you ran the STLink firmware as locking seems to be part of its functionality

Apart from that, I guess you could have accidentally written to the registers that control this, especially using CooCox
But I have not heard of our Core ever Protecting its self.

Posts: 18
Joined: Thu Oct 08, 2015 5:44 am

Re: STM32F103C8T Flash Protect

Post by jbforrer » Fri Nov 20, 2015 4:03 am

Hi Roger,

Think I have my ST-Link issues sorted out. You have a good point that ST-Link somehow enabled Flash Protect. Probably operator error.
Upgraded ST-Link utility to the latest (V3.7.0) which also provides new firmware (V2.J24.S4).
So far, both STM32duino and CooCox download working fine.

Thanks much.

Posts: 67
Joined: Sat Aug 13, 2016 1:28 pm

Re: [SOLVED] STM32F103C8T Flash Protect

Post by VadimEL » Sat Jan 07, 2017 5:24 pm

How to enable flash protection?

I find code

Code: Select all

#ifdef NDEBUG
    if (FLASH_GetReadOutProtectionStatus() == RESET)

did it work?

User avatar
Posts: 1241
Joined: Mon Apr 27, 2015 1:45 pm

Re: [SOLVED] STM32F103C8T Flash Protect

Post by martinayotte » Sat Jan 07, 2017 7:48 pm

While doing some quick searches, I think "PCROP" (for "Proprietary Code Read Out Protection") is only available on bigger STM32, such the F4xx series, it doesn't seem to be available on smaller F1xx.

Post Reply