cancel
Showing results for 
Search instead for 
Did you mean: 

ST-Link can't connect in VSCode using ST-Link GDB server; but OK in Keil

Austin_Jia
Associate

屏幕截图 2026-05-27 204853.png

6 REPLIES 6
LaurentL
ST Employee

Hello,

In the debug console text, can you check that the STLINK Firmware is not outdated and needs to be upgraded.

Or check if you see any error message.

Rgds,

Laurent

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Andrew Neil
Super User

Welcome to the forum

Please see How to write your question to maximize your chances to find a solution for best results.

In particular:

  • What STM32 device are you using?
  • What board?
  • What ST-Link?

Note that both a clone STM32 and a clone ST-Link could cause this type of thing - see:

Blue pill (STM32F1) programs OK via Arduino IDE but not Keil. Chip ID:0x2BA01477

How to recognize a genuine ST-LINK/V2 versus a cloned one

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
luiscoelho23
Associate

I had a similar problem, solved it with :

"serverPort": 50000 (configuration launch.json)
Andrew Neil
Super User

@Austin_Jia wrote:
AndrewNeil_0-1780063616248.png

Could you translate the rest of that message (the bit after "(error138):") to English, please?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

Yes, not sure about the non-english portion of the error but I just had a very similar problem and changing the port fixed it. This not too useful error message is exactly what you will get if the stlink gdb server fails to open the port it wants, which by default is 61234 and 61235. which just happen to be in a range windows will assign at random for a variety of things. 


@Nate42 wrote:
AndrewNeil_0-1780933742801.png

It seems that "tried to join a drive to a directory on a joined drive" is a generic thing that GDB says when pretty much anything goes wrong.

I see it when the connection fails because my target is not powered up, and when I've forgotten to connect  the ST-Link.

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.