Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux Virtual USB device driver

My goal is to create a virtual USB char device (not block device) for Linux 2.6.32 and above (I use debian squeeze) that would be recognize by the system.

I would like that this device be listed with lsusb as a normal USB device, and that every application could use libusb in order to open the device, and send control message, and make bulk write/read. But behind this virtual device, it's behavior would be set by my application. I want to set it's product ID, it's vendor ID, answer to USB status, and bulk read.

I've read some posts about how to use USB/IP in order to create a virtual USB device, and that's exactly what I want to do Installation and emulation of virtual USB Device http://breaking-the-system.blogspot.fr/2014/08/emulating-usb-devices-in-python-with-no.html

But unfortunately, when I tried with 2.6.32 kernel and above, I didn't succeed making it work. So I looked at how to create a kernel module that would create the virtual device : http://pete.akeo.ie/2011/08/writing-linux-device-driver-for-kernels.html

This one looks great also, but the sample provided doest not indicate how to make it an USB device. I've seen some post talking about it with windows but none that could help me with Linux.

I would like to avoid buying some USB programmable cards when it can be done with software.

Have anyone any leads on how to make the first methods works under newer kernel, or convert the sample code of the second method for making an USB device ?

like image 787
billbon Avatar asked Jul 01 '15 14:07

billbon


1 Answers

I have fixed the code of http://breaking-the-system.blogspot.fr/2014/08/emulating-usb-devices-in-python-with-no.html (first method using USB/IP) to work with linux 4.3.

In the original code are missing USB requests like set configuration and get status. Without the implementation of all USB requests used for the OS driver the code will not work.

The fixed code can be downloaded in https://github.com/lcgamboa/USB-Emulation .

like image 167
lcgamboa Avatar answered Oct 25 '22 15:10

lcgamboa