espressif / openocd-esp32

OpenOCD branch with ESP32 JTAG support
Other
360 stars 132 forks source link

Could not run/continue: Don't know how to run. Try "help target". (from exec-run) (OCD-667) #261

Closed skanky-dev closed 1 year ago

skanky-dev commented 1 year ago

Development Kit

Custom board

Module or chip used

ESP32-WROOM-32E

Debug Adapter

ESP_PROG

OpenOCD version

v0.11.0-esp32-20220706

Operating System

Win10 Pro

Using an IDE ?

VS Code

OpenOCD command line

F5

JTAG Clock Speed

20000 kHz

ESP-IDF version

esp-idf-v4.4.3

Problem Description

Press F5 to debug project Programs as expected, sets up to start debugging as expected and then VS Code shows pop up message "Could not run/continue: Don't know how to run. Try "help target". (from exec-run)"

This is an existing project I've taken over. After extensive searching I can't find any results for this pop up error message and after working through everything I can think of on the project config I can't find what the problem might be!

Debug Logs

---------------------------
 ---------------------------
 ----- TERMINAL OUTPUT -----
 ---------------------------
 ---------------------------
 *  Executing task: openocd -s C:\Users\Dev\.espressif\tools\openocd-esp32\v0.11.0-esp32-20220706\openocd-esp32\share\openocd\scripts -c 'adapter_khz 12000' -f interface\ftdi\esp32_devkitj_v1.cfg -f C:\Users\Dev\.espressif\tools\openocd-esp32\v0.11.0-esp32-20220706\openocd-esp32\share\openocd\scripts\board\esp-wroom-32.cfg  

Open On-Chip Debugger  v0.11.0-esp32-20220706 (2022-07-06-15:48)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
DEPRECATED! use 'adapter speed' not 'adapter_khz'
adapter speed: 12000 kHz

adapter speed: 20000 kHz

WARNING: boards/esp-wroom-32.cfg is deprecated, and may be removed in a future release.
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Error: libusb_open() failed with LIBUSB_ERROR_NOT_SUPPORTED
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: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : [esp32.cpu0] Debug controller was reset.
Info : [esp32.cpu0] Core was reset.
Info : [esp32.cpu1] Debug controller was reset.
Info : [esp32.cpu1] Core was reset.
Info : starting gdb server for esp32.cpu0 on 3333
Info : Listening on port 3333 for gdb connections
Info : accepting 'gdb' connection on tcp/3333
Info : [esp32.cpu0] Target halted, PC=0x4019FF4E, debug_reason=00000000
Info : Set GDB target to 'esp32.cpu0'
Info : [esp32.cpu1] Target halted, PC=0x4019FF4E, debug_reason=00000000
Warn : No symbols for FreeRTOS!
Info : [esp32.cpu0] Target halted, PC=0x40092612, debug_reason=00000001
Info : Flash mapping 0: 0x10020 -> 0x3f400020, 195 KB
Info : Flash mapping 1: 0x50020 -> 0x400d0020, 877 KB
Info : [esp32.cpu0] Target halted, PC=0x40092612, debug_reason=00000001
Info : Auto-detected flash bank 'esp32.cpu0.flash' size 4096 KB
Info : Using flash bank 'esp32.cpu0.flash' size 4096 KB
Info : [esp32.cpu0] Target halted, PC=0x40092612, debug_reason=00000001
Info : Flash mapping 0: 0x10020 -> 0x3f400020, 195 KB
Info : Flash mapping 1: 0x50020 -> 0x400d0020, 877 KB
Info : Using flash bank 'esp32.cpu0.irom' size 880 KB
Info : [esp32.cpu0] Target halted, PC=0x40092612, debug_reason=00000001
Info : Flash mapping 0: 0x10020 -> 0x3f400020, 195 KB
Info : Flash mapping 1: 0x50020 -> 0x400d0020, 877 KB
Info : Using flash bank 'esp32.cpu0.drom' size 196 KB
Info : New GDB Connection: 1, Target esp32.cpu0, state: halted
Warn : Prefer GDB command "target extended-remote :3333" instead of "target remote :3333"
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : [esp32.cpu0] requesting target halt and executing a soft reset
Info : [esp32.cpu0] Debug controller was reset.
Info : [esp32.cpu0] Core was reset.
Info : [esp32.cpu0] Target halted, PC=0x500000CF, debug_reason=00000000
Info : [esp32.cpu1] requesting target halt and executing a soft reset
Info : [esp32.cpu0] Core was reset.
Info : [esp32.cpu0] Target halted, PC=0x40000400, debug_reason=00000000
Info : [esp32.cpu1] Debug controller was reset.
Info : [esp32.cpu1] Core was reset.
Info : [esp32.cpu1] Target halted, PC=0x40000400, debug_reason=00000000
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : [esp32.cpu0] requesting target halt and executing a soft reset
Info : [esp32.cpu0] Debug controller was reset.
Info : [esp32.cpu0] Core was reset.
Info : [esp32.cpu0] Target halted, PC=0x500000CF, debug_reason=00000000
Info : [esp32.cpu1] requesting target halt and executing a soft reset
Info : [esp32.cpu0] Core was reset.
Info : [esp32.cpu0] Target halted, PC=0x40000400, debug_reason=00000000
Info : [esp32.cpu1] Debug controller was reset.
Info : [esp32.cpu1] Core was reset.
Info : [esp32.cpu1] Target halted, PC=0x40000400, debug_reason=00000000
Info : [esp32.cpu0] Target halted, PC=0x40092612, debug_reason=00000001
Info : Flash mapping 0: 0x10020 -> 0x3f400020, 195 KB
Info : Flash mapping 1: 0x50020 -> 0x400d0020, 877 KB
Info : [esp32.cpu0] Target halted, PC=0x40092612, debug_reason=00000001
Info : Auto-detected flash bank 'esp32.cpu1.flash' size 4096 KB
Info : Using flash bank 'esp32.cpu1.flash' size 4096 KB
** Programming Started **
Info : [esp32.cpu0] Target halted, PC=0x40092612, debug_reason=00000001
Info : [esp32.cpu0] Target halted, PC=0x40092612, debug_reason=00000001
Info : PROF: Erased 1249280 bytes in 5296.98 ms
Info : PROF: Data transferred in 5366.67 ms @ 227.329 KB/s
Info : [esp32.cpu0] Target halted, PC=0x40092612, debug_reason=00000001
Info : PROF: Wrote 1249280 bytes in 5756.35 ms (data transfer time included)
** Programming Finished in 11781 ms **
Info : [esp32.cpu0] Target halted, PC=0x400D7D68, debug_reason=00000001
Info : Set GDB target to 'esp32.cpu0'
Info : [esp32.cpu1] Target halted, PC=0x4019FF4E, debug_reason=00000000
Info : dropped 'gdb' connection
shutdown command invoked

--------------------------------
--------------------------------
----- DEBUG CONSOLE OUTPUT -----
--------------------------------
--------------------------------
1-gdb-set target-async on
2-list-features
3-environment-directory "C:\\_PROJECTS\\project1\\firm\\rpdintl-100-216_project1"
4-file-exec-and-symbols "C:\\_PROJECTS\\project1\\firm\\rpdintl-100-216_project1\\build\\100_216_project1.elf"
undefinedC:\Users\Dev\.espressif\tools\xtensa-esp32-elf\esp-2021r2-patch5-8.4.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-gdb.exe: warning: Couldn't determine a path for the index cache directory.
5-interpreter-exec console "target remote :3333"
6-interpreter-exec console "mon reset halt"
7-interpreter-exec console "mon program_esp ./build/100_216_project1.bin 0x10000"
8-interpreter-exec console "flushregs"
9-interpreter-exec console "thb app_main"
10-interpreter-exec console "c"
11-break-insert -f "c:\\_PROJECTS\\project1\\firm\\rpdintl-100-216_project1\\main\\rpd_main.c:674"
Remote debugging using :3333
0x4019ff4e in esp_pm_impl_waiti () at C:/Espressif/frameworks/esp-idf-v4.4.3/components/hal/esp32/include/hal/cpu_ll.h:183
183     asm volatile ("waiti 0\n");
12-thread-info
13-thread-info
JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
[esp32.cpu0] requesting target halt and executing a soft reset
[esp32.cpu0] Debug controller was reset.
[esp32.cpu0] Core was reset.
[esp32.cpu0] Target halted, PC=0x500000CF, debug_reason=00000000
[esp32.cpu1] requesting target halt and executing a soft reset
[esp32.cpu0] Core was reset.
[esp32.cpu0] Target halted, PC=0x40000400, debug_reason=00000000
[esp32.cpu1] Debug controller was reset.
[esp32.cpu1] Core was reset.
[esp32.cpu1] Target halted, PC=0x40000400, debug_reason=00000000
JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
[esp32.cpu0] requesting target halt and executing a soft reset
[esp32.cpu0] Debug controller was reset.
[esp32.cpu0] Core was reset.
[esp32.cpu0] Target halted, PC=0x500000CF, debug_reason=00000000
[esp32.cpu1] requesting target halt and executing a soft reset
[esp32.cpu0] Core was reset.
[esp32.cpu0] Target halted, PC=0x40000400, debug_reason=00000000
[esp32.cpu1] Debug controller was reset.
[esp32.cpu1] Core was reset.
[esp32.cpu1] Target halted, PC=0x40000400, debug_reason=00000000
[esp32.cpu0] Target halted, PC=0x40092612, debug_reason=00000001
Flash mapping 0: 0x10020 -> 0x3f400020, 195 KB
Flash mapping 1: 0x50020 -> 0x400d0020, 877 KB
[esp32.cpu0] Target halted, PC=0x40092612, debug_reason=00000001
Auto-detected flash bank 'esp32.cpu1.flash' size 4096 KB
Using flash bank 'esp32.cpu1.flash' size 4096 KB
** Programming Started **
[esp32.cpu0] Target halted, PC=0x40092612, debug_reason=00000001
[esp32.cpu0] Target halted, PC=0x40092612, debug_reason=00000001
PROF: Erased 1249280 bytes in 5296.98 ms
PROF: Data transferred in 5366.67 ms @ 227.329 KB/s
[esp32.cpu0] Target halted, PC=0x40092612, debug_reason=00000001
PROF: Wrote 1249280 bytes in 5756.35 ms (data transfer time included)
** Programming Finished in 11781 ms **
Register cache flushed.
Hardware assisted breakpoint 1 at 0x400d7d68: file C:/_PROJECTS/project1/firm/rpdintl-100-216_project1/main/rpd_main.c, line 654.
Continuing.
[esp32.cpu0] Target halted, PC=0x400D7D68, debug_reason=00000001
Set GDB target to 'esp32.cpu0'
[esp32.cpu1] Target halted, PC=0x4019FF4E, debug_reason=00000000
[New Thread 1073469596]
[New Thread 1073469248]
[New Thread 1073446224]
[New Thread 1073461380]
[New Thread 1073445612]
[Switching to Thread 1073468900]

Thread 1 "main" hit Temporary breakpoint 1, app_main () at C:/_PROJECTS/project1/firm/rpdintl-100-216_project1/main/rpd_main.c:654
warning: Source file is more recent than executable.
654 {
14-thread-info
Running executable
15-exec-run
16-thread-info
17-stack-info-depth --thread 1
18-stack-info-depth --thread 1
-gdb-exit
19-stack-list-frames --thread 1 0 2
20-stack-list-frames --thread 1 0 2
[Inferior 1 (Remote target) detached]

Expected behavior

Debugging to start as normal

Screenshots

No response

gerekon commented 1 year ago

Hi @skanky-dev

Actually the problem is not related to OpenOCD. Looks like VsCode debug session setup problem. Do you use Espressif VsCode extention for debugging? Looks like not and you use VsCode builtin debugger instead. Here the description how to setup it. From my side I can tell that -exec-run is wrong command when you already run the program and stopped at app_main. -exec-continue or its equivalent -interpreter-exec console "c" should be used instead. But sorry I can not tell you why VsCode builtin debugger use -exec-run in your case. I know that many people use it successfully for Espressif chips, so looks like configuration problem.

If you want to use Espressif VsCode extention for debugging, please have a look at how to setup it and how to debug with it and more details on debug configuration.

skanky-dev commented 1 year ago

Hi, as far as I'm aware I'm already using the Espressif VsCode extension. This is my launch.json:

{
    "version": "0.2.0",
    "configurations": [        
        {
            "name": "OpenOCD Debugging",
            "type": "gdb",
            "request": "launch",
            "printCalls": true,
            "target": "./build/100_216_project1.elf",
            "cwd": "${workspaceFolder}",
            "autorun": [
                "target remote :3333",
                "mon reset halt",
                "mon program_esp ./build/100_216_project1.bin 0x10000",
                "flushregs",
                "thb app_main",
                "c"
            ],
            "preLaunchTask": "openocd_debug",
            "gdbpath": "C:\\Users\\Dev\\.espressif\\tools\\xtensa-esp32-elf\\esp-2021r2-patch5-8.4.0\\xtensa-esp32-elf\\bin\\xtensa-esp32-elf-gdb"
        }
    ]
}

And this is my tasks.json openocd_debug task

{
    "label": "openocd_debug",
    "type": "shell",
    "isBackground": true,
    "command": "openocd -s C:\\Users\\Dev\\.espressif\\tools\\openocd-esp32\\v0.11.0-esp32-20220706\\openocd-esp32\\share\\openocd\\scripts -c 'adapter_khz 12000' -f interface\\ftdi\\esp32_devkitj_v1.cfg -f C:\\Users\\Dev\\.espressif\\tools\\openocd-esp32\\v0.11.0-esp32-20220706\\openocd-esp32\\share\\openocd\\scripts\\board\\esp-wroom-32.cfg ",
    "problemMatcher": [
        {
            "pattern": [
            {
                "regexp": ".",
                "file": 1,
                "location": 2,
                "message": 3
            }
            ],
            "background": {
            "activeOnStart": true,
            "beginsPattern": ".",
            "endsPattern": ".",
            }
        }
    ]
}
gerekon commented 1 year ago

No. It should have "type": "espidf" like below. See here

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "espidf",
      "name": "Launch",
      "request": "launch",
      "debugPort": 9998,
      "logLevel": 2,
      "mode": "manual",
      "verifyAppBinBeforeDebug": false,
      "tmoScaleFactor": 1,
      "initGdbCommands": [
        "target remote :3333",
        "symbol-file /path/to/program.elf",
        "mon reset halt",
        "flushregs",
        "thb app_main"
      ],
      "env": {
        "CUSTOM_ENV_VAR": "SOME_VALUE"
      }
    }
  ]
}
skanky-dev commented 1 year ago

Thank you!!! I changed that and debugging is now working :-)