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