Brussels / 3 & 4 February 2018


The free toolchain for the STM8

Getting into first place when non-free tools had years of head start.

The STM8 is STMicroelectronics' current 8-bit microcontroller architecture. In recent years a free toolchain or the STM8 architecture appeared and quickly surpassed the non-free ones. The central part of the toolchain is the Small Device C Compiler (SDCC), which features some optimizations suited to highly irregular architectures such as the STM8 The talk introduces all parts of the free toolchain for the STM8 and also discusses remaining gaps.

The STM8 is a popular 8-bit architecture by ST Microelectronics commonly used in household electronics, automotive application and industrial controls. For quite a while there were no free tools, and the irregular architecture makes it hard to support in GCC or LLVM. In recent years free tools for it started to appear and now form a free toolchain that surpassed preexisting non-free ones. The most important part is the Small Device C Compiler (SDCC). New tree-decomposition-based algorithms from recent compiler research have been implemented in SDCC, including a new register allocator particularly suited to irregular architectures with few registers. SDCC quickly surpassed the non-free compiler in standard compliance and OS support and generates substantially faster integer code. Programs can be flashed by stcgal (via a serial link on STM8 devices that have a bootloader) and stm8flash (via the SWIM interface of ST-LINK hardware). OpenOCD and GDB allow on-target debugging via the ST-LINK. IDEs complete the development environment. However, stcgal still needs non-free binary blobs for use with some devices and the ST-LINK has non-free firmware. SDCC still falls short in floating-point performance. While there are some ports of free RTOSes that use the free toolchain for the STM8, more would be desirable.


Philipp Klaus Krause