使用 ESP-Prog / Jlink 進行 JTAG 調試時的常見錯誤及解決辦法

此篇博客用來記錄使用 ESP-PROG / Jlink 來對 ESP32-Lyrat 進行 JTAG 調試時遇到的一些問題以及解決辦法。如果對進行 JTAG 相關操作有疑惑,請參考以下資料:

1. Error: libusb_open() failed with LIBUSB_ERROR_NOT_FOUND

此錯誤出現的原因是設備沒有被找到,相關 log 如下 :

openocd -f interface\ftdi\esp32_devkitj_v1.cfg -f board\
esp32-wrover-kit-1.8v.cfg
Open On-Chip Debugger  v0.10.0-esp32-20200309 (2020-03-09-11:51)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
adapter speed: 9600 kHz

Warn : Interface already configured, ignoring
Info : Configured 2 cores
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
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 '*', seri
al '*' at bus location '*'
Error: no device found
Error: unable to open ftdi device with vid 0403, pid 6014, description '*', seri
al '*' at bus location '*'

Assertion failed!

Program: C:\Users\example\.espressif\tools\openocd-esp32\v0.10.0-esp32-20200309\ope
nocd-esp32\bin\openocd.exe
File: src/jtag/core.c, Line 343

Expression: jtag_trst == 0

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

解決辦法如後續 1.1 及 1.2。

1.1 檢查硬件連線是否正確

JTAG 調試需要連接的引腳爲 MTDO、MTDI、MTCK、MTMS 與 GND。以調試 ESP32 爲例,ESP-Prog 與 Jlink 需要連接的引腳對應關係如下。

在這裏插入圖片描述

1.2 檢查 JTAG 調試的驅動是否正確

如果硬件連線完全正確,則說明是驅動未正確安裝,以 Windows 爲例,在接入 ESP-Prog 後,打開 設備管理器(右擊 我的電腦-> 左擊 屬性 -> 界面左上角可查看到 設備管理器) ,顯示如下。
在這裏插入圖片描述
此時需要使用 zadig 來安裝正確的驅動,zadig 的下載鏈接點擊 這裏。安裝完成後,打開 zadig,在 zadig 界面裏點擊 Options -> List All Devices,如下。
在這裏插入圖片描述

選擇 Dual RS2332-HS(Interface 0),然後點擊 Install DriverReplace Driver(如果你有類似驅動,則會像下圖一樣顯示 Replace Driver),如下。
在這裏插入圖片描述
在這裏插入圖片描述
zadig 提示驅動安裝完成後,可以再次點開設備管理器(右擊 我的電腦-> 左擊 屬性 -> 界面左上角可查看到 設備管理器),發現驅動已經被正確安裝。如下。
在這裏插入圖片描述
然後重新使用 OpenOCD 即可發現此錯誤已消失。關於 Interface 0Interface 1 的介紹請查看此博客第五節。

2. Error: JTAG scan chain interrogation failed: all ones

此錯誤出現的原因基本是 JTAG 需要的 GPIO 口異常(比如被複用等),相關 log 如下 :

./bin/openocd -s share/openocd /
/scripts -f interface/jlink.cfg -f board/esp32-wrover.cfg
Open On-Chip Debugger  v0.10.0-esp32-20190708 (2019-07-08-11:03)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
adapter speed: 9600 kHz
adapter speed: 20000 kHz
Info : Configured 2 cores
esp32 interrupt mask on
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : J-Link V9 compiled Jul 19 2017 16:11:45
Info : Hardware version: 9.70
Info : VTarget = 3.332 V
Info : Reduced speed from 20000 kHz to 15000 kHz (maximum).
Info : Reduced speed from 20000 kHz to 15000 kHz (maximum).
Info : clock speed 20000 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 3333 for gdb connections

解決方法:此時需要檢查 JTAG 對應的 GPIO 口是否被其他功能定義與使用(比如 SDIO 等)。
以 ESP32_Lyrat 開發板爲例,JTAG 對應的 GPIO 口爲 GPIO12 至 GPIO15。 這幾個 GPIO 同時被用作 SDIO。如果要進行 JTAG 調試,需要撥動對應的撥碼開關,將撥碼開關 3-6 撥至 ON,如下
在這裏插入圖片描述
在這裏插入圖片描述
完成上述操作後再進行 JTAG 調試,此錯誤已經消失。

注:ESP32 在使用 AT 固件時再進行 JTAG 調試,也會因爲 GPIO 衝突而導致上述錯誤,具體信息請參考此博客第五節。

3. Error: JTAG scan chain interrogation failed: all zeroes

此錯誤出現的原因與第二點相同,基本是 JTAG 需要的 GPIO 口異常(比如被複用等),相關 log 如下 :

./bin/openocd -s share/openocd/scripts -f interface/jlink.cfg -f board/esp32-wrover.cfg
Open On-Chip Debugger  v0.10.0-esp32-20190708 (2019-07-08-11:03)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
adapter speed: 9600 kHz
adapter speed: 20000 kHz
Info : Configured 2 cores
esp32 interrupt mask on
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : J-Link V9 compiled Jul 19 2017 16:11:45
Info : Hardware version: 9.70
Info : VTarget = 3.338 V
Info : Reduced speed from 20000 kHz to 15000 kHz (maximum).
Info : Reduced speed from 20000 kHz to 15000 kHz (maximum).
Info : clock speed 20000 kHz
Error: JTAG scan chain interrogation failed: all zeroes
Error: Check JTAG interface, timings, target power, etc.
Error: Trying to use configured scan chain anyway...
Error: esp32.cpu0: IR capture error; saw 0x00 not 0x01
Warn : Bypassing JTAG setup events due to errors
Info : Listening on port 3333 for gdb connections

解決方法同第二點,在這裏不多做贅述。

4. Error: No symbols for FreeRTOS

此錯誤出現的原因是因爲沒有進行相關軟件配置,相關 log 如下 :

./bin/openocd -s share/openocd/scripts -f interface/ftdi/esp32_devkitj_v1.cfg -f board/esp32-wrover.cfg
Open On-Chip Debugger  v0.10.0-esp32-20190708 (2019-07-08-11:03)
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
esp32 interrupt mask on
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
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 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Listening on port 3333 for gdb connections
Info : esp32: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : accepting 'gdb' connection on tcp/3333
Error: No symbols for FreeRTOS
Info : Target halted. PRO_CPU: PC=0x400E568C (active)    APP_CPU: PC=0x400E568C 
Info : Target halted. PRO_CPU: PC=0x400916EE (active)    APP_CPU: PC=0x400E568C

解決方法:如果是使用 ST 系列產品,請參考 ST-LINK No symbols for FreeRTOS
如果是其他開發板,暫時還沒有找到解決辦法,但是此 Error 應該不影響 JTAG & GDB 調試,可以暫時忽略此錯誤,或參考 ST 資料自行進行類比配置。

5.相關參考

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章