Problem: Setting up JTAG debugger for ESP32

e2738729
Posts: 35
Joined: Mon Nov 05, 2018 6:22 pm

Problem: Setting up JTAG debugger for ESP32

Postby e2738729 » Thu Nov 15, 2018 11:05 pm

Hi everyone,

I have a lot of troubles setting up JTAG debugger for ESP32 and hopefully you could help me.
The behavior is that after I started openOCD on mingw32.exe and run openOCD, and I click on "debug" button in Eclipse, eclipse does not response and stucks at 87% "Launching Scan"

Hardware setup: ESP32-THING (Sparkfun), TIAO USB Multi-protocol Adapter.
Software Setup: OS Windows, Ecclipse, OpenOCD.

So I decided to run openOCD and GDB from mingw32.exe terminals. The below are the steps that I did:

1. Selected USB serial COM3 and Baudrate 115200 on Putty
2. Setup GDB in Eclipse using the below link: https://docs.espressif.com/projects/esp ... mmand-line
3. I opened mingw32.exe twice so that I have 2 terminals opened.
4. On the first mingw32 terminal, I typed

Code: Select all

cd ~/esp/openocd-esp32
bin/openocd -s share/openocd/scripts -f interface/ftdi/tumpa.cfg -f board/esp-wroom-32.cfg
The below is the log output on the openOCD:

Code: Select all

Open On-Chip Debugger 0.10.0-dev (2018-09-20-12:54)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
none separate
adapter speed: 20000 kHz
esp32 interrupt mask on
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 : Detected debug stubs @ 3ffb3900 on core0 of target 'esp32'
cpu0: Current bits set: BreakIn BreakOut RunStallIn
cpu1: Current bits set: BreakIn BreakOut RunStallIn
5. I then typed on the second mingw32 terminal:

Code: Select all

 xtensa-esp32-elf-gdb -x .gdbinit build/scan.elf
Now, both openOCD and GDB terminals show new information:
The below is the log output from the openOCD:

Code: Select all

Info : accepting 'gdb' connection on tcp/3333
Info : Target halted. PRO_CPU: PC=0x40131B3E (active) APP_CPU: PC=0x40131B3E
Info : Target halted. PRO_CPU: PC=0x4009175E (active) APP_CPU: PC=0x40131B3E
Info : Flash mapping 0: 0x10020 -> 0x3f400020, 83 KB
Info : Flash mapping 1: 0x30018 -> 0x400d0018, 394 KB
Info : Target halted. PRO_CPU: PC=0x4009175E (active) APP_CPU: PC=0x40131B3E
Info : Auto-detected flash size 4096 KB
Info : Using flash size 4096 KB
Info : Target halted. PRO_CPU: PC=0x4009175E (active) APP_CPU: PC=0x40131B3E
Info : Flash mapping 0: 0x10020 -> 0x3f400020, 83 KB
Info : Flash mapping 1: 0x30018 -> 0x400d0018, 394 KB
Info : Using flash size 396 KB
Info : Target halted. PRO_CPU: PC=0x4009175E (active) APP_CPU: PC=0x40131B3E
Info : Flash mapping 0: 0x10020 -> 0x3f400020, 83 KB
Info : Flash mapping 1: 0x30018 -> 0x400d0018, 394 KB
Info : Using flash size 84 KB
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)
cpu0: Current bits set: BreakIn BreakOut RunStallIn
cpu1: Current bits set: BreakIn BreakOut RunStallIn
Info : esp32: Debug controller was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core was reset (pwrstat=0x5F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x5000004B (active) APP_CPU: PC=0x00000000
Info : esp32: Core was reset (pwrstat=0x1F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x40000400 (active) APP_CPU: PC=0x40000400
Info : Detected debug stubs @ 3ffb3900 on core0 of target 'esp32'
The below is the log output from GDB mingw32:

Code: Select all

GNU gdb (crosstool-NG crosstool-ng-1.22.0-80-g6c4433a5) 7.10
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-host_pc-mingw32 --target=xtensa-esp32-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
0x40131b3e in ?? ()
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)
cpu0: Current bits set: BreakIn BreakOut RunStallIn
cpu1: Current bits set: BreakIn BreakOut RunStallIn
esp32: Debug controller was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Core was reset (pwrstat=0x5F, after clear 0x0F).
Target halted. PRO_CPU: PC=0x5000004B (active) APP_CPU: PC=0x00000000
esp32: Core was reset (pwrstat=0x1F, after clear 0x0F).
Target halted. PRO_CPU: PC=0x40000400 (active) APP_CPU: PC=0x40000400
No symbol table is loaded. Use the "file" command.
Make hw breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
Detected debug stubs @ 3ffb3900 on core0 of target 'esp32'
I was not able to answer Y or N, what should I do to make it works on Eclipse?

Thank you for your help

ESP_igrr
Posts: 2067
Joined: Tue Dec 01, 2015 8:37 am

Re: Problem: Setting up JTAG debugger for ESP32

Postby ESP_igrr » Fri Nov 16, 2018 2:03 am

What is the contents of your .gdbinit file? If you are setting a breakpoint in this file, you might need to pass the .elf file as the first argument to Gdb, before passing the gdbinit file.

e2738729
Posts: 35
Joined: Mon Nov 05, 2018 6:22 pm

Re: Problem: Setting up JTAG debugger for ESP32

Postby e2738729 » Mon Nov 19, 2018 5:17 pm

Hi esp_igrr,

Thank you and sorry for the late reply. The below is the content of my .gdbinit. This is the code that I got from the jtag instruction from expressif website:

Code: Select all

set auto-load safe-path /
target remote :3333
mon reset halt
flushregs
thb app_main
c
you might need to pass the .elf file as the first argument to Gdb, before passing the gdbinit file.
What does it mean by passing the .elf file as the first argument to Gdb?

Thanks again

ESP_igrr
Posts: 2067
Joined: Tue Dec 01, 2015 8:37 am

Re: Problem: Setting up JTAG debugger for ESP32

Postby ESP_igrr » Tue Nov 20, 2018 12:10 am

xtensa-esp32-elf-gdb build/scan.elf -x .gdbinit

e2738729
Posts: 35
Joined: Mon Nov 05, 2018 6:22 pm

Re: Problem: Setting up JTAG debugger for ESP32

Postby e2738729 » Wed Nov 21, 2018 3:59 am

Hi ESP_igrr,

I tried your code and the output log from both terminals are the same as before. Do you think there is something else I could look in to?

Thank you,

e2738729
Posts: 35
Joined: Mon Nov 05, 2018 6:22 pm

Re: Problem: Setting up JTAG debugger for ESP32

Postby e2738729 » Wed Nov 21, 2018 4:05 am

Another thing I forgot to mention but it might be important. TIAO USB Multi-Protocol Adapter drivers (both Interface 0 and 1) are now WinUSB since I used Zadig to convert them.

ESP_igrr
Posts: 2067
Joined: Tue Dec 01, 2015 8:37 am

Re: Problem: Setting up JTAG debugger for ESP32

Postby ESP_igrr » Wed Nov 21, 2018 2:43 pm

It's strange that gdb still says

No symbol table is loaded. Use the "file" command.
Make hw breakpoint pending on future shared

even though the command file is specified after the elf file. Could you please try renaming .gdbinit into gdbinit (without leading dot) and try again? Maybe gdb is loading .gdbinit implicitly... Alternatively, start gdb without -x gdbinit argument, and type the commands into gdb console directly, as a test.

e2738729
Posts: 35
Joined: Mon Nov 05, 2018 6:22 pm

Re: Problem: Setting up JTAG debugger for ESP32

Postby e2738729 » Sun Nov 25, 2018 3:38 pm

Hi esp_igrr,

I tried both of your methods and the results are the same. The problem is that gdb does not prompt me to write "-x .gdbinit."

Code: Select all

xtensa-esp32-elf-gdb build/scan.elf

Code: Select all

GNU gdb (crosstool-NG crosstool-ng-1.22.0-80-g6c4433a5) 7.10
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-host_pc-mingw32 --target=xtensa-esp32-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
0x40131b3e in ?? ()
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)
cpu0: Current bits set: BreakIn BreakOut RunStallIn
cpu1: Current bits set: BreakIn BreakOut RunStallIn
esp32: Debug controller was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Core was reset (pwrstat=0x5F, after clear 0x0F).
Target halted. PRO_CPU: PC=0x5000004B (active)    APP_CPU: PC=0x00000000
esp32: Core was reset (pwrstat=0x1F, after clear 0x0F).
Target halted. PRO_CPU: PC=0x40000400 (active)    APP_CPU: PC=0x40000400
No symbol table is loaded.  Use the "file" command.
Make hw breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
Detected debug stubs @ 3ffb3900 on core0 of target 'esp32'

Code: Select all

xtensa-esp32-elf-gdb build/scan.elf -x gdbinit

Code: Select all

GNU gdb (crosstool-NG crosstool-ng-1.22.0-80-g6c4433a5) 7.10
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-host_pc-mingw32 --target=xtensa-esp32-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
0x40131b3e in ?? ()
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)
cpu0: Current bits set: BreakIn BreakOut RunStallIn
cpu1: Current bits set: BreakIn BreakOut RunStallIn
esp32: Debug controller was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Core was reset (pwrstat=0x5F, after clear 0x0F).
Target halted. PRO_CPU: PC=0x5000004B (active)    APP_CPU: PC=0x00000000
esp32: Core was reset (pwrstat=0x1F, after clear 0x0F).
Target halted. PRO_CPU: PC=0x40000400 (active)    APP_CPU: PC=0x40000400
No symbol table is loaded.  Use the "file" command.
Make hw breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
Detected debug stubs @ 3ffb3900 on core0 of target 'esp32'

ESP_igrr
Posts: 2067
Joined: Tue Dec 01, 2015 8:37 am

Re: Problem: Setting up JTAG debugger for ESP32

Postby ESP_igrr » Sun Nov 25, 2018 11:04 pm

If you start xtensa-esp32-elf-gdb without any arguments, do you still see it connecting to the target? In theory it should not, unless there is some global .gdbinit file in your home directory which tells it to (or tells it to allow loading .gdbinit in the project directory).

e2738729
Posts: 35
Joined: Mon Nov 05, 2018 6:22 pm

Re: Problem: Setting up JTAG debugger for ESP32

Postby e2738729 » Mon Nov 26, 2018 3:10 pm

I think you are right,
I think it tried to run the .gdbinit in .\home\khoil, eventhough my .gdbinit file I want it to run is in D:\esp32\scan\

So what is the best way for me to fix this?
Thank you again for your help.

Code: Select all

$ xtensa-esp32-elf-gdb
GNU gdb (crosstool-NG crosstool-ng-1.22.0-80-g6c4433a5) 7.10
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-host_pc-mingw32 --target=xtensa-esp32-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
C:\msys32\home\khoil/.gdbinit:2: Error in sourced command file:
:3333: The system tried to join a drive to a directory on a joined drive.
.gdbinit:2: Error in sourced command file:
:3333: The system tried to join a drive to a directory on a joined drive.
(gdb)

Who is online

Users browsing this forum: No registered users and 131 guests