cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to program STM32F1x using the ST-link/openOCD

evert2
Associate II
Posted on January 09, 2014 at 12:31

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'.

#openocd
6 REPLIES 6
Posted on January 09, 2014 at 12:39

Doesn't OpenOCD have it's own forum? You'd have better luck there

https://forum.sparkfun.com/viewforum.php?f=18

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
chen
Associate II
Posted on January 09, 2014 at 12:51

Hi

While I do not have a solution to your problem, you can check the problem is not the

STM32F103 with the ST-link/V2.

Compile and link a Intel Hex or Motorola S-Rec output file.

Load this into ST-Link Utility and program the STM32F103.

If there is a problem with the STM32F103 or ST-Link the utility program will tell you.

Posted on January 09, 2014 at 13:01

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

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
evert2
Associate II
Posted on January 09, 2014 at 14:39

As I said, with the ST-linkV2 programmer and the ST-link utility everything works fine.

Evert Huijben

ntfreak
Associate II
Posted on January 15, 2014 at 16:25

According to your log you are using OpenOCD v0.6.1 - that is very old.

I suggest if possible to build from src and use the latest master branch.

Cheers

Spen
turboscrew
Senior III
Posted on January 17, 2014 at 15:58

Is there a reason to use OpenOCD? Are you using Linux?

If you are using Windows, you might like to try CoIDE (Windows-only/ARM-only).

http://www.coocox.org/CooCox_CoIDE.htm