Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32C3 GDB can't connect through USB built-in JTAG (OCD-412) #182

Closed
jeancf opened this issue Oct 2, 2021 · 4 comments
Closed

ESP32C3 GDB can't connect through USB built-in JTAG (OCD-412) #182

jeancf opened this issue Oct 2, 2021 · 4 comments

Comments

@jeancf
Copy link

jeancf commented Oct 2, 2021

Environment

  • Development Kit: Ai-Thinker NodeMCU Series ESP32-C3S Kit and Lilygo TTGO T-OI PLUS
  • Module or chip used: ESPC32C3
  • Debug Adapter: USB built-in
  • OpenOCD version: v0.10.0-esp32-20210902
  • Operating System: Linux (Arch)
  • Using an IDE?: No
  • OpenOCD command line: openocd -f board/esp32c3-builtin.cfg or openocd -f board/esp32c3-builtin.cfg -c "adapter_khz 3000"
  • JTAG Clock: default or 3000 khz
  • ESP-IDF version: git master

Problem Description

I tested with the 2 boards mentioned above with the same result. I will describe the output of the Liliygo here but I can provide the NodeMCU as well if necessary.

Steps to reproduce the behavior:

  1. followed the documentation to install ESP-IDF from git.
  2. built hello_world example with idf.py build
  3. connected USB cable to 5V, GND, D+ and D- pins
  4. uploaded binary with openocd -f board/esp32c3-builting.cfg -c "program_esp build/hello_world.bin 0x10000 verify exit" with no error
  5. Launch openocd for debugging with openocd -f board/esp32c3-builtin.cfg
  6. In a separate console, launch riscv32-esp-elf-gdb
  7. At the (gdb) prompt, enter target remote :3333
  8. gdb fails. See detailed logs below
Reading symbols from build/hello-world.elf...
Ignoring packet error, continuing...
warning: unrecognized item "timeout" in "qSupported" response
Remote replied unexpectedly to 'vMustReplyEmpty': PacketSize=4000;qXfer:memory-map:read+;qXfer:features:read+;qXfer:threads:read+;QStartNoAckMode+;vContSupported+

Debug Logs

gdb_log.txt

w +$qSupported:multiprocess+;swbreak+;hwbreak+;qRelocInsn+;fork-events+;vfork-events+;exec-events+;vContSupported+;QThreadEvents+;no-resumed+#df
r +<Timeout: 2 seconds>
w -
r <Timeout: 2 seconds>
w -
r <Timeout: 2 seconds>
w -+$vMustReplyEmpty#3a
r <Timeout: 2 seconds>
w $vMustReplyEmpty#3a
r <Timeout: 2 seconds>
w $vMustReplyEmpty#3a
r <Timeout: 2 seconds>
w $vMustReplyEmpty#3a
r <Timeout: 2 seconds>+$PacketSize=4000;qXfer:memory-map:read+;qXfer:features:read+;qXfer:threads:read+;QStartNoAckMode+;vContSupported+#02
w +
End of log

openocd_log.txt (too large to fit here)

Expected behavior

A functional debug prompt

@github-actions github-actions bot changed the title ESP32C3 GDB can't connect through USB built-in JTAG ESP32C3 GDB can't connect through USB built-in JTAG (OCD-412) Oct 2, 2021
@DmytroKorniienko
Copy link

DmytroKorniienko commented Oct 2, 2021

Same issue. I'm trying custom config for platformio:

debug_tool = custom
debug_server =
$PLATFORMIO_CORE_DIR/packages/tool-openocd-esp32/bin/openocd
-f
$PLATFORMIO_CORE_DIR/packages/tool-openocd-esp32/share/openocd/scripts/board/esp32c3-builtin.cfg

but get an error:

PlatformIO Unified Debugger -> http://bit.ly/pio-debug
PlatformIO: debug_tool = custom
PlatformIO: Initializing remote target...
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
adapter speed: 5000 kHz

Info : tcl server disabled
Info : telnet server disabled
Info : esp_usb_jtag: Device found. Base speed 40000KHz, div range 1 to 255
Info : clock speed 5000 kHz
Error: esp_usb_jtag: usb sent only 0 out of 1 bytes.
Error: esp_usb_jtag: usb sent only 0 out of 2 bytes.
Error: esp_usb_jtag: usb sent only 0 out of 4 bytes.
Error: esp_usb_jtag: usb sent only 0 out of 13 bytes.
Error: missing data from bitq interface


update:
Seems driver replacment (USB JTAG/serial debug unit (Interface 2) to WinUSB (v6.1.7600.16385) ) solve this issue:

.platformio\packages\tool-openocd-esp32\bin>openocd -f ...\share\openocd\scripts\board\esp32c3-builtin.cfg
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

@jeancf
Copy link
Author

jeancf commented Oct 7, 2021

Hello. I am the OP and my problem is not resolved. My issue is unrelated to that of @DmytroKorniienko above.

@gerekon
Copy link
Collaborator

gerekon commented Oct 8, 2021

@jeancf

It looks like GDB's remote timeout expires while OpenOCD tries to get flash mapping for your app (default is 2 sec). Can you try set remotetimeout 10 (or higher) before target remote :3333?

@jeancf
Copy link
Author

jeancf commented Oct 10, 2021

Thank you for your feedback.

Out of multiple attempts with different values of time out I managed to connect only once to the board. I then tried installing idf on another host and with this one I managed to connect flawlessly at every attempt. It turns out that there is something wrong with the USB interface of the first host (an old Dell laptop).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants