On Windows users should ensure that the following software is installed:
git
(optional, but recommended)cmake
7-zip
MinGW-w64
-
Install
git
from https://git-scm.com/download/win -
Install
cmake
from https://cmake.org/download
Ensure that you add cmake to the $PATH system variable when following the instructions by the setup assistant. -
Install
- EITHER: Download MinGW-w64 from hhttp://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-win32/sjlj/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0.7z. Extract content to
C:\mingw-w64\
and addC:\mingw-w64\bin\
to PATH-Variable. - OR: MSVC toolchain from Visual Studio Build Tools 2019
- EITHER: Download MinGW-w64 from hhttp://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-win32/sjlj/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0.7z. Extract content to
-
Create a new destination folder at a place of your choice
-
Open the command-line (cmd.exe) and execute
cd C:\$Path-to-your-destination-folder$\
-
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 the stlink zip-sourcefolder from the Release page on GitHub.
Visual Studio IDE is not necessary, only Windows SDK & build tools are required (~3,3GB).
-
Open https://visualstudio.microsoft.com/downloads/
-
Navigate through menus as follows (might change overtime)
All downloads > Tools for Visual Studio 2019 > Build Tools for Visual Studio 2019 > Download
-
Start downloaded executable. After Visual Studio Installer bootstraps and main window pops up, open
Individual Components
tab, and pick
- latest build tools (eg.
MSVC v142 - VS 2019 C++ x64/x86 build tools (v14.25)
) - latest Windows SDK (eg.
Windows 10 SDK (10.0.18362.0)
)
- After installation finishes, you can press
Launch
button in Visual Studio Installer's main menu.- Thus you can open
Developer Command Prompt for VS 2019
. It iscmd.exe
instance with adjusted PATHs including eg.msbuild
. - Alternatively, you can use
Developer Powershell for VS 2019
which is the same thing forpowershell.exe
. Both are available from Start menu. - Another option is to add
msbuild
to PATH manually. Its location should beC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin
. Then, it should be available from anypowershell.exe
orcmd.exe
session.
- Thus you can open
- Open command-line with administrator privileges
- Move to the
stlink
directory - Execute
mingw64-build.bat
NOTE:
Per default the build script (currently) uses C:\mingw-w64\x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0\mingw64\bin
.
When installing different toolchains make sure to update the path in the mingw64-build.bat
.
This can be achieved by opening the .bat file with a common text editor.
- In a command prompt, change the directory to the folder where the stlink files were cloned (or unzipped) to.
- Make sure the build folder exists (
mkdir build
if not). - From the build folder, run cmake (
cd build; cmake ..
).
This will create a solution file stlink.sln
in the build folder.
Now, you can build whole stlink
suite using following command:
msbuild /m /p:Configuration=Release stlink.sln
Options:
/m
- compilation runs in parallel utilizing multiple cores/p:Configuration=Release
- generates Release, optimized build.
Directory <project_root>\build\Release
contains final executables.
(st-util.exe
is located in <project_root>\build\src\gdbserver\Release
).
NOTE 1:
Executables link against libusb.dll library. It has to be placed in the same directory as binaries or in PATH.
It can be copied from: <project_root>\build\3rdparty\libusb-{version}\MS{arch}\dll\libusb-1.0.dll
.
NOTE 2:
ST-LINK drivers are required for stlink
to work.
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
.
As an option you may also install to an individual user-defined folder e.g $HOME
with make install DESTDIR=$HOME
.
When installing system-wide (sudo make install
) the dynamic library cache needs to be updated with the command ldconfig
.
- 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/* /etc/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