Unable to program STM32F1x with OpenOCD/ST-link

Hello,

I like to program my STM32F103 with the ST-link/V2 device by using openOCD.

However I got next message:

Error: flash write failed at address 0x80016f8

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

By using the ST-link Utility, it works fine with the same programmer.

I am using the stm32f1x_stlink.cfg target script and next openocd script for writing:

I call this script from my makefile (IMGFILE is my binary)

roc stm_flash {IMGFILE} {

reset halt

sleep 10

wait_halt 2

flash write_image erase $IMGFILE 0x08008000

sleep 10

verify_image $IMGFILE 0x08008000

sleep 10

reset run

}

Does anyone has an idea what is going on?

Regards Evert Huijben

Here is the complete logging:

make program

Open On-Chip Debugger 0.6.1 (2014-01-08-11:14)

Licensed under GNU GPL v2

For bug reports, read

http://openocd.sourceforge.net/doc/doxygen/bugs.html

adapter speed: 1000 kHz

srst_only separate srst_nogate srst_open_drain

Info : clock speed 1000 kHz

Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints

stm_erase

target state: halted

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

xPSR: 0x01000000 pc: 0x08000160 msp: 0x20000400

auto erase enabled

Info : device id = 0x20036410

Info : flash size = 128kbytes

Error: flash write algorithm aborted by target

target state: halted

target halted due to breakpoint, current mode: Thread

xPSR: 0x01000000 pc: 0x08000160 msp: 0x20000400

Error: flash write failed at address 0x80016f8

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

Runtime Error: /home/evert/sandbox/multi_IO/projects/chibiOs/make/…/…/…/boards/multiIo/stm32f1-openocd.cfg:12:

in procedure ‘stm_flash’

in procedure ‘flash’ called at file “/home/evert/sandbox/multi_IO/projects/chibiOs/make/…/…/…/boards/multiIo/stm32f1-openocd.cfg”, line 12

make: Nothing to be done for `program’.