On Windows users should ensure that the following software is installed:
git
(optional, but recommended)7zip
MSYS2
- Install
MSYS2
from https://www.msys2.org/
Follow the installation instructions on the website. - Install
mingw-w64
via the MSYS2 UCRT64 Shell:pacman -S mingw-w64-x86_64-cmake mingw-w64-x86_64-make mingw-w64-x86_64-gcc git
- Fetch the project sourcefiles by running
git clone https://github.com/stlink-org/stlink.git
from the command-line (cmd.exe)
or download and extract (7zip
) the stlink zip-sourcefolder from the Release page on GitHub.
- Open the command-line (cmd.exe) with administrator privileges
- Move to the
stlink
directory and executeC:\$Path-to-your-stlink-folder$\mingw64-build.bat
Depending on the flavour of compilation the final executables will be placed in the following directories:
- Local compilation:
<project_root>\build-mingw\bin
- Local installation:
C:\Program Files (x86)\stlink\bin
- Package Generation (portable):
C:\Users\swift\Desktop\stlink\build-mingw\dist
Remove C:\Program Files (x86)\stlink\
and C:\$Path-to-your-stlink-folder$
.
NOTE:
ST-LINK drivers are required for programmers to work with stlink
.
On Windows users should ensure that the following software is installed:
git
(Required for building LibUSB if missing)7zip
cmake
MSVC
Compiler (Tested with Visual Studio 2022 and Build Tools for Visual Studio 2022)
- Install
Build Tools for Visual Studio
from https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022 - Install
cmake
from https://cmake.org/download/#latest --> Binary distributions --> Windows x64 Installer
Ensure that you add cmake to the $PATH system variable when following the instructions by the setup assistant. Follow the installation instructions on the website. - Fetch the project source files by running
git clone https://github.com/stlink-org/stlink.git
from the command-line (cmd.exe
/powershell.exe
)
or download and extract (7zip
) the latest stlink.zip
release from the Release page on GitHub.
- Open the command-line (
cmd.exe
/powershell.exe
) with administrator privileges - Move to the
stlink
directory withcd C:\$Path-to-your-stlink-folder$\
- Create a new
build
subdirectory and move into it withcd .\build
. - Configure the project, using the following command:
cmake -G "Visual Studio 17 2022" .. -DCMAKE_BUILD_TYPE="Release"
- Build the project, using the following command:
cmake --build . --target ALL_BUILD
- Install the project, using the following command:
cmake --build . --target INSTALL
- Add the
bin
folder of the installation path (C:\Program Files (x86)\stlink\bin
) to thePATH
environment variables:- Run
SystemPropertiesAdvanced.exe
- press on
Environment Variables
button - On
System Variables
list, find and selectPath
variable - Press
Edit..
button bellow the list - On the new Window, press
New
button - On the new row, type the
bin
path of your installation (C:\Program Files (x86)\stlink\bin
) - Press
OK
button to all three windows to save your changes
- Run
NOTE:
- ST-LINK drivers are required for programmers to work with
stlink
. - Package generation for MSVC is not yet implemented/tested.
Install the following packages from your package repository:
git
gcc
orclang
ormingw32-gcc
ormingw64-gcc
(C-compiler; very likely gcc is already present)build-essential
(on Debian based distros (Debian, Ubuntu))cmake
rpm
(on Debian based distros (Debian, Ubuntu), needed for package build withmake package
)libusb-1.0
libusb-1.0-0-dev
(development headers for building)libgtk-3-dev
(optional, needed forstlink-gui
)pandoc
(optional, needed for generating manpages from markdown)
or execute (Debian-based systems only): apt-get install gcc build-essential cmake libusb-1.0 libusb-1.0-0-dev libgtk-3-dev pandoc
(Replace gcc with the intended C-compiler if necessary or leave out any optional package not needed.)
- Open a new terminal console
- Create a new destination folder at a place of your choice e.g. at
~/git
:mkdir $HOME/git
- Change to this directory:
cd ~/git
- Fetch the project sourcefiles by running
git clone https://github.com/stlink-org/stlink.git
- Change into the project source directory:
cd stlink
- Run
make clean
-- required by some linux variants. - Run
make release
to create the Release target. - Run
make install
to full install the package with complete system integration. This might require sudo permissions. - Run
make debug
to create the Debug target (optional)
The debug target is only necessary in order to modify the sources and to run under a debugger. - Run
make package
to build a Debian Package. The generated packages can be found in the subdirectory./build/Release/dist
. - Installing system-wide (
sudo make install
) requires the dynamic library cache to be updated withsudo ldconfig
afterwards.
As an option you may also install to an individual user-defined folder e.g $HOME
with make install DESTDIR=$HOME
.
- Run
make uninstall
to perform a clean uninstall of the package from the system. - Run
make clean
to clean the build-folder within the project source and remove all compiled and linked files and libraries.
Install the following packages from your package repository:
mingw-w64
mingw-w64-common
mingw-w64-i686-dev
mingw-w64-x86-64-dev
After following the steps for installation above, proceed with from the build dircetory itself:
$ sudo sh ./cmake/packaging/windows/generate_binaries.sh
The generated zip-packages can be found in the subdirectory ./build/dist
.
By default most distributions don't allow access to USB devices.
In this context udev rules, which create devices nodes, are necessary to run the tools without root permissions.
To achieve this you need to ensure that the group plugdev
exists and the user who is trying to access these devices is a member of this group.
Within the sourcefolder of the project, these rules are located in the subdirectory config/udev/rules.d
and are automatically installed along with sudo make install
on linux.
Afterwards it may be necessary to reload the udev rules:
$ sudo cp -a config/udev/rules.d/* /lib/udev/rules.d/
$ sudo udevadm control --reload-rules
$ sudo udevadm trigger
udev will now create device node files, e.g. /dev/stlinkv3_XX
, /dev/stlinkv2_XX
, /dev/stlinkv1_XX
.
As the STLINKV1's SCSI emulation is somehow broken, the best advice possibly is to tell your operating system to completely ignore it.
Choose one of the following options before connecting the device to your computer:
modprobe -r usb-storage && modprobe usb-storage quirks=483:3744:i
- OR
echo "options usb-storage quirks=483:3744:i" >> /etc/modprobe.conf
modprobe -r usb-storage && modprobe usb-storage
- OR
cp stlink_v1.modprobe.conf /etc/modprobe.d
modprobe -r usb-storage && modprobe usb-storage
To put the compiled shared libs into a different directory during installation,
you can use the cmake option cmake -DLIB_INSTALL_DIR:PATH="/usr/lib64" ..
.
The cmake build system of this toolset includes GNUInstallDirs
to define GNU standard installation directories.
This module provides install directory variables as defined by the GNU Coding Standards.
Below are the preset default cmake options, which apply if none of these options are redefined:
-DCMAKE_INSTALL_SYSCONFDIR=/etc
-DCMAKE_INSTALL_PREFIX=/usr/local
Please refer to the related cmake documentation for details.
Author: nightwalker-87