USB

From Braindump
Jump to navigation Jump to search

usb (host-hub-device otg). works with one host, with several ports, which can be expanded with a hub to connect a device. A device like an android phone can switch a role by using otg on-the-go. The device can act as an device towards a computer and as a host if you plugin a mouse or keyboard

hardware support is defined in a dtb device tree blob, default dtb definitions are collocated with the linux source code, but is linux independent and is also used for bsd. The linux kernel has an xhci hostcontroller interface that manages which device is plugged in where, how fast the port is and which device class it supports. One device can support multiple devices as a composite or compound device. usb device can use messages and streams.

When you plugin a USB device, it is recognized by linux by usb-id, which just like pci has a vendor and device id, which may not be well maintained by the vendor. A driver in linux is loaded based on the USB ID, the driver can be inside the kernel, loaded as a module or managed by hotplug. http://www.linux-usb.org/usb.ids

Android can connect to a host using MTP Media Transfer Protocol or Mass Storage Device. With the correct drivers the device is added to the device tree in /dev, before you can mount it as a disk.

dmesg | grep usb
lsmod | grep usb
lsusb
blkid
ls -l /dev/disk/by-id/