Skip to main content
Mohan1
Associate III
January 14, 2020
Solved

How can I remove error like 'Waiting for debugger connection... Debugger connected Debugger connection lost. Shutting down...'

  • January 14, 2020
  • 14 replies
  • 11274 views

I am generating code using STM32CubeIDE, but when I start to debug I am getting errors like:

"STMicroelectronics ST-LINK GDB server. Version 5.2.3

Copyright (c) 2019, 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

Waiting for debugger connection...

Debugger connected

Debugger connection lost.

Shutting down..."

I am using the latest version of st-link USB driver(en.stsw link009). Also I am using USB to TTL converter. Initially everything was working very well, near about ten code executed successfully. But now facing the above error. So how can I solve it?

This topic has been closed for replies.
Best answer by mattias norlander

We have seen issues with a few number of devices that the user is forced to perform a mass erase before being able to flash a new bianry. This is obviously a bug and we try to fix it for the next version. If you do run into this problem with CubeIDE and ST-LINK GDB server then you can try to add the following to force a mass erase before programming the new binary:

In your debug configuration > Startup tab > Initialization commands > Add: monitor flash mass_erase

This will force CubeProgrammer_CLI version to peform a mass erase before programming new content. At least it automates the procedure you describe @GNels.2​ in your post above.

Other issues leading to debugger connection lost after the initial launch of your application typically includes:

  • Device goes into low-power mode without being configured to allow debug.
  • The application re-assigns the SWD related IO pins to some other function

14 replies

paul19
Associate III
May 11, 2021

Got the same problem. @mattias norlander​'s solution didn't work for me, but @AT.1revisan​ 's one did.

Here is what I did exactly (source at https://www.st.com/resource/en/user_manual/dm00613038-stm32cubeide-stlink-gdb-server-stmicroelectronics.pdf, page 8):

  1. Download and install STM32CubeProgrammer from https://www.st.com/en/development-tools/stm32cubeprog.html
  2. Run STM32CubeProgrammer
  3. Click "Connect" (top right green button)
  4. Click the bottom left eraser icon

Done. After that STM32CubeIDE could run and debug my program correctly.

mt95
Visitor II
June 19, 2021

I followed precisely these steps and it worked for me. Thank you for guiding through them, @paul19​! (the solution by @mattias norlander​  unfortunately also didn't work for me)

I can at last start with my brand new Nucleo board after a day of frustration and looking for solutions.

MDe V.3
Visitor II
May 28, 2021

I had the same problem.

I tried adding "monitor flash mass_erase" to the debug configuration, as suggested above, without solving the error.

But,

I opened a new project on CubeIDE, just an empty project.

I loaded it onto the MCU and it removed the error.

Going back to my original project the problem disappeared.

That's my 2 cents.

Mauro

ypiotrp
Associate III
August 12, 2021

I had the same issue with my STM32L071. The problem turned out to be with flash memory address in linker script. I accidentally changed it to 0x80000000, when it supposed to be 0x08000000. That's why the debugger couldn't flash the MCU with my program. Hope it helps someone.

surendra.bitwerks
Visitor II
September 30, 2021

I guess this problem is connected with DMA. ( If you enable DMA such issues are coming.)