Programming STM32 from TrueSTUDIO using ST-LINK clone

In this article I will explain how to program STM32 microcontroller directly from TrueSTUDIO using ST-LINK clone we made in previous article.

If you are using some ST-LINK clone or you are just using SWDIO and SWDCLK to program STM32 microcontroller, you need to use ST-LINK Utility. And each time you need to load new program into utility and connect to target and program it. But recently I found new shorter solution for this. CLI (Command Line Interface) for ST-LINK Utility. With this program we can program our microcontroller directly from TrueSTUDIO. Let me explain how.

In TrueSTUDIO in menu select: Run -> External Tools -> External Tools Configuration…

Here we need to add new configuration for each project in which we want to use CLI (maybe there is some shortcuts, but I don’t know it yet):

First we select New configuration (marked with red).

Then we enter data in all four marked locations. Name is anything we want, that let’s us know to which program configuration belongs. Location and Working Directory are locations of ST-LINK CLI and this always stays the same. Arguments are data that CLI needs to know where to find our program and what to do with it.

  • c SWD -> tells ST-LINK CLI to use SWD interface for programming
  • -p … -> tells ST-LINK CLI where to find hex file of our program
  • -Rst -> tells ST-LINK CLI to reset our microcontroller after programming
  • there exists also -Run, but this one does not work here, actually it blocks TrueSTUDIO beause our clone ST-LINK can’t perform this operation

When you are done click Apply and Close. You can also run this configuration here before closing.

Now to program our microcontroller from TrueSTUDIO using this configuration, we need to click on Run -> External Tools -> select one of the configurations (in cas below it is RFM12B_BluPil_001):

And click on configuration we want to run. If everything is ok, you should see output in console window at the bottom of TrueSTUDIO:

This is all there is! Now you don’t need to switch between application and reload .hex file, each time you want to program your microcontroller.


’till next time!