Platformio on visual code debug fails with chinese stlink v2 windows 10

I am new to STM32 and to PlatformIO. I am using Windows 10, Visual Studio Code, STM32F103C8T6 Blue Pill, working Chinese STLINK V2 with last firmware version. I have read several posts about this issue but most of them work on Linux and use openocd. I can perfectly upload and run my program using all these same components. I can’t debug.

This is my platformio.ini:

[env:bluepill_f103c8]
platform = ststm32
board = bluepill_f103c8
framework = stm32cube
upload_protocol = stlink
debug_tool = stlink

;debug_init_cmds =
  ;set CPUTAPID 0x2ba01477
  ;target extended-remote $DEBUG_PORT
  ;$INIT_BREAK
  ;monitor reset halt
  ;$LOAD_CMDS
  ;monitor init
  ;monitor reset halt

upload_flags = -c set CPUTAPID 0x2ba01477

; change MCU frequency
board_build.f_cpu = 72000000L

I always use the upload_flags = -c set CPUTAPID 0x2ba01477 to flash the code, but I have tried the commented lines because they don’t work for me.

Is there a solution for this issue when using Windows 10 and STM32 framework?
Most who solved the problem use Arduino and Linux, e.g.:

This is what the DEBUG CONSOLE shows:

Reading symbols from d:\DATA\Carpetas\PlatformIO-Work\NEW_TIM2_CH1_PWM\.pio\build\bluepill_f103c8\firmware.elf...
done.
PlatformIO Unified Debugger -> bit.ly/pio-debug
PlatformIO: debug_tool = stlink
PlatformIO: Initializing remote target...
xPack Open On-Chip Debugger 0.12.0-01004-g9ea7f3d64-dirty (2023-01-30-15:04)
Licensed under GNU GPL v2
For bug reports, read  openocd.org/doc/doxygen/bugs.html
hla_swd
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
none separate

Info : tcl server disabled
Info : telnet server disabled
Info : clock speed 1000 kHz
Info : STLINK V2J43S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.238650
Warn : UNEXPECTED idcode: 0x2ba01477
Error: expected 1 of 1: 0x1ba01477

.pioinit:13: Error in sourced command file:
---------------------------------------------------------

Could you please guide me to get it to work?
Thank you in advance.

Setting a custom debug server command per Debugging of STM32F103 clone "BluePill" board, wrong idcode - #6 by maxgerhardt should work. A more generalized notation of this would be

debug_server =
  ${platformio.packages_dir}/tool-openocd/bin/openocd
  -s ${platformio.packages_dir}/tool-openocd/scripts
  -f interface\stlink.cfg
  -c "transport select hla_swd"
  -c "set CPUTAPID 0x2ba01477"
  -f target\stm32f1x.cfg
  -c "reset_config none"

Thank you for your reply. Again, I am sorry for my inexperience.
From your 3 possible options, I chose #2:

1. Directly modify the openOCD debug server invocation in the platformio.ini to have the right flags. E.g.

debug_server =
  C:\Users\Maxi\.platformio\packages\tool-openocd\bin\openocd.exe
  -s C:\Users\Maxi\.platformio\packages\tool-openocd\scripts
  -f interface\stlink.cfg
  -c "transport select hla_swd"
  -c "set CPUTAPID 0x2ba01477"
  -f target\stm32f1x.cfg
  -c "reset_config none"

(use adapted path information)

After the addition, my actual corrected platformio.ini is as follows:

[env:bluepill_f103c8]
platform = ststm32
board = bluepill_f103c8
framework = stm32cube
upload_protocol = stlink
debug_tool = stlink

  debug_server =
  c:\Users\Bob\.platformio\packages\tool-openocd\bin\openocd.exe
  -s c:\Users\Bob\.platformio\packages\tool-openocd\openocd\scripts\interface\
  -f interface\stlink.cfg
  -c "transport select hla_swd"
  -c "set CPUTAPID 0x2ba01477"
  -f target\stm32f1x.cfg
  -c "reset_config none"

; change MCU frequency
board_build.f_cpu = 72000000L

======================================

I changed this path to match what I found in the indicated directory.
Now, after a project Clean, the terminal shows the following:

debug_server =
c:\Users\Bob\.platformio\packages\tool-openocd\bin\openocd.exe
-s c:\Users\Bob\.platformio\packages\tool-openocd\openocd\scripts\interface\
-f interface\stlink.cfg
-c "transport select hla_swd"
-c "set CPUTAPID 0x2ba01477"
-f target\stm32f1x.cfg
-c "reset_config none"`. Please use one of `blackmagic, cmsis-dap, jlink, stlink` or `custom`:
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\builder\main.py", line 173:
    env.SConscript("$BUILD_SCRIPT")
  File "C:\Users\Bob\.platformio\packages\tool-scons\scons-local-4.5.2\SCons\Script\SConscript.py", line 598:
    return _SConscript(self.fs, *files, **subst_kw)
  File "C:\Users\Bob\.platformio\packages\tool-scons\scons-local-4.5.2\SCons\Script\SConscript.py", line 285:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "C:\Users\Bob\.platformio\platforms\ststm32\builder\main.py", line 120:
    target_elf = env.BuildProgram()
  File "C:\Users\Bob\.platformio\packages\tool-scons\scons-local-4.5.2\SCons\Util\envs.py", line 242:
    return self.method(*nargs, **kwargs)
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\builder\tools\piobuild.py", line 61:
    env.ProcessProgramDeps()
  File "C:\Users\Bob\.platformio\packages\tool-scons\scons-local-4.5.2\SCons\Util\envs.py", line 242:
    return self.method(*nargs, **kwargs)
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\builder\tools\piobuild.py", line 111:
    env.PrintConfiguration()
  File "C:\Users\Bob\.platformio\packages\tool-scons\scons-local-4.5.2\SCons\Util\envs.py", line 242:
    return self.method(*nargs, **kwargs)
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\builder\tools\pioplatform.py", line 231:
    _get_debug_data(),
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\builder\tools\pioplatform.py", line 195:
    % board_config.get_debug_tool_name(env.GetProjectOption("debug_tool")),
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\platform\board.py", line 126:
    raise DebugInvalidOptionsError(
========================== [FAILED] Took 4.04 seconds ==========================

Could you please guide me and indicate my error?
Thank you.

Try setting debug_tool = custom instead. Also, not sure if this is a copy-paste error or not, but there should be no spaces in front of debug_server.

Dear Maximilian:

Yesterday, I tried to buy an original STlink/V2 bundle from Mouser, Digikey, Newark, Arrow, Allied and a couple more distributors. Nobody has stock. This is the reason I am bothering you and asking for help because in this way I am forced me to use these Chinese fake products. I am sorry for that.
From your last suggestions, please be patient with these long texts:

Option debug_tool = custom
…throws an error on the Debug console:

Reading symbols from d:\DATA\Carpetas\PlatformIO-Work\NEW_TIM2_CH1_PWM.pio\build\bluepill_f103c8\firmware.elf…
done.
PlatformIO Unified Debugger → Redirecting...
PlatformIO: debug_tool = custom
PlatformIO: Initializing remote target…
.pioinit:13: Error in sourced command file:

=================================
Now, again returning to with option:
debug_tool = stlink, the platformio.ini contains the following.
I had to correct the paths in order to point to the files such as stlink.cfg
In my PC, your original suggested paths didn’t work.
This option, also fails.

[env:bluepill_f103c8]
platform = ststm32
board = bluepill_f103c8
framework = stm32cube
upload_protocol = stlink
debug_tool = stlink
debug_server = c:\Users\Bob\.platformio\packages\tool-openocd\bin\openocd.exe-s
c:\Users\Bob\.platformio\packages\tool-openocd\openocd\scripts\interface
-f interface\stlink.cfg
-c "transport select hla_swd"
-c "set CPUTAPID 0x2ba01477"
-f target\stm32f1x.cfg
-c "reset_config none"

===============================
This is what the console shows. Also I attach a picture of what the platformio.ini errors are.
Maybe you can detect something here. I am starting with STM32 chips AND with PlatformIO at the same time. I can’t offer any experience nor wise assumptions here.

Executing task: C:\Users\Bob.platformio\penv\Scripts\platformio.exe run

InvalidProjectConfError: Invalid 'D:\DATA\Carpetas\PlatformIO-Work\NEW_TIM2_CH1_PWM\platformio.ini' (project configuration file): 'Source contains parsing errors: 'D:\\DATA\\Carpetas\\PlatformIO-Work\\NEW_TIM2_CH1_PWM\\platformio.ini'
        [line 20]: '-f interface\\stlink.cfg\n'
        [line 21]: '-c "transport select hla_swd"\n'
        [line 22]: '-c "set CPUTAPID 0x2ba01477"\n'
        [line 23]: '-f target\\stm32f1x.cfg\n'
        [line 24]: '-c "reset_config none"\n''
Traceback (most recent call last):
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\project\config.py", line 99, in read
    self._parser.read(path, "utf-8")
  File "C:\Users\Bob\.platformio\python3\Lib\configparser.py", line 713, in read
    self._read(fp, filename)
  File "C:\Users\Bob\.platformio\python3\Lib\configparser.py", line 1132, in _read
    raise e
configparser.ParsingError: Source contains parsing errors: 'D:\\DATA\\Carpetas\\PlatformIO-Work\\NEW_TIM2_CH1_PWM\\platformio.ini'
        [line 20]: '-f interface\\stlink.cfg\n'
        [line 21]: '-c "transport select hla_swd"\n'
        [line 22]: '-c "set CPUTAPID 0x2ba01477"\n'
        [line 23]: '-f target\\stm32f1x.cfg\n'
        [line 24]: '-c "reset_config none"\n'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\Bob\.platformio\penv\Scripts\platformio.exe\__main__.py", line 7, in <module>
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\__main__.py", line 134, in main
    maintenance.on_platformio_exit()
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\maintenance.py", line 65, in on_platformio_exit
    telemetry.on_exit()
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\telemetry.py", line 177, in on_exit
    TelemetryLogger().send()
    ^^^^^^^^^^^^^^^^^
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\util.py", line 132, in get_instance
    _instances[cls] = cls(*args, **kwargs)
                      ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\telemetry.py", line 78, in __init__
    self._http_session = HTTPSession()
                         ^^^^^^^^^^^^^
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\http.py", line 52, in __init__
    self.headers.update({"User-Agent": app.get_user_agent()})
                                       ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\app.py", line 277, in get_user_agent
    if not get_setting("enable_telemetry"):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\app.py", line 208, in get_setting
    with State() as state:
         ^^^^^^^
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\app.py", line 88, in __init__
    self.path = resolve_state_path("core_dir", "appstate.json")
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\app.py", line 77, in resolve_state_path
    state_dir = ProjectConfig.get_instance().get("platformio", conf_option_dir)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\project\config.py", line 489, in get_instance
    instance = {"mtime": mtime, "config": ProjectConfig(path)}
                                          ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\project\config.py", line 87, in __init__
    self.read(path, parse_extra)
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\project\config.py", line 101, in read
    raise exception.InvalidProjectConfError(path, str(exc)) from exc
platformio.project.exception.InvalidProjectConfError: Invalid 'D:\DATA\Carpetas\PlatformIO-Work\NEW_TIM2_CH1_PWM\platformio.ini' (project configuration file): 'Source contains parsing errors: 'D:\\DATA\\Carpetas\\PlatformIO-Work\\NEW_TIM2_CH1_PWM\\platformio.ini'
        [line 20]: '-f interface\\stlink.cfg\n'
        [line 21]: '-c "transport select hla_swd"\n'
        [line 22]: '-c "set CPUTAPID 0x2ba01477"\n'
        [line 23]: '-f target\\stm32f1x.cfg\n'
        [line 24]: '-c "reset_config none"\n''
Exception ignored in atexit callback: <function _finalize at 0x0000025B4FC66F20>
Traceback (most recent call last):
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\telemetry.py", line 313, in _finalize
    telemetry = TelemetryLogger()
                ^^^^^^^^^^^^^^^^^
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\util.py", line 132, in get_instance
    _instances[cls] = cls(*args, **kwargs)
                      ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\telemetry.py", line 78, in __init__
    self._http_session = HTTPSession()
                         ^^^^^^^^^^^^^
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\http.py", line 52, in __init__
    self.headers.update({"User-Agent": app.get_user_agent()})
                                       ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\app.py", line 277, in get_user_agent
    if not get_setting("enable_telemetry"):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\app.py", line 208, in get_setting
    with State() as state:
         ^^^^^^^
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\app.py", line 88, in __init__
    self.path = resolve_state_path("core_dir", "appstate.json")
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\app.py", line 77, in resolve_state_path
    state_dir = ProjectConfig.get_instance().get("platformio", conf_option_dir)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\project\config.py", line 489, in get_instance
    instance = {"mtime": mtime, "config": ProjectConfig(path)}
                                          ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\project\config.py", line 87, in __init__
    self.read(path, parse_extra)
  File "C:\Users\Bob\.platformio\penv\Lib\site-packages\platformio\project\config.py", line 101, in read
    raise exception.InvalidProjectConfError(path, str(exc)) from exc
platformio.project.exception.InvalidProjectConfError: Invalid 'D:\DATA\Carpetas\PlatformIO-Work\NEW_TIM2_CH1_PWM\platformio.ini' (project configuration file): 'Source contains parsing errors: 'D:\\DATA\\Carpetas\\PlatformIO-Work\\NEW_TIM2_CH1_PWM\\platformio.ini'
        [line 20]: '-f interface\\stlink.cfg\n'
        [line 21]: '-c "transport select hla_swd"\n'
        [line 22]: '-c "set CPUTAPID 0x2ba01477"\n'
        [line 23]: '-f target\\stm32f1x.cfg\n'
        [line 24]: '-c "reset_config none"\n''

 *  The terminal process "C:\Users\Bob\.platformio\penv\Scripts\platformio.exe 'run'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

No, you misunderstood. Only the debug_server line is supposed to not have any spaces in front of it.

Use this exact platformio.ini with no modifications

[env:bluepill_f103c8]
platform = ststm32
board = bluepill_f103c8
framework = stm32cube
; so that upload works
upload_protocol = stlink
upload_flags = -c set CPUTAPID 0x2ba01477 
; so that debug works
debug_tool = custom
debug_server =
  ${platformio.packages_dir}/tool-openocd/bin/openocd
  -s ${platformio.packages_dir}/tool-openocd/scripts
  -f interface\stlink.cfg
  -c "transport select hla_swd"
  -c "set CPUTAPID 0x2ba01477"
  -f target\stm32f1x.cfg
  -c "reset_config none"

Maximilian your last suggestion works.
I find a difference from the previous one in which I had to change paths (erroneous for sure)
${platformio.packages_dir}/tool-openocd/bin/openocd
-s ${platformio.packages_dir}/tool-openocd/scripts

against

c:\Users\Bob.platformio\packages\tool-openocd\bin\openocd.exe-s
c:\Users\Bob.platformio\packages\tool-openocd\openocd\scripts\interface

This eliminated syntax errors marked in red in the platformio.ini file
However, this started a debugger that stops in the first default breakpoint of my main() program.
From there, it fails to stop in further breakpoints and hangs.
The expected orange screen footer never appears and stays light blue as in a release version.


I tested this in 3 different fake Bluepills and 2 different Stlink/V2 fake dongles.
I manage in C language, my program uses DMA for 4 active ADC channels, Systik 1ms interrupt for toggling LED 1/sec , uses SPI for a FRAM memory and prints results in a terminal via UART. This program has been written and run without any debug session, but exporting STM32CubeMX initializer,
It works as expected.
But the debug session likes to stop into the dma low level functions and inside the Systick handler and never returns to the only breakpoint placed after the ADC conversion. Variables are shown as the Call stack pane, but by now the debugger is unusable, as I remember from a first attempt in an Arduino IDE some time ago with a simple program. I such situation, the debugger was predictable and the orange footer was there.

There must be something still missing.
Thank you for this first victory.

Hi, did you tried to update the firmware of ST-link programmer with STM32 ST-LINK Utility software?

Test the debug capabilities in the simplest possible blink project first. This makes it easier to differentiate whether it’s something on the PlatformIO (GDB + OpenOCD + …) side or firmware code side that’s at fault.

Dear Maximilian, here is a small blink project. This project started in STM32CubeMX and generated the necessary .c and .h files. The only addition is strictly your last suggested platformio.ini that now starts a debugger.

The project has a minimum while loop inside main(). The blink action takes place inside the SysTick interrupt c module. A software prescaler decrements a static variable in order to obtain a LED visible frequency. The debugger installs a temporary breakpoint when the program starts. The only user breakpoint is located in the LED toggling line of code.

Everything works fine, every time the GO command is hit, making the program to be stopped precisely inside de SysTick interrupt. The variable is correctly shown in the left window. Changing the position of the breakpoint allows to see how the variable decrements as expected.

However, the screen footer does not change its color to orange, as expected and I could experienced under Arduino framework when I made my first experiment. (I am not returning there).

I could have made a more “professional” program with a delay_ms() function based upon the SysTick interrupt, but this is the simplest it came to mind, ask you asked for. I normally need to debug interrupts in my projects, that are not so naive. But reasonably I understand that you are tracking a problem, so we go down to basics.

What the Debug Terminal shows, mix of yellow and red text:

Summary

Reading symbols from d:\DATA\Carpetas\PlatformIO-Work\Timer Sys Tick interrupt.pio\build\bluepill_f103c8\firmware.elf…
done.
PlatformIO Unified Debugger → pio-debug
PlatformIO: debug_tool = custom
PlatformIO: Initializing remote target…
xPack Open On-Chip Debugger 0.12.0-01004-g9ea7f3d64-dirty (2023-01-30-15:04)
Licensed under GNU GPL v2
For bug reports, read

  • openocd.org
    hla_swd
    0x2ba01477
    Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
    none separate

Info : tcl server disabled
Info : telnet server disabled
Info : clock speed 1000 kHz
Info : STLINK V2J43S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.238650
Info : [stm32f1x.cpu] Cortex-M3 r2p1 processor detected
Info : [stm32f1x.cpu] target has 6 breakpoints, 4 watchpoints
Info : starting gdb server for stm32f1x.cpu on pipe
Info : accepting ‘gdb’ connection from pipe
[stm32f1x.cpu] halted due to debug-request, current mode: Thread
xPSR: 0x61000000 pc: 0x08000a16 msp: 0x20004fd8
Info : device id = 0x20036410
Info : flash size = 128 KiB
0x08000a16 in HAL_RCC_ClockConfig (RCC_ClkInitStruct=0x20000030, FLatency=0) at C:\Users\Bob.platformio\packages\framework-stm32cubef1\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc.c:922
922 if (__HAL_FLASH_GET_LATENCY() != FLatency)
[stm32f1x.cpu] halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08000af4 msp: 0x20005000
Loading section .isr_vector, size 0x10c lma 0x8000000
Loading section .text, size 0xba0 lma 0x800010c
Loading section .rodata, size 0x24 lma 0x8000cac
Loading section .init_array, size 0x4 lma 0x8000cd0
Loading section .fini_array, size 0x4 lma 0x8000cd4
Loading section .data, size 0x10 lma 0x8000cd8
[stm32f1x.cpu] halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08000c48 msp: 0x20005000
Start address 0x8000c48, load size 3304
Transfer rate: 6 KB/sec, 550 bytes/write.
[stm32f1x.cpu] halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08000c48 msp: 0x20005000
[stm32f1x.cpu] halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08000c48 msp: 0x20005000
Temporary breakpoint 1 at 0x8000b6c: file src\main.c, line 74.
PlatformIO: Initialization completed
PlatformIO: Resume the execution to debug_init_break = tbreak main
PlatformIO: More configuration options → pio-debug
Note: automatically using hardware breakpoints for read-only addresses.

Temporary breakpoint 1, main () at src\main.c:74
74 HAL_Init();

Here is the small program:
Timer Sys Tick interrupt.zip

YES.
Al the fake Stlink-V2 debuggers have been FLASHED with the original ST-Link upgrade last version

Dear Maximilian, I would like to add to the simple minimalist program you asked for, the version of the program that fails to debug. Maybe you would like to check it or test it to find where the problem is.
As I said before, this program never switches the footer bar from light blue to orange once F5 id pressed to star the debug session. However, the debugger starts and the program can be single stepped until it reaches the mainloop() function inside the main.c module.

The program, when paused, is always inside the SysTick interrupt handler or the DMA interrupt, in both cases it can be single stepped but never returns to main().

Here is the download link:

Thank you in advance for your opinions.

Hello again I just wanted to close this issue with an autoreply, in order to leave some useful data and share with other people who may experiment a similar problem.

I can’t ask the PlatformIO Community to have enough time to examine my code, so I found the solution by myself. As I am new to this line of processors, I am getting the skills to “know” the machine in a more deeper view.

As I have many years as a programmer and hardware designer, and as the small, simple blink program worked fine and also could be debugged, I must say that I skipped a terribly important fact that produced the problem. My goal was to have some “popular” STM32F103C8T6 interfaces working in the form of .c working modules. This includes SysTick event with a timer module for a “custom” delay_ms() function, and the chance to run some tasks on the same 1ms tick, keyboard, multiplexed LED display, etc.

Also serial asynchronous communications, SPI, and ADC. I am really porting very simple working modules coming from Freescale, Atmel and some other families. My uploaded software has all these features working fine as expected. The other goal is to avoid using HAL as much as possible to reduce overhead.

For the ADC, I picked a YouTube video example using continuous conversion of 4 channels with DMA that use DMA interrupts. This was my fatal error, not considering that a 72MHz clock CPU was continuously converting and ADC/DMA interrupting and storing values in a RAM array at a rate so high that made the ADC/DMA combination not to ever return to the main loop. This happening in the megahertz region !

The solution was to go down to a more simple and conventional code, triggering ADC without DMA conversions as needed in a loop or even inside the SysTick handler call, along with other mentioned useful simple services.

Once fixed the ADC/DMA problem, the program returned to normal and the debugger began to work perfectly in all its features.

I recommend all STM32 newbies to take care with DMA interrupt rates in continuous processes such as ADC conversion with 1.5us conversion time, even with many samples per channel. I am NOT saying not to use DMA, which is such a powerful feature. Just take care at the rate at which interrupts events occur.

So I will report this post as problem SOLVED. However, there is still a detail that I need to resolve concerning that in both PlatformIO installations that I regularly use in separate Windows 10 Pro machines, the light blue status bar at the bottom of the screen remains light blue instead of changing to orange when switching to debug mode. But I will consult if I may open a different post for this issue.

Thank you all for your time and advice !