Add new microcontroller to PlatformIO

Hi
I want to write a program for an STM8S005K6T6C microcontroller using PlatformIO.Is there a way to add STM8S005K6T6C to PlatformIO?

https://github.com/platformio/platform-ststm8/ already exists as a platform and it has a STM8S003 board.

I would just suggest adding a new board definition to that platform, or to your project.

E.g., first copy the regular https://github.com/platformio/platform-ststm8/tree/develop/examples/spl-blink project, then add `boards/stm8s005k6.json" to your project with content

{
  "build": {
    "core": "sduino",
    "extra_flags": "-DSTM8S_006 -DSTM8S005",
    "f_cpu": "16000000L",
    "cpu": "stm8",
    "mcu": "stm8s005f6t6",
    "variant": "standard"
  },
  "debug": {
    "svd_path": "STM8S005K6.svd",
    "openocd_target": "stm8s003"
  },
  "frameworks": [
    "arduino",
    "spl"
  ],
  "upload": {
    "maximum_ram_size": 2048,
    "maximum_size": 32768,
    "protocol": "stlinkv2",
    "protocols": [
      "serial",
      "stlinkv2"
    ]
  },
  "name": "ST STM8S005K6 chip",
  "url": "https://www.st.com/resource/en/datasheet/stm8s005k6.pdf",
  "vendor": "ST"
}

then set the platformio.ini as

[env:stm8s005k6]
platform = ststm8
framework = spl
board = stm8s005k6

Of course, the above values may not all be correct. You have to understand what each of them are doing, or referencing.

  • extra_flags are extra compiler flags, usually -D (definitions) that identify the chip towards the SDK code. You can e.g. see that the example code expects one of these macros to be activated

So essentially, as documented in

https://docs.platformio.org/en/latest/platforms/creating_board.html

Thank you very much for replying to my question maxgerhardt.
I will do the method you advised me and I will tell you the result.