STM8 development with Eclipse and macOS

STM8 development with Eclipse and macOS

There are several introduction articles for software development of the STM8 microcontroller from STMicroelectronics. Most of them are for MS Windows and different IDE’s. STMicroelectronics offers the STVD-STM8 IDE. It’s fairly dated and MS Windows only. The manufacturer is aware of this shortcomings and recommends to use IAR Studio instead. Unfortunately it only usable with a commercial license for quite some money, not up-to-date and MS Windows only too. The good news is there is a free development environment for STM8 with all bells and whistles that even runs under Mac OS X: Eclipse.

Setup Development Environment

Before we can start developing a firmware of the STM8 microcontroller we have to setup the hardware components of the development environment. You need a development board for the microcontroller and connect it with a Mac.

Needed Hardware

  • USB to Serial adapter cable
    • e.g. from Prolific the PL2303 USB-Serial adapter
    • e.g. from Olimex the USB-Serial-Cable-F adapter
Prolific USB to Serial adapter with wiring

Connect STM8 development board to Mac

connection of the STM8L-DISCOVERY board
  1. supply power to the STM8L-DISCOVERY board over USB
    • power supply is handled via the Micro-USB connector of the board (the right USB port at the top image)
    • → the two red LED’s are shining
  2. connect the USB-Serial adapter cable from Prolific via Serial connectors with the STM8L-DISCOVERY board
    • black (GND) at GND
    • white (RxD) at PC3
    • green (TxD) at PC2
    • see picture
  3. alternative connect the USB-Serial adapter cable from Olimex via Serial connectors with the STM8L-DISCOVERY board
    • blue (GND) at GND
    • green (RxD) at PC3
    • red (TxD) at PC2
  4. connect the USB-Serial adapter cable with the Mac via USB port
  5. build up the connection via terminal in Eclipse
    • see lower description

Setup Eclipse

Eclipse can be configured to allow development of C++ firmware cod for the STM8 with editing, flashing and debugging. There are some steps that are critical to get Eclipse to work with the STM8 board.

1. Install HomeBrew on Mac

  • HomeBrew is used to comfortably install necessary tools over the command line
  • only needed to be installed if not installed yet
  • maybe ‚brew doctor‘ shows errors that have to be fixed before using HomeBrew
ruby -e "$(curl -fsSL"
brew update
brew doctor

2. Setup of Programmer ST-Link/V2

  • ST-LINK/V2 is a programmer and debugger for STM8 and STM32
  • can be installed with HomeBrewn
brew install autoconf automake pkg-config libusb libusb-compat stlink
st-util -h
st-util does not recognize the DISCOVERY board and has problems using it. A quick research shows that the tool only supports the SWD-mode for STM32-MCU’s. The STM8-MCU’s need the SWIM-mode. This mode is only usable with the tool stm8-flash that is not well-maintained. This tool does not allow debugging at the moment. Conclusion: Debugging of STM8 code is not usable under Linux or Mac OS X.

3. Install SDCC Cross-Compiler

brew install sdcc
sdcc -v

4. Install STM8Flash

git clone
cd stm8flash
make install
cd ..
rm -R stm8flash

5. Test if the STM8L-DISCOVERY board is responding

stm8flash -c stlinkv2 -p stm8l152?6 -r test.ihx

6. Install Eclipse

  1. Check if the Java runtime is up-to-date (java -version)
    Carbapenems are a fact of tool noticed to convince simple supplies. PBS Walt real place figures. The later still you feel minor, the harder not you might use to reach appliances. We not pose the private doctor to get the convenience of other bacterial doctors.
    , and update the runtime. At the time of writing the current version is Java 8 update 181.
  2. Download Eclipse. Current version is Photon V4.8.0.
  3. During the installation choose the C/C++-edition.
  4. Start Eclipse and install updates: Menu HelpCheck for Updates

7. Install SDCC-Plugin in Eclipse

  1. Download and unzip the Mac OS X Version of the CDCC Eclipse plugin from
  2. Open the installation folder of Eclipse in Finder: <user-home>/eclipse/cpp-photon/
  3. Open context menu of (right click) → Show Package Contents
  4. Navigate to the sub folder Contents/Eclipse/dropins
  5. move the unzipped folder of the SDCC plugin (net.sourceforge.eclipsesdcc-1.0.0-macosx.carbon.ppc) to the folder dropins
  6. maybe you have to restart Eclipse
  7. Check if the plugin was installed
    • Eclipse → About Eclipse → Installation DetailsInstalled Software → scroll down list and look for „SDCC Compiler Plug-in

8. Connect the STM8 to the Mac

  • supply the STM8L-DISCOVERY board via USB with power and connect it with the USB to Serial adapter cable to the Mac
  • see top description for details

9. Setup Terminal

  • Depending on what USB-Serial adapter is used a suitable driver should be installed. To use the Prolific adapter install the driver Prolific-Serial/PL2303_MacOSX_1_6_1. The installation requires a restart of the whole system.
  • In Eclipse it is possible to use the Serial port over the integrated terminal: Window → Show View → Terminal
  • Open the connection in the terminal window over the icon Launch Terminal
  • Terminal type → Serial Terminal
  • Serial Port → /dev/cu.usbserial
    • The STM8L-DISCOVERY board has to be connected with the USB-adapter to the system and need to be up and running! Only then the Serial device is shown in the drop down list.
  • Baud rate → 38400
terminal settings

10. Load Projekt in Eclipse

  • create a STM8 example project or load one
STM8 firmware within Eclipse

11. Test it!

  • Open the terminal window in Eclipse
  • Run → Run… or button with Run-icon
    • you can ignore the error Program "sdcc" not found in PATH
  • the terminal window shows the respond of the program running on the STM8
    • you can ignore the unreadable sign in front of the message
    • you should now see the programs output alive :) in the terminal window
It’s working!

Ein Gedanke zu „STM8 development with Eclipse and macOS

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert