Debugging by Blackmagic probe error

I have the latest PlatformIO and I can Upload firmware to the bluepill but when debugging I get the following error:

undefinedError: Traceback (most recent call last):
  File "/Users/engmoh/.platformio/penv/lib/python3.8/site-packages/platformio/__main__.py", line 109, in main
    cli()  # pylint: disable=no-value-for-parameter
  File "/Users/engmoh/.platformio/penv/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/Users/engmoh/.platformio/penv/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/Users/engmoh/.platformio/penv/lib/python3.8/site-packages/platformio/commands/__init__.py", line 44, in invoke
    return super(PlatformioCLI, self).invoke(ctx)
  File "/Users/engmoh/.platformio/penv/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/engmoh/.platformio/penv/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/engmoh/.platformio/penv/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/Users/engmoh/.platformio/penv/lib/python3.8/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/engmoh/.platformio/penv/lib/python3.8/site-packages/platformio/commands/debug/command.py", line 117, in cli

        server_executable = debug_options["server"]["executable"].lower()
TypeError: 'NoneType' object is not subscriptable

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

An unexpected error occurred. Further steps:

* Verify that you have the latest version of PlatformIO using
  `pip install -U platformio` command

* Try to find answer in FAQ Troubleshooting section
  https://docs.platformio.org/page/faq.html

* Report this problem to the developers
  https://github.com/platformio/platformio-core/issues

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

What could be the issue?

What’s the full platformio.ini and minimal code that you’re using?

If I go to the code location where the error occurs (line 117 of .platformio/penv/lib/python3.8/site-packages/platformio/commands/debug/command.py according to your log), the code looks different. It looks like so: platformio-core/command.py at v5.1.1 · platformio/platformio-core · GitHub

Do you have more than one PlatformIO installation? Or did you modify some files?

Uploading code with a Black Magic Probe built for the CMSIS framework to a Blue Pill (see https://stackoverflow.com/questions/66684660/debugging-with-blackmagic-probe-and-platformio-undefinederror) works for me.

,ini
This is the platformio.ini configuration:

[env:bluepill_f103c8]
platform = ststm32
board = bluepill_f103c8
framework = cmsis
board_build.mcu = stm32f103c8t6                 ; change microcontroller (override)
board_build.f_cpu = 8000000L                    ; change MCU frequency   (override)
upload_protocol = blackmagic                    ; SWD interface
debug_tool = blackmagic
debug_port = /dev/tty.usbmodem7BBB54AD1
upload_port = /dev/tty.usbmodem7BBB54AD1 

This is the ini …

This is the minimal code , used to work before!

#include "stm32f1xx.h"
#include <stdio.h>


//? ========= PROTOTYPES ===========
void portsInit(void);
void delay(uint32_t delay);


int main(void)
{
    portsInit();
    //sprintf("Size of an \"int\" is %u byte(s).", sizeof(int));      // %u is used for unsined integers
    while(1)
    {
        GPIOC->ODR ^= GPIO_ODR_ODR13_Msk;
        delay(50000);
        
        GPIOC->ODR ^= GPIO_ODR_ODR13_Msk;
        delay(50000);
    }
}


void portsInit(void)
{
    //* Enable clock to port "A" and "B" (Default SysCLK = 8Mhz ext. OSC):
    RCC->APB2ENR |= ((1<<2) | (1<<3) | (1<<4));

    //* Set Pin Modes and Pin Configuration. (Reset Value = 0x4444 4444):
    
    //! Setting Mode for Pin PB11 MODE[1:0], "Bit1" of the MODE register = 1 and "Bit0" = 1
    GPIOB->CRH |= GPIO_CRH_MODE11_Msk;           // Set PB11 MODE as Output @ 50Mhz (max).  
    //! Setting Configuration for Pin PB11 CNF[1:0]
    GPIOB->CRH &= ~(GPIO_CRH_CNF11_Msk);
    /*
        * Final GPIOB->CRH register must equal 0b 0011 0100 0100 0100 or 0x3444,
        * to set pb11 pin as an Output MODE @ 50Mhz configured as General purpose
        * output push-pull configuration.
    */
    
    //! Setting Mode for Pin PB10 MODE[1:0], "Bit1" of the MODE register = 1 and "Bit0" = 1
    GPIOB->CRH |= GPIO_CRH_MODE10_Msk;           // Set PB11 MODE as Output @ 50Mhz (max).  
    //! Setting Configuration for Pin PB11 CNF[1:0]
    GPIOB->CRH &= ~(GPIO_CRH_CNF10_Msk);

    GPIOC->CRH |= GPIO_CRH_MODE13_Msk;           // Set PC13 MODE as Output @ 50Mhz (max).  
    //! Setting Configuration for Pin PC13 CNF[1:0]
    GPIOC->CRH &= ~(GPIO_CRH_CNF13_Msk);

}// End portsInit() Function.

void delay(uint32_t delay)
{
    for(uint32_t i = 0; i < delay; i++)
    {
        __asm__("nop");
        //! LOOP DOING NOTHING WASTING TIME (PSUDO-DELAY)
    }
}
,,,

I have one installation of VScode and platformio… I haven’t modified any file but the STlink.cfg configuration file (Or i can’t really remmeber the name) in the openOCD folder to allow non original boards STM32 MCUs to get debugged using openocd.

It used to work before.

There seems to be some extreme duplication going on with this post. It’s posted

They all declare the same debug_port = /dev/tty.usbmodem7BBB54AD1 so thus I assume it’s the same author.

The latter link confirmed that this was a bug in the STM32 platform code and is now fixed in the dev branch – have you tried that?