stlink and OpenOCD

2,073 views
Skip to first unread message

Spencer Oliver

unread,
Dec 19, 2011, 6:40:57 AM12/19/11
to stm3...@googlegroups.com
Hi,

I looked into adding support for the stlink to OpenOCD about a year
ago - never got around to finishing as it required quite a bit of
work.

Seems someone else has taken the 'bull by the horns' and added support.
It is still being reviewed on our gerrit server but feel free to
checkout/comment before we get this added to master repo.

http://openocd.zylin.com/279

Cheers
Spen

Uwe Bonnes

unread,
Dec 19, 2011, 7:06:16 AM12/19/11
to stm3...@googlegroups.com
>>>>> "Spencer" == Spencer Oliver <sp...@spen-soft.co.uk> writes:

Spencer> Hi, I looked into adding support for the stlink to OpenOCD
Spencer> about a year ago - never got around to finishing as it required
Spencer> quite a bit of work.

Spencer> Seems someone else has taken the 'bull by the horns' and added
Spencer> support. It is still being reviewed on our gerrit server but
Spencer> feel free to checkout/comment before we get this added to
Spencer> master repo.

Spencer> http://openocd.zylin.com/279

You you please give me a head start how to checkout/clone the code at zylin?

Thanks
--
Uwe Bonnes b...@elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------

Spencer Oliver

unread,
Dec 19, 2011, 7:18:37 AM12/19/11
to stm3...@googlegroups.com
On 19 December 2011 12:06, Uwe Bonnes

<b...@elektron.ikp.physik.tu-darmstadt.de> wrote:
>
> You you please give me a head start how to checkout/clone the code at zylin?
>

No problem.

Checkout the OpenOCD code as normal:
git clone git://openocd.git.sourceforge.net/gitroot/openocd/openocd

the checkout the stlink patch (with configs)
git fetch http://openocd.zylin.com/p/openocd refs/changes/87/287/1 &&
git checkout FETCH_HEAD

build as normal
Here is my config - using STM32C-EVAL and STLINK-V2

set CPUTAPID 0x1ba01477
source [find interface/stlink-usb.cfg]
source [find target/stm32f2x_stlink.cfg]

Cheers
Spen

Spencer Oliver

unread,
Dec 19, 2011, 7:24:53 AM12/19/11
to stm3...@googlegroups.com

make sure to use the --enable-stlink when calling OpenOCD configure, eg.

./configure --enable-maintainer-mode --enable-stlink
make

I have only tested under ubuntu using libusb-1.0

Cheers
Spen

Karl P

unread,
Dec 28, 2011, 4:18:04 PM12/28/11
to stm3...@googlegroups.com, Spencer Oliver

On 12/19/2011 12:18 PM, Spencer Oliver wrote:
> On 19 December 2011 12:06, Uwe Bonnes
> <b...@elektron.ikp.physik.tu-darmstadt.de> wrote:
>>
>> You you please give me a head start how to checkout/clone the code at zylin?
>>
>
> No problem.
>
> Checkout the OpenOCD code as normal:
> git clone git://openocd.git.sourceforge.net/gitroot/openocd/openocd
>
> the checkout the stlink patch (with configs)
> git fetch http://openocd.zylin.com/p/openocd refs/changes/87/287/1&&
> git checkout FETCH_HEAD

This bit all worked ok...

>
> build as normal

ahhhh, this bit could do with some work.... the git checkout has a README, that
refers to a non-existant INSTALL file. There's no configure... The developers
guide, at http://openocd.sourceforge.net/doc/doxygen/html/index.html has no
section on building. The users guide:
http://openocd.sourceforge.net/doc/html/Developers.html#Developers refers to the
README file...

Ok, let's try "bootstrap" ok, now we have a configure..... and can run make...

Ok, now what?


> Here is my config - using STM32C-EVAL and STLINK-V2
>
> set CPUTAPID 0x1ba01477
> source [find interface/stlink-usb.cfg]
> source [find target/stm32f2x_stlink.cfg]

I don't get that far...

The documentation on where these damn .cfg files are located is pervese to say
the least. I resorted to "find" in the top level directory to look for them.

http://openocd.sourceforge.net/doc/html/Running.html#Running refers to the list
of search paths, but none of those names match any obvious directories in the
git package. Eventually, it seems that it's all underneath the tcl directory.

karlp@tera:~/src/openocd-git/src$ ./openocd -f ../tcl/interface/stlink-usb.cfg
Open On-Chip Debugger 0.6.0-dev-00294-ga84e2e3 (2011-12-28-20:31)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.sourceforge.net/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'stlink'
1 kHz
trst_and_srst separate srst_gates_jtag trst_push_pull srst_open_drain
Error: Translation from khz to jtag_speed not implemented
Error: Translation from khz to jtag_speed not implemented
Error: Translation from jtag_speed to khz not implemented
Info : adapter-specific clock speed value 0
Error: BUG: current_target out of bounds
karlp@tera:~/src/openocd-git/src$

Now what? There's no "board" file I can see for any of the STM32 Discovery
boards, do I really need a board config to verify that I can talk to the programmer?

Later, I tried with the stm32f2x_stlink.cfg file, (I wasn't expecting to need a
different target config, I thought that was the point of the separation of
interface and target configs?) and it then _starts_, but commands like "reg"
don't do anything, nor does

> mdb 0x08000000 32
mdb ['phys'] address [count]
stm32.cpu mdb address [count]
in procedure 'mdb'

> stm32.cpu cget -coreid
65536
> stm32.cpu cget -variant


I can't really say whether this is user error or patch error at this point.

Cheers,
Karl P

Spencer Oliver

unread,
Jan 4, 2012, 3:58:01 PM1/4/12
to Karl P, stm3...@googlegroups.com
On 28 December 2011 21:18, Karl P <ka...@tweak.net.au> wrote:
> On 12/19/2011 12:18 PM, Spencer Oliver wrote:
>>
>> On 19 December 2011 12:06, Uwe Bonnes
>> <b...@elektron.ikp.physik.tu-darmstadt.de>  wrote:
>>>
>>>
>>> You you please give me a head start how to checkout/clone the code at
>>> zylin?
>>>
>>
>> No problem.
>>
>> Checkout the OpenOCD code as normal:
>> git clone git://openocd.git.sourceforge.net/gitroot/openocd/openocd
>>
>> the checkout the stlink patch (with configs)
>> git fetch http://openocd.zylin.com/p/openocd refs/changes/87/287/1&&
>> git checkout FETCH_HEAD
>
> This bit all worked ok...
>

Thats good.

>>
>> build as normal
>
> ahhhh, this bit could do with some work....  the git checkout has a README,
> that refers to a non-existant INSTALL file.  There's no configure...  The
> developers guide, at
> http://openocd.sourceforge.net/doc/doxygen/html/index.html has no section on
> building.  The users guide:
> http://openocd.sourceforge.net/doc/html/Developers.html#Developers refers to
> the README file...
>
> Ok, let's try "bootstrap"  ok, now we have a configure..... and can run
> make...
>
> Ok, now what?
>

INSTALL does exist.
As usual with Open Source projects some things may need tweaking -
patches are always welcome :)

The initial stlink support has been merged into master now so a simple
clone is required:
git clone git://openocd.git.sourceforge.net/gitroot/openocd/openocd

When building from git master then configure will need generating ...
./bootstrap
./configure --enable-maintainer-mode --enable-stlink
make

Cheers
Spen

Reply all
Reply to author
Forward
0 new messages