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 https://github.com/stlink-org/stlink
cd stlink
cmake .
make

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:

lsusb

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

then:

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 https://github.com/stlink-org/stlink .

Check these articles related to STM32.

The older version of this post is here.

Share this:

Comments

  1. By on4aol

    Reply

  2. By Grig

    Reply

  3. By goodsw

    Reply

    • By Grig

  4. By Natural

    Reply

    • By eblink

    • By Grig

  5. By Natural

    Reply

    • By Natural

    • By RB

    • By Grig

  6. By Grig

    Reply

  7. By enjay

    Reply

  8. By enjay

    Reply

  9. By Grig

    Reply

  10. By anonymous

    Reply

    • By Grig

  11. By Jose

    Reply

    • By Grig

  12. By DarkstartXt

    Reply

    • By Grig

    • By Dirceu

  13. By anand

    Reply

    • By Grig

  14. By Grig

    Reply

  15. By Pete

    Reply

    • By Pete

    • By Grig

  16. By Nadejda

    Reply

    • By Grig

  17. By ahmed

    Reply

    • By Grig

  18. By Peter Glen

    Reply

    • By Grig

  19. By Карина

    Reply

    • By Grig

  20. By Chao

    Reply

    • By Chao Jiang

  21. By billy

    Reply

  22. By Pavel

    Reply

    • By Grig

    • By Paul Kupriyanov

  23. By Alexander Letetski

    Reply

    • By Grig

    • By Iorecc

  24. Reply

    • By Grig

  25. By Neculiti Ivan

    Reply

  26. By deiva

    Reply

  27. By xuraax

    Reply

    • By Grig

Leave a Reply to Alexander Letetski Cancel reply

Your email address will not be published. Required fields are marked *