JTAG Debugging

ELESSUK
Posts: 2
Joined: Sat Jan 06, 2018 12:47 am

JTAG Debugging

Postby ELESSUK » Sat Feb 10, 2018 11:14 pm

I am trying to get JTAG debugging working with esp-idf using an ESP-Wrover-Kit and Ubuntu 17.10.
I have the correct JTAG links set on JP8.
The project I am trying to debug is the hello_world example in the examples directory. I have modified hello_world_main.c to count down from 100 with a delay of 2.5secs:

Code: Select all

for (int i = 100; i >= 0; i--)
    {
        printf("Restarting program in %d seconds...\n", i);
        vTaskDelay(2500 / portTICK_PERIOD_MS);
    }
    printf("Restarting now.\n");
    fflush(stdout);
    esp_restart();
}
It builds ok and runs ok.

I then run openocd with:

Code: Select all

bin/openocd -s share/openocd/scripts -f interface/ftdi/esp32_devkitj_v1.cfg -f board/esp-wroom-32.cfg
and get the following:

Code: Select all

Open On-Chip Debugger 0.10.0-dev-ga859564 (2017-07-24-16:16)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
none separate
adapter speed: 20000 kHz
force hard breakpoints
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 : esp32: Debug controller was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core was reset (pwrstat=0x5F, after clear 0x0F).
I have created a gdbinit file with:

Code: Select all

 target remote :3333
 mon reset halt
 thb app_main
 x $a1=0
 c
When I try to connect gdb with:

Code: Select all

xtensa-esp32-elf-gdb -x gdbinit build/hello-world.elf 
It seems to crash and needs to be powered off before I can restart the application. The reset button doesn't work, I just get a POWERON_RESET message followed by lots of RTCWDT_RTC_RESET messages:

I get the following in the terminal window:

Code: Select all

Restarting program in 90 seconds...                                             
                                                                                
Restarting program in 89 seconds...                                             
                                                                                
ets Jun  8 2016 00:22:57                                                        
                                                                                
                                                                                
                                                                                
rst:0x3 (SW_RESET),boot:0x3e (SPI_FAST_FLASH_BOOT)                              
                                                                                
flash read err, 1000                                                            
                                                                                
ets_main.c 371 
The following in the openOCD window:

Code: Select all

Open On-Chip Debugger 0.10.0-dev-ga859564 (2017-07-24-16:16)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
none separate
adapter speed: 20000 kHz
force hard breakpoints
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 : esp32: Debug controller was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core was reset (pwrstat=0x5F, after clear 0x0F).
Info : accepting 'gdb' connection on tcp/3333
Info : Target halted. PRO_CPU: PC=0x400D1AEA (active)    APP_CPU: PC=0x00000000 
esp32: target state: halted
Info : Use core0 of target 'esp32'
Info : Target halted. PRO_CPU: PC=0x40091D07 (active)    APP_CPU: PC=0x400D1AEA 
Info : Auto-detected flash size 4096 KB
Info : Using flash size 4096 KB
Info : Set current thread to 0x00000000, old= 0x00000000
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 : 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 
esp32: target state: halted
Info : esp32: Core was reset (pwrstat=0x1F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x40000400 (active)    APP_CPU: PC=0x40000400 
esp32: target state: halted
And the following in the gdb window:

Code: Select all

~/esp/hello_world$ xtensa-esp32-elf-gdb -x gdbinit build/hello-world.elf 
GNU gdb (crosstool-NG crosstool-ng-1.22.0-80-g6c4433a) 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=x86_64-build_pc-linux-gnu --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"...
Reading symbols from build/hello-world.elf...done.
0x400d1aea in esp_vApplicationIdleHook ()
    at /home/elessuk/esp/esp-idf/components/esp32/./freertos_hooks.c:62
62	    asm("waiti 0");
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)
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: target state: halted
esp32: Core was reset (pwrstat=0x1F, after clear 0x0F).
Target halted. PRO_CPU: PC=0x40000400 (active)    APP_CPU: PC=0x40000400 
esp32: target state: halted
Hardware assisted breakpoint 1 at 0x400d1f94: file /home/elessuk/esp/hello_world/main/./hello_world_main.c, line 27.
0x0:	0x00000000
Any suggestions as to what is happening or what I am doing wrong?

Thanks in advance
Elessuk

aboaboit
Posts: 9
Joined: Mon Jul 02, 2018 9:02 pm

Re: JTAG Debugging

Postby aboaboit » Tue Jul 17, 2018 1:37 pm

Assuming you still have the problem, try lowering the adapter_speed value in your adapter/ board config: I had recurring resets in the breakpoint unit and setting it to 5000 fixed it. It might work even with higher values, I haven't tested yet.

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

Re: JTAG Debugging

Postby ESP_igrr » Tue Jul 17, 2018 1:49 pm

ELESSUK wrote:

Code: Select all

bin/openocd -s share/openocd/scripts -f interface/ftdi/esp32_devkitj_v1.cfg -f board/esp-wroom-32.cfg
Does your Wrover-KIT come with WROOM or WROVER module? If it's WROVER (like most ESP-WROVER-KITs) then you need to specify config file esp32-wrover.cfg.

If your WROVER-KIT uses WROOM module, then you may be seeing https://github.com/espressif/openocd-esp32/issues/38.

Who is online

Users browsing this forum: Bing [Bot] and 90 guests