getting the debugger working in VS Code

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

getting the debugger working in VS Code

Postby mzimmers » Wed Sep 22, 2021 1:32 am

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...

ESP_bignacio
Posts: 214
Joined: Wed May 02, 2018 12:12 pm

Re: getting the debugger working in VS Code

Postby ESP_bignacio » Sun Sep 26, 2021 9:46 am

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

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: getting the debugger working in VS Code

Postby mzimmers » Fri Oct 01, 2021 11:23 pm

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...

ESP_bignacio
Posts: 214
Joined: Wed May 02, 2018 12:12 pm

Re: getting the debugger working in VS Code

Postby ESP_bignacio » Fri Oct 08, 2021 1:27 pm

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 ?

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: getting the debugger working in VS Code

Postby mzimmers » Fri Oct 08, 2021 6:04 pm

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...

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: getting the debugger working in VS Code

Postby mzimmers » Tue Nov 02, 2021 9:33 pm

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 27788 times
Any ideas what I'm doing wrong? Thanks...

ProtonBoarder
Posts: 3
Joined: Fri Nov 05, 2021 10:31 am

Re: getting the debugger working in VS Code

Postby ProtonBoarder » Sun Nov 07, 2021 12:28 am

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

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: getting the debugger working in VS Code

Postby mzimmers » Mon Jan 03, 2022 11:10 pm

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.

lg.lindstrom
Posts: 47
Joined: Fri Sep 17, 2021 4:02 pm

Re: getting the debugger working in VS Code

Postby lg.lindstrom » Sun Feb 27, 2022 1:42 pm

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 ?

ashelman-ec
Posts: 9
Joined: Fri May 13, 2022 6:08 am

Re: getting the debugger working in VS Code

Postby ashelman-ec » Wed May 18, 2022 2:17 pm

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"

Who is online

Users browsing this forum: No registered users and 21 guests