Dual processor debugging with VSCode for Windows

Zoltan Janosy
Posts: 15
Joined: Tue Apr 12, 2022 11:15 am

Dual processor debugging with VSCode for Windows

Postby Zoltan Janosy » Fri Feb 28, 2025 1:32 pm

I'm using VSCode on Windows with ESP-IDF v5.3.2. I have a custom board with two ESP32-S3s on it. I would like to debug both of them simultaneously using a single PC.

One processor is connected to the PC via the built-in USB-JTAG port, the other one is connected via an ESP-PROG JTAG programmer. Both work (after spending a couple of hours to find the right drivers for each port), but only one at a time.

I have started two instances of VSCode. I could also start two instances of OpenOCD by configuring them on different ports in the two VSCode projects. To do that I've added an "idf.openOcdLaunchArgs" entry to '.vscode/settings.json':

Code: Select all

{
    "idf.adapterTargetName": "esp32s3",
    "idf.portWin": "COM71",
    "idf.openOcdConfigs": [
        "interface/ftdi/esp32_devkitj_v1.cfg",
        "target/esp32s3.cfg"
    ],
    "idf.openOcdLaunchArgs": [
        "-c tcl port 6667",
        "-c telnet_port 4445",
        "-c gdb port 3334",
    ],
    "idf.flashType": "JTAG"
    },
}
Is this the right way to do this?

I also read in the docs that
You can change these settings by modifying [openocd.tcl.host] and [openocd.tcl.port].
Where can I modify those?

However, I could not figure out how to configure gdb to use the secondary ports. Any ideas?

bignacio
Espressif staff
Espressif staff
Posts: 258
Joined: Wed May 02, 2018 12:12 pm

Re: Dual processor debugging with VSCode for Windows

Postby bignacio » Wed Mar 05, 2025 5:49 am

Hi Zoltan Janosy very interesting use case!

openocd.tcl.host and openocd.tcl.port you can modify in .vscode/settings.json.

To configure GDB to use a custom port you need to set something like this in .vscode/launch.json

Code: Select all

{
  "configurations": [
    {
      "type": "gdbtarget",
      "request": "attach",
      "name": "Eclipse CDT GDB Adapter",
      "target": {
        "connectCommands": [
          "set remotetimeout 20",
          "-target-select extended-remote localhost:3333"
        ]
      }
    }
  ]
}
and modify 3333 to openOCD port. The value of target I show before is the default value which is populated by extension if not defined before.

I will update the debugging documentation to include launch.json customization. It used to be documented in v1.8.1 but we haven't moved to new documentation yet

Zoltan Janosy
Posts: 15
Joined: Tue Apr 12, 2022 11:15 am

Re: Dual processor debugging with VSCode for Windows

Postby Zoltan Janosy » Wed Mar 05, 2025 10:57 am

Thank you for the quick reply! I tried to set up the two VSCode instances with different settings:

processor 1

'settings.json'

Code: Select all

{
    "idf.adapterTargetName": "esp32s3",
    "idf.portWin": "COM71",
    "idf.openOcdConfigs": [
        "interface/ftdi/esp32_devkitj_v1.cfg",
        "target/esp32s3.cfg"
    ],
    "idf.openOcdLaunchArgs": [
        "-c tcl port 6666",
        "-c telnet_port 4444",
        "-c gdb port 3333",
    ],
    "idf.flashType": "JTAG",
    "idf.customExtraVars": {
        "OPENOCD_SCRIPTS": "C:\\Espressif\\VSC\\tools\\openocd-esp32\\v0.12.0-esp32-20240318/openocd-esp32/share/openocd/scripts",
        "IDF_CCACHE_ENABLE": "1",
        "ESP_ROM_ELF_DIR": "C:\\Espressif\\VSC\\tools\\esp-rom-elfs\\20240305/",
        "IDF_TARGET": "esp32s3"
    },
}
'launch.json'

Code: Select all

{
    "version": "0.2.0",
    "configurations": [   
      {
        "type": "gdbtarget",
        "request": "attach",
        "name": "Eclipse CDT GDB Adapter",
        "target": {
          "connectCommands": [
            "set remotetimeout 20",
            "-target-select extended-remote localhost:3333"
          ]
      },
    ]
  }

processor 2

'settings.json'

Code: Select all

{
    "idf.flashType": "JTAG",
    "idf.portWin": "COM33",
    "idf.openOcdConfigs": [
        "board/esp32s3-builtin.cfg"
    ],
    "idf.openOcdLaunchArgs": [
        "-c tcl port 6667",
        "-c telnet_port 4445",
        "-c gdb port 3334",
    ],
    "idf.espIdfPathWin": "C:\\Espressif\\v5.3.2\\esp-idf",
    "idf.toolsPathWin": "C:\\Espressif\\tools",
    "idf.customExtraVars": {
        "OPENOCD_SCRIPTS": "C:\\Espressif\\VSC\\tools\\openocd-esp32\\v0.12.0-esp32-20240318/openocd-esp32/share/openocd/scripts",
        "IDF_CCACHE_ENABLE": "1",
        "ESP_ROM_ELF_DIR": "C:\\Espressif\\VSC\\tools\\esp-rom-elfs\\20240305/",
        "IDF_TARGET": "esp32s3"
    }
}
'launch.json'

Code: Select all

{
    "version": "0.2.0",
    "configurations": [
      {
        "type": "gdbtarget",
        "request": "attach",
        "name": "Eclipse CDT GDB Adapter",
        "target": {
          "connectCommands": [
            "set remotetimeout 20",
            "-target-select extended-remote localhost:3334"
          ]
        }
        },
    ]
  }
However, when I start the second debugger, I get an error:
Cannot read properties of null (reading 'port')
Do I need to set some more options?

Zoltan Janosy
Posts: 15
Joined: Tue Apr 12, 2022 11:15 am

Re: Dual processor debugging with VSCode for Windows

Postby Zoltan Janosy » Wed Mar 05, 2025 11:03 am

P.S.: both configurations work in isolation.

Zoltan Janosy
Posts: 15
Joined: Tue Apr 12, 2022 11:15 am

Re: Dual processor debugging with VSCode for Windows

Postby Zoltan Janosy » Wed Mar 05, 2025 2:38 pm

Flashing via JTAG does not work when I change the port settings. The flasher does not detect that OpenOCD is running. Changing 'tcl port' back to 6666 fixes this.

I found another port setting in 'esp_debug_adapter': it defaults to 43474. Maybe this needs to be set differently, too?

bignacio
Espressif staff
Espressif staff
Posts: 258
Joined: Wed May 02, 2018 12:12 pm

Re: Dual processor debugging with VSCode for Windows

Postby bignacio » Thu Mar 06, 2025 2:57 am

I think the issue here is that openOCD instance for both cases point to PATH openOCD. Since you are running 2 instances of openOCD it is likely that second debug session is point to openOCD from first debug session or second openOCD session is not starting at all

Could you share your the doctor command output and ESP-IDF output from both vscode window as described in https://docs.espressif.com/projects/vsc ... oting.html

The ESP-IDF output should display the output from openOCD communication between vscode and openOCD.

Does the 2nd execution of openOCD giving you an error? Do you see 2 openOCD execution in your system process ?

Who is online

Users browsing this forum: No registered users and 1 guest