Debugging with JLink doesn't work

AndreRamakers
Posts: 5
Joined: Fri Mar 20, 2020 1:18 pm

Debugging with JLink doesn't work

Postby AndreRamakers » Fri Mar 20, 2020 2:03 pm

Hi,
I am working on my own board. The code, letting a led blink, is working, the led blinks.
The tools, all latest version, are running on Ubuntu (virtual machine) under Visual Studio Code. Compiling and programming works fine but I am already busy for two weeks trying to get the debugging working. I am using a JLink and have checked all signals with an osciloscope. The connection is running:
Openocd.JPG
Openocd.JPG (149.29 KiB) Viewed 6620 times
gdb.JPG
gdb.JPG (45.09 KiB) Viewed 6620 times
I don't know how to go further. Can someone give me some advice? Thanks in advance.

andyn_ff
Posts: 18
Joined: Mon Jun 10, 2019 4:34 pm

Re: Debugging with JLink doesn't work

Postby andyn_ff » Thu Mar 26, 2020 5:26 pm

Can you post your openocd *.cfg file and any gdb config in .gdbinit (or similar)?
I have recently got JTAG debugging working okay with a J-Link BASE and the DevKitC board with ESP32 WROVER-B module, and it worked following the instructions in the online docs. If you post your config files, maybe I can compare to mine and see if I spot anything useful?

AndreRamakers
Posts: 5
Joined: Fri Mar 20, 2020 1:18 pm

Re: Debugging with JLink doesn't work

Postby AndreRamakers » Fri Mar 27, 2020 1:44 pm

Hi, do you use all the latest versions? Like openocd 20191114? I also tried version 20190313, same result.
Here is the openocd board config:
  1. # BEA OpenOCD configuration file for ESP32-WROOM on RPU board.
  2. #
  3. # It uses a JLINK cable
  4. #
  5. # For example, OpenOCD can be started for ESP32 debugging on
  6. #
  7. #   openocd -f board/esp32-wroom-jlink-3.3v.cfg
  8. #
  9.  
  10. # Source the JTAG interface configuration file
  11. source [find interface/jlink.cfg]
  12. set ESP32_FLASH_VOLTAGE 3.3
  13. # Source the ESP32 configuration file
  14. source [find target/esp32.cfg]
And here JLink interface:
  1. #
  2. # SEGGER J-Link
  3. #
  4. # http://www.segger.com/jlink.html
  5. #
  6.  
  7. interface jlink
  8. #adapter driver jlink
  9.  
  10. # The serial number can be used to select a specific device in case more than
  11. # one is connected to the host.
  12. #
  13. # Example: Select J-Link with serial number 123456789
  14. # If not set either number is used
  15. #jlink serial xxxxxxxx
  16.  
  17. adapter_khz 1000
And finaly the GDB init for which I tried to add/remove every item:

target remote localhost:3333
set remote hardware-watchpoint-limit 2
mon reset halt
flushregs
thb app_main
c

I also did it all manually to find out what goes wrong. I am at the point now that the mon reset halt instruction gives the error that the target does not support the monitor instruction.

One more question to which I can't find the answer: besides the jtag connection, is the serial connection mandatory to make things work? I have the serial connection on ttyACM0 and I can't find how to change the default setting in vscode.

Thanks for the help!

Scott.Bonomi
Posts: 73
Joined: Mon Mar 09, 2020 7:36 pm

Re: Debugging with JLink doesn't work

Postby Scott.Bonomi » Mon Jun 29, 2020 9:53 pm

I found this to be helpful. At least it got me far enough along to ask for more help.

I seem to be getting a JTAG connection, and connecting to the gdb app. However I seem to be failing to get a good connection to the processor. I am using a JLINK Plus Compact, with bare wires to a prototype board and a ESP32-U4WDH on a DevKit RevC Demo Board.


OpenOCD.cfg::
source [find interface/jlink.cfg]
set ESP32_FLASH_VOLTAGE 3.3
source [find board/esp32-u4wdh.cfg]

esp32-u4wdh.cfg::
transport select jtag
adapter_khz 1000
set ESP32_ONLYCPU 1
source [find target/esp32.cfg]


esp32.cfg is unchanged except for setting flash size if auto fails.
} else {
set _FLASH_SIZE 0x0400000
}

What I have for a JLINK definition is::
<!-- -->
<!-- Espressif ESP32 -->
<!-- -->
<Device>
<ChipInfo Vendor="Espressif" Name="ESP32-U4DWH" Core="Tensilica LX6" JLinkScriptFile="Devices/Espressif/ESP32-U4DWH.JLinkScript" />
<FlashBankInfo Name="Internal Flash" BaseAddr="0x3F400000" MaxSize="0x00400000" Loader="Devices/Maxim/MAX32600/MAX32600.FLM" LoaderType="FLASH_ALGO_TYPE_OPEN" AlwaysPresent="1"/>
</Device>

I do not have any expectation of the loader working, but I I was copying from another vendor part.



What I get with this is::

==================================================================================================
=
=
= OPENOCD OUTPUT
=
=
=================================================================================================


C:\Users\sbonomi\Desktop\esp-idf\simple>openocd
Open On-Chip Debugger v0.10.0-esp32-20190313 (2019-03-13-09:57)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
adapter speed: 1000 kHz
adapter speed: 1000 kHz
Info : Configured 1 cores
esp32 interrupt mask on
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : J-Link V11 compiled Jun 9 2020 13:38:27
Info : Hardware version: 11.00
Info : VTarget = 3.341 V
Info : clock speed 1000 kHz
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Listening on port 3333 for gdb connections
Info : accepting 'gdb' connection on tcp/3333
Error: No symbols for FreeRTOS
Info : Target halted. PRO_CPU: PC=0x4014A8D2
Info : Target halted. PRO_CPU: PC=0x4009171A
Info : Flash mapping 0: 0x10020 -> 0x3f400020, 97 KB
Info : Flash mapping 1: 0x30018 -> 0x400d0018, 495 KB
Info : Target halted. PRO_CPU: PC=0x4009171A
Info : Auto-detected flash size 4096 KB
Info : Using flash size 4096 KB
Info : Target halted. PRO_CPU: PC=0x4009171A
Info : Flash mapping 0: 0x10020 -> 0x3f400020, 97 KB
Info : Flash mapping 1: 0x30018 -> 0x400d0018, 495 KB
Info : Using flash size 496 KB
Info : Target halted. PRO_CPU: PC=0x4009171A
Info : Flash mapping 0: 0x10020 -> 0x3f400020, 97 KB
Info : Flash mapping 1: 0x30018 -> 0x400d0018, 495 KB
Info : Using flash size 100 KB
Warn : negative reply, retrying
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Error: cpu0: xtensa_write_memory (line 802): DSR (FFFFFFFF) indicates target still busy!
Error: cpu0: xtensa_write_memory (line 802): DSR (FFFFFFFF) indicates DIR instruction generated an exception!
Error: cpu0: xtensa_write_memory (line 802): DSR (FFFFFFFF) indicates DIR instruction generated an overrun!
Warn : esp32: Failed writing 4 bytes at address 0x3ff48000, data - 00, 20, 49, 9c, 4c, 00, 00, 00
Error: xtensa_write_uint32_list: error writing to 3ff48000
Warn : esp32_soc_reset xtensa_write_uint32_list (reg_value_pairs_pre) err=-4



Info : xtensa_poll: Target offline
Error: xtensa_poll: Target failure
Polling target esp32 failed, trying to reexamine
Examination failed, GDB will be halted. Polling again in 100ms
Warn : xtensa_read_memory: esp32: target not halted
Warn : xtensa_read_memory: esp32: target not halted
Warn : xtensa_read_memory: esp32: target not halted
Warn : esp32: xtensa_resume: target not halted
Info : target esp32 was not halted when resume was requested
Error: xtensa_poll: Target failure
Error: xtensa_poll: Target failure
Warn : target esp32 is not halted (gdb fileio)
Error: FreeRTOS_update_threads not TARGET_HALTED!
Warn : xtensa_read_memory: esp32: target not halted
Error: Could not read FreeRTOS thread count from target
Polling target esp32 failed, trying to reexamine
Examination failed, GDB will be halted. Polling again in 300ms
Error: xtensa_poll: Target failure
Error: esp32: Failed to wait halted target to remove flash BPs (-305)!
Info : dropped 'gdb' connection
Info : accepting 'gdb' connection on tcp/3333
Error: FreeRTOS_update_threads not TARGET_HALTED!
Warn : xtensa_read_memory: esp32: target not halted
Error: Could not read FreeRTOS thread count from target
Error: xtensa_poll: Target failure


Warn : xtensa_read_memory: esp32: target not halted
Warn : xtensa_read_memory: esp32: target not halted
Error: FreeRTOS_update_threads not TARGET_HALTED!
Warn : xtensa_read_memory: esp32: target not halted
Error: Could not read FreeRTOS thread count from target
Warn : xtensa_read_memory: esp32: target not halted
Warn : xtensa_read_memory: esp32: target not halted
Error: JTAG scan chain interrogation failed: all ones
Error: Check JTAG interface, timings, target power, etc.
Error: Trying to use configured scan chain anyway...
Error: esp32.cpu0: IR capture error; saw 0x1f not 0x01
Warn : Bypassing JTAG setup events due to errors
Error: xtensa_poll: Target failure
Error: xtensa_poll: Target failure


==================================================================================================
=
=
= GDB OUTPUT
=
=
=================================================================================================


C:\Users\sbonomi\Desktop\esp-idf\simple>xtensa-esp32-elf-gdb -x gdbinit build/simple.elf
GNU gdb (crosstool-NG esp-2019r2) 8.1.0.20180627-git
Copyright (C) 2018 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_w64-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"...
Reading symbols from build/simple.elf...done.
0x4014a8d2 in esp_pm_impl_waiti () at C:/Users/sbonomi/Desktop/esp-idf/components/esp32/pm_esp32.c:484
484 asm("waiti 0");
JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
cpu0: xtensa_write_memory (line 802): DSR (FFFFFFFF) indicates target still busy!
cpu0: xtensa_write_memory (line 802): DSR (FFFFFFFF) indicates DIR instruction generated an exception!
cpu0: xtensa_write_memory (line 802): DSR (FFFFFFFF) indicates DIR instruction generated an overrun!
esp32: Failed writing 4 bytes at address 0x3ff48000, data - 00, 20, 49, 9c, 4c, 00, 00, 00
xtensa_write_uint32_list: error writing to 3ff48000
esp32_soc_reset xtensa_write_uint32_list (reg_value_pairs_pre) err=-4



xtensa_poll: Target offline
xtensa_poll: Target failure
Polling target esp32 failed, trying to reexamine
Examination failed, GDB will be halted. Polling again in 100ms
Hardware assisted breakpoint 1 at 0x400d6ecc: file ../main/main.c, line 909.
esp32: xtensa_resume: target not halted
target esp32 was not halted when resume was requested
xtensa_poll: Target failure
xtensa_poll: Target failure
[New Thread 1073463452]
[New Thread 1073538972]
[New Thread 1073542552]
[New Thread 1073474780]
[New Thread 1073468200]
[New Thread 1073486040]
[New Thread 1073412952]
[New Thread 1073526376]
[New Thread 1073479248]
[New Thread 1073453928]

Thread 1 received signal SIGINT, Interrupt.
[Switching to Thread 1073465436]
0x4014a8d2 in esp_pm_impl_waiti () at C:/Users/sbonomi/Desktop/esp-idf/components/esp32/pm_esp32.c:484
484 asm("waiti 0");

Thread 1 received signal SIGINT, Interrupt.
0x4014a8d2 in esp_pm_impl_waiti () at C:/Users/sbonomi/Desktop/esp-idf/components/esp32/pm_esp32.c:484
484 asm("waiti 0");
JTAG scan chain interrogation failed: all ones
Check JTAG interface, timings, target power, etc.
Trying to use configured scan chain anyway...
esp32.cpu0: IR capture error; saw 0x1f not 0x01
Bypassing JTAG setup events due to errors
xtensa_poll: Target failure
xtensa_poll: Target failure
xtensa_poll: Target failure




With the xtensa poll lines continuing forever



Suggestions appreciated

Who is online

Users browsing this forum: No registered users and 54 guests