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.
Anyone managed to get debugging working with IDF 4.1 / VS Code / Windows
-
- Posts: 229
- Joined: Wed May 02, 2018 12:12 pm
Re: Anyone managed to get debugging working with IDF 4.1 / VS Code / Windows
@Brian Thanks for your reply. Although I did not try it again yet, it explained part of my confusion, There are many references to the "ESP debug adapter" after your explanation I became aware this refers to a software adapter and not to the ESP USB JTAG adapter board. Probably it might save some confusion if the "JTAG debugging - overview" diagram will be updated and includes the "ESP debug adapter" as well (and showing for each part in the diagram whether it is software or hardware ) Probably also adding information about the communication channels/protocols (e.g. TCP port numbers)
What I am actually missing is a step by step explanation, which starts at VS code install end ending with a JTAG debug session of the blink example (including breakpoint)
You also mentioned the following:
What I am actually missing is a step by step explanation, which starts at VS code install end ending with a JTAG debug session of the blink example (including breakpoint)
You also mentioned the following:
It is not so obvious for me, How do I change the loglevel via the debug console ?You can set logLevel from 0-5 to show more message from debugAdapter and openOCD in the debug console.
-
- Posts: 229
- Joined: Wed May 02, 2018 12:12 pm
Re: Anyone managed to get debugging working with IDF 4.1 / VS Code / Windows
In your project's directory .vscode/launch.json you can add an extra field called logLevel and set to 0-5 as shown in DEBUGGING documentation.
With regards to documentation, we keep updating the docs to better describe all features but definitely need to clarify this better. Thanks.
At some time we will release more materials explaining how to use the extension and features.
With regards to documentation, we keep updating the docs to better describe all features but definitely need to clarify this better. Thanks.
At some time we will release more materials explaining how to use the extension and features.
Re: Anyone managed to get debugging working with IDF 4.1 / VS Code / Windows
I gave it again a try with increased logging information and an updated openOCD to v0.10.0-esp32-20201202
- OpenOCD detects the ESP32
- When starting a debug session:
- OpenOCD detects the ESP32
- When starting a debug session:
2021-02-21 09:40:24,081 - Debug Adapter (main) - INFO - Listening on port 43474
DEBUG_ADAPTER_READY2CONNECT
2021-02-21 09:40:24,081 - Debug Adapter (main) - CRITICAL - Debug adapter -> Extension: DEBUG_ADAPTER_READY2CONNECT
2021-02-21 09:40:24,381 - Gdb - INFO - NOTIFY: thread-group-added {'id': 'i1'}
2021-02-21 09:40:34,464 - Gdb - INFO - CONS: 'Ignoring packet error, continuing...\\n'
2021-02-21 09:40:34,465 - Debug Adapter (main) - ERROR - Failed to wait for completion of command "-target-select remote 127.0.0.1:3333" / 10!
Is thre a mismatch between GDB and OpenOCD ?2021-02-21 09:51:18,067 - Gdb - DEBUG - RESULT: done None
2021-02-21 09:51:18,067 - Gdb - DEBUG - Connecting to 127.0.0.1:3333
2021-02-21 09:51:18,067 - Gdb - DEBUG - MI->: -target-select remote 127.0.0.1:3333
2021-02-21 09:51:28,068 - Gdb - DEBUG - MI<-:
[{'message': None,
'payload': 'Ignoring packet error, continuing...\\n',
'stream': 'stdout',
'type': 'console'},
{'message': None,
'payload': 'warning: unrecognized item \\"timeout\\" in \\"qSupported\\" '
'response\\n',
'stream': 'stdout',
'type': 'log'}]
2021-02-21 09:51:28,068 - Gdb - INFO - CONS: 'Ignoring packet error, continuing...\\n'
2021-02-21 09:51:28,068 - Gdb - DEBUG - LOG: 'warning: unrecognized item \\"timeout\\" in \\"qSupported\\" response\\n'
2021-02-21 09:51:28,069 - Debug Adapter (main) - ERROR - Failed to wait for completion of command "-target-select remote 127.0.0.1:3333" / 10!
Traceback (most recent call last):
Re: Anyone managed to get debugging working with IDF 4.1 / VS Code / Windows
Hi Bignacio, Can I rewind this post a bit. I have been developing my project from the terminal (but coding in VSCode): it all works fine. But I want to use this plugin to debug. Having installed the ESP-IDF plugin, I can run up a demo project. I imagine I just need to copy across the .vcsode folder, and I'd be able to run my project too - is that so.ESP_bignacio wrote: ↑Wed Feb 03, 2021 9:34 amAt some time we will release more materials explaining how to use the extension and features.
My main question is how do I debug. I have a WROVER devkit with built in JTAG which I bought expressly for this purpose. I need some step by step to get this to work... Thanks.
monkey
-
- Posts: 229
- Joined: Wed May 02, 2018 12:12 pm
Re: Anyone managed to get debugging working with IDF 4.1 / VS Code / Windows
Hi @espdorian well it seems that the debug adapter can't connect to your openOCD session. Are you sure openOCD is running locally on port 3333 ?
Hey @monkey I have yet to prepare a video material but basically:
1) Make sure you install the extension and execute the ESP-IDF: Configure ESP-IDF extension command. This will install/use existing ESP-IDF, ESP-IDF Tools and create a python virtual environment with all required python packages.
2) Create a project from ESP-IDF: Show examples projects or ESP-IDF: Create project which will include .vscode directory.
3) Select your serial port. Build and flash your project.
4) If you didn't change /your_project_dir/.vscode/launch.json just pressing F5 will launch openOCD and the debug Adapter eventually launching a debug session.
If you have any error at any point, please share your extension log file or the ESP-IDF: Doctor Command output (will be copied to the clipboard) to get an idea of your setup environment.
Hey @monkey I have yet to prepare a video material but basically:
1) Make sure you install the extension and execute the ESP-IDF: Configure ESP-IDF extension command. This will install/use existing ESP-IDF, ESP-IDF Tools and create a python virtual environment with all required python packages.
2) Create a project from ESP-IDF: Show examples projects or ESP-IDF: Create project which will include .vscode directory.
3) Select your serial port. Build and flash your project.
4) If you didn't change /your_project_dir/.vscode/launch.json just pressing F5 will launch openOCD and the debug Adapter eventually launching a debug session.
If you have any error at any point, please share your extension log file or the ESP-IDF: Doctor Command output (will be copied to the clipboard) to get an idea of your setup environment.
Who is online
Users browsing this forum: No registered users and 7 guests