Custom STM32 board with arduino framework cannot run debugger

Hi,
I know that this is already been discuss a lot of time but I cannot find a precise way to create/place the variant.h and variant.cpp for my board with Arduino Framework.

And I think this is giving me issue with the deugger that is not launching/uploading.

I’ve created a custom board.json in ~/.platformio/boards.
Now to define custom pin definitions to be used like special leds etc. I created the two variant .h and .cpp files. And in board.json I have added the block:

{
  "build": {
    "arduino": {
      "variant_h": "my_variant.h"
    },
    ...
  },
  ....
}

But to make this working I had to put the two .h and .cpp files into the path: ~/.platformio/packages/framework-arduinoststm32/variants/STM32G0xx/G030C(6-8)T/

This does not seem to be the best solution.

My board should only override a generic target so it can share most of the definition file with the generic variant.

So, I’ve managed to have a custom board and its variant into my project forlder so I dont have to edit the framework.

When I try to run the debugger all I get is the build process than it stops without any message no upload.

I have the STLINK connected to SWD pins of the MCU.

Processing my_board(platform: ststm32; board: my_board; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/gtd_daughter.html
PLATFORM: ST STM32 (15.2.0) > MY BOARD V1 G030C8
HARDWARE: STM32G030C8T6 64MHz, 8KB RAM, 64KB Flash
DEBUG: Current (stlink) External (blackmagic, jlink, stlink)
PACKAGES:
 - framework-arduinoststm32 @ 4.20100.211028 (2.1.0)
 - framework-cmsis @ 2.50700.210515 (5.7.0)
 - toolchain-gccarmnoneeabi @ 1.90201.191206 (9.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 17 compatible libraries
Scanning dependencies...
Dependency Graph
|-- Wire @ 1.0
|-- SPI @ 1.0
|-- Adafruit BusIO @ 1.14.1
|   |-- Wire @ 1.0
|   |-- SPI @ 1.0
|-- ArduinoLog @ 1.1.1
Building in debug mode
Checking size .pio\build\my_board\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [===       ]  26.3% (used 2152 bytes from 8192 bytes)
Flash: [========= ]  90.5% (used 59320 bytes from 65536 bytes)
=============================================================== [SUCCESS] Took 8.27 seconds ===============================================================

Environment    Status    Duration
-------------  --------  ------------
my_board       SUCCESS   00:00:08.270
=============================================================== 1 succeeded in 00:00:08.270 ===============================================================

My board is defined as:

{
  "build": {
    "core": "stm32",
    "cpu": "cortex-m0plus",
    "extra_flags": "-DSTM32G0xx -DSTM32G030xx",
    "f_cpu": "64000000L",
    "framework_extra_flags": {
      "arduino": "-D__CORTEX_SC=0"
    },
    "mcu": "stm32g030c8t6",
    "product_line": "STM32G030xx",
    "variants_dir": "variants",
    "variant": "MY_BOARD_V1"
  },
  "debug": {
    "default_tools": [
      "stlink"
    ],
    "jlink_device": "STM32G030C8",
	"openocd_extra_args": [
      "-c",
      "reset_config none"
    ],
    "openocd_target": "stm32g0x",
    "svd_path": "STM32G030.svd"
  },
  "frameworks": [
    "arduino",
    "cmsis",
    "libopencm3",
    "stm32cube"
  ],
  "name": "MY BOARD V1 G030C8",
  "upload": {
    "disable_flushing": false,
    "maximum_ram_size": 8192,
    "maximum_size": 65536,
    "protocol": "stlink",
    "protocols": [
      "blackmagic",
      "dfu",
      "jlink",
      "serial",
	  "stlink"
    ],
	"require_upload_port": true,
    "use_1200bps_touch": false,
    "wait_for_upload_port": false
  },
  "url": "https://www.st.com/content/st_com/en/products/microcontrollers-microprocessors/stm32-32-bit-arm-cortex-mcus/stm32-mainstream-mcus/stm32g0-series/stm32g0x0-value-line/stm32g030c8.html",
  "vendor": "ST"
}

What are the messages in the “Debug Console” tab in VSCode after starting debugging?

No tab is opened. No upload process is started l.

Can you show the a screenshot of VSCode after you press “Start Debugging”?

Uhm after your last comment I’ve managed to get this tab open.
In that It was throwing an error abount pio command not found added to path and now its working!

Thanks a lot for the hint!

It sis throwing an error can I ignore it?

undefinedC:\Users\Hitech95\.platformio\packages\toolchain-gccarmnoneeabi\bin\arm-none-eabi-gdb.exe: warning: Couldn't determine a path for the index cache directory.

I haven’t seen any adverse effects from it.