Getting STLink with Versalon firmware working with OpenOCD

So you updated your STM32VLDISCOVER with Versalon firmware as I did here.

But, what next? Now you need get OpenOCD support.

First clone OpenOCD:

$ git clone

Then go back OpenOCD tree to 6 Jun 2011:

$ cd openocd
$ git checkout e899fcaca0d207eadea569b9dd9b2d54afafcfd4

Apply this patch (openocd_stlink.patch.tar.gz) to add support the Versalon-STLink on OpenOCD:

$ patch -p1 < ../patch/openocd.patch

Execute bootstrap to create the configure:

$ ./bootstrap

Setup configure parameters:

$ ./configure --enable-maintainer-mode --enable-vsllink --enable-usbprog --enable-jlink --enable-ft2232_libftdi

Compile it:

$ make

Install it:

$ sudo make install

Start OpenOCD with stlinkversa config:

# openocd -f stlinkversa.cfg
Open On-Chip Debugger 0.5.0-dev-00906-ge899fca-dirty (2012-02-21-17:04)
Licensed under GNU GPL v2
For bug reports, read
Warn : must select a transport.
Info : OpenOCD runs in SWD mode
1000 kHz
adapter_nsrst_delay: 100
jtag_ntrst_delay: 100
cortex_m3 reset_config sysresetreq
Info : Versaloon(0x33)by Simon(compiled on Oct 25 2011)
Info : USB_TO_XXX abilities: 0x00000008:0x00000040:0xC0000006
Info : clock speed 1000 kHz
Info : stm32.cpu: hardware has 6 breakpoints, 4 watchpoints

Now open a new terminal e connect to openocd server by telnet:

$ telnet 4444

Execute these commands to erase stm32f100 internal flash:

> reset halt
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08000b4c msp: 0x20000400
> stm32x unlock 0
stm32x unlocked.
INFO: a reset or power cycle is required for the new settings to take effect.
> flash probe 0
device id = 0x10016420
flash size = 128kbytes
flash 'stm32x' found at 0x08000000
> stm32x mass_erase 0
stm32x mass erase complete

To flash your binary (i.e. blinky.bin) copy your .bin to directory where you ran openocd command and from telnet execute:

> flash write_bank 0 blinky.bin 0
wrote 132 bytes from file blinky.bin to flash bank 0 at offset 0x00000000 in 0.154993s (0.832 KiB/s)
> reset run

P.S.: If you receive the error message “`pkglibdir’ is not a legitimate directory for `DATA'” then read it: