Skip to main content
SDall.11
Associate III
April 12, 2022
Question

Debugging with Visual Studio Code

  • April 12, 2022
  • 4 replies
  • 9165 views

Hi, I hope to don't be off topic.

Usually I use Visual Studio Code and I tried to use it for develop and debug on STM32.

Unfortunately I can't debug my firmware looking at the variables in real time.

I can look them only when I reach a breakpoint.

With STM32CubeIde this function works fine, but with Visual Studio Code doesn't work.

I'm working under linux and I tried gdb and openOCD.

I would like to use Visual Studio Code because I know it pretty well and because STM32CubeIde is too heavy.

Have you any suggestion for me?

Thanks.

Regards.

This topic has been closed for replies.

4 replies

Tesla DeLorean
Guru
April 12, 2022

>>.. too heavy

Made me laugh, not a big Eclipse/STM32CubeIDE user, but Visual Studio always stuck me as an absolute monster, certainly Microchip/ATMEL's abomination, which needed very fast modern CPU's to overcome it's own inertia, and the gravity well it was forming.

I think the ST-LINK (or whatever) will cause a lot of drag if it keeps halting the CPU to stuff memory reading/monitoring into the flow. Perhaps Segger has some better tools?

There are some Team openOCD players on the forum, perhaps there are some settings, or higher clocking options?

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
TDK
Super User
April 12, 2022

Visual Studio Code is different from the Visual Studio you're likely thinking of. Brilliant naming scheme, I know, but VS Code is quite a bit more lightweight.

https://stackoverflow.com/questions/30527522/what-are-the-differences-between-visual-studio-code-and-visual-studio

"If you feel a post has answered your question, please click ""Accept as Solution""."
TDK
Super User
April 12, 2022

> Visual Studio Code

> looking at the variables in real time.

> I'm working under linux

That's a pretty specific niche. Support of Linux in general isn't the greatest and features like live expressions or real time monitoring takes quite a bit of development work that probably hasn't been done for that set of tools.

There are other ways to monitor variables while running. Consider sending out telemetry data via UART or SWO.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Pavel A.
Super User
April 12, 2022

If there's no ready VS Code add-on for live variables, you can make it yourself or motivate somebody else to make it for you. VS Code is a free, opensource software.

mattias norlander
ST Employee
April 13, 2022

Hi,

The following guide written by @Tilen MAJERLE​ deserves mentioning in this context:

https://github.com/MaJerle/stm32-cube-cmake-vscode

Then related to your question about "live data" when using VS Code... I don't think SWV tracing or other mechanisms for live data is supported in VS Code yet.

Maybe you could use VS Code + STM32CubeMonitor + ST-LINK server.

CubeMonitor would extract live data while the debug session is controlled from VS Code debugger? Never tried, but sounds conceptually possible assuming ST-LINK server is used.

Feel free to explore and share your findings!