[Bug 284042] FTDI: UART breaks JTAG

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 13 Jan 2025 22:08:32 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=284042

            Bug ID: 284042
           Summary: FTDI: UART breaks JTAG
           Product: Base System
           Version: Unspecified
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: usb
          Assignee: usb@FreeBSD.org
          Reporter: bsd@orsolic.org

I am using non-clone FTDI2232H (it should be original, it is part of ESPprog
and survived FTDI's FTtool on Windows).
FTDI is used for JTAG (channel 0) and UART (channel 1).
If UART is also used, JTAG will work only for the first run, then it will fail.
To make it work again unpluging and pluggin USB cable is needed.
JTAG will work multiple times if UART is not used (eg "cu" is not run).

If I comment functions uftdi_cfg_set_dtr() and uftdi_cfg_set_rts() in uftdi.c
then it works without problems (both JTAG and UART).
Tried on -CURRENT from 2024.01.12.

dmesg after connecting FTDI:
uftdi0 on uhub0
uftdi0: <FTDI Dual RS232-HS, class 0/0, rev 2.00/7.00, addr 10> on usbus0
uftdi1 on uhub0
uftdi1: <FTDI Dual RS232-HS, class 0/0, rev 2.00/7.00, addr 10> on usbus0

usbconfig
ugen0.2: <FT2232C/D/H Dual UART/FIFO IC Future Technology Devices
International, Ltd> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (500mA)

OpenOCD run will succeed every time:
openocd -f board/esp32p4-ftdi.cfg -c "init; reset; exit"
Open On-Chip Debugger v0.12.0-eol-8078-g4071bf78-dirty (2024-12-27-18:08)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "jtag". To override use
'transport select <transport>'.
Info : clock speed 10000 kHz
Info : JTAG tap: esp32p4.tap0 tap/device found: 0x00012c25 (mfg: 0x612
(Espressif Systems), part: 0x0012, ver: 0x0)
Info : JTAG tap: esp32p4.tap1 tap/device found: 0x00012c25 (mfg: 0x612
(Espressif Systems), part: 0x0012, ver: 0x0)
Info : [esp32p4.hp.cpu0] datacount=1 progbufsize=2
Info : [esp32p4.hp.cpu0] Core 0 made part of halt group 1.
Info : [esp32p4.hp.cpu0] Examined RISC-V core; found 2 harts
Info : [esp32p4.hp.cpu0]  XLEN=32, misa=0x40901125
Info : [esp32p4.hp.cpu0] Examination succeed
Info : [esp32p4.hp.cpu1] datacount=1 progbufsize=2
Info : [esp32p4.hp.cpu1] Core 1 made part of halt group 1.
Info : [esp32p4.hp.cpu1] Examined RISC-V core; found 2 harts
Info : [esp32p4.hp.cpu1]  XLEN=32, misa=0x40901125
Info : [esp32p4.hp.cpu1] Examination succeed
Info : [esp32p4.hp.cpu0] starting gdb server on 3333
Info : Listening on port 3333 for gdb connections
Info : JTAG tap: esp32p4.tap0 tap/device found: 0x00012c25 (mfg: 0x612
(Espressif Systems), part: 0x0012, ver: 0x0)
Info : JTAG tap: esp32p4.tap1 tap/device found: 0x00012c25 (mfg: 0x612
(Espressif Systems), part: 0x0012, ver: 0x0)
Info : [esp32p4.hp.cpu0] Reset cause (24) - (JTAG CPU reset)
Info : [esp32p4.hp.cpu1] Reset cause (24) - (JTAG CPU reset)

But if something is using UART port (2nd channel on FTDI), OpenOCD will fail
(which uses 1st channel on FTDI):
cu -s 115200 -l /dev/cuaU1
openocd -f board/esp32p4-ftdi.cfg -c "init; reset; exit"
Open On-Chip Debugger v0.12.0-eol-8078-g4071bf78-dirty (2024-12-27-18:08)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "jtag". To override use
'transport select <transport>'.
Info : clock speed 10000 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: esp32p4.tap0: IR capture error; saw 0x1f not 0x01
Warn : Bypassing JTAG setup events due to errors
Error: [esp32p4.hp.cpu0] Unsupported DTM version: 15
Error: [esp32p4.hp.cpu0] Examination failed
Warn : target esp32p4.hp.cpu0 examination failed
Error: [esp32p4.hp.cpu1] Unsupported DTM version: 15
Error: [esp32p4.hp.cpu1] Examination failed
Warn : target esp32p4.hp.cpu1 examination failed
Info : [esp32p4.hp.cpu0] starting gdb server on 3333
Info : Listening on port 3333 for gdb connections
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: esp32p4.tap0: IR capture error; saw 0x1f not 0x01
Warn : Bypassing JTAG setup events due to errors
Error: [esp32p4.hp.cpu0] Unsupported DTM version: 15
Error: [esp32p4.hp.cpu1] Unsupported DTM version: 15
Error: [esp32p4.hp.cpu0] Unsupported DTM version: -1

Error: [esp32p4.hp.cpu0] Unsupported DTM version: -1
Error: [esp32p4.hp.cpu0] Could not identify target type.
Error: [esp32p4.hp.cpu1] Unsupported DTM version: -1
Error: [esp32p4.hp.cpu1] Could not identify target type.

-- 
You are receiving this mail because:
You are the assignee for the bug.