Can I program all kinds of SWD-programmable chips (ARM-MCUs) with ST-Link?

  • "The ST-LINK/V2 is an in-circuit debugger and programmer for the STM8 and STM32 microcontroller families." I don't think you can immediately, but it should be achievable in theory. Someone managed to connect it to a LPC MCU here : lpcware.com/content/forum/… – Fluffy Aug 4 '16 at 14:42
  • 1
    Perhaps in some cases if you use something like openocd rather than the ST software. If you run into difficulty there are open source CMSIS-DAP implementations you could flash onto it, which are more universal by placing the host software in finer control of the details. – Chris Stratton Aug 4 '16 at 14:46
  • This isn't what you asked, but there are also debuggers that cover multiple targets such as the PE micro debuggers. – mkeith Aug 5 '16 at 6:06
  • I use ST link to program lpc1549, it works. – user2425240 Jul 20 '17 at 7:25

To add to the existing answer; some chips are known not to work properly with ST-LINK and OpenOCD.

In particular, if your target is from the Atmel SAMD21 family of MCUs, you are likely to run into weird issues, where the processor is detected, but any attempts to erase flash sectors fail with an error.

The reason is rather involved, to quote:

AFAIK the problem is in half word (16-bit) write to NVMCTRL->CTRLA register. STLink does not implement half word memory access and OpenOCD emulates is as two byte operations. Unfortunately CTRLA register comprises from key and command an have to be written atomically. If STLink writes two bytes, NVM controller sets PROGE bit in STATUS: "An invalid command and/or a bad keyword was/were written in the NVM Command register"

The workaround involves recompiling OpenOCD with code patches. Not fun.

However, if you don't mind flashing your ST-Link (through another ST-Link), you can convert it to a CMSIS-DAP adapter, which works just fine with the SAMD and should also work with STM32 and other Cortex-M chips.

Yes I believe this is possible, although I haven't tried it. You would likely be in breach of the ST Licence agreement, if you tried programming devices other than those from ST

As an example Segger (One of the market leaders in debuggers and programmers) supports converting your ST-Link to J-link (essentially overwriting the ST-Link chip with the Segger code). This is also reversible, so if you want to restore your ST-link device back to its original form you can.

There are several version of ST-Link, however. Take a look at the following links which provide further info and a guide on how to do this.

https://www.segger.com/jlink-st-link.html
https://www.segger.com/jlink-ob.html

  • 1
    I have been using the stlink header on nucleo and discovery boards on most of the the major cortex-m brands...and the ones I couldnt get it to work on were issues getting openocd configured not the stlink. – old_timer Jul 14 '17 at 12:44

You could also flash the st-link and convert it to a Black Magic Probe. The same image will also convert a Blue Pill into a BMP.

I've done both. The Blue Pill has the advantage that the usb-rs232 bridge the BMP exports is easily available.

The BMP supports a range of chips to include but not limited to:
ST Microelectronics STM32F0, STM32F1, STM32F3, STM32F2, STM32F4, STM32F7, STM32L0, STM32L1, STM32L4
Atmel SAM3N, SAM3X, SAM3S, SAM3U, SAM4S, SAM4L, SAM D20, D21
Nordic nRF51, nRF52 (These are why I use the BMP)

The BMP is open source, can be used for commercial programming and the hardware can be cheap(The "real" BMP costs around $60, a blue pill 5 pack from amazon was less than $20 shipped).

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.