Search code examples
linuxusbdriverlibusb

Converting a driver to linux


I'm trying to write a linux driver to a device that i have the windows driver of (Similar to the case described Here, but a different device)

I'm using Libusb for the communication on the linux side, and SourceUSB as my USB sniffer (on the windows machine). Now I think I've replicated the controls and bulks properly, but I can't really test the linux log against the windows one. I'm running Ubuntu 12.04 on a VM.

So my questions are:

  1. Is there a multiplatform logger? That could really simplify the log compare process.
  2. When I attach the USB device to the VM - I get the VM driver in Windows. Sniffing this device gives me exactly what the device sees, right? I mean - Is this where I want to sniff?

EDIT: I've compiled my application on windows (libusb is cross platform - A big thanks to libusb developers who did such a good job) and my application worked properly.

When sniffing the VM driver while running my application on linux, I see the requests to the USB as VENDOR_DEVICE instead of CONTROL_TRANSFER and BULK_OR_INTERRUPT. This seems to be the problem if I understand correctly, since this is what the device "sees".

So I guess my problem now is why does Linux sends my requests as vendor.

ANOTHER EDIT: Problem solved:

  1. Listening to the VM driver gave me the wrong requests (I was listening to the VM driver traffic, not, as i wanted, the traffic of the my USB linux driver
  2. Libusb is perfectly multiplatform. It took me a few minutes to get my code to compile under windows, and from there it was pretty easy to debug and compare logs

Solution

  • You can use Wireshark to capture USB traffic. This page explain how to do it for Linux and Windows : CaptureSetup/USB