I don't succeed to launch GDB but i succeed to launch OPENOCD (ESP-IDF and ESP32-C3 with ESP-PROG and VSCODE and Win10)

joseMiguel
Posts: 22
Joined: Sun Oct 25, 2020 11:43 pm

I don't succeed to launch GDB but i succeed to launch OPENOCD (ESP-IDF and ESP32-C3 with ESP-PROG and VSCODE and Win10)

Postby joseMiguel » Thu Sep 14, 2023 10:34 am

Good Morning,

I'am trying to make an ESP32-C3 based project. (ESP-IDF project and VSCODE on Win10)

I would like to use the external debugger ESP-PROG

I am stuck on launching the debugger with VSCODE

Here below my launch.json

Code: Select all

{
  "version": "0.2.0",
  "configurations": [
    // {
    //   "preLaunchTask": "OpenOCD: Start openOCD",
    //   "type": "espidf",
    //   "name": "Launch",
    //   "request": "launch",
    //   "debugPort": 43474,
    //   "logLevel": 2,
    //   "mode": "manual",
    //   "verifyAppBinBeforeDebug": false,
    //   "tmoScaleFactor": 1,
    //   "initGdbCommands": [
    //     "target extended-remote :3333",
    //     "symbol-file  ${workspaceFolder}/build/fast-scan.elf",
    //     "mon reset halt",
    //     "flushregs",
    //     "thb app_main"
    //   ],
    //   "env": {
    //     "CUSTOM_ENV_VAR": "SOME_VALUE"
    //   }      
    // },

    {
      "preLaunchTask": "OpenOCD: Start openOCD",
      "name": "Launch",
      "type": "cppdbg",
      "request": "launch",
      "cwd": "${workspaceFolder}/build",
      "program": "${workspaceFolder}/build/fast-scan.elf",
      "miDebuggerPath": "C:/Users/josem/.espressif/tools/riscv32-esp-elf-gdb/11.2_20220823/riscv32-esp-elf-gdb/bin/riscv32-esp-elf-gdb-3.9.exe",
      //"MIMode": "gdb",
      //"windows": {"${workspaceFolder}\\build\\${command:espIdf.getProjectName}.elf"},
      "environment": [{ "name": "PATH", "value": "${config:idf.customExtraPaths}" }],
      
      "setupCommands": [
        {"text": "target remote 127.0.0.1:3333"},
        {"text" : "set remote hardware-watchpoint-limit 2"},
        {"text": "mon reset halt"},
        {"text": "thb app_main"},
        {"text": "flushregs"}
      ],
      "externalConsole": false,
      "logging": {
         "engineLogging": true
      }
      
    }
  ]
}
here below my tasks.json

Code: Select all

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Build - Build project",
            "type": "shell",
            "command": "${config:idf.pythonBinPath} ${config:idf.espIdfPath}/tools/idf.py build",
            "windows": {
                "command": "${config:idf.pythonBinPathWin} ${config:idf.espIdfPathWin}\\tools\\idf.py build",
                "options": {
                    "env": {
                        "PATH": "${env:PATH};${config:idf.customExtraPaths}"
                    }
                }
            },
            "options": {
                "env": {
                    "PATH": "${env:PATH}:${config:idf.customExtraPaths}"
                }
            },
            "problemMatcher": [
                {
                    "owner": "cpp",
                    "fileLocation": [
                        "relative",
                        "${workspaceFolder}"
                    ],
                    "pattern": {
                        "regexp": "^\\.\\.(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                        "file": 1,
                        "line": 2,
                        "column": 3,
                        "severity": 4,
                        "message": 5
                    }
                },
                {
                    "owner": "cpp",
                    "fileLocation": "absolute",
                    "pattern": {
                        "regexp": "^[^\\.](.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                        "file": 1,
                        "line": 2,
                        "column": 3,
                        "severity": 4,
                        "message": 5
                    }
                }
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        },
        {
            "label": "Set ESP-IDF Target",
            "type": "shell",
            "command": "${command:espIdf.setTarget}",
            "problemMatcher": {
                "owner": "cpp",
                "fileLocation": "absolute",
                "pattern": {
                    "regexp": "^(.*):(//d+):(//d+)://s+(warning|error)://s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 5
                }
            }
        },
        {
            "label": "Clean - Clean the project",
            "type": "shell",
            "command": "${config:idf.pythonBinPath} ${config:idf.espIdfPath}/tools/idf.py fullclean",
            "windows": {
                "command": "${config:idf.pythonBinPathWin} ${config:idf.espIdfPathWin}\\tools\\idf.py fullclean",
                "options": {
                    "env": {
                        "PATH": "${env:PATH};${config:idf.customExtraPaths}"
                    }
                }
            },
            "options": {
                "env": {
                    "PATH": "${env:PATH}:${config:idf.customExtraPaths}"
                }
            },
            "problemMatcher": [
                {
                    "owner": "cpp",
                    "fileLocation": [
                        "relative",
                        "${workspaceFolder}"
                    ],
                    "pattern": {
                        "regexp": "^\\.\\.(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                        "file": 1,
                        "line": 2,
                        "column": 3,
                        "severity": 4,
                        "message": 5
                    }
                },
                {
                    "owner": "cpp",
                    "fileLocation": "absolute",
                    "pattern": {
                        "regexp": "^[^\\.](.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                        "file": 1,
                        "line": 2,
                        "column": 3,
                        "severity": 4,
                        "message": 5
                    }
                }
            ]
        },
        {
            "label": "Flash - Flash the device",
            "type": "shell",
            "command": "${config:idf.pythonBinPath} ${config:idf.espIdfPath}/tools/idf.py -p ${config:idf.port} -b ${config:idf.flashBaudRate} flash",
            "windows": {
                "command": "${config:idf.pythonBinPathWin} ${config:idf.espIdfPathWin}\\tools\\idf.py flash -p ${config:idf.portWin} -b ${config:idf.flashBaudRate}",
                "options": {
                    "env": {
                        "PATH": "${env:PATH};${config:idf.customExtraPaths}"
                    }
                }
            },
            "options": {
                "env": {
                    "PATH": "${env:PATH}:${config:idf.customExtraPaths}"
                }
            },
            "problemMatcher": [
                {
                    "owner": "cpp",
                    "fileLocation": [
                        "relative",
                        "${workspaceFolder}"
                    ],
                    "pattern": {
                        "regexp": "^\\.\\.(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                        "file": 1,
                        "line": 2,
                        "column": 3,
                        "severity": 4,
                        "message": 5
                    }
                },
                {
                    "owner": "cpp",
                    "fileLocation": "absolute",
                    "pattern": {
                        "regexp": "^[^\\.](.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                        "file": 1,
                        "line": 2,
                        "column": 3,
                        "severity": 4,
                        "message": 5
                    }
                }
            ]
        },
        {
            "label": "Monitor: Start the monitor",
            "type": "shell",
            "command": "${config:idf.pythonBinPath} ${config:idf.espIdfPath}/tools/idf.py -p ${config:idf.port} monitor",
            "windows": {
                "command": "${config:idf.pythonBinPathWin} ${config:idf.espIdfPathWin}\\tools\\idf.py -p ${config:idf.portWin} monitor",
                "options": {
                    "env": {
                        "PATH": "${env:PATH};${config:idf.customExtraPaths}"
                    }
                }
            },
            "options": {
                "env": {
                    "PATH": "${env:PATH}:${config:idf.customExtraPaths}"
                }
            },
            "problemMatcher": [
                {
                    "owner": "cpp",
                    "fileLocation": [
                        "relative",
                        "${workspaceFolder}"
                    ],
                    "pattern": {
                        "regexp": "^\\.\\.(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                        "file": 1,
                        "line": 2,
                        "column": 3,
                        "severity": 4,
                        "message": 5
                    }
                },
                {
                    "owner": "cpp",
                    "fileLocation": "absolute",
                    "pattern": {
                        "regexp": "^[^\\.](.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                        "file": 1,
                        "line": 2,
                        "column": 3,
                        "severity": 4,
                        "message": 5
                    }
                }
            ],
            "dependsOn": "Flash - Flash the device"
        },
        {
            "label": "OpenOCD: Start openOCD",
            "type": "shell",
            "presentation": {
                "echo": true,
                "reveal": "never",
                "focus": false,
                "panel": "new"
            },
            //"command": "openocd -s ${command:espIdf.getOpenOcdScriptValue} ${command:espIdf.getOpenOcdConfigs}",
            //"command": "openocd -s ../share/openocd/scripts/  ${command:espIdf.getOpenOcdConfigs} -c ftdi tdo_sample_edge falling",
            "command": "openocd -s ../share/openocd/scripts/  ${command:espIdf.getOpenOcdConfigs}",
            "windows": {
                //"command": "openocd.exe -s ../share/openocd/scripts/  ${command:espIdf.getOpenOcdConfigs} -c ftdi tdo_sample_edge falling",
                "command": "openocd.exe -s ../share/openocd/scripts/  ${command:espIdf.getOpenOcdConfigs}",
                //"command": "openocd.exe -s ${command:espIdf.getOpenOcdScriptValue} ${command:espIdf.getOpenOcdConfigs}",
                "options": {
                    "env": {
                        "PATH": "${env:PATH};${config:idf.customExtraPaths}"
                    }
                }
            },
            "options": {
                "env": {
                    "PATH": "${env:PATH}:${config:idf.customExtraPaths}"
                }
            },
            "problemMatcher": {
                "owner": "cpp",
                "fileLocation": "absolute",
                "pattern": {
                    "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 5
                }
            }
        },
        {
            "label": "adapter",
            "type": "shell",
            "command": "${config:idf.pythonBinPath}",
            "isBackground": true,
            "options": {
                "env": {
                    "PATH": "${env:PATH}:${config:idf.customExtraPaths}",
                    "PYTHONPATH": "${command:espIdf.getExtensionPath}/esp_debug_adapter/debug_adapter"
                }
            },
            "problemMatcher": {
                "background": {
                    "beginsPattern": "\bDEBUG_ADAPTER_STARTED\b",
                    "endsPattern": "DEBUG_ADAPTER_READY2CONNECT",
                    "activeOnStart": true
                },
                "pattern": {
                    "regexp": "(\\d+)-(\\d+)-(\\d+)\\s(\\d+):(\\d+):(\\d+),(\\d+)\\s-(.+)\\s(ERROR)",
                    "file": 8,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 9
                }
            },
            "args": [
                "${command:espIdf.getExtensionPath}/esp_debug_adapter/debug_adapter_main.py",
                "-e",
                "${workspaceFolder}/build/${command:espIdf.getProjectName}.elf",
                "-s",
                "${command:espIdf.getOpenOcdScriptValue}",
                "-ip",
                "localhost",
                "-dn",
                "${config:idf.adapterTargetName}",
                "-om",
                "connect_to_instance"
            ],
            "windows": {
                "command": "${config:idf.pythonBinPathWin}",
                "options": {
                    "env": {
                        "PATH": "${env:PATH};${config:idf.customExtraPaths}",
                        "PYTHONPATH": "${command:espIdf.getExtensionPath}/esp_debug_adapter/debug_adapter"
                    }
                }
            }
        }
    ]
}
OPENOCD launch message is OK

Code: Select all

 *  Executing task: openocd.exe -s ../share/openocd/scripts/  -f board/esp32c3-ftdi.cfg 

Open On-Chip Debugger v0.11.0-esp32-20221026 (2022-10-26-14:48)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html    
Info : Listening on port 6666 for tcl connections   
Info : Listening on port 4444 for telnet connections
Info : ftdi: if you experience problems at higher adapter clocks, try the command "ftdi tdo_sample_edge falling"
Info : clock speed 20000 kHz
Info : JTAG tap: esp32c3.cpu tap/device found: 0x00005c25 (mfg: 0x612 (Espressif Systems), part: 0x0005, ver: 0x0)
Info : datacount=2 progbufsize=16
Info : Examined RISC-V core; found 1 harts
Info :  hart 0: XLEN=32, misa=0x40101104
Info : starting gdb server for esp32c3 on 3333
Info : Listening on port 3333 for gdb connections
Warn : Haven't made progress in mpsse_flush() for 330995ms.
Warn : Haven't made progress in mpsse_flush() for 331002ms.
Could you help me please

Best regards

Jose Miguel
José Michel

joseMiguel
Posts: 22
Joined: Sun Oct 25, 2020 11:43 pm

Re: I don't succeed to launch GDB but i succeed to launch OPENOCD (ESP-IDF and ESP32-C3 with ESP-PROG and VSCODE and Win

Postby joseMiguel » Thu Sep 14, 2023 1:35 pm

Hello all,

My local settings.json in the .vscode directory here below

Code: Select all

{
    "C_Cpp.intelliSenseEngine": "Tag Parser",
    "idf.adapterTargetName": "esp32c3",
    "idf.customExtraPaths": "C:\\Users\\josem\\.espressif\\tools\\xtensa-esp-elf-gdb\\11.2_20220823\\xtensa-esp-elf-gdb\\bin;C:\\Users\\josem\\.espressif\\tools\\riscv32-esp-elf-gdb\\11.2_20220823\\riscv32-esp-elf-gdb\\bin;C:\\Users\\josem\\.espressif\\tools\\xtensa-esp32-elf\\esp-2022r1-11.2.0\\xtensa-esp32-elf\\bin;C:\\Users\\josem\\.espressif\\tools\\xtensa-esp32s2-elf\\esp-2022r1-11.2.0\\xtensa-esp32s2-elf\\bin;C:\\Users\\josem\\.espressif\\tools\\xtensa-esp32s3-elf\\esp-2022r1-11.2.0\\xtensa-esp32s3-elf\\bin;C:\\Users\\josem\\.espressif\\tools\\riscv32-esp-elf\\esp-2022r1-11.2.0\\riscv32-esp-elf\\bin;C:\\Users\\josem\\.espressif\\tools\\esp32ulp-elf\\2.35_20220830\\esp32ulp-elf\\bin;C:\\Users\\josem\\.espressif\\tools\\cmake\\3.24.0\\bin;C:\\Users\\josem\\.espressif\\tools\\openocd-esp32\\v0.11.0-esp32-20221026\\openocd-esp32\\bin;C:\\Users\\josem\\.espressif\\tools\\ninja\\1.10.2;C:\\Users\\josem\\.espressif\\tools\\idf-exe\\1.0.3;C:\\Users\\josem\\.espressif\\tools\\ccache\\4.6.2\\ccache-4.6.2-windows-x86_64;C:\\Users\\josem\\.espressif\\tools\\dfu-util\\0.9\\dfu-util-0.9-win64",
    "idf.customExtraVars": {
        "OPENOCD_SCRIPTS": "C:\\Users\\josem\\.espressif\\tools\\openocd-esp32\\v0.11.0-esp32-20221026/openocd-esp32/share/openocd/scripts",
        "PATH": "C:\\Users\\josem\\.espressif\\tools\\openocd-esp32\\v0.11.0-esp32-20221026/openocd-esp32/bin",
        "IDF_CCACHE_ENABLE": "1",
        "IDF_TARGET": "esp32c3"
    },
    "idf.espIdfPathWin": "c:\\ESP\\esp-idf-v5.0",
    "idf.openOcdLaunchArgs": ["ftdi_tdo_sample_edge falling"],
    "idf.openOcdScriptValue": "openocd-esp32/share/openocd/scripts/",
    "idf.openOcdConfigs": [
        //"interface/ftdi/esp32_devkitj_v1.cfg",
        //"target/esp32c3.cfg",
        "board/esp32c3-ftdi.cfg"
        //"ftdi_tdo_sample_edge falling"
        

    ],
    "idf.portWin": "COM11",
    "idf.pythonBinPathWin": "C:\\Users\\josem\\.espressif\\python_env\\idf5.0_py3.9_env\\Scripts\\python.exe",
    "idf.toolsPathWin": "C:\\Users\\josem\\.espressif"
}
I'am waiting your help

Jose Miguel
José Michel

Who is online

Users browsing this forum: g3_san and 104 guests