ESP32 debug issue on custom board using J-Link

Ashvajit.P
Posts: 34
Joined: Fri Feb 26, 2021 9:03 am

ESP32 debug issue on custom board using J-Link

Postby Ashvajit.P » Fri Feb 26, 2021 10:00 am

I am trying to debug my ESP32 WROOM 32D on custom board using J-link, while doing so I am facing the error shown in figure while connecting to target device.
Steps I followed :
> Changed the J-link driver with WinUSB driver
> Debug Settings in Visual GDB :
Debug using : Open OCD
JTAG/SWD Programmer : Segger J-link
Target device : ESP32
Program FLASH Memory : Always
  • Debug using : Open OCD
  • JTAG/SWD Programmer : Segger J-link
  • Target device : ESP32
  • Program FLASH Memory : Always
  • Program FLASH using : OpenOCD(via J-TAG)
> Pin connections from J-link to esp32 via 24 to 10 pin connector
connector used : https://www.segger.com/products/debug-p ... m-adapter/
J-link - ESP32 connections
  • (1)VTREF - 3V3
  • (Pin 5)TDI - MTDI(IO12)
  • (Pin 7)TMS - MTMS(IO14)
  • (Pin 9)TCK - MTCK(IO13)
  • (Pin 13)TDO - MTDO(IO15)
  • (Pin 15)RESET - EN(3) Pin
Experiment :
Meanwhile when I tried same thing with my ESP32 DEVKITC, I have only replaced Reset pin of the controller to 3rd pin of J-LINK i.e. nTRST in that case I am able to debug my development board but when I am trying to debug using the above given connections I am not able to debug my device. Also 24-10 pin converter has RESET pin is connected to 15th pin of J-LINK.

1. What is difference between nTRST and RESET pin in J-LINK while debugging ESP32 ?
2. What is Ideal method to debug ESP32 while using Visual Studio w/ Visual GDB ?
Attachments
debug_test_esp32.PNG
Debug Test Connection Log
debug_test_esp32.PNG (70.48 KiB) Viewed 10480 times

ESP_Sprite
Posts: 9757
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32 debug issue on custom board using J-Link

Postby ESP_Sprite » Mon Mar 01, 2021 3:28 am

tRST is a JTAG signal that the ESP32 does not have; you should not need to connect it. Are you sure you don't have a program running on the ESP32 that uses the JTAG GPIOs (GPIO12-15) for something else?

Ashvajit.P
Posts: 34
Joined: Fri Feb 26, 2021 9:03 am

Re: ESP32 debug issue on custom board using J-Link

Postby Ashvajit.P » Mon Mar 01, 2021 10:06 am

I haven't programmed it it once.
I am sharing my schematic of my custom board which I have took reference from ESP32Devkit C itself.
Please let me know if you find anything.
Attachments
esp32_hwPNG.PNG
esp32_hwPNG.PNG (55.87 KiB) Viewed 10427 times

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

Re: ESP32 debug issue on custom board using J-Link

Postby Scott.Bonomi » Mon Mar 01, 2021 7:02 pm

With text lost to the right on the invocation line, it is not clear what all you are doing.
I think you might want to get a log from openocd to see exactly what is going on.

For my work on a custom ESP32-U4WDH, I use:
openocd -f interface/jlink.cfg -f board/esp32-solo-1.cfg -d3 -l ./OCDLOG_TurboII.log


And My config file, which may be redundant, has the following:

adapter driver jlink
source [find interface/jlink.cfg]
set ESP32_FLASH_VOLTAGE 3.3 (This is a U4WDH specific feature)
transport select jtag
set ESP32_RTOS FreeRTOS
source [find board/esp32-solo-1.cfg]

Ashvajit.P
Posts: 34
Joined: Fri Feb 26, 2021 9:03 am

Re: ESP32 debug issue on custom board using J-Link

Postby Ashvajit.P » Tue Mar 02, 2021 5:42 am

Posting whole log here :

C:\Users\APRASAD\AppData\Local\VisualGDB\EmbeddedDebugPackages\com.sysprogs.esp32.core\bin\openocd.exe -c "gdb_port 52266" -c "telnet_port 52265" -f interface/jlink.cfg -c "adapter_khz 3000" -f target/esp32.cfg -c "echo VisualGDB_OpenOCD_Ready"
Open On-Chip Debugger 0.10.0 (2021-01-25)
Licensed under GNU GPL v2
libusb1 09e75e98b4d9ea7909e8837b7a3f00dda4589dc3
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
adapter speed: 3000 kHz

Info : FreeRTOS creation
Info : FreeRTOS creation
VisualGDB_OpenOCD_Ready
Info : Listening on port 6666 for tcl connections
Info : Listening on port 52265 for telnet connections
Info : J-Link V9 compiled Dec 13 2019 11:14:50
Info : Hardware version: 9.30
Info : VTarget = 3.272 V
Info : clock speed 3000 kHz
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
Info : Listening on port 52266 for gdb connections
Info : accepting 'gdb' connection on tcp/52266
Warn : No symbols for FreeRTOS!
Error: Target not examined yet
Error executing event gdb-attach on target esp32.cpu0:

Error: Target not halted
Error: auto_probe failed
Error: Connect failed. Consider setting up a gdb-attach event for the target to prepare target for GDB connect, or use 'gdb_memory_map disable'.
Error: attempted 'gdb' connection rejected


I think the configurations you are mentioning are there in the first line.
Can you tell how should I change these settings in my config file while using visual studio ?
I don't know the method using command line for the same or where I can find the correct path for this config file.
Also attaching my visual studio project folder image.
Attachments
project_directory.PNG
project_directory.PNG (44.9 KiB) Viewed 10380 times

rpoelvogels
Posts: 6
Joined: Wed Jan 30, 2019 9:35 am

Re: ESP32 debug issue on custom board using J-Link

Postby rpoelvogels » Tue Mar 09, 2021 8:21 am

Hi,
Error: JTAG scan chain interrogation failed: all ones
This error usually means that other firmware on the ESP32 blocks the JTAG pins.
Note that when you buy a fresh board it's usually flashed with AT firmware, which will indeed block the JTAG pins.
You can prevent the AT firmware pin from running by holding IO0 low during reset, after which you should be able to use the JTAG pins.

Kind regards,

Remco Poelstra

Ashvajit.P
Posts: 34
Joined: Fri Feb 26, 2021 9:03 am

Re: ESP32 debug issue on custom board using J-Link

Postby Ashvajit.P » Fri Mar 26, 2021 9:51 am

Hi,
I was not able reply for a while, I tried to program my custom board serially using FTDI cable while keeping Boot pin grounded and was able to successfully program it. There was a soft AP program preloaded in ESP32.
JTAG debugging was also working fine after programming it serially.

devlat
Posts: 15
Joined: Thu Oct 29, 2020 9:33 am

Re: ESP32 debug issue on custom board using J-Link

Postby devlat » Tue May 17, 2022 9:04 am

So what is correct way to connect J-Link to ESP32? Do we need to connect (Pin 15)nRESET or (Pin 3)nTRST to EN pin of ESP32?
It is confusing because i see people connect it differently. I would be thankful for any explanation.

ESP_Sprite
Posts: 9757
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32 debug issue on custom board using J-Link

Postby ESP_Sprite » Wed May 18, 2022 1:45 pm

ESP32 does not use nTRST, so I think it must be nRESET.

devlat
Posts: 15
Joined: Thu Oct 29, 2020 9:33 am

Re: ESP32 debug issue on custom board using J-Link

Postby devlat » Tue May 24, 2022 2:33 pm

Thank you for reply. Yes, it seems you are correct, as according to J-LInk documentation pin 15 (nRESET) should be connected to CPU reset, so we must connect it to EN on ESP32. Pin 3 (nTRST) should not be connected to anything, as ESP32 does not have this signal,
and according to J-Link documentation it is optional. It is understandable, as according to JTAG specs it is optional too, because same functionality (JTAG RESET) can be achieved with TCK and TMS pins, that is why ESP32 omits nTRST.
It also should be noted, that J-Link also has RTCK pin (Return test clock signal from the target) which is not available too and should be connected to GND if not in use. I did it too, to be safe. This way everything works fine: i can flash firmware, debug target etc.

Who is online

Users browsing this forum: No registered users and 218 guests