ESP32C3 VS Code Extension debugger not working

k.venkatraman
Posts: 1
Joined: Sun Apr 23, 2023 1:49 am

ESP32C3 VS Code Extension debugger not working

Postby k.venkatraman » Sun Apr 23, 2023 1:59 am

Hello,
I am having difficulty setting up debugger for ESP32C3 M1 Dev kit on VS Code on MacOS.
I am able to flash the blink.elf binary over internal JTAG on the command line using

Code: Select all

openocd -f board/esp32c3-builtin.cfg -c "program_esp /Users/k.venkatraman/Cue-Hub/ESP-Projects/blink/build/blink.bin 0x10000 verify exit"
But, when I try to debug using the ESP-IDF adapter within VS Code, I get the following error on the OUTPUT window
[OpenOCD]
Open On-Chip Debugger v0.11.0-esp32-20220706 (2022-07-06-15:49)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
debug_level: 2

[OpenOCD]
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
[OpenOCD]
❌ Error: no device found
Error: unable to open ftdi device with vid 0403, pid 6010, description '*', serial '*' at bus location '*'
[OpenOCD]
❌ Error: no device found
Error: unable to open ftdi device with vid 0403, pid 6014, description '*', serial '*' at bus location '*'

Error: Unsupported xlen: -1
Error: Unknown target arch!
[OpenOCD]
[Stopped] : OpenOCD Server
[Debug Adapter]
2023-04-22 20:57:22,052 - Debug Adapter (main) - DEBUG - START_TIME_2023_04_22_20-57-22
[Debug Adapter]
2023-04-22 20:57:22,052 - Debug Adapter (main) - DEBUG - Init errors:None
2023-04-22 20:57:22,052 - Debug Adapter (main) - INFO - Working directory: /
[Debug Adapter]
2023-04-22 20:57:22,053 - Debug Adapter (main) - INFO - Arguments:
{ 'app_flash_off': 65536,
'board_type': None,
'cmdfile': '/Users/k.venkatraman/Cue-Hub/ESP-Projects/blink/gdbinit',
'core_file': (),
'debug': 5,
'developer_mode': 'none',
'device_name': 'esp32c3',
'elfpath': ( '/Users/k.venkatraman/Cue-Hub/ESP-Projects/blink/build/blink.elf',),
'log_file': '/Users/k.venkatraman/Cue-Hub/ESP-Projects/blink/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': 1,
'toolchain_prefix': 'riscv32-esp-elf-'}
[Debug Adapter]
DEBUG_ADAPTER_STARTED
2023-04-22 20:57:22,053 - Debug Adapter (main) - CRITICAL - Debug adapter -> Extension: DEBUG_ADAPTER_STARTED
[Debug Adapter]
2023-04-22 20:57:22,053 - Debug Adapter (main) - INFO - Starting. Cmd: /Users/k.venkatraman/.vscode/extensions/espressif.esp-idf-extension-1.6.1/esp_debug_adapter/debug_adapter_main.py -d 5 -e /Users/k.venkatraman/Cue-Hub/ESP-Projects/blink/build/blink.elf -l /Users/k.venkatraman/Cue-Hub/ESP-Projects/blink/debug.log -p 43474 -dn esp32c3 -a 0x10000 -t riscv32-esp-elf- -x /Users/k.venkatraman/Cue-Hub/ESP-Projects/blink/gdbinit

[Debug Adapter]
2023-04-22 20:57:22,056 - Debug Adapter (main) - INFO - Listening on port 43474
[Debug Adapter]
DEBUG_ADAPTER_READY2CONNECT
2023-04-22 20:57:22,056 - Debug Adapter (main) - CRITICAL - Debug adapter -> Extension: DEBUG_ADAPTER_READY2CONNECT
[Debug Adapter]
2023-04-22 20:57:22,057 - Debug Adapter (main) - DEBUG - Got connection
[Debug Adapter]
2023-04-22 20:57:22,057 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Debug adapter -> Extension: DEBUG_ADAPTER_STARTED\n", "source": {}}, "seq": 0}

[Debug Adapter]
2023-04-22 20:57:22,058 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Starting. Cmd: /Users/k.venkatraman/.vscode/extensions/espressif.esp-idf-extension-1.6.1/esp_debug_adapter/debug_adapter_main.py -d 5 -e /Users/k.venkatraman/Cue-Hub/ESP-Projects/blink/build/blink.elf -l /Users/k.venkatraman/Cue-Hub/ESP-Projects/blink/debug.log -p 43474 -dn esp32c3 -a 0x10000 -t riscv32-esp-elf- -x /Users/k.venkatraman/Cue-Hub/ESP-Projects/blink/gdbinit\n\n", "source": {}}, "seq": 1}

2023-04-22 20:57:22,058 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Listening on port 43474\n", "source": {}}, "seq": 2}

2023-04-22 20:57:22,058 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Debug adapter -> Extension: DEBUG_ADAPTER_READY2CONNECT\n", "source": {}}, "seq": 3}

2023-04-22 20:57:22,058 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Got connection\n", "source": {}}, "seq": 4}

[Debug Adapter]
2023-04-22 20:57:22,059 - Debug Adapter (ReaderThread) - DEBUG - read line: >>b'Content-Length: 453\\r\\n'<<

2023-04-22 20:57:22,059 - Debug Adapter (ReaderThread) - DEBUG - read line: >>b'\\r\\n'<<

[Debug Adapter]
2023-04-22 20:57:22,060 - Debug Adapter(Command Processor) - DEBUG - Got json: {
"arguments": {
"adapterID": "espidf",
"clientID": "vscode",
"clientName": "Visual Studio Code",
"columnsStartAt1": true,
"linesStartAt1": true,
"locale": "en-us",
"pathFormat": "path",
"supportsArgsCanBeInterpretedByShell": true,
"supportsInvalidatedEvent": true,
"supportsMemoryReferences": true,
"supportsProgressReporting": true,
"supportsRunInTerminalRequest": true,
"supportsVariablePaging": true,
"supportsVariableType": true
},
"command": "initialize",
"seq": 1,
"type": "request"
}
[Debug Adapter]
2023-04-22 20:57:22,060 - 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-us\",\n \"pathFormat\": \"path\",\n \"supportsArgsCanBeInterpretedByShell\": true,\n \"supportsInvalidatedEvent\": true,\n \"supportsMemoryReferences\": true,\n \"supportsProgressReporting\": true,\n \"supportsRunInTerminalRequest\": true,\n \"supportsVariablePaging\": true,\n \"supportsVariableType\": true\n },\n \"command\": \"initialize\",\n \"seq\": 1,\n \"type\": \"request\"\n}\n", "source": {}}, "seq": 5}

[Debug Adapter]
2023-04-22 20:57:22,066 - Gdb - DEBUG - MI->: -gdb-set mi-async on
[Debug Adapter]
2023-04-22 20:57:22,384 - 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]
2023-04-22 20:57:22,385 - Gdb - INFO - NOTIFY: thread-group-added {'id': 'i1'}
2023-04-22 20:57:22,385 - Gdb - DEBUG - RESULT: done None
2023-04-22 20:57:22,385 - Gdb - DEBUG - MI->: -gdb-set logging file /var/folders/mf/j3g8lz8s4pj_ktqjjzw_bkdh0000gq/T/gdb_proc.log
[Debug Adapter]
2023-04-22 20:57:22,385 - Gdb - DEBUG - MI<-:
[{'message': 'done',
'payload': None,
'stream': 'stdout',
'token': None,
'type': 'result'}]
[Debug Adapter]
2023-04-22 20:57:22,385 - Gdb - DEBUG - RESULT: done None
2023-04-22 20:57:22,385 - Gdb - DEBUG - MI->: -gdb-set logging on
[Debug Adapter]
2023-04-22 20:57:22,385 - Gdb - DEBUG - MI<-:
[{'message': 'done',
'payload': None,
'stream': 'stdout',
'token': None,
'type': 'result'}]
2023-04-22 20:57:22,385 - Gdb - DEBUG - RESULT: done None
2023-04-22 20:57:22,385 - Gdb - DEBUG - MI->: -gdb-set arch riscv:rv32
[Debug Adapter]
2023-04-22 20:57:22,386 - Gdb - DEBUG - MI<-:
[{'message': None,
'payload': 'The target architecture is set to \\"riscv:rv32\\".\\n',
'stream': 'stdout',
'type': 'console'},
{'message': 'done',
'payload': None,
'stream': 'stdout',
'token': None,
'type': 'result'}]
[Debug Adapter]
2023-04-22 20:57:22,386 - Gdb - INFO - CONS: 'The target architecture is set to \\"riscv:rv32\\".\\n'
2023-04-22 20:57:22,386 - Gdb - DEBUG - RESULT: done None
[Debug Adapter]
2023-04-22 20:57:22,386 - Debug Adapter (main) - DEBUG - Created gdb object of type: GdbEsp32c3
[Debug Adapter]
2023-04-22 20:57:22,387 - Gdb - DEBUG - MI->: -file-exec-and-symbols /Users/k.venkatraman/Cue-Hub/ESP-Projects/blink/build/blink.elf
[Debug Adapter]
2023-04-22 20:57:22,387 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Created gdb object of type: GdbEsp32c3\n", "source": {}}, "seq": 6}

[Debug Adapter]
2023-04-22 20:57:22,413 - Gdb - DEBUG - MI<-:
[{'message': 'done',
'payload': None,
'stream': 'stdout',
'token': None,
'type': 'result'}]
[Debug Adapter]
2023-04-22 20:57:22,413 - Gdb - DEBUG - RESULT: done None
2023-04-22 20:57:22,413 - Gdb - DEBUG - Connecting to 127.0.0.1:3333
[Debug Adapter]
2023-04-22 20:57:22,413 - Gdb - DEBUG - MI->: -target-select remote 127.0.0.1:3333
[Debug Adapter]
2023-04-22 20:57:32,413 - Gdb - DEBUG - MI<-:
[]
[Debug Adapter]
2023-04-22 20:57:32,414 - Debug Adapter (main) - ERROR - Failed to wait for completion of command "-target-select remote 127.0.0.1:3333" / 10!
Traceback (most recent call last):
File "/Users/k.venkatraman/.vscode/extensions/espressif.esp-idf-extension-1.6.1/esp_debug_adapter/debug_adapter/command_processor.py", line 52, in __call__
on_request(protocol_message)
File "/Users/k.venkatraman/.vscode/extensions/espressif.esp-idf-extension-1.6.1/esp_debug_adapter/debug_adapter/command_processor.py", line 75, in on_initialize_request
raise e
File "/Users/k.venkatraman/.vscode/extensions/espressif.esp-idf-extension-1.6.1/esp_debug_adapter/debug_adapter/command_processor.py", line 70, in on_initialize_request
self.da.adapter_init()
File "/Users/k.venkatraman/.vscode/extensions/espressif.esp-idf-extension-1.6.1/esp_debug_adapter/debug_adapter/debug_adapter.py", line 329, in adapter_init
raise e
File "/Users/k.venkatraman/.vscode/extensions/espressif.esp-idf-extension-1.6.1/esp_debug_adapter/debug_adapter/debug_adapter.py", line 325, in adapter_init
self.start_gdb()
File "/Users/k.venkatraman/.vscode/extensions/espressif.esp-idf-extension-1.6.1/esp_debug_adapter/debug_adapter/debug_adapter.py", line 659, in start_gdb
raise e
File "/Users/k.venkatraman/.vscode/extensions/espressif.esp-idf-extension-1.6.1/esp_debug_adapter/debug_adapter/debug_adapter.py", line 656, in start_gdb
self._gdb.connect()
File "/Users/k.venkatraman/.vscode/extensions/espressif.esp-idf-extension-1.6.1/esp_debug_adapter/debug_adapter/debug_backend/debug_backend/gdb.py", line 578, in connect
self.target_select(remote_mode, self._remote_target, tmo=tmo)
File "/Users/k.venkatraman/.vscode/extensions/espressif.esp-idf-extension-1.6.1/esp_debug_adapter/debug_adapter/debug_backend/debug_backend/gdb.py", line 255, in target_select
res, _ = self._mi_cmd_run('-target-select %s %s' % (tgt_type, tgt_params),
File "/Users/k.venkatraman/.vscode/extensions/espressif.esp-idf-extension-1.6.1/esp_debug_adapter/debug_adapter/debug_backend/debug_backend/gdb.py", line 206, in _mi_cmd_run
raise DebuggerTargetStateTimeoutError(
debug_adapter.debug_backend.debug_backend.defs.DebuggerTargetStateTimeoutError: Failed to wait for completion of command "-target-select remote 127.0.0.1:3333" / 10!
[Debug Adapter]
2023-04-22 20:57:32,414 - 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]
2023-04-22 20:57:32,415 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Failed to wait for completion of command \"-target-select remote 127.0.0.1:3333\" / 10!\n", "source": {}}, "seq": 8}

2023-04-22 20:57:32,415 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Failed to wait for completion of command \"-target-select remote 127.0.0.1:3333\" / 10!\n", "source": {}}, "seq": 9}

[Debug Adapter]
2023-04-22 20:57:32,447 - Debug Adapter (ReaderThread) - DEBUG - read line: >>b'Content-Length: 79\\r\\n'<<

2023-04-22 20:57:32,447 - Debug Adapter (ReaderThread) - DEBUG - read line: >>b'\\r\\n'<<

2023-04-22 20:57:32,447 - Debug Adapter(Command Processor) - DEBUG - Got json: {
"arguments": {
"restart": false
},
"command": "disconnect",
"seq": 2,
"type": "request"
}
2023-04-22 20:57:32,448 - Debug Adapter (main) - DEBUG - Adapter is Stopping...
2023-04-22 20:57:32,448 - Debug Adapter (main) - DEBUG - Stopping target poller
2023-04-22 20:57:32,448 - 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}

2023-04-22 20:57:32,448 - Debug Adapter (main) - DEBUG - Closing the GDB process
2023-04-22 20:57:32,448 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Debug Adapter stopped\n", "source": {}}, "seq": 11}

2023-04-22 20:57:32,448 - Debug Adapter (main) - DEBUG - Closing the Socket
2023-04-22 20:57:32,448 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Adapter is Stopping...\n", "source": {}}, "seq": 12}

2023-04-22 20:57:32,448 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Stopping target poller\n", "source": {}}, "seq": 13}

2023-04-22 20:57:32,448 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Closing the GDB process\n", "source": {}}, "seq": 14}

2023-04-22 20:57:32,448 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Closing the Socket\n", "source": {}}, "seq": 15}

2023-04-22 20:57:32,448 - Debug Adapter (main) - DEBUG - Stopping of the Writer thread
2023-04-22 20:57:32,449 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Stopping of the Writer thread\n", "source": {}}, "seq": 16}

2023-04-22 20:57:32,449 - Debug Adapter (main) - DEBUG - Stopping of the Reader thread
2023-04-22 20:57:32,449 - Debug Adapter (main) - DEBUG - Adapter is Stopped
DEBUG_ADAPTER_STOPPED
2023-04-22 20:57:32,449 - Debug Adapter (main) - CRITICAL - Debug adapter -> Extension: DEBUG_ADAPTER_STOPPED
2023-04-22 20:57:32,449 - Debug Adapter(Command Processor) - DEBUG - Processed command: disconnect
[Stopped] : ESP-IDF Debug Adapter
My launch.json file is as below:

Code: Select all

{
    "version": "0.2.0",
    "configurations": [
      {
        "type": "espidf",
        "name": "ESP-IDF OpenOcd",
        "request": "launch",
        "debugPort": 43474,
        "logLevel": 5
      }
    ]
  }

ESP_bignacio
Posts: 229
Joined: Wed May 02, 2018 12:12 pm

Re: ESP32C3 VS Code Extension debugger not working

Postby ESP_bignacio » Tue Apr 25, 2023 6:02 am

Based on your output it seems you are having some timeout issues.

You can increase the timeout of the debug adapter with "tmoScaleFactor": 2, in your launch.json where 2 is the timeout scale factor (a multiplier) as described in debugging documentation

Who is online

Users browsing this forum: No registered users and 58 guests