Hi,
the challenge is to create a cross-platform tool which tells you about the EHCI USB debug ports in your machine and whether something is attached to them. With existing tools, this is possible only for a few corner cases: specific Linux kernel versions, special kernel configurations and a non-mounted /proc/bus/usb together with a patched lsusb shipped with opensuse.
Suggestion: Create a patch for lspci and make sure upstream merges it. That would at least take care of being independent on available dmesg output from a recent, but not too recent kernel. With a patched lspci (similar to the recent VPD patches) it is possible to display the USB debug physical port number. After that, you just have to write a new tool from scratch which can display the USB devices attached to a given controller and physical port.
On 09.09.2008 03:31, Carl-Daniel Hailfinger wrote:
I wanted to know which physical port of my multiple USB controllers have the debug capability. There was no way to find that easily, so I created a tool which will do most of the work for the user.
Example output: The following PCI devices support a USB debug port (says lspci): 0000:00:1d.7 The following PCI devices support a USB debug port (says the kernel): 0000:00:1d.7 PCI device 0000:00:1d.7, USB bus 3, USB physical port 1 Currently connected high-speed devices: /: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/6p, 480M |__ Port 2: Dev 20, If 0, Class=stor., Driver=usb-storage, 480M
The output can be improved, but it's a good start.
New version. Example output: The following PCI devices support a USB debug port (says lspci): 0000:00:0b.1 0000:04:08.3 The following PCI devices support a USB debug port (says the kernel): 0000:00:0b.1 0000:04:08.3 Common subset is: 0000:00:0b.1 0000:04:08.3 The following debug ports exist: PCI device 0000:00:0b.1, USB bus 1, USB physical port 1 Attached devices: PCI device 0000:04:08.3, USB bus 3, USB physical port 1 Attached devices: Bus 03 Port 1 Dev 11, If 0, Class=stor., Driver=usb-storage, 480M Currently connected high-speed devices: Bus 03 Port 1 Dev 11, If 0, Class=stor., Driver=usb-storage, 480M Bus 03 Port 4 Dev 13, If 0, Class=stor., Driver=usb-storage, 480M
This only works if /proc/bus/usb is not mounted and if your lsusb can cope with that. Basically, lsusb has two different output formats, depending on whether /proc/bus/usb is available. Besides that, lsusb has lots of other quirks which make it near unusable. If you look at the script, you'll notice lots of code is only there to get the output format of various tools in shape. lsusb is the worst offender there.
Regards, Carl-Daniel