Begginer in platform.io, need help with programming stm8

I found the error. As you can see here, you have a src\main.cpp file

But the implementation of the Arduino framework for STM8 devices is in C (see example). You must rename the file to main.c.

When the file is named main.cpp then PIO will attempt to compile it using the host g++ (which really makes no sense actually, bug…). But then the stm8s.h file will throw an error because of the unsupported compiler (either CSMC, cosmic, raisonance, IAR or SDCC ), and even if that erro would no be there it would be impossible to link because the compiler would produce machine code for the host machine architecture and not the STM8.

But when the file is named main.c the code successfully compiles:

Processing stm8 (platform: ststm8; board: stm8sblue; framework: arduino)
CONFIGURATION: https://docs.platformio.org/page/boards/ststm8/stm8sblue.html
PLATFORM: ST STM8 1.0.1 > ST STM8S103F3 Breakout Board
HARDWARE: STM8S103F3P6 16MHz, 1KB RAM, 8KB Flash
PACKAGES: tool-stm8binutils 0.230.0 (2.30), toolchain-sdcc 1.30804.10766 (3.8.4), framework-arduinoststm8 0.40.181216
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 13 compatible libraries
Scanning dependencies...
No dependencies
sdcc -o .pio\build\stm8\src\main_esp.c.rel -c -mstm8 -DF_CPU=16000000L -DPLATFORMIO=40001 -DSTM8S_BLUE -DSTM8S103 -DARDUINO_ARCH_STM8 -DARDUINO=10802 -Ddouble=float -DUSE_STDINT -D__PROG_TYPES_COMPAT__ -Iinclude -Isrc -IC:\Users\Maxi\.platformio\packages\framework-arduinoststm8\cores\sduino -IC:\Users\Maxi\.platformio\packages\framework-arduinoststm8\STM8S_StdPeriph_Driver\inc -IC:\Users\Maxi\.platformio\packages\framework-arduinoststm8\variants\standard src\main_esp.c
[..]
DATA:    [=         ]   6.8% (used 70 bytes from 1024 bytes)
PROGRAM: [===       ]  30.5% (used 2495 bytes from 8192 bytes)
 [SUCCESS] Took 2.94 seconds 

2 Likes