Understanding "driverless" USB HID - usb

I'm at the beginning of trying to develop a USB HID bootloader for a Kinetis processor, and getting no help from that department. I have made some modifications to Kinetis firmware designed for a similar processor(I'm using the KL26Z, the original code is for KL25Z), and I do now see the beginning of the USB enumeration(on a PC running W7). However, the PC asks for driver software, and I don't understand why, as I thought the whole point of going the HID route was that one didn't need to install drivers. So the device shows up under device manager, but as a non-working problem device. My problem is that I don't really know what should happen. Any insights would be welcome.

Here's what should happen: the computer will ask your device for its USB descriptors when it detects your device. The descriptors must have certain fields like bDeviceClass set properly to indicate that it is an HID. If the computer sees those fields, it will attach the HID driver to your device.
In the Device Manager, you should look at the "Compatible Ids" of your device. Do you see USB\Class_03 in that list? If so, that should match the driver input.inf that comes with Windows, so the INF file will be applied to your device, and you device will show up as "USB Input Device" in the Device Manager. If you don't see USB\Class_03 in your list then there is probably some problem with your device's USB descriptors or its USB stack.

Related

USB hub and the identification of positions

I need to attach 8 devices of the same kind (RFID readers) to the 8 positions of the USB hub. I need to recognize which reader is not plugged-in. I also need to know which exact device sends the data (based on the physical location)
I am aware of "a path" related to an USB plug. However, I am still a newbie in the topic. Are the positions at the USB hub numbered always the same way, or are the numbers in the path assigned based on when the USB device is plugged in? In other words, can I tell whether a specific position at the USB hub is connected or not? Can I reliably determine which device sends the data based on the communication path?

Read Data Across USB Port

I'm playing around with an old Trackball I purchased from Sparkfun. My trackball powers on, but it doesn't actually work. All the lights flash, and it indicates that I've left and right clicked, but the mouse on my screen does nothing.
I want to monitor the input values of the trackball across a USB port so I can track down the problem. I've looked for code I can run on Netbeans, but came up empty handed.
Please advise
You didn't specified what OS are you using. You need dedicated driver for this device. In case of Linux you would need to write your own driver for the kernel. But first you need to have specification of protocol which this device is using over usb and also usb protocol itself. It is quite sophisticated task to do...
In case of Windows there are some programs for dumping transmission between usb host (PC) and device (trackball), but at the moment I can't give you any name of such program. In case of Linux you can dump the transmission using tcpdump or wireshark commands.

USB HID device detection

I am trying to access an USB HID device under Ubuntu(kernel-3.0). I want to write a program which could notify me whenever an USB device is attached to the bus i.e is there any event generated whenever an USB device is plugged in which I can monitor. I have looked into DBus and HAL without any success. But I don't want linux to load its current modules(USBHID and HID) when the device is plugged in. I also want to ask if the mentioned modules are also the device drivers used for HID devices.
My sole purpose is to run a script whenever an USB device is plugged into the bus which will indirectly call the above mentioned modules.
I am writing my code in C. I am quite new to linux. So it would be of great help if anyone could point me in the right direction.
Thanks..
The UDisks deamon will send the D-Bus signal "DeviceAdded" when a USB drive is inserted, and probably another "DeviceAdded" for each partition on the drive. If you have automount you would also get a "DeviceChanged" signal when the partition(s) are mounted. You can then query the UDisks interface, as well as individual devices about their properties, for example. You can find more info on the UDisks interface here: http://hal.freedesktop.org/docs/udisks/UDisks.html
One way to get more familiar with what goes on with block devices (or whatever) on D-Bus, is to install and use D-Feet to inspect the bus. UDisks appear on the System bus. You can see what is there and inspect the properties for individual devices as well as the UDisks interface itself.
Another way, which would also allow you to see what signals are transmitted on the bus, is to run dbus-monitor from the command line.

linux usb driver: probing already plugged devices

I am writing an Usb driver and I have an issue.
When I insmod the driver with the device already plugged in before hand, the probe function is not called. It is only called after I disconnect the device and plug it again.
I want to make it so that it works when I start my pc with the device already plugged in.
Could someone please help me?
From Documentation/driver-model/binding.txt:
When a new device is added, the bus's list of drivers is iterated over
to find one that supports it. In order to determine that, the device
ID of the device must match one of the device IDs that the driver
supports. The format and semantics for comparing IDs is bus-specific.
From the same source:
The process is almost identical for when a new driver is added.
The bus's list of devices is iterated over to find a match. Devices
that already have a driver are skipped. All the devices are iterated
over, to bind as many devices as possible to the driver.
So it looks like you have a problem in the ID matching, that is in your case specific to the USB bus, see the usb_device_match function in drivers/usb/core/driver.c.
Or it may be that your device already is bound to a device that is unloaded when the device is unplugged (you can check that by controlling if there is a symlink to a driver in the corresponding /sys/bus/usb/xxxxx directory)
"Or it may be that your device already is bound to a device that is unloaded when the device is unplugged (you can check that by controlling if there is a symlink to a driver in the corresponding /sys/bus/usb/xxxxx directory)"
And if there is a symlink?
This can be solved by writing a proper udev rule for your device. Look for examples at /etc/udev/rules.d/

Multiple Driver for USB Device

Is it possible for a USB device to support multiple drivers? I'd like to support my own proprietary driver but also CCID as a second choice. When the device is plugged in, the user can select which one to use. The driver to use is determined by what the USB descriptor says, right? If that is so, is it possible to indicate that both drivers are supported? Is the idea of supporting two drivers doable?
On Windows, having two supported drivers is possible. In fact, to get Microsoft Logo certification, it is mandatory that the USB device supports this functionality. (Requirement CONNECT-0123)
However, the UI behavior you describe isn't offered by Microsoft. Driver selection is automatic.
Your USB device can indicate it supports two interfaces. In that case, both drivers will be loaded.
I am sure that it is not possible for a device to use two drivers at the same time but what is possible is for the device to enumerate using one class type and driver and then during its operation, in response to some command over the USB or operation of the device, for it to disconnect and then re-enumerate as a different type of device using the second driver.
As an example the product that I am developing normally enumerates as a CDC (serial port emulation) but when I need to reload the code it re-enumerates as a different device type and uses the chip vendor supplied driver to perform the code download. Once this completes then the device re-enumerates itself again as a CDC device type and resumes its serial port emulation.
You therefore need to provide a "command" interface that will trigger the transition between the two operating modes and to ensure that the two drivers are installed on the host computer ready for the mode switch.