I have a custom board that is using ESP32-C6 chip and there is connected builtin USB-JTAG to USB socket to allow debugging but it doesn't work. Openocd reports error on this stage:
Code: Select all
[OpenOCD]
Info : Flash mapping 0: 0x20020 -> 0x42020020, 55 KB
Info : Flash mapping 1: 0x30020 -> 0x42000020, 109 KB
Info : Using flash bank 'esp32c6.drom' size 56 KB
[OpenOCD]
❌ Warn : negative reply, retrying
Warn : negative reply, retrying
Warn : negative reply, retrying
Error: GDB missing ack(2) - assumed good
Error: GDB missing ack(2) - assumed good
Error: GDB missing ack(2) - assumed good
[OpenOCD]
❌ Error: Error on socket 'GDB': errno==104, message: Connection reset by peer.
Info : dropped 'gdb' connect
---
Tools and versions that I am using:
IDE: VSCode
ESP-IDF extension: 1.7.0
ESP-IDF: v5.2-beta1
Open On-Chip Debugger v0.12.0-esp32-20230921 (2023-09-21-13:41)
The debug session in VSCode is configured to use esp-debug-adapter. Configuration was taken from those tutorials:
https://github.com/espressif/vscode-esp ... bugging.md
https://github.com/espressif/vscode-esp ... BUGGING.md
Config files looks like this:
lanuch.json
Code: Select all
{
"type": "espidf",
"name": "Debug-esp-adapter",
"request": "launch",
"appOffset": "0x20000", /* Must know on which offset app was loaded - see via Monitor logs - bootloader should print this info */
// "debugPort": 4444,
"logLevel": 5,
"mode": "auto",
"verifyAppBinBeforeDebug": false,
"tmoScaleFactor": 3,
"initGdbCommands": [
"target remote :3333",
"set remote hardware-watchpoint-limit 2",
"symbol-file ${workspaceFolder}/build/${command:espIdf.getProjectName}.elf",
"mon reset halt",
"flushregs",
"thb app_main"
],
"env": {
"CUSTOM_ENV_VAR": "SOME_VALUE"
}
}
Code: Select all
{
"idf.flashType": "UART",
"idf.adapterTargetName": "esp32c6",
"idf.port": "/dev/ttyACM0",
"idf.openOcdConfigs": [
/* Via ESP-prog JTAG */
// "board/esp32c6-ftdi.cfg"
/* Via ESP-USB JTAG */
"board/esp32c6-builtin.cfg"
],
"idf.openOcdDebugLevel": 2
}
Code: Select all
/home/slawek/.espressif_v52-beta1/tools/openocd-esp32/v0.12.0-esp32-20230921/openocd-esp32/bin/openocd
[OpenOCD]
Open On-Chip Debugger v0.12.0-esp32-20230921 (2023-09-21-13:41)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
debug_level: 2
Info : only one transport option; autoselecting 'jtag'
Info : esp_usb_jtag: VID set to 0x303a and PID to 0x1001
Info : esp_usb_jtag: capabilities descriptor set to 0x2000
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : esp_usb_jtag: serial (54:32:04:03:60:1C)
Info : esp_usb_jtag: Device found. Base speed 24000KHz, div range 1 to 255
Info : clock speed 24000 kHz
Info : JTAG tap: esp32c6.cpu tap/device found: 0x0000dc25 (mfg: 0x612 (Espressif Systems), part: 0x000d, ver: 0x0)
/home/slawek/.espressif/tools/openocd-esp32/v0.12.0-esp32-20230419/openocd-esp32/bin/openocd
[OpenOCD]
Info : [esp32c6] datacount=2 progbufsize=16
[Debug Adapter]
2024-02-01 09:39:41,257 - Debug Adapter (main) - DEBUG - START_TIME_2024_02_01_09-39-41
2024-02-01 09:39:41,257 - Debug Adapter (main) - DEBUG - Init errors:None
2024-02-01 09:39:41,257 - Debug Adapter (main) - INFO - Working directory: /mnt/c/MojeProgramy/VSCode-win32-x64
2024-02-01 09:39:41,258 - Debug Adapter (main) - INFO - Arguments:
{ 'app_flash_off': 131072,
'board_type': None,
'cmdfile': '/home/user/projects/workspace/test_proj/esp-idf-vscode-generated.gdb',
'core_file': (),
'debug': 5,
'developer_mode': 'none',
'device_name': 'esp32c6',
'elfpath': ( '/home/user/projects/workspace/test_proj/build/test_proj.elf',),
'log_file': '/home/user/projects/workspace/test_proj/debug.log',
'log_mult_files': None,
'log_no_debug_console': None,
'oocd': 'openocd',
'oocd_args': None,
'oocd_ip': 'localhost',
'oocd_mode': 'connect_to_instance',
'oocd_scripts': None,
'port': 43474,
'postmortem': False,
'tmo_scale_factor': 3,
'toolchain_prefix': 'riscv32-esp-elf-'}
[Debug Adapter]
DEBUG_ADAPTER_STARTED
2024-02-01 09:39:41,258 - Debug Adapter (main) - CRITICAL - Debug adapter -> Extension: DEBUG_ADAPTER_STARTED
2024-02-01 09:39:41,258 - Debug Adapter (main) - INFO - Starting. Cmd: /home/slawek/.vscode-server/extensions/espressif.esp-idf-extension-1.7.0/esp_debug_adapter/debug_adapter_main.py -d 5 -e /home/user/projects/workspace/test_proj/build/test_proj.elf -l /home/user/projects/workspace/test_proj/debug.log -p 43474 -dn esp32c6 -a 0x20000 -t riscv32-esp-elf- -x /home/user/projects/workspace/test_proj/esp-idf-vscode-generated.gdb -tsf 3
2024-02-01 09:39:41,258 - Debug Adapter (main) - INFO - Listening on port 43474
DEBUG_ADAPTER_READY2CONNECT
2024-02-01 09:39:41,258 - Debug Adapter (main) - CRITICAL - Debug adapter -> Extension: DEBUG_ADAPTER_READY2CONNECT
[Debug Adapter]
2024-02-01 09:39:41,263 - Debug Adapter (main) - DEBUG - Got connection
2024-02-01 09:39:41,264 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Debug adapter -> Extension: DEBUG_ADAPTER_STARTED\n", "source": {}}, "seq": 0}
2024-02-01 09:39:41,265 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Starting. Cmd: /home/slawek/.vscode-server/extensions/espressif.esp-idf-extension-1.7.0/esp_debug_adapter/debug_adapter_main.py -d 5 -e /home/user/projects/workspace/test_proj/build/test_proj.elf -l /home/user/projects/workspace/test_proj/debug.log -p 43474 -dn esp32c6 -a 0x20000 -t riscv32-esp-elf- -x /home/user/projects/workspace/test_proj/esp-idf-vscode-generated.gdb -tsf 3\n\n", "source": {}}, "seq": 1}
2024-02-01 09:39:41,265 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Listening on port 43474\n", "source": {}}, "seq": 2}
2024-02-01 09:39:41,265 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Debug adapter -> Extension: DEBUG_ADAPTER_READY2CONNECT\n", "source": {}}, "seq": 3}
2024-02-01 09:39:41,265 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Got connection\n", "source": {}}, "seq": 4}
[Debug Adapter]
2024-02-01 09:39:41,278 - Debug Adapter (ReaderThread) - DEBUG - read line: >>b'Content-Length: 514\\r\\n'<<
[Debug Adapter]
2024-02-01 09:39:41,279 - Debug Adapter (ReaderThread) - DEBUG - read line: >>b'\\r\\n'<<
2024-02-01 09:39:41,279 - Debug Adapter(Command Processor) - DEBUG - Got json: {
"arguments": {
"adapterID": "espidf",
"clientID": "vscode",
"clientName": "Visual Studio Code",
"columnsStartAt1": true,
"linesStartAt1": true,
"locale": "en",
"pathFormat": "path",
"supportsArgsCanBeInterpretedByShell": true,
"supportsInvalidatedEvent": true,
"supportsMemoryEvent": true,
"supportsMemoryReferences": true,
"supportsProgressReporting": true,
"supportsRunInTerminalRequest": true,
"supportsStartDebuggingRequest": true,
"supportsVariablePaging": true,
"supportsVariableType": true
},
"command": "initialize",
"seq": 1,
"type": "request"
}
[Debug Adapter]
2024-02-01 09:39:41,279 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Got json: {\n \"arguments\": {\n \"adapterID\": \"espidf\",\n \"clientID\": \"vscode\",\n \"clientName\": \"Visual Studio Code\",\n \"columnsStartAt1\": true,\n \"linesStartAt1\": true,\n \"locale\": \"en\",\n \"pathFormat\": \"path\",\n \"supportsArgsCanBeInterpretedByShell\": true,\n \"supportsInvalidatedEvent\": true,\n \"supportsMemoryEvent\": true,\n \"supportsMemoryReferences\": true,\n \"supportsProgressReporting\": true,\n \"supportsRunInTerminalRequest\": true,\n \"supportsStartDebuggingRequest\": true,\n \"supportsVariablePaging\": true,\n \"supportsVariableType\": true\n },\n \"command\": \"initialize\",\n \"seq\": 1,\n \"type\": \"request\"\n}\n", "source": {}}, "seq": 5}
[Debug Adapter]
2024-02-01 09:39:41,282 - Gdb - DEBUG - MI->: -gdb-set mi-async on
[OpenOCD]
Info : [esp32c6] Examined RISC-V core; found 2 harts
Info : [esp32c6] XLEN=32, misa=0x40903105
Info : starting gdb server for esp32c6 on 3333
Info : Listening on port 3333 for gdb connections
[Debug Adapter]
2024-02-01 09:39:41,422 - Gdb - DEBUG - MI<-:
[{'message': 'thread-group-added',
'payload': {'id': 'i1'},
'stream': 'stdout',
'token': None,
'type': 'notify'},
{'message': 'done',
'payload': None,
'stream': 'stdout',
'token': None,
'type': 'result'}]
[Debug Adapter]
2024-02-01 09:39:41,422 - Gdb - INFO - NOTIFY: thread-group-added {'id': 'i1'}
2024-02-01 09:39:41,422 - Gdb - DEBUG - RESULT: done None
2024-02-01 09:39:41,422 - Gdb - DEBUG - MI->: -gdb-set logging file /tmp/gdb_proc.log
2024-02-01 09:39:41,423 - Gdb - DEBUG - MI<-:
[{'message': 'done',
'payload': None,
'stream': 'stdout',
'token': None,
'type': 'result'}]
[Debug Adapter]
2024-02-01 09:39:41,423 - Gdb - DEBUG - RESULT: done None
2024-02-01 09:39:41,423 - Gdb - DEBUG - MI->: -gdb-set logging on
2024-02-01 09:39:41,424 - Gdb - DEBUG - MI<-:
[{'message': None,
'payload': "Warning: 'set logging on', an alias for the command 'set logging "
"enabled', is deprecated.\\n",
'stream': 'stdout',
'type': 'console'},
{'message': None,
'payload': "Use 'set logging enabled on'.\\n\\n",
'stream': 'stdout',
'type': 'console'},
{'message': 'done',
'payload': None,
'stream': 'stdout',
'token': None,
'type': 'result'}]
2024-02-01 09:39:41,424 - Gdb - INFO - CONS: ("Warning: 'set logging on', an alias for the command 'set logging enabled', "
'is deprecated.\\n')
[Debug Adapter]
2024-02-01 09:39:41,424 - Gdb - INFO - CONS: "Use 'set logging enabled on'.\\n\\n"
2024-02-01 09:39:41,424 - Gdb - DEBUG - RESULT: done None
[Debug Adapter]
2024-02-01 09:39:41,425 - Debug Adapter (main) - DEBUG - Created gdb object of type: GdbEspRiscv
2024-02-01 09:39:41,429 - Gdb - DEBUG - MI->: -file-exec-and-symbols /home/user/projects/workspace/test_proj/build/test_proj.elf
2024-02-01 09:39:41,429 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Created gdb object of type: GdbEspRiscv\n", "source": {}}, "seq": 6}
[Debug Adapter]
2024-02-01 09:39:41,482 - Gdb - DEBUG - MI<-:
[{'message': 'done',
'payload': None,
'stream': 'stdout',
'token': None,
'type': 'result'}]
[Debug Adapter]
2024-02-01 09:39:41,482 - Gdb - DEBUG - RESULT: done None
2024-02-01 09:39:41,483 - Gdb - DEBUG - Connecting to 127.0.0.1:3333
2024-02-01 09:39:41,483 - Gdb - DEBUG - MI->: -target-select remote 127.0.0.1:3333
[OpenOCD]
Info : accepting 'gdb' connection on tcp/3333
[OpenOCD]
Memory protection is enabled. Reset target to disable it...
[OpenOCD]
Info : JTAG tap: esp32c6.cpu tap/device found: 0x0000dc25 (mfg: 0x612 (Espressif Systems), part: 0x000d, ver: 0x0)
[OpenOCD]
Info : [esp32c6] Reset cause (24) - (JTAG CPU reset)
[OpenOCD]
Warn : No symbols for FreeRTOS!
[OpenOCD]
Info : [esp32c6] Found 4 triggers.
[OpenOCD]
Info : Flash mapping 0: 0x20020 -> 0x42020020, 55 KB
Info : Flash mapping 1: 0x30020 -> 0x42000020, 109 KB
[OpenOCD]
Info : Auto-detected flash bank 'esp32c6.flash' size 4096 KB
Info : Using flash bank 'esp32c6.flash' size 4096 KB
[OpenOCD]
Info : Flash mapping 0: 0x20020 -> 0x42020020, 55 KB
Info : Flash mapping 1: 0x30020 -> 0x42000020, 109 KB
Info : Using flash bank 'esp32c6.irom' size 112 KB
[OpenOCD]
Info : Flash mapping 0: 0x20020 -> 0x42020020, 55 KB
Info : Flash mapping 1: 0x30020 -> 0x42000020, 109 KB
Info : Using flash bank 'esp32c6.drom' size 56 KB
[OpenOCD]
❌ Warn : negative reply, retrying
Warn : negative reply, retrying
Warn : negative reply, retrying
Error: GDB missing ack(2) - assumed good
Error: GDB missing ack(2) - assumed good
Error: GDB missing ack(2) - assumed good
[OpenOCD]
❌ Error: Error on socket 'GDB': errno==104, message: Connection reset by peer.
Info : dropped 'gdb' connection
[Debug Adapter]
2024-02-01 09:40:11,483 - Gdb - DEBUG - MI<-:
[{'message': None,
'payload': 'Ignoring packet error, continuing...\\n',
'stream': 'stdout',
'type': 'console'},
{'message': None,
'payload': 'warning: unrecognized item \\"timeout\\" in \\"qSupported\\" '
'response\\n',
'stream': 'stdout',
'type': 'log'},
{'message': 'error',
'payload': {'msg': "Remote replied unexpectedly to 'vMustReplyEmpty': "
'PacketSize=4000;qXfer:memory-map:read+;qXfer:features:read+;qXfer:threads:read+;QStartNoAckMode+;vContSupported+'},
'stream': 'stdout',
'token': None,
'type': 'result'}]
2024-02-01 09:40:11,483 - Gdb - INFO - CONS: 'Ignoring packet error, continuing...\\n'
2024-02-01 09:40:11,483 - Gdb - DEBUG - LOG: 'warning: unrecognized item \\"timeout\\" in \\"qSupported\\" response\\n'
[Debug Adapter]
2024-02-01 09:40:11,483 - Gdb - DEBUG - RESULT: error {'msg': "Remote replied unexpectedly to 'vMustReplyEmpty': "
'PacketSize=4000;qXfer:memory-map:read+;qXfer:features:read+;qXfer:threads:read+;QStartNoAckMode+;vContSupported+'}
2024-02-01 09:40:11,483 - Debug Adapter (main) - ERROR - Failed to connect to "remote 127.0.0.1:3333"!
Traceback (most recent call last):
File "/home/slawek/.vscode-server/extensions/espressif.esp-idf-extension-1.7.0/esp_debug_adapter/debug_adapter/command_processor.py", line 52, in __call__
on_request(protocol_message)
File "/home/slawek/.vscode-server/extensions/espressif.esp-idf-extension-1.7.0/esp_debug_adapter/debug_adapter/command_processor.py", line 75, in on_initialize_request
raise e
File "/home/slawek/.vscode-server/extensions/espressif.esp-idf-extension-1.7.0/esp_debug_adapter/debug_adapter/command_processor.py", line 70, in on_initialize_request
self.da.adapter_init()
File "/home/slawek/.vscode-server/extensions/espressif.esp-idf-extension-1.7.0/esp_debug_adapter/debug_adapter/debug_adapter.py", line 329, in adapter_init
raise e
File "/home/slawek/.vscode-server/extensions/espressif.esp-idf-extension-1.7.0/esp_debug_adapter/debug_adapter/debug_adapter.py", line 325, in adapter_init
self.start_gdb()
File "/home/slawek/.vscode-server/extensions/espressif.esp-idf-extension-1.7.0/esp_debug_adapter/debug_adapter/debug_adapter.py", line 678, in start_gdb
raise e
File "/home/slawek/.vscode-server/extensions/espressif.esp-idf-extension-1.7.0/esp_debug_adapter/debug_adapter/debug_adapter.py", line 675, in start_gdb
self._gdb.connect()
File "/home/slawek/.espressif_v52-beta1/python_env/idf5.2_py3.10_env/lib/python3.10/site-packages/esp_debug_backend/gdb.py", line 599, in connect
self.target_select(remote_mode, self._remote_target, tmo=tmo)
File "/home/slawek/.espressif_v52-beta1/python_env/idf5.2_py3.10_env/lib/python3.10/site-packages/esp_debug_backend/gdb.py", line 265, in target_select
raise DebuggerError('Failed to connect to "%s %s"!' % (tgt_type, tgt_params))
esp_debug_backend.defs.DebuggerError: Failed to connect to "remote 127.0.0.1:3333"!
2024-02-01 09:40:11,484 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "response", "request_seq": 1, "success": false, "command": "initialize", "seq": 7, "message": "Failed to init Debug Adapter!", "body": {}}
[Debug Adapter]
2024-02-01 09:40:11,484 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Failed to connect to \"remote 127.0.0.1:3333\"!\n", "source": {}}, "seq": 8}
2024-02-01 09:40:11,484 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Failed to connect to \"remote 127.0.0.1:3333\"!\n", "source": {}}, "seq": 9}
[Debug Adapter]
2024-02-01 09:40:11,555 - Debug Adapter (ReaderThread) - DEBUG - read line: >>b'Content-Length: 79\\r\\n'<<
2024-02-01 09:40:11,555 - Debug Adapter (ReaderThread) - DEBUG - read line: >>b'\\r\\n'<<
2024-02-01 09:40:11,555 - Debug Adapter(Command Processor) - DEBUG - Got json: {
"arguments": {
"restart": false
},
"command": "disconnect",
"seq": 2,
"type": "request"
}
2024-02-01 09:40:11,556 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Got json: {\n \"arguments\": {\n \"restart\": false\n },\n \"command\": \"disconnect\",\n \"seq\": 2,\n \"type\": \"request\"\n}\n", "source": {}}, "seq": 10}
2024-02-01 09:40:11,556 - Debug Adapter (main) - DEBUG - Adapter is Stopping...
2024-02-01 09:40:11,557 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Debug Adapter stopped\n", "source": {}}, "seq": 11}
2024-02-01 09:40:11,558 - Debug Adapter (main) - DEBUG - Stopping target poller
2024-02-01 09:40:11,559 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Adapter is Stopping...\n", "source": {}}, "seq": 12}
2024-02-01 09:40:11,559 - Debug Adapter (main) - DEBUG - Closing the GDB process
2024-02-01 09:40:11,560 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Stopping target poller\n", "source": {}}, "seq": 13}
2024-02-01 09:40:11,561 - Debug Adapter (main) - DEBUG - Closing the Socket
2024-02-01 09:40:11,562 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Closing the GDB process\n", "source": {}}, "seq": 14}
2024-02-01 09:40:11,563 - Debug Adapter (main) - DEBUG - Stopping of the Writer thread
2024-02-01 09:40:11,564 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Closing the Socket\n", "source": {}}, "seq": 15}
2024-02-01 09:40:11,565 - Debug Adapter (main) - DEBUG - Stopping of the Reader thread
2024-02-01 09:40:11,565 - Debug Adapter (main) - DEBUG - Adapter is Stopped
DEBUG_ADAPTER_STOPPED
2024-02-01 09:40:11,565 - Debug Adapter (main) - CRITICAL - Debug adapter -> Extension: DEBUG_ADAPTER_STOPPED
2024-02-01 09:40:11,565 - Debug Adapter(Command Processor) - DEBUG - Processed command: disconnect
[Stopped] : ESP-IDF Debug Adapter
[OpenOCD]
[Stopped] : OpenOCD Server