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/texane/stlink
cd stlink
cmake .
make

Now we copy the built binaries to their place:

cd bin
sudo cp st-* /usr/local/bin

then udev rules:

sudo cp etc/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:

Then, keeping the ST-Link device plugged, and still NO TARGET BOARD CONNECTED, then type:

st-flash --debug read dummy.file 0 256

You should see something like:

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 texane for doing the hard work!

Check these articles related to STM32.

Share this:

Comments

  1. By on4aol

    Reply

  2. By Grig

    Reply

  3. By goodsw

    Reply

    • By Grig

  4. By Natural

    Reply

  5. By Natural

    Reply

    • By Natural

  6. By Grig

    Reply

  7. By enjay

    Reply

  8. By enjay

    Reply

  9. By Grig

    Reply

Leave a Reply

Your email address will not be published.