Begginer in platform.io, need help with programming stm8

I have a lot of experience with arduino ide and i just discovered platform io and i have a few problems with it, i don’t know how to find the examples, select the upload port…, and when i try to program the stm8 it just gives me errors and i dont?know what they even mean, so can someone explain me the basics of platform io and where are the different options located (upload port, baud rate, examples…) and how to fix the errors while programming stm8 and also what are the recommended packages to install and where to use platform io (atom or VScode)

errors in atom:

[.pio\build\stm8sblue\src\main.cpp.rel] Error 1

[.pio\build\stm8sblue\libFrameworkArduinoVariant.lib] Error 309

warnings in atom:

C:\Users-markonjak-.platformio\packages\framework-arduinoststm8\cores\sduino\HardwareSerial.c:38:2: warning: #warning “using uart1 for HardwareSerial”

C:\Users-markonjak-.platformio\packages\framework-arduinoststm8\cores\sduino\WInterrupts.c:73: warning 85: in function attachInterrupt unreferenced function argument : ‘mode’

Okay so first of all we’re going to need to be able to reproduce your error. What main.cpp and platformio.ini do you have? Are all packages up to date?

That’s what the documentation is for.

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