Installing ST-Link v2 to flash STM32 targets on Linux

This guide is targeting Linux users and ST-Link v2 hardware.

First, we are going to install the necessary libraries and build tools:

sudo apt-get install git make cmake libusb-1.0-0-dev
sudo apt-get install gcc build-essential

Now, we will download and build the ST-Link utilities:

cd ~myusername
mkdir stm32
cd stm32
git clone
cd stlink
cmake .

Now we copy the built binaries to their place:

cd bin
sudo cp st-* /usr/local/bin
cd ../lib
sudo cp *.so* /lib32

then udev rules:

sudo cp stlink/config/udev/rules.d/49-stlinkv* /etc/udev/rules.d/

Now, plug the ST-Link device into the USB port, but DON’T CONNECT the target board, then type:


If everything went OK, you should see something like this:


Now, disconnect the ST-LINK from USB, connect the four wires to the target board as in the picture

then plug back the ST-Link to the USB and type:

st-flash read dummy.bin 0 0xFFFF

You should see something like:

If the target board is not connected, the ST-Link device will be identified, but you (obviously) will get an error during memory read.

We can decide it is correctly installed.

Please add comments if you encounter any issue using this guide. I hope it will help you.

Thanks for the effort to all contributors to this repository .

Check these articles related to STM32.

The older version of this post is here.

Share this:


  1. By on4aol

  2. By Grig

  3. By goodsw

    • By Grig

  4. By Natural

    • By eblink

    • By Grig

  5. By Natural

    • By Natural

    • By RB

    • By Grig

  6. By Grig

  7. By enjay

  8. By enjay

  9. By Grig

  10. By anonymous

    • By Grig

  11. By Jose

    • By Grig

  12. By DarkstartXt

    • By Grig

    • By Dirceu

  13. By anand

    • By Grig

  14. By Grig

  15. By Pete

    • By Pete

    • By Grig

  16. By Nadejda

    • By Grig

  17. By ahmed

    • By Grig

  18. By Peter Glen

    • By Grig

  19. By Карина

    • By Grig

  20. By Chao

    • By Chao Jiang

  21. By billy

  22. By Pavel

    • By Grig

    • By Paul Kupriyanov

  23. By Alexander Letetski

    • By Grig

    • By Iorecc

    • By Grig

  24. By Neculiti Ivan

  25. By deiva

  26. By xuraax

    • By Grig