Starting Electronics needs your help! Please make a donation to help cover our hosting and other costs. Click the donate button to send a donation of any amount.

ST-LINK/V2 SWD Linux Programming

Created on: 28 August 2012

The ST-LINK/V2 programmer/debugger can be used to program STM32 microcontrollers in Linux.

In this tutorial, the ST-LINK is used in SWD mode to program a STM32 Value Line Discovery Board.

Linux Software

Install the st-link command line program as described in the Programming STM32 Microcontroller Flash in Linux tutorial on this website.


Set up the hardware as shown in the Using the ST-LINK/V2 to Program STM32F100 Microcontrollers tutorial and video on this website. The tutorial is for Windows, but the hardware is set up the same for Linux.


If you are using the STM32 Value Line Discovery board, make sure that you have removed the two jumper links from the CN3 header pins. Plug the ST-LINK/V2 into a spare USB port on the PC. Power up the target board – if using the STM32 value line discovery board, it can be powered from a spare USB port.

In a terminal window, change to the directory containing the binary file that you want to load to the STM32 board. Enter:

st-flash write myflash.bin 0x8000000

Where myflash is the name of your binary file to load.