Skip to content
Free US shipping on orders $35+
Order by 3pm ET — ships same-day from the US
Free US shipping on orders $35+
Skip to main content

STM8S + ST-Link V2: Program in Arduino IDE | ShillehTek

April 18, 2026

STM8S + ST-Link V2: Program in Arduino IDE | ShillehTek
Project

Set up Arduino IDE with the Sduino core to program an STM8S dev board using an ST-Link V2 over SWIM, then upload a blink sketch with ShillehTek parts.

1 hr Intermediate1 parts

Project Overview

STM8S + ST-Link V2 programming in Arduino IDE: In this tutorial, you will set up the Arduino IDE to program STM8S microcontroller development boards using the Sduino board package and an ST-Link V2 programmer, then upload a blink sketch over the SWIM interface.

  • Time: 1 to 2 hours
  • Skill level: Intermediate
  • What you will build: A fully configured Arduino IDE environment for programming STM8S dev boards via the ST-Link V2 SWIM interface.
STM8S development board blinking its onboard LED after being programmed using an ST-Link V2 over SWIM
An STM8S dev board running a blink sketch uploaded through the ST-Link V2 programmer.

Parts List

From ShillehTek

External

  • STM8S103F3P6 or STM8S003F3P6 minimum development board - the target microcontroller board
  • STM8S103K3T6 core development board (optional alternative) - a larger STM8 dev board variant
  • Dupont jumper wires - for connecting the ST-Link to the dev board SWIM pins
  • USB cable - to connect the ST-Link V2 to your computer
  • Computer with Arduino IDE installed

Note: The STM8S dev boards run at 3.3V. Some boards can be powered directly from the ST-Link V2 dongle, while others require a separate USB power connection. The ST-Link connects through the SWIM interface pins (RST, SWIM, GND, 3.3V), not through the SWD pins which are for different chip families.

Step-by-Step Guide

Step 1 - Get Familiar with the STM8 Dev Board

Goal: Understand what the STM8S minimal development board is and how it compares to other microcontrollers.

What to do: The STM8S minimal dev boards are compact boards similar in concept to an Arduino Nano. They feature an STM8S microcontroller from STMicroelectronics with 1kB of RAM and 8kB of flash memory for your programs. As an 8-bit processor, it is comparable to an ATtiny or 8051 chip. The boards come in two common variants:

  • STM8S103F3P6 / STM8S003F3P6 - the small board with the built-in LED on pin B5
  • STM8S103K3T6 - the larger board with the built-in LED on pin C3

Both boards have the same specifications and compile with the same programs. They need to be programmed through the SWIM interface pins until a bootloader is added for USB programming.

STM8S103F3P6 minimal development board shown for identifying onboard LED and SWIM programming pins
The STM8S minimal development board - compact and ready for SWIM programming.

Expected result: You understand the STM8S dev board basics and know which LED pin your board uses.

Step 2 - Connect the ST-Link V2 Programmer

Goal: Wire the ST-Link V2 to your STM8 dev board through the SWIM interface.

What to do: The ST-Link V2 is a USB programmer dongle that uploads compiled code to the STM8 chip. Look at the label printed on the programmer and identify the SWIM pins (not the SWD pins which are for other chip families). Connect four wires between the ST-Link and your dev board:

  • RST - Reset
  • SWIM - Single Wire Interface Module (data line)
  • GND - Ground
  • 3.3V - Power (some boards can be powered from the ST-Link)
ST-Link V2 programmer dongle with SWIM and SWD pin labels visible for correct STM8 wiring
The ST-Link V2 programmer - use the SWIM pins (not SWD) for STM8 programming.
ST-Link V2 wired to an STM8 development board using RST, SWIM, GND, and 3.3V connections
Connect RST, SWIM, GND, and 3.3V between the ST-Link V2 and the STM8 board.

Expected result: Your ST-Link V2 is wired to the STM8 dev board and ready for programming.

Step 3 - Add the Sduino Boards Manager URL

Goal: Configure the Arduino IDE to access the Sduino board package for STM8 support.

What to do: Open the Arduino IDE and go to File > Preferences (or press Ctrl+comma). In the Preferences dialog, find the "Additional Boards Manager URLs" field and add the following URL:

https://github.com/tenbaht/sduino/raw/master/package_sduino_stm8_index.json

Also enable "Show verbose output during compilation and upload" by ticking both checkboxes. This will help you see detailed build messages later. Click OK to save your settings.

Arduino IDE Preferences menu path highlighted to open settings before installing the Sduino STM8 core
Open Preferences from the File menu or with the keyboard shortcut Ctrl+comma.
Arduino IDE Preferences showing the Additional Boards Manager URLs field with the Sduino STM8 JSON URL entered
Paste the Sduino JSON URL into the Additional Boards Manager URLs field and click OK.

Expected result: The Sduino board package URL is saved in your Arduino IDE preferences.

Step 4 - Install the Sduino Core and Select Your Board

Goal: Install the Sduino software package and configure the IDE for your STM8 board.

What to do: Go to Tools > Board > Boards Manager. In the search field, type "STM8" and you should see the Sduino package appear. Click Install and wait for the download to complete. This adds all the tools and libraries needed to compile code for STM8 processors.

Arduino IDE Tools menu with Boards Manager highlighted for installing the Sduino STM8 board package
Access Boards Manager through the Tools menu to install new board packages.
Arduino IDE Boards Manager search results showing the Sduino STM8 package ready to install
Search for STM8 in Boards Manager and install the Sduino package.

After installation, go to Tools > Board > STM8S Boards and select the STM8S103F3 Breakout Board.

Arduino IDE board selection menu showing STM8S103F3 Breakout Board selected for Sduino
Select the STM8S103F3 Breakout Board from the STM8S Boards submenu.

Then go to Tools > Programmer and select ST-Link/V2.

Arduino IDE Tools menu showing ST-Link/V2 selected as the programmer for uploading to STM8 over SWIM
Set the programmer to ST-Link/V2 under the Tools menu.
STM8S103F microcontroller pin diagram and technical details used for reference when wiring and coding
Pin layout and technical details of the STM8S103F microcontroller.

Expected result: Sduino is installed, your board is selected as STM8S103F3, and the programmer is set to ST-Link/V2.

Step 5 - Write and Upload a Blink Sketch

Goal: Create a simple blink program and upload it to the STM8 board via the ST-Link V2.

What to do: Create a new sketch in the Arduino IDE and paste the following code. This program configures all GPIO ports as outputs and toggles every IO pin, which will blink the built-in LED on your dev board.

// STM8S blink Sduino ST-Link/V2
void setup() {
  GPIOA->DDR = 0XFF;
  GPIOB->DDR = 0XFF;
  GPIOC->DDR = 0XFF;
  GPIOD->DDR = 0XFF;
  GPIOE->DDR = 0XFF; // all ports output
}
void loop() {
  --GPIOA->ODR;
  GPIOB->ODR++;
  GPIOC->ODR--;
  GPIOD->ODR++;
  GPIOE->ODR--; // toggle all IO ports
  {int n = 20000; while(n-- >0);} // nop loop delay
}

This code uses STM8-specific GPIO register access rather than Arduino's digitalWrite() function. The DDR registers set pin direction (output), and the ODR registers control pin state. The delay is a simple decrement loop; adjust the value of n to change the blink speed.

Upload the sketch normally using the Upload button. The Arduino IDE knows to use the ST-Link V2 based on your programmer selection. You can also use Sketch > Export Compiled Binary to generate a .hex file for manual uploading.

Arduino IDE Sketch menu showing Upload and Export Compiled Binary options for STM8 Sduino projects
Upload your sketch normally or export the compiled binary as a .hex file.
STM8 development board blinking LED indicating a successful firmware upload using ST-Link V2
Success - the built-in LED blinks after uploading the sketch via ST-Link V2.

Expected result: The sketch uploads successfully and the built-in LED on your STM8 board blinks.

Step 6 - Understand the Toolchain Behind the Scenes

Goal: Learn what software components make the Sduino build process work.

What to do: When you installed the Sduino package, it added several key components to your Arduino IDE. Since you enabled verbose output, you can inspect the build messages to understand what happens during compilation and upload.

SDCC (Small Device C Compiler): Instead of the GCC compiler used for AVR Arduinos, Sduino uses SDCC to compile your code into a .hex file. SDCC supports multiple 8-bit architectures including 8051, PIC, and STM8 processors.

Arduino IDE verbose output showing SDCC compilation commands while building an STM8 sketch
Verbose build output reveals the SDCC compiler and toolchain at work.
SDCC Small Device C Compiler interface used by Sduino to compile STM8 code
SDCC - the Small Device C Compiler that builds your STM8 programs.

Standard Peripheral Library (SPL): Sduino gives you access to STMicroelectronics' open-source SPL, which provides hardware abstraction functions for all STM8 peripherals. You can include any SPL file in your projects and reuse them with other development tools as well.

STM8 Standard Peripheral Library file list showing peripheral driver source files
The Standard Peripheral Library provides ready-made peripheral drivers for STM8 chips.
STM8 microcontroller family lineup showing different model numbers and specifications
The STM8 product line includes many model variants with similar specifications.

stm8flash: The firmware upload is handled by the stm8flash utility. In the verbose upload output, you can see it being called with the circuit type (stlinkv2) and target part (stm8s103) to transfer your compiled .hex file to the chip.

Verbose upload output showing stm8flash transferring a compiled HEX file to an STM8 via stlinkv2
The stm8flash utility handles the actual firmware transfer to the STM8 chip.
Arduino IDE upload verbose output showing the full stm8flash command and successful write to stm8s103
Full upload output - stm8flash writes the .hex file via stlinkv2 to stm8s103.

A note on bootloaders: You may notice a "Burn Bootloader" option in the Tools menu. For STM8 boards with limited flash memory, burning a bootloader is generally not recommended. Bootloader programs allow USB programming but consume precious flash space on these small chips.

Expected result: You understand that Sduino uses SDCC for compilation, SPL for peripheral access, and stm8flash for uploading firmware via the ST-Link V2.

Conclusion

You set up the Arduino IDE to program STM8S microcontrollers using the Sduino board package and an ST-Link V2 programmer. You connected the SWIM interface, installed and selected the correct board and programmer settings, and uploaded a blink sketch that toggles GPIO pins. You also learned how SDCC, SPL, and stm8flash work together behind the scenes.

Want the exact parts used in this build? Grab them from ShillehTek.com. If you want help customizing this project or building something for your product, check out our IoT consulting services.

Credits

All photos and images in this tutorial are credited to Patrick Fitzgerald on Hackster.io. The original guide served as the reference for this ShillehTek version. We thank them for their excellent work in the maker community.