1

I have a PYNQ-Z2 board and it contains FT2232HQ chip, which convert data from USB to JTAG and UART

The problem is the board is working and is detected by Vivado (I can program it), but the device doesn't show up as /dev/ttyUSB* device, it shows up as /dev/ftdi-x (where x is a random number) and I can't open a serial port with this device file.

I used lsusb command and I found the chip is correctly detected:

Bus 003 Device 017: ID 0403:6010 Future Technology Devices International, Ltd FT2232C Dual USB-UART/FIFO IC

After that I tried to check the syslog file, and I noticed two weird behaviors, the first is when I connect the board two ttyUSB devices are recognized, not one! /dev/ttyUSB0 & /dev/ttyUSB1.

the second behavior is these two devices are immediately disconnected after they are connected.

Here is the full syslog:

Oct 27 11:45:20 ao20xa kernel: [73109.798748] usb 3-4: new high-speed USB device number 17 using xhci_hcd
Oct 27 11:45:21 ao20xa kernel: [73109.949757] usb 3-4: New USB device found, idVendor=0403, idProduct=6010
Oct 27 11:45:21 ao20xa kernel: [73109.949761] usb 3-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Oct 27 11:45:21 ao20xa kernel: [73109.949763] usb 3-4: Product: TUL
Oct 27 11:45:21 ao20xa kernel: [73109.949765] usb 3-4: Manufacturer: Xilinx
Oct 27 11:45:21 ao20xa kernel: [73109.949767] usb 3-4: SerialNumber: 1234-tul
Oct 27 11:45:21 ao20xa kernel: [73109.950844] ftdi_sio 3-4:1.0: FTDI USB Serial Device converter detected
Oct 27 11:45:21 ao20xa kernel: [73109.950899] usb 3-4: Detected FT2232H
Oct 27 11:45:21 ao20xa kernel: [73109.951100] usb 3-4: FTDI USB Serial Device converter now attached to ttyUSB0
Oct 27 11:45:21 ao20xa kernel: [73109.951815] ftdi_sio 3-4:1.1: FTDI USB Serial Device converter detected
Oct 27 11:45:21 ao20xa kernel: [73109.951861] usb 3-4: Detected FT2232H
Oct 27 11:45:21 ao20xa kernel: [73109.952058] usb 3-4: FTDI USB Serial Device converter now attached to ttyUSB1
Oct 27 11:45:21 ao20xa mtp-probe: checking bus 3, device 17: "/sys/devices/pci0000:00/0000:00:14.0/usb3/3-4"
Oct 27 11:45:21 ao20xa mtp-probe: bus: 3, device: 17 was not an MTP device
Oct 27 11:45:21 ao20xa systemd-udevd[18701]: Process '/bin/sh -c 'basename $(dirname $(realpath /sys/devices/pci0000:00/0000:00:14.0/usb3/3-4/device)) > /sys/bus/usb/drivers/ftdi_sio/unbind'' failed with exit code 1.
Oct 27 11:45:21 ao20xa kernel: [73110.089464] ftdi_sio ttyUSB1: FTDI USB Serial Device converter now disconnected from ttyUSB1
Oct 27 11:45:21 ao20xa kernel: [73110.089536] ftdi_sio 3-4:1.1: device disconnected
Oct 27 11:45:21 ao20xa kernel: [73110.089818] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0
Oct 27 11:45:21 ao20xa kernel: [73110.089865] ftdi_sio 3-4:1.0: device disconnected
Oct 27 11:45:21 ao20xa snapd[16139]: hotplug.go:199: hotplug device add event ignored, enable experimental.hotplug
Oct 27 11:45:21 ao20xa upowerd[1835]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.0
Oct 27 11:45:21 ao20xa snapd[16139]: hotplug.go:199: hotplug device add event ignored, enable experimental.hotplug
Oct 27 11:45:21 ao20xa upowerd[1835]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.1
Oct 27 11:45:21 ao20xa systemd-udevd[18701]: Process '/bin/sh -c 'basename $(dirname $(realpath /sys/devices/pci0000:00/0000:00:14.0/usb3/3-4/device)) > /sys/bus/usb/drivers/ftdi_sio/unbind'' failed with exit code 1.
Oct 27 11:45:21 ao20xa upowerd[1835]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:14.0/usb3/3-4
Oct 27 11:45:21 ao20xa ModemManager[1044]: <info>  (tty/ttyUSB0): released by device '/sys/devices/pci0000:00/0000:00:14.0/usb3/3-4'
Oct 27 11:45:21 ao20xa ModemManager[1044]: <info>  (tty/ttyUSB1): released by device '/sys/devices/pci0000:00/0000:00:14.0/usb3/3-4'
Oct 27 11:45:21 ao20xa ModemManager[1044]: <info>  Couldn't check support for device '/sys/devices/pci0000:00/0000:00:14.0/usb3/3-4': Operation was cancelled
Oct 27 11:45:21 ao20xa upowerd[1835]: unhandled action 'unbind' on /sys/devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.0
Oct 27 11:45:21 ao20xa upowerd[1835]: unhandled action 'unbind' on /sys/devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.1

So, I wonder if any one could help fixing this problem.

Ralph
  • 471
  • 5
  • 14
Abady
  • 113
  • 1
  • 1
  • 7
  • 1
    The two ttyUSB devices will be because the FT2232HQ has two USB interface descriptors (check the `bNumInterfaces` value in the `lsusb -v` output), each of which implements a serial port. The rest of the strange behavior with the ttyUSB devices disappearing seems to be due to some custom UDEV rules running some sort of custom script on your system. – Ian Abbott Oct 27 '20 at 16:24
  • 1
    So for starters, try `grep -l ftdi_sio /etc/udev/rules.d/*.rules` and then list the contents of the matching \*.rules files. If none are listed, try it with /lib/udev/rules.d/\*.rules instead. – Ian Abbott Oct 27 '20 at 16:29
  • I found one file in the first directory, the second was empty, the first file was: ```/etc/udev/rules.d/10-lattice.rules``` and here is its content: ```ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", MODE="0666", SYMLINK+="ftdi-%n", RUN+="/bin/sh -c 'basename $(dirname $(realpath /sys%p/device)) > /sys/bus/usb/drivers/ftdi_sio/unbind'",RUN+="/root/ftdi_fixer.py" ``` – Abady Oct 28 '20 at 10:58
  • Thank you very much **lan Abbott** , I commented this sole line in the file and every thing is working now, I tried the UART and it works fine. It seems like this line run a script to unbind the device once it is connected. – Abady Oct 28 '20 at 11:14
  • But I wonder, shouldn't this script stop both UART as well as JTAG, why JTAG was working? – Abady Oct 28 '20 at 11:23
  • I cannot comment on the /root/ftdi_fixer.py script as I have not seen it. However, the UDEV rule would have applied to both serial ports, so it would have unbound both serial ports and run the script twice. It is possible to change the UDEV rule so that it only applies to one of the two serial ports by adding `ATTRS{bInterfaceNumber}=="00", ` or `ATTRS{bInterfaceNumber}="01", ` after `ATTRS{idProduct}="6010", `. Also the "ftdi_sio" driver has some code to ignore serial ports reserved for JTAG, but it needs to check for specific strings in the USB device descriptor. – Ian Abbott Oct 28 '20 at 16:35
  • @IanAbbott this helped me (my device was connecting and immediately disconnecting) – Ralph Sep 16 '22 at 00:37

2 Answers2

0

In my case, my user wasn't in the group dialout. When I added:

sudo adduser <my_user> dialout

And logged out and in, finally after the hours of looking for the answer I managed to connect to the serial.

jwpol
  • 1,188
  • 10
  • 22
0

As mentioned in the comments by Ian Abbot and Abady, running:

grep -l ftdi_sio /etc/udev/rules.d/*.rules

and commenting out the lines there helped. For me they were:

#lattice
#BUS=="usb", ACTION=="add", ATTRS{idVendor}=="1134", ATTRS{idProduct}=="8001", MODE=="0666", GROUP=="plugdev", SYMLINK+="lattice-%n"
#FTDI
#SUBSYSTEM=="usb", ACTION=="add", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", MODE=="0666", GROUP=="plugdev", SYMLINK+="ftdi-%n"
#SUBSYSTEM=="usb",  ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", RUN+="/bin/sh -c 'basename %p >/sys/bus/usb/drivers/ftdi_sio/unbind'"

It seems there was a rule which was causing the disconnect (renaming the ttyUSB* to ftdi-*)

Ralph
  • 471
  • 5
  • 14