Monday, July 13, 2026

CMakeLists.txt for building STM8 projects with SDCC

A short guide to CMakeLists.txt for building STM8 projects with SDCC.

The goal is to produce two output files: .elf for debugging and .ihx for flashing the chip.

The overall workflow is as follows:
* configure CMake to use SDCC as the build tool
* set the correct compiler and linker options
* build the *.elf
* convert the *.elf into binary data in *.ihx

Next, I go through the key parts in more detail, and at the end you’ll find the complete CMakeLists.txt file. I’ll note upfront: I’m using CMake version 4.2.3, but the solution should also work on relatively newer versions, I haven’t tested older releases.

Wednesday, June 24, 2026

How to Build stm8-binutils-gdb on Ubuntu 26.04 with GCC 15

A few years ago, I set up the toolchain for STM8 development. Back then, simply following the steps in the README was enough to get everything compiled and working out of the box. However, after installing a clean Ubuntu 26.04 along with GCC/G++ 15, I found that compiling stm8-binutils-gdb wasn't as straightforward as it used to be. That is exactly what we will look into today.

The Problem and the Proposed Solution 

Since there is no official .deb package available in the repositories, we have to build the toolchain from source. You can find the project homepage at  https://stm8-binutils-gdb.sourceforge.io, and the source archives are available for download on https://sourceforge.net/projects/stm8-binutils-gdb/files/.

If you simply follow the instructions, the build fails with a compilation error in the readline library, which is required by stm8-gdb. Apparently, it has not been adapted for building with modern GCC v15. On the other hand, readline is available as a .deb package in the repositories. The idea is to avoid building it from source and instead link against the pre-compiled version provided by the repository.However, there are no out-of-the-box configuration flags to achieve this, so we will need to slightly modify the build configuration scripts.