This post is also available in: cs
This post is part of a series of articles about STM8 development with OpenSource tools. You can find an overview of the whole toolchain in the post STM8 Development with OpenSource Tools.
Hint
If you have a Linux distribution based on Debian (Ubuntu, Mint, Devuan, …), you don’t need to do anything from this article. Just use our repository with precompiled packages. Another option is the pre-prepared installation for VirtualBox.
This article is for users of other distributions and other operating systems, and for those who want to compile the tools from source code. It is organised by operating system:
In each chapter the tools are in the same order as in the following table. The flashing script, which is common to all systems, is in the chapter OpenOCD flashing script.
| Tool | What it is for | Debian package | Procedure |
|---|---|---|---|
| make, git | toolchain | make, git |
Linux, macOS, Windows |
| SDCC | compiler | sdcc, sdcc-libraries |
Linux, macOS, Windows |
| OpenOCD | flashing and debugging | openocd |
Linux, macOS, Windows |
| stm8flash | flashing | stm8flash |
Linux, macOS, Windows: STVP instead |
| STVP | flashing on Windows | — | Windows |
| stm8-binutils-gdb | debugger stm8-gdb |
stm8-binutils-gdb |
Linux, macOS, Windows |
| cgdb | frontend for GDB | cgdb |
Linux, macOS, Windows |
| ccls | LSP server for the editor | ccls |
Linux, macOS, Windows |
| SDCC-gas, sdccrm | historical solutions | — | Historical Solutions |
Watch out for SDCC version
In the SDCC compiler (regardless of OS), version 4.5.0 has a bug that makes it unusable for the STM8 platform. The bug is already fixed, but you need to be careful and install version 4.4.0, 4.6.0 or newer, or a nightly build.
Quick one-command install¶
If you don’t want to assemble everything by hand, one command is enough. The script installs
the SDCC compiler, OpenOCD, stm8-gdb, make, git, python and the VS Code / VSCodium
extension. If a package manager is missing (Homebrew on macOS, Chocolatey on Windows), it installs
that too. The scripts are in the toolchain repository,
so have a look at them before running. You can run them repeatedly; anything already installed is skipped.
Linux (Debian, Ubuntu, Mint, …; amd64):
1 | |
macOS (Apple Silicon):
1 | |
Windows 10/11 (in PowerShell; asks once for administrator rights). You can choose the package manager, both variants do the same thing. With Chocolatey (the script installs it if missing):
1 | |
Or with winget (already included in Windows 10/11):
1 | |
The script does not install the ST-Link driver for Windows (ST publishes it only after registration). If the board is not found, install STSW-LINK009.
The following chapters describe how to install each tool by hand, or compile it from source.
Linux¶
Basic Tools¶
On Linux you call something like:
1 | |
SDCC¶
SDCC - Small Device C Compiler is a C compiler for STM8. Why SDCC and how the toolchain uses it is described in the main article. Watch out for version 4.5.0 (see the warning above).
On Debian and derived distributions you install SDCC in the right version from our repository:
1 | |
Otherwise SDCC is part of most Linux distributions; so you call something like:
1 | |
But check the version (sdcc -v) so you don’t end up with 4.5.0.
From source code¶
Sometimes it happens that your distribution doesn’t have SDCC in the right version,
or you want to install a nightly build. I use the program
Stow for installing
non-distribution packages.
1 | |
Libraries and dependencies needed for the build can be installed like this:
1 | |
Then just download the source code, unpack and install:
1 2 3 4 5 6 7 | |
One small note: SDCC supports many different platforms that I don’t need.
So my ./configure looks like this:
1 2 3 4 5 6 7 8 | |
OpenOCD¶
Open On-Chip Debugger is a tool for uploading a program to the chip and for debugging. How the toolchain uses it is described in the main article.
Installation on Linux is done with a simple command:
1 | |
To enable openocd to do simple flashing, you need to add a script, see
OpenOCD flashing script.
stm8flash¶
A program for uploading a program to the chip.
https://github.com/vdudouyt/stm8flash
On Debian and derived distributions there is a ready-made package in our repository:
1 | |
From source code¶
In most Linux distributions it needs to be built manually:
1 2 3 4 5 6 | |
stm8-binutils-gdb¶
The STM8 port of GNU binutils is needed
for linking and
debugging. It contains the debugger
stm8-gdb, whose use is described in A small STM8-GDB course.
Newer and nicer GDB v15.0¶
A significantly newer version of stm8-gdb based on GDB 15.0 is currently available.
It brings improvements over the old version 8.1: working with it is clearer
thanks to colours, and it is simply a newer version overall…
On Debian and derived distributions there is a ready-made package in our repository:
1 | |
A prebuilt package is also available on the releases page…
You can download the sources from my fork on GitLab:
1 2 | |
The build is very simple:
1 2 3 4 5 6 7 | |
And again Stow.
1 2 | |
Our toolchain needs GDB with Python support.
./configure turns it on by itself when it finds python3. You can verify it like this
(it must print 1):
1 | |
Legacy GDB 8.1¶
On the internet you will find various guides for building GDB version 8.1 from older sources. Specifically, it is the project stm8-binutils-gdb. It works well, but if you want to use it, I recommend rather our repo stm8-binutils-gdb-legacy, because its sources can be built even today, with the current Python 3.12+.
1 2 3 4 5 6 7 8 9 10 11 | |
cgdb¶
cgdb is a colourful frontend for GDB. make debug opens it
automatically; when cgdb is not installed, it starts GDB in TUI mode.
More in the article A small STM8-GDB course.
1 | |
ccls¶
ccls is an
LSP server for
code completion and error highlighting in the editor. It is optional. Why I
recommend it is described in the main article.
1 | |
An alternative is clangd, which also works quite
well (sudo apt install clangd).
macOS¶
Basic Tools¶
On macOS it should be easy, because it is also Unix. Just use HomeBrew:
1 | |
SDCC¶
Watch out for version 4.5.0 (see the warning above). HomeBrew already offers SDCC in version 4.6.0, so just:
1 | |
From source code¶
If you want a different version, for example a nightly build, download the source code, unpack it, and ….
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |
OpenOCD¶
1 | |
For the flashing script see OpenOCD flashing script.
stm8flash¶
stm8flash is not in HomeBrew, so you have to build it.
The project’s Makefile accounts for macOS and looks for the libusb library using
pkg-config:
1 2 3 4 5 6 | |
stm8-binutils-gdb¶
It works on a Mac with Apple Silicon (arm64). A volunteer tried the build from
sources and the content of the prebuilt package on a clean MacBook (macOS 26),
then also with a connected Nucleo-STM8S208RB: flashing, debugging through OpenOCD, make cgdb and the VS Code extension work.
Prebuilt package¶
From version v15.0.50-stm8.2 the
releases
have an installer .pkg and an archive .tar.gz with the same content (macOS
12 and newer). Their stm8-gdb has its own bundled Python, so make debug
and the VS Code extension work and you do not need to install anything else
(HomeBrew, Python).
(Built on a Mac with Apple Silicon (arm64).)
The best way to install the .pkg is the terminal:
1 | |
(Replace nazev.pkg with the name of the downloaded file.) The installer is not signed,
so when installing by clicking, you must right-click the file → Open. Unpack the archive with
sudo tar -xzf stm8-binutils-gdb-macos-arm64.tar.gz -C /, or without
administrator rights into your own folder and add it to PATH:
1 2 | |
Check (it must print 1):
1 | |
PATH and VS Code
make cgdb and the VS Code extension need stm8-gdb and openocd in
PATH.
Older release
Do not use v15.0.50-stm8.1: its stm8-gdb has no Python and its
stm8-ld writes wrong addresses.
From source¶
The easiest way is the script contrib/build-macos.sh in the repository. It
needs only the Command Line Tools (xcode-select --install) and
Python 3.14 from python.org, not
HomeBrew. It downloads and builds GMP and MPFR itself and makes the same
package as the one in the releases:
1 2 3 | |
By hand, the procedure is similar to
GDB v15.0 on Linux, but you have to install GMP
and MPFR from HomeBrew and pass them to ./configure, use the zlib of the
system (the bundled one does not compile with the new SDK) and give Python
explicitly, because the Command Line Tools have no python3-config:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
Python from HomeBrew (--with-python=$(brew --prefix python)/bin/python3) works too.
Without Texinfo (makeinfo) add MAKEINFO=true to both
make and make install.
cgdb¶
cgdb is in HomeBrew:
1 | |
make cgdb (and make debug) work with it on macOS if stm8-gdb is in
PATH; otherwise cgdb says Debugger "stm8-gdb" not found.
ccls¶
1 | |
Windows¶
I spent a lot of time porting to Windows. But Microsoft throws quite a few obstacles in my way: I get it working — it works, an update comes — and I have to debug yet another problem. It just causes trouble and I have absolutely no motivation to fix it, because I don’t know when Microsoft will break my work again; and I haven’t even tried it on W11. Compilation is terribly slow. So my advice is:
Hint
If you really insist on Windows and have some good reason to use this underdeveloped OS, install VirtualBox and use the pre-prepared installation.
Nevertheless, at the moment it seems that the toolchain is fully functional on Windows too, so if you are brave and don’t mind that compilation is really slow, go for it:
Basic Tools¶
On Windows the easiest way to install is with Chocolatey:
1 | |
If you don’t have Python yet, you can also install Python:
1 | |
Bash is part of the Git package.
On Windows it is also worth setting up Bash a little so it works well with make.
So copy the configuration from .make/bashrc to the home directory.
1 | |
SDCC¶
On Windows the SDCC installation must be done by clicking through the installer. You can download it here: https://sourceforge.net/projects/sdcc/files/sdcc-win64/ and continue in the Windows-favourite way — by clicking. Watch out for version 4.5.0 (see the warning above).
OpenOCD¶
On Windows it is similarly simple thanks to Chocolatey:
1 | |
For the flashing script see OpenOCD flashing script.
STVP¶
The toolchain uses the STVP program for flashing on Windows.
STVP is for Windows only. If you have already installed STVD, you already have STVP installed, because it is part of its installation. It can also be installed separately — without STVD.
stm8-binutils-gdb¶
A ready-made binary package for Windows is available on the
releases page:
the installer stm8-binutils-gdb-windows-x64-setup.exe and the archive
stm8-binutils-gdb-windows-x64.zip with the same content. Just download and
install it.
If you want to compile it yourself, you will find the installation script
contrib/build-windows.sh in the repository
stm8-binutils-gdb.
cgdb¶
I have no verified procedure for Windows. Moreover, I expect that Windows users will rather use the VSCode plugin
ccls¶
Chocolatey does offer a ccls package, but it is old (a 2022 version)
and unusable. Install ccls for Windows from our
releases on GitLab instead.
An alternative is the clangd plugin for VS Code (for VSCodium it is on Open VSX). It also works well (verified 9 Nov 2026): the plugin downloads the required binaries itself.
OpenOCD Flashing Script¶
To enable openocd to do simple flashing, you need to add a
script
that can do it. It is part of the
toolchain (file .make/stm8s-flash.cfg,
make flash uses it, nothing to add). If you use openocd without the
toolchain, add it to the end of the stm8s.cfg configuration file:
1 2 3 4 5 6 7 8 9 10 | |
On Linux the full path might look like this: /usr/share/openocd/scripts/target/stm8s.cfg.
On macOS with HomeBrew most likely $(brew --prefix)/share/openocd/scripts/target/stm8s.cfg.
If you installed on Windows using Chocolatey, it will most likely be this path:
C:\ProgramData\chocolatey\lib\openocd\tools\install\share\openocd\scripts\target\stm8s.cfg.
Historical Solutions¶
The following two tools are more of a historical leftover and in the vast majority of cases you don’t need them. Why they exist at all is described in the article on dead code removal.
SDCC-gas¶
https://github.com/hainguyen8y/sdcc-gas
The project is most likely dead
The original XaviDCR92/sdcc-gas repository has disappeared from GitHub (404),
so I link to a copy by another user (same history, last commit from 10 Nov 2019).
The original page is also preserved in the
Wayback Machine.
More in the separate article.
For everything to work you need to download the source code mentioned above and build it. I do it like this (I use Stow):
1 2 3 4 5 6 7 8 9 10 | |
SDCC-gas also needs stm8-binutils-gdb.
I have not tried building SDCC-gas on macOS or Windows.
sdccrm¶
https://github.com/sealj553/sdccrm
The original repository has disappeared
The XaviDCR92/sdccrm repository has disappeared from GitHub (404) and
development is most likely dead. I therefore link to a working copy by another
user. The original state is also preserved in the
Wayback Machine.
More in the separate article.
You have to build sdccrm from source code. It is a fairly small program with
no dependencies, so it can be compiled easily on Linux and on Windows —
but just in case, a Windows binary is included in the
toolchain
in the file .make/sdccrm.exe.
On Linux:
1 | |
or on macOS:
1 | |
or on Windows:
1 | |
and then just:
1 2 | |