cancel
Showing results for 
Search instead for 
Did you mean: 

Can't Disable Read/Write (PCROP) Protection using ST-LINK

PMart.1
Associate III

Hi There,

I am having an issue where I cannot disable Read/Write Protection in the option bytes using ST-LINK. Every time I try to disable it for both banks (uncheck the checkboxes and hit apply) I get the following error:

Could not set Option bytes!

Please reset the target and retry.

Whenever I try to program or erase the chip I get the following error:

Some flash sectors are read protected.

For background, I tried enabling write protection for a single sector that I was planning on placing user data in. This didn't work as programming/erasing the flash wouldn't work as there was a sector write protected. I then disabled the write protection and now I am stuck in this quagmire. I never messed with the Read Out Protection dropdown and it seems like it is set at Level 0. Furthermore I never messed with the Read/Write (PCROP) Protection settings tab, I only touched the Write Protection tab.

How can I get back to a programmable chip? Thanks for any help you can provide.

0693W000004JmUSQA0.png

1 ACCEPTED SOLUTION

Accepted Solutions
PMart.1
Associate III

I was able to fix this using the command line interface.

First I enabled RDP level 1 with DMEPA. DMEPB, DMESA, DMESB enabled:

ST-LINK_CLI.exe -c -OB RDP=1 DMEPA=1 DMEPAB=1 DMESA=1 DEMESB=1

Then I switched back to RDP level 0 and set the address ranges to have the end after the start:

ST-LINK_CLI.exe -c -OB RDP=0 PROT_AREA_START1=0x08000100 PROT_AREA_END1=0x08000000 PROT_AREA_START2=0x08100100 PROT_AREA_END2=0x08100000

From reading the data sheet it sounded like you could only disable the PCROP when switching from RDP Level 1 to Level 0. For some reason though doing this through the ST-LINK UI doesn't work.

View solution in original post

2 REPLIES 2
PMart.1
Associate III

Note all sectors on the Write Protection tab are unchecked with "No Protection" listed.

PMart.1
Associate III

I was able to fix this using the command line interface.

First I enabled RDP level 1 with DMEPA. DMEPB, DMESA, DMESB enabled:

ST-LINK_CLI.exe -c -OB RDP=1 DMEPA=1 DMEPAB=1 DMESA=1 DEMESB=1

Then I switched back to RDP level 0 and set the address ranges to have the end after the start:

ST-LINK_CLI.exe -c -OB RDP=0 PROT_AREA_START1=0x08000100 PROT_AREA_END1=0x08000000 PROT_AREA_START2=0x08100100 PROT_AREA_END2=0x08100000

From reading the data sheet it sounded like you could only disable the PCROP when switching from RDP Level 1 to Level 0. For some reason though doing this through the ST-LINK UI doesn't work.