Setup JTAG Debugging

park_lemon
Posts: 10
Joined: Mon Sep 07, 2020 10:07 am

Setup JTAG Debugging

Postby park_lemon » Mon Sep 14, 2020 3:28 am

Hi all,

I need to setup JTAG Debugging by following this link:
https://docs.espressif.com/projects/esp ... index.html

I found a problem at CONFIGURING ESP32 TARGET
for quick jump, you may refer to the following link:
https://docs.espressif.com/projects/esp ... p32-target

I want to run OpenOCD:
openocd -f board/esp32-wrover-kit-3.3v.cfg

But, I got this WARNING:

C:\Users\vinodh\Desktop\esp-idf>openocd --version
Open On-Chip Debugger v0.10.0-esp32-20191114 (2019-11-14-14:19)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html

C:\Users\vinodh\Desktop\esp-idf>echo %OPENOCD_SCRIPTS%
C:\Users\vinodh\.espressif\tools\openocd-esp32\v0.10.0-esp32-20191114\openocd-esp32\share\openocd\scripts

C:\Users\vinodh\Desktop\esp-idf>openocd -f board/esp32-wrover-kit-3.3v.cfg
Open On-Chip Debugger v0.10.0-esp32-20191114 (2019-11-14-14:19)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
none separate
adapter speed: 20000 kHz
Info : Configured 2 cores
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Error: type 'esp32' is missing virt2phys
Error: libusb_open() failed with LIBUSB_ERROR_NOT_SUPPORTED
Error: libusb_open() failed with LIBUSB_ERROR_NOT_FOUND
Error: no device found
Error: unable to open ftdi device with vid 0403, pid 6010, description '*', serial '*' at bus location '*'

Warn : Flash driver of esp32.flash does not support free_driver_priv()
Warn : Flash driver of esp32.irom does not support free_driver_priv()
Warn : Flash driver of esp32.drom does not support free_driver_priv()

What I need to do solve this problem?
Thank you very much for your kind help
May god bless you.

Thanks and best regards

Xavi92
Posts: 45
Joined: Thu Mar 28, 2019 2:26 pm

Re: Setup JTAG Debugging

Postby Xavi92 » Mon Sep 14, 2020 9:04 am

From what I read from the log you attached, libusb is failing to locate your device. Could you please ensure the device is recognized by Windows and its vendor ID and product ID match those from the log (0403 and 6010, respectively)?

park_lemon
Posts: 10
Joined: Mon Sep 07, 2020 10:07 am

Re: Setup JTAG Debugging

Postby park_lemon » Mon Sep 14, 2020 9:41 am

Hi,

Thank you very much Xavi92, your post really help me to solve the problem.
May god bless you.

The solution that I used:
I use USB Driver Tool to update the USB Driver. (Install Libusb -WinUSB).
You may download the USB Driver Tool by clicking the below link:
https://visualgdb.com/UsbDriverTool/

For those who faced similar problem as i faced,
I suggest you to refer these links as a references:

1. https://docs.espressif.com/projects/esp ... index.html

2. https://mcuoneclipse.com/2019/10/20/jta ... d-openocd/

3. https://dzone.com/articles/eclipse-jtag ... segger-j-l

4. https://visualgdb.com/UsbDriverTool/

Hope, these links will be useful to you to solve the problem.

Thank you very much.....

park_lemon
Posts: 10
Joined: Mon Sep 07, 2020 10:07 am

Re: Setup JTAG Debugging

Postby park_lemon » Mon Sep 14, 2020 10:19 am

Hi,

After update the USB driver, i got another ERROR

Error: type 'esp32' is missing virt2phys

How to solve this error?

Here is the log:

C:\Users\vinodh\Desktop\esp-idf>openocd -f board/esp32-wrover-kit-3.3v.cfg
Open On-Chip Debugger v0.10.0-esp32-20191114 (2019-11-14-14:19)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
none separate
adapter speed: 20000 kHz
Info : Configured 2 cores
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Error: type 'esp32' is missing virt2phys
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 : Listening on port 3333 for gdb connections

Thank you in advance for your kind help.

park_lemon
Posts: 10
Joined: Mon Sep 07, 2020 10:07 am

Re: Setup JTAG Debugging

Postby park_lemon » Mon Sep 14, 2020 11:22 am

Hi all,

I got this error,
I need your help on how to solve this.

Error: libusb_handle_events() failed with LIBUSB_ERROR_IO
Error: unable to purge ftdi rx buffers: LIBUSB_ERROR_IO
Error: error while flushing MPSSE queue: -4
Error: libusb_handle_events() failed with LIBUSB_ERROR_IO
Error: unable to purge ftdi rx buffers: LIBUSB_ERROR_IO
Error: error while flushing MPSSE queue: -4
Error: xtensa_mcore_poll: Target failure
Polling target esp32 failed, trying to reexamine
Error: libusb_handle_events() failed with LIBUSB_ERROR_IO
Error: unable to purge ftdi rx buffers: LIBUSB_ERROR_IO
Error: error while flushing MPSSE queue: -4
Examination failed, GDB will be halted. Polling again in 6300ms

park_lemon
Posts: 10
Joined: Mon Sep 07, 2020 10:07 am

Re: Setup JTAG Debugging

Postby park_lemon » Tue Sep 15, 2020 3:00 am

Hi all,

I got this errors after run:

idf.py build

What is the problems and how to solve it.
Thank you very much for your help.

C:\Users\vinodh\Desktop\esp-idf>idf.py build
Executing action: all (aliases: build)
Running cmake in directory c:\users\vinodh\desktop\esp-idf\build
Executing "cmake -G Ninja -DPYTHON_DEPS_CHECKED=1 -DESP_PLATFORM=1 --warn-uninitialized -DCCACHE_ENABLE=1 c:\users\vinodh\desktop\esp-idf"...
Warn about uninitialized values.
-- The C compiler identification is GNU 6.3.0
-- The CXX compiler identification is GNU 6.3.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/MinGW/bin/c++.exe
-- Check for working CXX compiler: C:/MinGW/bin/c++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:5 (message):
Current directory 'C:/Users/vinodh/Desktop/esp-idf' is not buildable.
Change directories to one of the example projects in
'C:/Users/vinodh/Desktop/esp-idf/examples' and try again.


-- Configuring incomplete, errors occurred!
See also "C:/Users/vinodh/Desktop/esp-idf/build/CMakeFiles/CMakeOutput.log".
cmake failed with exit code 1

Xavi92
Posts: 45
Joined: Thu Mar 28, 2019 2:26 pm

Re: Setup JTAG Debugging

Postby Xavi92 » Tue Sep 15, 2020 6:04 am

Each one of your messages are different, unrelated questions:
park_lemon wrote:
Mon Sep 14, 2020 10:19 am
After update the USB driver, i got another ERROR

Error: type 'esp32' is missing virt2phys
Despite the error message, it even pops up on valid setups (where JTAG is able to program and debug) so I guess it can be safely ignored.
park_lemon wrote:
Mon Sep 14, 2020 10:19 am
C:\Users\vinodh\Desktop\esp-idf>openocd -f board/esp32-wrover-kit-3.3v.cfg
There are missing command line arguments here - you are not instructing the JTAG adapter what to do. Assuming you are using the JTAG adapter from the WROVER-KIT development board, you should be using the following command line arguments:

Code: Select all

openocd -f board/esp32-wrover-kit-3.3v.cfg -s share/openocd/scripts -f interface/ftdi/esp32_devkitj_v1.cfg -f board/esp-wrover-kit-3.3v.cfg -c "init; reset halt; program_esp build/bootloader/bootloader.bin 0x1000 verify; program_esp build/partition_table/partition-table.bin 0x8000 verify; program_esp build/your-application.bin 0x10000 verify"
Where your-application.bin must be replaced with the name of the .bin file generated by esp-idf from your project. 0x1000, 0x8000 and 0x10000 are the default physical offsets where the second-stage bootloader, partition table and user firmware are stored respectively in memory, but modify them if you are using non-default locations (although I assume you are not).

Once it performs all listed actions successfully, the following info message shall pop up telling OpenOCD is now waiting for an incoming connection from gdb:

Code: Select all

Info : Listening on port 3333 for gdb connections
Via command line, you can debug your application using xtensa-esp32-elf-gdb, which is included among the packages esp-idf installs when executing the install.bat/install.sh scripts. I like using VSCodium instead, so using the Native Debug extension I create a file namely launch.json inside a subfolder namely .vscode with the following configuration:

Code: Select all

{
    "version": "0.2.0",
    "configurations":
    [
        {
            "type": "gdb",
            "request": "launch",
            "name": "Launch Program",
            "target": "${workspaceFolder}/build/your-application.elf",
            "cwd": "${workspaceFolder}",
            "gdbpath": "xtensa-esp32-elf-gdb",
            "autorun":
            [
                "target remote :3333",
                "mon reset halt",
                "flushregs",
                "thb app_main",
                "c"
            ],
            "preLaunchTask": "openocd"
        }
    ]
}
Again, replace your-application.elf with the name of the .elf file generated by esp-idf from your project. The openocd pre-launch task must be placed on a separate file namely tasks.json, also inside the .vscode folder:

Code: Select all

{
    "version": "2.0.0",
    "tasks":
    [
        {
            "label": "openocd",
            "type": "shell",
            "isBackground": true,
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "dependsOn": "build",
            "command": "openocd",
            "args": [
                "-s",
                "share/openocd/scripts",
                "-f",
                "interface/ftdi/esp32_devkitj_v1.cfg",
                "-f",
                "board/esp-wroom-32.cfg",
                "-c",
                "\"init; reset halt; program_esp build/bootloader/bootloader.bin 0x1000 verify; program_esp build/partition_table/partition-table.bin 0x8000 verify; program_esp build/your-application.bin 0x10000 verify\""
            ]
        }
    ]
}
Also replace your-application-bin as described above. Notice these configuration files assume openocd and xtensa-esp32-elf-gdb are listed in your PATH.

Now, about the other messages you posted:
park_lemon wrote:
Mon Sep 14, 2020 11:22 am
Hi all,

I got this error,
I need your help on how to solve this.

Error: libusb_handle_events() failed with LIBUSB_ERROR_IO
Error: unable to purge ftdi rx buffers: LIBUSB_ERROR_IO
Error: error while flushing MPSSE queue: -4
Error: libusb_handle_events() failed with LIBUSB_ERROR_IO
Error: unable to purge ftdi rx buffers: LIBUSB_ERROR_IO
Error: error while flushing MPSSE queue: -4
Error: xtensa_mcore_poll: Target failure
Polling target esp32 failed, trying to reexamine
Error: libusb_handle_events() failed with LIBUSB_ERROR_IO
Error: unable to purge ftdi rx buffers: LIBUSB_ERROR_IO
Error: error while flushing MPSSE queue: -4
Examination failed, GDB will be halted. Polling again in 6300ms
This looks like a bad connection between the JTAG adapter and the ESP32. So please check connections.
park_lemon wrote:
Tue Sep 15, 2020 3:00 am
Hi all,

I got this errors after run:

idf.py build

What is the problems and how to solve it.
Thank you very much for your help.

C:\Users\vinodh\Desktop\esp-idf>idf.py build
Executing action: all (aliases: build)
Running cmake in directory c:\users\vinodh\desktop\esp-idf\build
Executing "cmake -G Ninja -DPYTHON_DEPS_CHECKED=1 -DESP_PLATFORM=1 --warn-uninitialized -DCCACHE_ENABLE=1 c:\users\vinodh\desktop\esp-idf"...
Warn about uninitialized values.
-- The C compiler identification is GNU 6.3.0
-- The CXX compiler identification is GNU 6.3.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/MinGW/bin/c++.exe
-- Check for working CXX compiler: C:/MinGW/bin/c++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:5 (message):
Current directory 'C:/Users/vinodh/Desktop/esp-idf' is not buildable.
Change directories to one of the example projects in
'C:/Users/vinodh/Desktop/esp-idf/examples' and try again.


-- Configuring incomplete, errors occurred!
See also "C:/Users/vinodh/Desktop/esp-idf/build/CMakeFiles/CMakeOutput.log".
cmake failed with exit code 1
As described on the log, you are not supposed to run idf.py build on $IDF_PATH (C:/Users/vinodh/Desktop/esp-idf in your case). Instead, create a project on a separate folder with the following CMakeLists.txt file and call idf.py build on your project folder:

Code: Select all

# The following lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(your-project)
At this point, you should provide at least one source file that defines app_main. You can use the example project at $IDF_PATH/examples/get-started/hello_world (C:/Users/vinodh/Desktop/esp-idf/examples/get-started/hello_world in your case).

Hope this helps.

Who is online

Users browsing this forum: No registered users and 93 guests