vscode-esp-idf-extension: ESP32-C3-DevKitC-02 flash using Internal JTAG but debug fails (OCD-401) (VSC-740)
Environment
- Development Kit: ESP32-C3-DevKitC-02
- Module or chip used: ESP32-C3-WROOM-02
- Debug Adapter: ESP32-C3 Internal JTAG
- OpenOCD version: v0.10.0-esp32-20210721
- Operating System: Windows 10
- Using an IDE?: VS Code
- ESP-IDF version: v4.3
Problem Description
Steps to reproduce the behavior:
- Build ESP-IDF blink example
- Flash and verify ESP32-C3 using Internal JTAG
- Disconnect Internal JTAG and verify blink running using devkit COM port.
- Disconnect COM port, reconnect internal JTAG and use F5 to start debug.
- Debug fails with VS Code connection refusal message:
connect ECONNREFUSED 127.0.0.1:43474
Debug Logs
OpenOCD log:
Open On-Chip Debugger v0.10.0-esp32-20210721 (2021-07-21-13:35)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'jtag'
Warn : Transport "jtag" was already selected
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : esp_usb_jtag: Device found. Base speed 40000KHz, div range 1 to 255
Info : clock speed 40000 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 : Listening on port 3333 for gdb connections
Terminal log:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS D:\Dropbox\DATA\DEVELOPMENT\ESP32C3\blink> C:\Users\nicol\.espressif\python_env\idf4.3_py3.8_env\Scripts\python.exe C:\Users\nicol\esp\esp-idf\tools\idf.py -p COM9 monitor
Executing action: monitor
Running idf_monitor in directory d:\dropbox\data\development\esp32c3\blink
Executing "C:\Users\nicol\.espressif\python_env\idf4.3_py3.8_env\Scripts\python.exe C:\Users\nicol\esp\esp-idf\tools/idf_monitor.py -p COM9 -b 115200 --toolchain-prefix riscv32-esp-elf- --decode-panic backt
d:\dropbox\data\development\esp32c3\blink\build\blink.elf -m 'C:\Users\nicol\.espressif\python_env\idf4.3_py3.8_env\Scripts\python.exe' 'C:\Users\nicol\esp\esp-idf\tools\idf.py' '-p' 'COM9'"...
--- WARNING: GDB cannot open serial ports accessed as COMx
--- Using \\.\COM9 instead...
--- idf_monitor on \\.\COM9 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ESP-ROM:esp32c3-api1-20210207
Build:Feb 7 2021
rst:0x15 (USB_UART_CHIP_RESET),boot:0xc (SPI_FAST_FLASH_BOOT)
Saved PC:0x42005a5e
0x42005a5e: cpu_ll_waiti at C:/Users/nicol/esp/esp-idf/components/hal/esp32c3/include/hal/cpu_ll.h:156
(inlined by) esp_pm_impl_waiti at C:/Users/nicol/esp/esp-idf/components/esp_pm/pm_impl.c:827
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd6100,len:0x1778
load:0x403ce000,len:0x8d4
load:0x403d0000,len:0x293c
entry 0x403ce000
I (24) boot: ESP-IDF v4.3-dirty 2nd stage bootloader
I (24) boot: compile time 16:00:58
I (25) boot: chip revision: 3
I (27) boot.esp32c3: SPI Speed : 80MHz
I (31) boot.esp32c3: SPI Mode : DIO
I (36) boot.esp32c3: SPI Flash Size : 4MB
I (41) boot: Enabling RNG early entropy source...
I (46) boot: Partition Table:
I (50) boot: ## Label Usage Type ST Offset Length
I (57) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (64) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (72) boot: 2 factory factory app 00 00 00010000 00100000
I (79) boot: End of partition table
I (83) esp_image: segment 0: paddr=00010020 vaddr=3c020020 size=05fa8h ( 24488) map
I (96) esp_image: segment 1: paddr=00015fd0 vaddr=3fc89a00 size=01a90h ( 6800) load
I (101) esp_image: segment 2: paddr=00017a68 vaddr=40380000 size=085b0h ( 34224) load
I (115) esp_image: segment 3: paddr=00020020 vaddr=42000020 size=15b1ch ( 88860) map
I (131) esp_image: segment 4: paddr=00035b44 vaddr=403885b0 size=013a0h ( 5024) load
I (132) esp_image: segment 5: paddr=00036eec vaddr=50000000 size=00010h ( 16) load
I (140) boot: Loaded app from partition at offset 0x10000
I (143) boot: Disabling RNG early entropy source...
I (160) cpu_start: Pro cpu up.
I (172) cpu_start: Pro cpu start user code
I (172) cpu_start: cpu freq: 160000000
I (172) cpu_start: Application information:
I (175) cpu_start: Project name: blink
I (207) cpu_start: App version: 1
I (207) cpu_start: Compile time: Aug 29 2021 16:59:10
I (208) cpu_start: ELF file SHA256: f3c5fe14c0f6c604...
I (214) cpu_start: ESP-IDF: v4.3-dirty
I (219) heap_init: Initializing. RAM available for dynamic allocation:
I (226) heap_init: At 3FC8C2D0 len 00033D30 (207 KiB): DRAM
I (232) heap_init: At 3FCC0000 len 0001F060 (124 KiB): STACK/DRAM
I (239) heap_init: At 50000010 len 00001FF0 (7 KiB): RTCRAM
Debug launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "espidf",
"name": "Launch",
"request": "launch",
"debugPort": 43474,
"logLevel": 2,
"mode": "manual",
"skipVerifyAppBinBeforeDebug": false,
"initGdbCommands": [
"target remote :3333",
"symbol-file D:/Dropbox/DATA/DEVELOPMENT/ESP32C3/blink/build/blink.elf",
"mon reset halt",
"flushregs",
"thb app_main"
],
"env": {
"CUSTOM_ENV_VAR": "SOME_VALUE"
}
}
]
}
Expected behavior
Debugging of flashed program.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 34 (13 by maintainers)
Big thanks bro, I followed your tips, it works smoothly. it also resolved the invalid issue when restart the debug, the details are as below:
@brianignacio5 Bro, I think you need to do some modifies about debugging to clarifying the debug issue when using the following configuration:
@NicolSpies Bro, regarding the monitor you mentioned, it is not mandatory when debugging, you can close it here as below:
Upgrading to latest ESP-IDF (Master branch, version 4.4) fixed the debugging problem using internal JTAG problem as reported. Debugging works as expected except the problem previously reported regarding the serial monitoring of ESP32c3 via the JTAG UART while debugging or running without debugging.
Upgrade was done by deleting the
.espressifandesp-idffolders and reconfiguring the ESP-IDF extension in VS Code.Appended more information here, I tried to return back from
v0.10.0-esp32-20210721tov0.10.0-esp32-20210401and type in the same commands you mentioned above with git(bash), not powershell(windows 10), it works well and can stop atapp_main(), the details as follows:However, it still cannot work when using the esp-idf-extension even if using the
v0.10.0-esp32-20210401, also it is the same as I mentioned above when typing in the same commands in thepowershell(windows 10)that is nothing happens.so based on lots of test results above, my summaries as follows:
v0.10.0-esp32-20210726, but it can be used for flashing with JTAG, whilev0.10.0-esp32-20210401can be used for debugging , but not flashingv0.10.0-esp32-20210401plusGDBare only available in git(bash) or other terminals (similar with linux) not powershell(windows10)v0.10.0-esp32-20210401plusvscodeplusesp-idf-extension, it cannot work:mode: automode: manualHowever, I tried to type in the same commands from powershell to git(bash), it seems that there is some difference, as below:
For OpenOCD
For GDB
while nothing happens when using the powershell with the same commands.
@NicolSpies In manual mode you need to start both DebugAdapter script and OpenOCD yourself.
python3 debug_adapter_main.py -e blink.elf -ip localhost -dn esp32c3 -d 5 -ln.debug_adapter_main.pyshould be somewhere in VsCode IDF plugin dir.@brianignacio5 Please correct me.