Page 1 of 1

getting the debugger working in VS Code

Posted: Wed Sep 22, 2021 1:32 am
by mzimmers
Hi all -

I'm delighted that we now have an interactive debugger for the ESP32. I've read https://github.com/espressif/vscode-esp ... bugging.md and they mostly make sense, but as a newcomer to this stuff, I could use a little more detail.

I'm using a ESP32-WROOM-32D board. The online help suggested I use the board/esp32-wrover-kit-1.8v.cfg, so I chose that from the command palette. (This is a file, right? I can't find it anywhere.)

This is the contents of my settings.json file:

Code: Select all

{
    "idf.adapterTargetName": "esp32",
    "workbench.colorTheme": "Visual Studio Light",
    "idf.espIdfPath": "/home/mzimmers/esp/esp-idf",
    "idf.pythonBinPath": "/home/mzimmers/.espressif/python_env/idf4.3_py3.8_env/bin/python",
    "idf.toolsPath": "/home/mzimmers/.espressif",
    "idf.customExtraPaths": "/home/mzimmers/.espressif/tools/xtensa-esp32-elf/esp-2021r1-8.4.0/xtensa-esp32-elf/bin:/home/mzimmers/.espressif/tools/xtensa-esp32s2-elf/esp-2021r1-8.4.0/xtensa-esp32s2-elf/bin:/home/mzimmers/.espressif/tools/xtensa-esp32s3-elf/esp-2021r1-8.4.0/xtensa-esp32s3-elf/bin:/home/mzimmers/.espressif/tools/riscv32-esp-elf/esp-2021r1-8.4.0/riscv32-esp-elf/bin:/home/mzimmers/.espressif/tools/esp32ulp-elf/2.28.51-esp-20191205/esp32ulp-elf-binutils/bin:/home/mzimmers/.espressif/tools/esp32s2ulp-elf/2.28.51-esp-20191205/esp32s2ulp-elf-binutils/bin:/home/mzimmers/.espressif/tools/openocd-esp32/v0.10.0-esp32-20210401/openocd-esp32/bin",
    "idf.customExtraVars": "{\"OPENOCD_SCRIPTS\":\"/home/mzimmers/.espressif/tools/openocd-esp32/v0.10.0-esp32-20210401/openocd-esp32/share/openocd/scripts\"}",
    "idf.gitPath": "git",
    "idf.flashType": "UART",
    "idf.saveScope": 2,
    "C_Cpp.autoAddFileAssociations": false
}
Anyway, if anyone know of some supplementary information for getting this going (or can already see what I'm doing wrong), I'd appreciate knowing about it. Thanks...

Re: getting the debugger working in VS Code

Posted: Sun Sep 26, 2021 9:46 am
by ESP_bignacio
What kind of issue are you having with debugging ?

To configure the debug adapter, you use the settings in your launch.json as per Visual Studio Code approach.

Take a look at https://github.com/espressif/vscode-esp ... BUGGING.md

Re: getting the debugger working in VS Code

Posted: Fri Oct 01, 2021 11:23 pm
by mzimmers
Hi bignacio - sorry for the late reply; lots of unrelated tasks going on right now.

My current issue with the debugger is when I get to the step where I press F5, it prompts me to select an environment, and the only choices are:

C++ (GDB/LLDB)
C++ (Windows)

I imagine this is something to do with a configuration file, but I thought I had followed the instructions faithfully, so I don't know.

Thanks...

Re: getting the debugger working in VS Code

Posted: Fri Oct 08, 2021 1:27 pm
by ESP_bignacio
If it is asking to choose this it is probably because visual studio code doesn't find a launch.json for the current project.

Is there a .vscode/launch.json ?

Are you opening one ESP-IDF project or several projects at the same time ?

Re: getting the debugger working in VS Code

Posted: Fri Oct 08, 2021 6:04 pm
by mzimmers
Hi bignacio -

Yes, I have a launch.json file. I'm only opening one project.

The behavior has changed -- now when I press F5, I get an error "The preLaunchTask 'C/C++: arm-none-eabi-g++ build active file' terminated with exit code -1.

Not sure what I've done to introduce this behavior...

Re: getting the debugger working in VS Code

Posted: Tue Nov 02, 2021 9:33 pm
by mzimmers
I'd like to return to this issue, please. When I try to start the debugger, I get this error:
debug.PNG
debug.PNG (178.14 KiB) Viewed 33215 times
Any ideas what I'm doing wrong? Thanks...

Re: getting the debugger working in VS Code

Posted: Sun Nov 07, 2021 12:28 am
by ProtonBoarder
Yuri R made a nice detailed video on how to setup the ESP-PROG on VS Code, it worked for me at least
https://www.youtube.com/watch?v=uq93H7T7cOQ

Re: getting the debugger working in VS Code

Posted: Mon Jan 03, 2022 11:10 pm
by mzimmers
Hi ProtonBoarder -

That is indeed a good video -- it does answer a few questions.

I'm trying to use his automated preRun task:

Code: Select all

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "preRun",
            "type": "shell",
            "windows": {
                "command": "clear & start openocd -c \"set ESP_RTOS none\" -f board/esp32-wrover-kit-3.3v.cfg & exit"
            }
        }
    ]
}
but I'm getting an error:

Code: Select all

At line:1 char:7
+ clear & start openocd -c set ESP_RTOS none -f board/esp32-wrover-kit- ...
+       ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string.
I've tried escaping the ampersand, but no change in results. Any idea what's wrong here?

Thanks...

EDIT: after some experimentation, I enclosed the ampersand in single quotes:

Code: Select all

                "command": "clear '&' start openocd -c \"set ESP_RTOS none\" -f board/esp32-wrover-kit-3.3v.cfg '&' exit"
That seems to have fixed it. Evidently the author of the video was using a basic Windows shell, and my system is configured for PowerShell, which doesn't like the naked ampersand.

Re: getting the debugger working in VS Code

Posted: Sun Feb 27, 2022 1:42 pm
by lg.lindstrom
I've tried his command line, and your modification of his command:

Code: Select all

 "command": "clear '&' start openocd -c \"set ESP_RTOS none\" -f board/esp32-wrover-kit-3.3v.cfg '&' exit"
nothing works for me.
I agree on the conclusion that different shells are used.

VsCode must have a way to control which shell that is used. I have searched among VsCode settings without understand which to use/change.

Have you looked into this ?

Re: getting the debugger working in VS Code

Posted: Wed May 18, 2022 2:17 pm
by ashelman-ec
In the Windows terminal, the ampersand is used to separate two commands on one line.

In PowerShell, a semicolon is used instead.

Try this instead:

Code: Select all

 "command": "clear ; start openocd -c \"set ESP_RTOS none\" -f board/esp32-wrover-kit-3.3v.cfg ; exit"