cancel
Showing results for 
Search instead for 
Did you mean: 

New STM32 VScode launch script

SharonVEC
Associate II

Hello,

With the latest release of the extension (3.6.4), the pre-release version (based on bundle manager) was moved to be the official release, thus making CLT obsolete.

My original launch file (based on CLT) does not work anymore, it included a Debug script, an Attach script, and a build+flash-only script.

To create a compatible launch file, I used the preset script - "STM32Cube: STM32 Launch ST-Link GDB Server" by using vscode's "create a launch.json file" option.

This does work for debugging, but creates a few issues-

a. Doe's not contain an "Attach" option - I could not find any help on the options for configuring the "stlinkgdbtarget" script type.

b. The "Memory Inspector" which is part of the extension pack, does not work anymore with the generated launch file. I get a "No debugger attached" while debugging.

c. The vscode reset debug button does not reset the core anymore - it re-flashes the device.

 

Can anyone help me create a launch file that will contain these features based on the new "stlinkgdbtarget" or some other script type?

It's pretty annoying that the pre-release was pushed to release, while it removes some useful features and also does not include a separate release for the "cube" CLI.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi Sharon,

Sorry I misunderstood.


What you provided, if I understand correctly, is to connect to a running gdb server that is currently connected to the device?


Exactly.

Your use case is the "hot attach".
Here the template for this mode:

{
    "type": "stlinkgdbtarget",
    "request": "launch",
    "name": "STM32Cube: STM32 Launch ST-Link GDB Server",
    "origin": "snippet",
    "cwd": "${workspaceFolder}",
    "serverReset": "None",
    "imagesAndSymbols": [
        {
            "symbolFileName": "${command:st-stm32-ide-debug-launch.get-projects-binary-from-context1}"
        }
    ]
}

 

Note the specific value for:

  • serverReset: set to "None" to avoid resetting the board when you launch the debug session
  • imagesAndSymbols: replace "imageFileName" with "symbolFileName" to load only the symbols
  • runEntry: not required in hot attach mode
  • preBuild: not required in hot attach mode

 

KR,
Flo

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.

View solution in original post

6 REPLIES 6
Cartu38 OpenDev
Lead III

@SharonVEC 
About memory inspector takes care to rely on CDT one. Works for me.
If former (2.x.y) STM32Cube extension end user  you may get x2 installed what maybe confusing. 3.6.x is pulling CDT one and I guess stuff is validated for usage of such.
Cartu38OpenDev_0-1764311134089.png

 

Florent V
ST Employee

Hi Sharon,

About the attach option:
You need to change the value of the "request" attribute to "attach".
By doing this, you will have access only to the attributes related to the attach option with autocompletion.
attach_mode.png
The restart button indeed stops the debug session and restarts it, so it reflashes the target.
However, in the next release, the reset button will be available.
restart_button3.png

Here the template of the debug configuration using attach mode:

{
	"type": "stlinkgdbtarget",
	"request": "attach",
	"name": "STM32Cube: STM32 Launch ST-Link GDB Server",
	"origin": "snippet",
	"cwd": "${workspaceFolder}",
	"preBuild": "${command:st-stm32-ide-debug-launch.build}",
	"runEntry": "main",
	"imagesAndSymbols": [
		{
			"imageFileName": "${command:st-stm32-ide-debug-launch.get-projects-binary-from-context1}"
		}
	],
	"serverHost": "localhost",
	"serverPort": "61234"
}



Kind Regards,
Flo

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.

Thank you for the responses

@Cartu38 OpenDev This indeed was my issue, and the CDT one works fine, thank you!

@Florent V Thanks, but I think the word "attach" was misused in my questions.

What I need is the ability to debug the device without re-downloading and resetting the device, more like "attaching" to the running code on the device.

What you provided, if I understand correctly, is to connect to a running gdb server that is currently connected to the device?

Thanks.

Hi Sharon,

Sorry I misunderstood.


What you provided, if I understand correctly, is to connect to a running gdb server that is currently connected to the device?


Exactly.

Your use case is the "hot attach".
Here the template for this mode:

{
    "type": "stlinkgdbtarget",
    "request": "launch",
    "name": "STM32Cube: STM32 Launch ST-Link GDB Server",
    "origin": "snippet",
    "cwd": "${workspaceFolder}",
    "serverReset": "None",
    "imagesAndSymbols": [
        {
            "symbolFileName": "${command:st-stm32-ide-debug-launch.get-projects-binary-from-context1}"
        }
    ]
}

 

Note the specific value for:

  • serverReset: set to "None" to avoid resetting the board when you launch the debug session
  • imagesAndSymbols: replace "imageFileName" with "symbolFileName" to load only the symbols
  • runEntry: not required in hot attach mode
  • preBuild: not required in hot attach mode

 

KR,
Flo

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.

Hi Florent,
Do You have a time frame for the reset button?
Is there a possibility to have this now (separate lunch script?).
The possibility to do a reset without flashing would reduce the debug time considerably, specially on big projects with external Flash usage.
best regards
Martin

Hi Martin,

 

Per forum policy, I cannot disclose any specific dates.
However, I can confirm that the reset button feature is already part of our codebase and has been successfully validated. It is expected to be included in the next update.

Note that the serverReset attribute is only used to define the type of reset to apply when starting the debug session.

 

The possibility to do a reset without flashing would reduce the debug time considerably, specially on big projects with external Flash usage.

Yes, the reset button is designed for those use cases. It will be available during the debug session. Using the default value (depending on the adapter), there will be nothing to add in the debug configuration (launch script); however, it will always be possible to modify the default behavior of this reset via a quickReset attribute.

KR,
Flo

 

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.