2

I have a single-board computer with a JTAG port serviced by FTDI hardware, but it's not connecting to the development system (Xilinx Vivado), and I'm trying to diagnose the problem. The command sudo lsusb -v -D /dev/ttyUSB0 reports Cannot open /dev/ttyUSB0, even though I've set permissions to 777 for the moment. I ran sudo usb-devices with and without the cable connected to be sure I was looking at the right device and here's what I got (serial number obfuscated by me):

T:  Bus=01 Lev=03 Prnt=04 Port=01 Cnt=01 Dev#=  9 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=0403 ProdID=6014 Rev=09.00
S:  Manufacturer=Digilent
S:  Product=Digilent USB Device
S:  SerialNumber=000000000000
C:  #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=0mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=ftdi_sio

I'm running a fresh install of 18.04.2 just yesterday updated to 18.04.4; the reinstall was prompted by a desire to solve this problem, and I wanted to make sure stale software was not the cause.

I think the inability of Vivado to see the device may be related to the inability of a common system tool such as lsusb to open the device. Any help would be appreciated.

  • 1
    The manpage for lsusb indicates that you are using -D incorrectly. It should look more like sudo lsusb -v -D /dev/bus/usb/001/001. Restore the permissions. – user535733 Mar 26 at 16:46
  • 1
    I got the same error, I think it's because /dev/ttyUSB0 major number 188. Try to find this device in /dev/bus/usb and use with lsusb -D, on my machine for example it's sudo lsusb -D /dev/bus/usb/003/119. Notice that devices in /dev/bus/usb have major 189, defined as #define USB_DEVICE_MAJOR 189 in Linux kernel. – Arkadiusz Drabczyk Mar 26 at 16:47
  • Thanks! That clears that problem. – RadlyEel Mar 26 at 17:25
0

Ok, it has nothing to do with major numbers as I thought. The Cannot open /dev/ttyUSB0 message is printed in dump_one_device() if pointer returned by get_usb_device() is NULL. This function in turn calls libusb_get_device_list() that returns a list of USB devices together with their bus and device numbers which are extracted using libusb_get_bus_number() and libusb_get_device_address() and concatenated with "/dev/bus/usb". You can check it with gdb (I've used today's master commit c92f1962892d709cb9bad3aac2440932dd9684f6 from https://github.com/gregkh/usbutils):

$ gdb --args ./lsusb -vD /dev/ttyUSB0
Reading symbols from ./lsusb...done.
(gdb) break usbutils/usbmisc.c:134
Breakpoint 1 at 0x40b827: file usbmisc.c, line 134.
(gdb) run
Starting program: /media/data/usbutils/lsusb -vD /dev/ttyUSB0
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7ffff6d44700 (LWP 4621)]

Thread 1 "lsusb" hit Breakpoint 1, get_usb_device (ctx=<optimized out>, path=path@entry=0x7fffffffddab "/dev/ttyUSB0") at usbmisc.c:134
134                     if (!strcmp(device_path, absolute_path)) {
(gdb) print device_path
$1 = "/dev/bus/usb/002/002", '\000' <repeats 4076 times>
(gdb) continue
Continuing.

Thread 1 "lsusb" hit Breakpoint 1, get_usb_device (ctx=<optimized out>, path=path@entry=0x7fffffffddab "/dev/ttyUSB0") at usbmisc.c:134
134                     if (!strcmp(device_path, absolute_path)) {
(gdb) print device_path
$2 = "/dev/bus/usb/002/001", '\000' <repeats 4076 times>
(gdb) continue
Continuing.

Thread 1 "lsusb" hit Breakpoint 1, get_usb_device (ctx=<optimized out>, path=path@entry=0x7fffffffddab "/dev/ttyUSB0") at usbmisc.c:134
134                     if (!strcmp(device_path, absolute_path)) {
(gdb) print device_path
$3 = "/dev/bus/usb/001/002", '\000' <repeats 4076 times>
(gdb) continue
Continuing.

Thread 1 "lsusb" hit Breakpoint 1, get_usb_device (ctx=<optimized out>, path=path@entry=0x7fffffffddab "/dev/ttyUSB0") at usbmisc.c:134
134                     if (!strcmp(device_path, absolute_path)) {
(gdb) print device_path
$4 = "/dev/bus/usb/001/001", '\000' <repeats 4076 times>
(...)

and so on until device_path is equal to the input argument. Of course /dev/ttyUSB0 will never match.

It's nice that you can also change to /dev/bus/usb and pass a relative device address:

$ cd /dev/bus/usb/
$ lsusb -D 001/001
Device: ID 1d6b:0002 Linux Foundation 2.0 root hub
(...)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.