Understanding sysfs and usb

Reference’s

1) http://www.makelinux.net/ldd3/chp-13-sect-2.shtml

2) Allen Stern’s description

:/sys/bus/usb/devices# ls -al usb*
usb1 -> ../../../devices/pci0000:00/0000:00:1d.7/usb1
usb2 -> ../../../devices/pci0000:00/0000:00:1d.0/usb2
usb3 -> ../../../devices/pci0000:00/0000:00:1d.1/usb3
usb4 -> ../../../devices/pci0000:00/0000:00:1d.2/usb4
usb5 -> ../../../devices/pci0000:00/0000:00:1d.3/usb5

this shows that it has 5 root hubs. Now, lets try to corelate it with lsusb. A simple shell script which will print only RootHubs available on your machine.

#!/bin/sh
TOTAL_BUS_NUM=$1
for (( i=1; i <= $TOTAL_BUS_NUM; i++ ))
do
lsusb -s $i:1
done

Run it as “bash lsusb.sh”

:~/USB$ bash lsusb.sh 5
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Android Android Commands Android Java Applications Application Libraries Bash / Shell Scripts Bluetooth driver Build Frameworks Commands and Packages Core Kernel C Programs Development Environment Setup Documents / Books Errors & Failures File Systems Framebuffer / Display Driver git Go Language Programs Hardware Platforms Home JAVA Programs Kernel & Device Drivers Kernel Booting and Porting Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL NDK / Middleware / HAL Network Driver OS Concepts PHP Procfs Filesystem Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Userspace Utilities Web design and development Wordpress Yocto / Bitbake / Openembedded

Leave a Reply