If you run into weird issues flashing your board, it might be because the board is locked.

First check for

  • Ground loops: Are you powering the board from a different power supply than the OpenOCD or J-Link programmer? Try to power the board from the programmer.

Via SWD

While pressing the boot button or shorting the boot pads, open OpenOCD, connect the SWD port and run:

  • For F4 and F7 devices, run:
> stm32f2x unlock 0
stm32f2x unlocked.
INFO: a reset or power cycle is required for the new settings to take effect.
> reset halt
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x1ff00c88 msp: 0x20003af8
  • For F3 devices, run:
> stm32f1x unlock 0
stm32f1x unlocked.
INFO: a reset or power cycle is required for the new settings to take effect.
> reset halt

Now try to debug or flash again.

Download and install: http://www.st.com/en/embedded-software/stsw-link004.html

Open the app, connect the board and reset the Option Bytes