Need help unlocking stm32f4

I’ve been trying all day to flash my stm32f4discovery using the OpenOCD cmd line on windows. I can’t seem to get the right combination of commands to unlock the device. First, start openocd:

openocd -f interface/stlink-v2.cfg -f target/stm32f4x_stlink.cfg

Next, I telnet to the server and run the following commands:

halt

flash probe 0

device id = 0x10016413

flash size = 8192kbytes

flash ‘stm32f2x’ found at 0x08000000

flash protect 0 0 last off

Device Security Bit Set

cleared protection for sectors 0 through 67 on flash bank 0

reset halt

target state: halted

target halted due to debug-request, current mode: Thread

xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc

flash erase_sector 0 0 last

stm32x device protected

failed erasing sectors 0 to 67

stm32f2x unlock 0

Device Security Bit Set

timed out waiting for flash

stm32f2x failed to unlock device

flash erase_sector 0 0 last

stm32x device protected

failed erasing sectors 0 to 67

I keep seeing messages saying “Device Security Bit Set” and “stm32x device protected”. I guessing those are clues, but I don’t know for sure. When I flash, I get this message:

flash write_image test.elf

Target is already running an algorithm

error starting target flash write algorithm

error writing to flash at address 0x08000000 at offset 0x00000000

in procedure ‘flash’

Can someone please provide some guidance?

TIA

What version of OpenOCD are you using? If I recall we fixed some issues relating to unlock for that target.

I would recommend to try the last release or better yet the code from our git server.

The only cmd that would be required is

reset init
stm32f2x unlock 0

You may need to power cycle after the unlock.

Cheers

Spen

What version of OpenOCD are you using? If I recall we fixed some issues relating to unlock for that target.

I would recommend to try the last release or better yet the code from our git server.

The only cmd that would be required is

reset init
stm32f2x unlock 0

You may need to power cycle after the unlock.

Cheers

Spen

Hi,

I am seeing exactly these same problems.

I have a new st-link/v2 and I loaded in the latest fw.

I am running the freddie openocd 0.7.0 distribution, which appears to be the current version.

The target chip is on my own board, using the STM32F427 in the 100 pin package.

There appears to be some kind of write or device locking going on that openocd cannot clear. I get the same sort of messages as are reported in this thread. I am really at my wits’ end.

Thanks!

I would suggest you get a newer OpenOCD, the one on Freddie’s site is a bit old and quite a few stm32 bugs have been fixed since then.

When reporting a problem you really should start a new thread, attach any info (os, board used, logs) to help us solve your problem.

Cheers

Spen