0

I have a device connected to my Debian linux box, lsusb says:

Bus 002 Device 005: ID 0525:a4a7 Netchip Technology, Inc. Linux-USB Serial Gadget (CDC ACM mode)

In

/sys/bus/usb/devices/

I have

drwxr-xr-x 4 root root 0 Sep  7 14:27 ..
lrwxrwxrwx 1 root root 0 Sep  7 14:27 1-0:1.0 -> ../../../devices/pci0000:00/0000:00:1a.7/usb1/1-0:1.0
lrwxrwxrwx 1 root root 0 Sep  7 14:27 2-0:1.0 -> ../../../devices/pci0000:00/0000:00:1d.7/usb2/2-0:1.0
lrwxrwxrwx 1 root root 0 Sep 13 08:32 2-3 -> ../../../devices/pci0000:00/0000:00:1d.7/usb2/2-3
lrwxrwxrwx 1 root root 0 Sep 13 08:32 2-3:2.0 -> ../../../devices/pci0000:00/0000:00:1d.7/usb2/2-3/2-3:2.0
lrwxrwxrwx 1 root root 0 Sep 13 08:32 2-3:2.1 -> ../../../devices/pci0000:00/0000:00:1d.7/usb2/2-3/2-3:2.1
lrwxrwxrwx 1 root root 0 Sep  7 14:27 3-0:1.0 -> ../../../devices/pci0000:00/0000:00:1a.0/usb3/3-0:1.0
lrwxrwxrwx 1 root root 0 Sep  7 14:27 4-0:1.0 -> ../../../devices/pci0000:00/0000:00:1d.0/usb4/4-0:1.0
lrwxrwxrwx 1 root root 0 Sep  7 14:27 5-0:1.0 -> ../../../devices/pci0000:00/0000:00:1d.1/usb5/5-0:1.0
lrwxrwxrwx 1 root root 0 Sep  7 14:27 6-0:1.0 -> ../../../devices/pci0000:00/0000:00:1d.2/usb6/6-0:1.0
lrwxrwxrwx 1 root root 0 Sep  7 14:27 usb1 -> ../../../devices/pci0000:00/0000:00:1a.7/usb1
lrwxrwxrwx 1 root root 0 Sep  7 14:27 usb2 -> ../../../devices/pci0000:00/0000:00:1d.7/usb2
lrwxrwxrwx 1 root root 0 Sep  7 14:27 usb3 -> ../../../devices/pci0000:00/0000:00:1a.0/usb3
lrwxrwxrwx 1 root root 0 Sep  7 14:27 usb4 -> ../../../devices/pci0000:00/0000:00:1d.0/usb4
lrwxrwxrwx 1 root root 0 Sep  7 14:27 usb5 -> ../../../devices/pci0000:00/0000:00:1d.1/usb5
lrwxrwxrwx 1 root root 0 Sep  7 14:27 usb6 -> ../../../devices/pci0000:00/0000:00:1d.2/usb6

How to find out which device is this?

0

I found / modify a script to get the /sys device based on lsusb output.

#!/bin/bash
#
# usb2sys - find lsusb device in /sys file system
#

die()
{
    echo "$@"
    exit 1
}

[[ $# -lt 1 ]] && die "need vendor and product ids (from lsusb) as dddd:dddd"

vendor=${1%:*}
product=${1##*:}

sys=/sys/bus/usb/devices/
cd $sys

for d in *; do
    path=$sys$d
    if [ -f $path/idProduct ]; then
      prod=$( cat $path/idProduct )
      vend=$( cat $path/idVendor )

      if [ $prod = $product -a $vend = $vendor ]; then
        echo prod = $prod
        echo vend = $vend
        echo /sys device is $path
      fi
    fi
done

the idea is to get the string 1d6b:0002 and check agains which is the idProduct:idVendor couple and compare it to the existing usb in /sys

You can use the script like this

lsusb | cut -d ' ' -f 6 | xargs -L 1 ./usb2sys

The output would be something like

prod = 0002
vend = 1d6b
/sys device is /sys/bus/usb/devices/usb1

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.