cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot start debug on vs code

zagoda
Visitor

I am on a Mac, I have generated my project for stm32g0b1rct6 using cubemx and I ran setup STM32Cube project(s) tool within vscode with all 3 options (CLANG, CLANG_GCC, GCC) and whenever I try to run debug, I get time out error: bound doStepConnectToTarget Failed: could not connect: Operation timed out.

 

I am working on a fresh VSCode profile where only the following extensions are installed: 

zagoda_0-1766398438913.png

 

 

Here is the verbose output from my debug console: 

 

From client: initialize({"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"stlinkgdbtarget","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en","supportsProgressReporting":true,"supportsInvalidatedEvent":true,"supportsMemoryReferences":true,"supportsArgsCanBeInterpretedByShell":true,"supportsMemoryEvent":true,"supportsStartDebuggingRequest":true,"supportsANSIStyling":true})
To client: {"seq":0,"type":"response","request_seq":1,"command":"initialize","success":true,"body":{"supportsEvaluateForHovers":true,"supportsConfigurationDoneRequest":true,"supportsSetVariable":true,"supportsConditionalBreakpoints":true,"supportsHitConditionalBreakpoints":true,"supportsLogPoints":true,"supportsFunctionBreakpoints":true,"supportsDisassembleRequest":true,"supportsReadMemoryRequest":true,"supportsWriteMemoryRequest":true,"supportsSteppingGranularity":true}}
From client: launch({"type":"stlinkgdbtarget","request":"launch","name":"STM32Cube: STM32 Launch ST-Link GDB Server","origin":"snippet","cwd":"/Users/hasanayan/source/midibits/firmware/app2","preBuild":"${command:st-stm32-ide-debug-launch.build}","runEntry":"main","verbose":true,"imagesAndSymbols":[{"imageFileName":"/Users/hasanayan/source/midibits/firmware/app2/build/Debug/app.elf"}],"__configurationTarget":6,"__sessionId":"bd3573a8-66d6-4bf4-8e88-febebb423231"})
From Debug Session: start Launch Sequence
From Debug Session: Step pre-build
From Debug Session: Step validate debug configuration
From Debug Session: Step ST-Link device check
From Debug Session: Step start STLink GDB Server
GDB Server command line executed: cube stlink-gdbserver -cp /Users/hasanayan/Library/Application Support/stm32cube/bundles/programmer/2.21.0/bin -k -d -m 0 -p 61234 -l 1
From Debug Session: Step check genuine ST device
From Debug Session: Step start RTOS Proxie(s)
From Debug Session: Step start gdb client debug
To client: {"seq":0,"type":"event","event":"output","body":{"category":"server","output":"\n\nSTMicroelectronics ST-LINK GDB server. Version 7.12.0\nCopyright (c) 2025, STMicroelectronics. All rights reserved.\n\nStarting server with the following options:\n        Persistent Mode            : Disabled\n        Logging Level              : 1\n        Listen Port Number         : 61234\n        Status Refresh Delay       : 15s\n        Verbose Mode               : Disabled\n        SWD Debug                  : Enabled\n        InitWhile                  : Enabled\n\n"}}

STMicroelectronics ST-LINK GDB server. Version 7.12.0
Copyright (c) 2025, STMicroelectronics. All rights reserved.

Starting server with the following options:
        Persistent Mode            : Disabled
        Logging Level              : 1
        Listen Port Number         : 61234
        Status Refresh Delay       : 15s
        Verbose Mode               : Disabled
        SWD Debug                  : Enabled
        InitWhile                  : Enabled

GDB notify async: thread-group-added,id="i1"
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"GNU gdb (GNU Tools for STM32 14.3.rel1.20251027-0700) 15.2.90.20241229-git\n"}}
GNU gdb (GNU Tools for STM32 14.3.rel1.20251027-0700) 15.2.90.20241229-git
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"Copyright (C) 2024 Free Software Foundation, Inc.\n"}}
Copyright (C) 2024 Free Software Foundation, Inc.
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law."}}
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"\nType \"show copying\" and \"show warranty\" for details.\n"}}

Type "show copying" and "show warranty" for details.
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"This GDB was configured as \"--host=aarch64-apple-darwin --target=arm-none-eabi\".\n"}}
This GDB was configured as "--host=aarch64-apple-darwin --target=arm-none-eabi".
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"Type \"show configuration\" for configuration details.\n"}}
Type "show configuration" for configuration details.
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"For bug reporting instructions, please see:\n"}}
For bug reporting instructions, please see:
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"<https://www.gnu.org/software/gdb/bugs/>.\n"}}
<https://www.gnu.org/software/gdb/bugs/>.
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"Find the GDB manual and other documentation resources online at:\n    <"}}
Find the GDB manual and other documentation resources online at:
    <To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"http://www.gnu.org/software/gdb/documentation/>.\n\n"}}
http://www.gnu.org/software/gdb/documentation/>.

To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"For help, type \"help\".\n"}}
For help, type "help".
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"Type \"apropos word\" to search for commands related to \"word\".\n"}}
Type "apropos word" to search for commands related to "word".
GDB command: 0 -gdb-set non-stop off
GDB result: 0 done
GDB command: 1 -gdb-set mi-async on
GDB result: 1 done
From Debug Session: Step load program
GDB command: 2 -file-exec-and-symbols "/Users/hasanayan/source/midibits/firmware/app2/build/Debug/app.elf"
GDB result: 2 done
From Debug Session: Step load symbols (STLink adapter)
GDB command: 3 -enable-pretty-printing
GDB result: 3 done
From Debug Session: Step load symbols /Users/hasanayan/source/midibits/firmware/app2/build/Debug/app.elf (STLink adapter)
GDB command: 4 add-symbol-file "/Users/hasanayan/source/midibits/firmware/app2/build/Debug/app.elf"
To client: {"seq":0,"type":"event","event":"output","body":{"category":"log","output":"add-symbol-file \"/Users/hasanayan/source/midibits/firmware/app2/build/Debug/app.elf\" \n"}}
add-symbol-file "/Users/hasanayan/source/midibits/firmware/app2/build/Debug/app.elf"
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"add symbol table from file \"/Users/hasanayan/source/midibits/firmware/app2/build/Debug/app.elf\"\n"}}
add symbol table from file "/Users/hasanayan/source/midibits/firmware/app2/build/Debug/app.elf"
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"(y or n) [answered Y; input not from terminal]\n"}}
(y or n) [answered Y; input not from terminal]
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"Reading symbols from /Users/hasanayan/source/midibits/firmware/app2/build/Debug/app.elf...\n"}}
Reading symbols from /Users/hasanayan/source/midibits/firmware/app2/build/Debug/app.elf...
GDB result: 4 done
From Debug Session: Step connect to target
GDB command: 5 -target-select remote localhost:61234
GDB result: 5 error,msg="could not connect: Operation timed out."
From Debug Session: Step cleanup Gdb Client.
GDB command: 6 -gdb-exit
From Debug Session: Step cleanup GDB Server
GDB result: 6 exit
To client: {"seq":0,"type":"event","event":"output","body":{"category":"server","output":"cube is killed by signal SIGTERM"}}
cube is killed by signal SIGTERMTo client: {"seq":0,"type":"response","request_seq":2,"command":"launch","success":false,"message":"bound doStepConnectToTarget Failed: could not connect: Operation timed out.","body":{"error":{"id":1,"format":"bound doStepConnectToTarget Failed: could not connect: Operation timed out.","showUser":true}}}

 

And here is my launch.json

 

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "type": "stlinkgdbtarget",
      "request": "launch",
      "name": "STM32Cube: STM32 Launch ST-Link GDB Server",
      "origin": "snippet",
      "cwd": "${workspaceFolder}",
      "preBuild": "${command:st-stm32-ide-debug-launch.build}",
      "runEntry": "main",
      "verbose": true,
      "imagesAndSymbols": [
        {
          "imageFileName": "${command:st-stm32-ide-debug-launch.get-projects-binary-from-context1}"
        }
      ]
    }
  ]
}

 

2 REPLIES 2
Cartu38 OpenDev
Lead III

@zagoda is your target device seen ?

Cartu38OpenDev_0-1766400041567.png

 

Yeah that was working fine. I opened up cube programmer and tried to connect there that wouldn't connect either. I was getting DEV_TARGET_HELD_UNDER_RESET error. I don't know why this happens but my project works on a UART connected mesh and my development boards (my pcb) are connected to each other during development and debugging. I disconnected them from each other, connected to them one by one and performed full chip erase and now they work fine. I face similar quirks from time to time and after full chip erase it goes back to normal for a good while. Could it be that my firmware is preventing the debugger to connect? Do you know a solution for this? Should I add a delay before my program starts if I am in Debug configuration to let the debugger connect?