reference:
https://processors.wiki.ti.com/index.php/USB_Debug_Techniques
https://linux.die.net/man/1/usb-devices
1. USB announce new devices
Say Y here if you want the USB core to always announce the
idVendor, idProduct, Manufacturer, Product, and SerialNumber
strings for every new USB device to the syslog. This option is
usually used by distro vendors to help with debugging and to
let users know what specific device was added to the machine
in what location.
plugin a usb mouse device:
2. lsusb
3. sysfs
/sys/bus/usb/devices/
3.1 name rules:
roothub-port:configuration.interface.
we can know that 1-1 is usb mouse devcie from plugin&remove test
1) usb1 and usb2 are roothub
2) 1-0:1.0 is roothub1, 2-0:1.0 is roothub2
3) 1-1 is a usb device which attach at roothub1 port1
4) 1-1:1.0 is a usb device interface which configuration is 1, interface is 0
3.2 plugin a usb mouse to host
4. debugfs
mount -t debugfs none /sys/kernel/debug
cat /sys/kernel/debug/usb/devices
the detail meaning see: https://www.cnblogs.com/hellokitty2/p/9418895.html
Location where the usb/devices file can normally be found for Linux kernel 2.6.31 and later, if debugfs is mounted.
5. usbfs(The USB Filesystem)
refer to:
https://lxr.missinglinkelectronics.com/linux+v2.6.38/Documentation/usb/proc_usb_info.txt
http://www.hep.by/gnu/kernel/usb/usbfs.html
the USB device filesystem is a dynamically generated filesystem, similar to the /proc filesystem. This filesystem can be mounted just about anywhere, however it is customarily mounted on /proc/bus/usb
In many modern systems the usbfs filsystem isn't used at all. Instead USB device nodes are created under /dev/usb/ or someplace similar. The "devices" file is available in debugfs, typically as /sys/kernel/debug/usb/devices.
-
/proc/bus/usb/devices ... a text file showing each of the USB devices on known to the kernel, and their configuration descriptors. You can also poll() this to learn about new devices.
-
/proc/bus/usb/BBB/DDD ... magic files exposing the each device's configuration descriptors, and supporting a series of ioctls for making device requests, including I/O to devices. (Purely for access by programs.)
mount -t usbfs none /proc/bus/usb
cat /proc/bus/usb/devices
Note, usbfs can normally be found for Linux kernels before 3.4(include 3.4). so, kernel4.14 don't support usbfs
kernel config: CONFIG_USB_DEVICEFS (make menuconfig ---> Device Drivers ---> USB support ---> USB device filesystem (DEPRECATED))
6. /dev/bus/usb/xxx
device node: /dev/bus/usb/bus_num/device_num
we can know that usb mouse(VID0x093a ,PID0x2510) device node is /dev/bus/usb/001/007
libusb open a usb device by open(/dev/bus/usb/xxx/xxx)
we can also find device number by check "usb announce info":
lsusb is also a good method:
7. usbmon
8. dev_dbg