Use of xHCI driver and USB_STORAGE driver - linux-kernel

I'm currently learning driver programming and am at very nascent stage. I'm unable to get the difference of use of xHCI, EHCI, or OHCI drivers and usb_storage.
When I plug my USB device (pen drive) and observe dmesg output, it says that my device is using the ehci driver, but my device stops working when I rmmod usb_storage.
There are many drivers for different kind of USB devices let it be mouse, keyboard, camera, etc.
As of now, I assume that the xHCI driver is for USB host and the other driver is for the device we connect to our USB host. Am I correct? If not, what is the explanation?

*HCI are specifications of USB hosts:
xHCI - for USB 3.0
EHCI - for USB 2.0
OHCI and UHCI - for USB 1.x
usb_storage is a upper level driver working on the USB host side, and it is responsible for communication only with USB storage devices, not keyboard, mouse, etc.
The USB is maintained in form of a stack and *hci drivers are the lowest level in that stack. usb-storage and other drivers are located on a higher level of this stack.

Related

Character device interface for USB device drivers

In Kernel USB subsystem is registering chardevices using "usb_major_init()" and "usb_devio_init()" functions.
How these character device drivers linked to the actual USB drivers registered using "usb_register_driver" and "usb_register_device_driver" functions in the kernel source?

Re-enumeration of USB device which is upgraded from old to new firmware with changes in the descriptor

If I connect a USB device to the host and then upgraded the USB device with a new firmware with changes in the Descriptor of the device. The host will use the old descriptor.
I know that I can force the device to re-enumerate itself by deleting Windows initialized driver for the device etc. or I can bump the ProductId in the descriptor and the device will re-enumerate.
Windows cash the information about the device etc. and thereby windows never ask the device to provide the information again on reconnecting about interfaces, configuration, endpoints, HID descriptor etc.
idProduct - changing this will re-enumerate the device because windows will think its a different device.
iSerialNumber - changing this will re-enumerate because windows need to differentiate between two same idProducts (two of same products connected)
bcdDevice - should do the trick of re-enumeration but it's not working as specified in USB specification.
My question is how can I force Re-enumeration of the USB device without deleting drivers etc. or changing idProduct or iSerialNumber?
Any help will be appreciated...

Is a terminal and USB Device or a USB Host

If I use Tera Term, to connect to a USB OTG port on a STM32 MCU, is Tera Term a USB Device or a USB Host.
The question arises as I presumably could configure the STM32 OTG port to be a USB Host CDC or a USB Device CDC.
It's possible that it doesn't matter what I configure the STM32 USB OTG port as, but it's possible that there may be a specific standard that defines what should be done.
If I use Tera Term, to connect to a USB OTG port on a STM32 MCU, is Tera Term a USB Device or a USB Host.
Neither.
Your computer is a USB host. The software running on your computer doesn't affect its role.

NVMe PCIe Hard Disk on Freescale LS2080A not recognised

I have a Freescale LS2080 box for which I am developing a custom linux 4.1.8 kernel using the Freescale Yocto project.
I have an NVMe hard disk attached to the LS2080 via a PCIe card, but the disk is not recognised when I boot up the board with my custom linux kernel.
I plugged the same combination of NVMe disk and PCIe card into a linux 3.16.7 desktop PC and it was detected and mounted without problem.
When building the LS2080 kernel using the Yocto project, I have enabled the NVMe block device driver and I have verified that this module is present in the kernel when booting on the board.
The PCIe slot on the board is working fine because I have tried it with a PCIe Ethernet card and a PCIe SATA disk.
I suspect that I am missing something in the kernel configuration or device tree, but I'm not sure what. When I add the NVMe driver to the kernel using menuconfig, the NVMe driver dependencies are supposed to be resolved.
Can anyone provide insight into what I am missing?
First make sure that PCIe device is recognized using lspci.
If device is not shown in lspci list this is enumeration problem, to check the error use PCIe analyzers.
If the device is shown in the list then simply add the device vendor id and device ID to NVMe driver and recompile to load the driver for your device.

Windows PC as a USB slave to emulate a thumbdrive

I need to create a application that will allow a Windows PC (XP/Vista) to emulate a thumbdrive. That is, when the PC is plugged into either another Windows system, or in this case, a piece of hardware that allows for USB thumbdrives to be plugged in, a folder on the computer looks like a giant thumbdrive. Any thoughts on where a guy would start to investigate this?
Update (more specific description):
I need to connect my PC to one of the newer multifuction devices that support scanning to a USB thumbdrive that is inserted into the front of the device. These units do not support WIA or TWAIN via the rear USB connector that you'd typically use for connectivity to a PC.
Most USB controllers in regular pc's dont have the possibility to function as an USB slave. So I'd start with investigating what kind of hardware you're going to use.
Another way to go: there are USB Link cables to link up 2 pc's over USB, maybe that's usable for you?
You cannot do this in an application. At the lowest level, the USB ports on your computer are controlled by an Host Controller Interface. This chip will manage up to 127 slave USB devices. You would need to seriously reprogram this chip before it implements the slave side of the USB protocol. Of course, at that point any USB hub in your PC will break down - those 8 USB ports you probably have are usually implemented by 2 smart USB hubs connecting to both USB1 and USB2 host controllers. Next, your USB keyboard and mouse will stop working.
Take an MCU with two Slave USBs. Write a simple frimware which makes one USB act as a Special Device Class and wait until PC on this USB provides mandatory data (including Device Class, of course) for the other USB. Write a PC program which connects to the Special Device (your MCU), uploads Mass Storage Device Class and redirects I/O to a dedicated partition. The other USB on the MCU will become an emulated Mass Storage Device.
Some of those code can be taken from Linux.

Resources