Debugging STM32F407 + FreeRTOS, can't break point other threads

Hi all,

I’m trying to debug some STM32F407 code generated by STM32CubeIDE, that includes FreeRTOS and LwIP. Because it seems to have different behavior when I compile and upload via STM32CubeIDE vs PlatformIO.

But I’m not able to break point in some driver code for LwIP. I think this piece code runs in another thread. I got this error when I try to put breakpoint:

Unable to get thread information: Cannot execute this command while the target is running.
Use the “interrupt” command to stop the target
and then try again. (from thread-info 1)

This is my configuration in platformio.ini:

[env]
platform = ststm32
board = genericSTM32F407VET6
framework = stm32cube
board_build.stm32cube.custom_config_header = yes
board_build.stm32cube.custom_system_setup = yes
board_build.stm32cube.startup_file = startup_stm32f407vgtx.s

platform_packages =
    framework-stm32cubef4 @ https://github.com/lealoureiro/STM32CubeF4.git#v1.27.1-pio

upload_protocol = stlink    

[env:genericSTM32F407VET6_release]
build_type = release
build_flags = -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -DHSE_VALUE=16000000L -fstack-usage -O0 -fdata-sections -MMD -MP -g3


[env:genericSTM32F407VET6_debug]
build_type = debug
debug_tool = stlink
debug_build_flags = -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -DHSE_VALUE=16000000L -fstack-usage -O0 -fdata-sections -MMD -MP -g3 -Og
debug_init_break = tbreak main
debug_init_cmds =
  target extended-remote $DEBUG_PORT
  $INIT_BREAK
  monitor reset halt
  $LOAD_CMDS
  monitor init
  monitor reset halt

Is also notice that STM32CubeIDE uses ST-Link GDB server where PlatformIO uses OpenOCD. Is this related? There is a way to use ST-Link GDB server in PlatformIO?

Same when you first press the pause button and then set the breakpoint?

yes, same issue.

I also noticed this message in the logs:

Info : Unable to match requested speed 2000 kHz, using 1800 kHz
target halted due to debug-request, current mode: Thread 

Might be the reason why the breakpoint on stops on main?