1
votes

I am currently working on a standalone STM32F4 based board (STM32F469). So far, everything worked fine. I was programming my microcontroller through ST-Link Utility with the STM32F4-DISCOVERY ST-Link via SWD.

Friday, when I left the work, everything was working well. This morning when I came back to my office, my program didn't start on the board. When I tried to connect to the STM32F4 via SWD, the STM32 ST-Link Utility displayed a warning saying :

Can not read memory! Disable Read Out Protection and retry

I did not set anything though. I did some researches and I try some things :

  • Change the Option Bytes in Target > Option Bytes > Read Out Protection. I don't know if it is relevant of the actual RDP state but when I open this tab, the RDP is on Level 1. When I set it to 0 and click on Apply, after few seconds an error is displayed saying Could not set Option bytes! Please reset the target and retry.
  • I tried to erase the chip. Of course it did not work since the RDP is set.
  • I have updated the ST-Link firmware. I did not update the STM32 ST-Link Utility since till now is worked well (v4.0.0.0). I did not change anything.
  • I tried to connect to the chip under reset. Sounds good, doesn't work.

I don't know what to do else. When I read the Reference Manual of my STM32F4 (RM0386), page 87 we can read :

Level 1: read protection enabled.

It is the default read protection level after option byte erase. The read protection Level 1 is activated by writing any value (except for 0xAA and 0xCC used to set Level 0 and Level 2, respectively) into the RDP option byte. When the read protection Level 1 is set:

  • No access (read, erase, program) to Flash memory or backup SRAM can be performed while the debug feature is connected or while booting from RAM or system memory bootloader. A bus error is generated in case of read request.
  • When booting from Flash memory, accesses (read, erase, program) to Flash memory and backup SRAM from user code are allowed.

When Level 1 is active, programming the protection option byte (RDP) to Level 0 causes the Flash memory and the backup SRAM to be mass-erased. As a result the user code area is cleared before the read protection is removed. The mass erase only erases the user code area. The other option bytes including write protections remain unchanged from before the mass-erase operation. The OTP area is not affected by mass erase and remains unchanged. Mass erase is performed only when Level 1 is active and Level 0 requested. When the protection level is increased (0->1, 1->2, 0->2) there is no mass erase.

First of all, is it possible that the RDP may have been activated by somehow supernatural phenomenon ? I swear I DID NOT set this bit. Plus, as I can read for the Level 1 description, it is posible to come back to Level 0 (but the user program is erased). For me, to go from Level 1 to Level 0 doesn't work. So.... I am afraid that the RDP level is actually 2 and in this case..... well I am dead.

Is there anyway to solve this ? I don't understand what could have change during the week-end since everything was working fine and now everything don't.

Thanks in advance.

2
Just disable the options in ST Link studio. It will say it fails, it does with every chip. Known bug in 4.0.0.0. but the chip will be erased and free to use. If it doesn't work it can't complete erase due to power supply problems.Jeroen3
ST LInk Studio ? Do you mean ST-Link Utility ? If so, how am I supposed to do that ? I haven't seen any options allowing me to do that (except through the Option Bytes options, but it doesn't work).vionyst
yes I meant ST Link Utility, sorry. Indeed the option byte window. It always says it failed, but it actually performed the action.Jeroen3
Look, all the FFFF show access to memory is available again, and it has been erased.Jeroen3
I tried but it doesn't work. Actually I don't have the option you have to Enable/Disable the RDP. My ST-Link Utility only provides me Level 0, Level 1, Level 2 option. Look. What is your ST-Link version ?vionyst

2 Answers

1
votes

I had the r/w protection get randomly set when I was playing with the option bytes while flash was erased (0xff...).

Try doing this:

  1. Disconnect everything from the chip and reset the power supply.
  2. Open ST-Link Utility and go to Target > Option Bytes.
  3. Uncheck PCROP_RDP (don't click 'Apply' yet!).
  4. Change Read-Out Protection to 0 (drop-down menu on top).
  5. Only now click 'Apply'.

You will see the chip erased and in the Option Bytes screen on the Read/Write Protection tab, you will see the respective bank that was previously protected is now be automatically unchecked.

0
votes

I think it's due to incomplete contact of your ST-link to your target board. I've faced this issue before when either one of the debug pins are shorting or one of the debug pin connections is cut. Since you did not activate the RDP yourself and cannot seem to remove the protection, I believe its definitely due to connectivity issues. Confirm the electrical connection and see if it works.