Re: Anyone managed to get debugging working with IDF 4.1 / VS Code / Windows
Posted: Thu Jan 28, 2021 8:27 am
Sorry I've joined the conversation a bit late. Here is some information with regards to ESP-IDF Debugging in Visual Studio Code.
There is several parts to achieve debug in visual studio code.
The IDF Monitor had a bug in v0.6.0 and it was fixed in v0.6.1
The debug configuration is explained in DEBUGGING.
A lot of settings are used by Visual Studio Code extension to configure things like serial port, IDF Target, openOCD config files, flash baud rate, etc. as shown in SETTINGS
There is a how to use section with steps to start. We recommend to use the ESP-IDF: Create ESP-IDF Project since it will copy the example (not modifying the original example) and add the .vscode folder files (settings.json, launch.json, c_cpp_properties.json) which you can also add these files to the current project with ESP-IDF: Add vscode configuration folder.
Let my try to explain a bit about the parts:
Visual Studio Code uses the launch.json in your current project .vscode/launch.json to know which debug to launch. The ESP-IDF extension contributes the espidf debug adapter to provide ESP-IDF project debug support. A debug adapter is basically a server running in your computer at a given port (the debugPort you configure in launch.json) that allow visual studio code to talk with openOCD and GDB. The setup mode to auto will execute and connect the debug adapter and openOCD in the background; a manual mode will just connect to the configured launch.json debugPort (debugAdapter) and settings.json openocd.tcl.port for openOCD port.
There is an output channel (Menu View -> Output) for openOCD and one for the ESP-IDF debug adapter beside the debug console. You can set logLevel from 0-5 to show more message from debugAdapter and openOCD in the debug console.
There is several parts to achieve debug in visual studio code.
The IDF Monitor had a bug in v0.6.0 and it was fixed in v0.6.1
The debug configuration is explained in DEBUGGING.
A lot of settings are used by Visual Studio Code extension to configure things like serial port, IDF Target, openOCD config files, flash baud rate, etc. as shown in SETTINGS
There is a how to use section with steps to start. We recommend to use the ESP-IDF: Create ESP-IDF Project since it will copy the example (not modifying the original example) and add the .vscode folder files (settings.json, launch.json, c_cpp_properties.json) which you can also add these files to the current project with ESP-IDF: Add vscode configuration folder.
Let my try to explain a bit about the parts:
Visual Studio Code uses the launch.json in your current project .vscode/launch.json to know which debug to launch. The ESP-IDF extension contributes the espidf debug adapter to provide ESP-IDF project debug support. A debug adapter is basically a server running in your computer at a given port (the debugPort you configure in launch.json) that allow visual studio code to talk with openOCD and GDB. The setup mode to auto will execute and connect the debug adapter and openOCD in the background; a manual mode will just connect to the configured launch.json debugPort (debugAdapter) and settings.json openocd.tcl.port for openOCD port.
There is an output channel (Menu View -> Output) for openOCD and one for the ESP-IDF debug adapter beside the debug console. You can set logLevel from 0-5 to show more message from debugAdapter and openOCD in the debug console.