Skip to main content
Visitor II
June 29, 2017
Question

Where do I find ST-LINK/V2 host interface details

  • June 29, 2017
  • 1 reply
  • 1721 views
Posted on June 29, 2017 at 14:02

I am a Linux user (hobbyist), with ST-LINK/V2 connecting to various STM8S  devices. I can find details of the SWIM and DM interfaces on the device side (ST document UM0470), but cannot locate any details of the host side. I am not a C programmer, but I have looked at the code for STM8FLASH (on GitHib) and it shows that I need to know more about the host side interface of ST-LINK/V2. Any assistance greatly appreciated.

Background: The STM8s are running custom code. I want to use debug module to stall cpu so can inject data and change program counter before restarting cpu; lots of times. I'll probably hack something together using Python, just to see if my idea actually works at all. But I cannot find details of host side commands to ST-LINK/V2 on st.com. I figure what I want is probably there, but I am looking for the wrong thing!!

    This topic has been closed for replies.

    1 reply

    Visitor II
    July 5, 2017
    Posted on July 05, 2017 at 08:21

    It sounds like you are looking for this:

    https://stm8-binutils-gdb.sourceforge.io/

     
    Visitor II
    July 5, 2017
    Posted on July 05, 2017 at 10:23

    Well that is another implementation that I haven't seen before. Thank you. There's several ST-LINK projects on GitHub (such as

    https://github.com/texane/stlink

     ,

    https://github.com/fpoussin/QStlink2

    ,

    https://github.com/afaerber/stlink

     , 

    https://github.com/pavelrevak/pystlink

    ). All these resources are implementations, so are subject to whatever scope the developer chooses. Some have good detail on SWIM, and others on DEBUG. It seems there is no ST reference at all. It just seems odd to me that a product can be produced that has a defined output interface but no defined input interface, but that seems to be the case for ST-LINK/V2. Basically, all the implementations are full of 'magic numbers' and a few examples of usages.

    Just a couple of examples of unknowns are

    • what does 0xF4 0x02 command actually return and what is it used for?
    • What do the commands 0xF4 0x03 thru - 0xF4 0x08 actually achieve?
    • Why does it take two commands to do a reset which is a single SWIM command?
    • What is the magic in the long series of commands to initialise a 'session'?
    • Which of the 'session' startup commands can cause a restart of the STM8 cpu? What parameter disables the restart?
    • etc...etc...etc...
    Visitor II
    July 6, 2017
    Posted on July 06, 2017 at 14:34

    What is your end goal? Debugging or programming?

    What I know for sure that the OpenOCD developers got a header file at some point in the past from the ST:

    https://sourceforge.net/p/openocd/mailman/message/35761273/

     

    I do not think that full protocol description would be publicly available.