Linux: look for USB "client" driver example - usb-drive

I want to write a USB communication driver for Embedded Linux device. The embedded Linux device connects to the Linux PC as a device.
So, I'm going to write two USB drivers, one for Linux PC and one for embedded Linux device.
I can refer to USB-skeleton.c for drivers on Linux PC, but is there a reference code for drivers on embedded Linux device?

Related

Include my USB device driver in Windows Update?

How would an OEM go about getting their USB device driver added to Windows Update, so that it will be downloaded and installed automatically when the device is connected to the PC? In our case, if it matters, it will be a custom USB device class, and the driver will wrap WinUSB.
Is it possible to do this for Windows 7, Windows 8, and Windows 10? 32 and 64-bit.
What keywords (for searching) and concepts should I be aware of?
The question is misguided. The interface to WinUSB lives in userspace - not kernel space - so that DLL will be a library that lives in userspace; it won't be a driver.
The device will report via its device descriptors to Windows that it can use the WinUSB driver, so Windows won't look for its wrapper.

TDS NOMAD windows CE5.0 device connects more than two USB devices

I have a TDS Nomad running windows CE 5.0 system. It has a USB host port. I have connected to the manufacture and ask if nomad can connect to more than 1 USB devices via USB hub (can connect to 7 USB devices, designed for windows ), they said they haven't tested to connect more than one USB device. If more than one devices is connected to nomad, there mightbe resource conflict.
The nomad works well with one USB device connect to it individually.
But I have a console application debugging in nomad using visual studio2005 and active sync.
I need to talk to both USB devices. Therefore I have to use USB hub. But it doesn't work most of the time. I think the drivers of two USB devices are all correctly installed on nomad.
But what I want to ask, is that has anyone tried to connect more than one USB device to windows CE product via USB hub and both of them works well ?
I'm slightly confused. here. You say the device has USB host and you want to connect more than one client device through a hub. This is definitely supported by the OS, and I've done this with several devices from several manufacturers, though never with a Nomad. Not sure what the OEM is talking about with "resource conflicts" as the USB spec itself allows for multiple devices (kind of the whole point behind a "bus").
But you say that your second "device" is the debugger. That isn't a USB Host connection from the device perspective, that's a USB Client connection, and it typically uses completely different hardware and drivers for that connection. Can a device have both a host and a client connection? Again, yes I've done this with many devices (but not a Nomad) and the OS fully supports it.
Now maybe this is USB OTG hardware (though back in the 5.0 days I doubt it) and the OEM didn't do the design well to handle a client and a host at the same time. Maybe the physical hardware is laid out poorly or the OAL portion of their USB driver is poorly done and can't route properly through a hub properly (I've definitely seen that before). Hard to say.
A USB Analyzer would tell you a whole lot about what's actually happening and where the problem is, but it is definitely a supported scenario by both the USB spec and the OS. If it's failing, it's a manufacturer/device-specific problem.

Mac OS X driver to work with Linux USB composite gadget driver g_multi

I'm interested in using the Linux USB composite gadget driver g_multi in an embedded Linux device, for Ethernet-over-USB and serial-over-USB (the Ethernet-over-USB is compiled for RNDIS mode; I'm not interested in the mass storage function, so I've disabled it). I've tested it, and got it working fine with both Windows and Linux. However, brief testing with Mac OS X shows that OS X doesn't automatically load the drivers for it.
I know that in principle OS X has the capability for Ethernet-over-USB, because it works automatically with the Linux USB g_ether driver (compiled for RNDIS mode). Likewise OS X works with serial-over-USB with the Linux USB g_serial driver—I can connect to the USB serial port with ZOC. But it does nothing when the Linux device is running g_multi.
I can't find any documentation that says how OS X might be made to work with a Linux device running the g_multi driver. Has anyone succeeded in doing so?
Can it be done with some sort of simple OS X driver that basically tells OS X to load its drivers for each of the component functions (a bit like the INF files I'm using for Windows, which just tell Windows to load the standard Windows driver for Ethernet- and serial-over-USB)? If so, what is the procedure for doing that?
RNDIS is unfortunately not supported by MAC OS. You need a 3rd party driver, like https://www.joshuawise.com/horndis.

Custom USB Driver for Windows? Mac?

I'd like to modify a USB driver to send and receive USB data over a network.
Take for example, an iMac and a PC. I have an iPod plugged in to my PC (in NY). I want my iMac (in LA) to recognize the iPod as plugged in to a local USB port and be able to communicate with the iPod.
Forget my qualifications, or lack thereof (I have background in web, iOS apps, I've toyed with Java and C).
Where can I get source code for a USB driver for Windows that I can modify? Mac OS?
Any tips or pointers towards accomplishing my goal would be appreciated as well.
It looks like folks are coming up with something close to what you want. If you do decide to roll your own, the USB driver source you asked for is libusb.
On the Mac OS X end, drivers are built up in a stack. What you want to do should be relatively simple (nothing is really simple in kernel land). You need to create a driver that can communicate over ethernet with the PC and looks like a USB device to the driver matching software. Then everything else will happen automatically.
The source code is available for Apple's USB stack. You should also read about the IOKit API and IOKit device driver guidelines and IOKit fundamentals.
Oh yes and you say you have toyed with Java and C. To write device drivers on OS X, you'll need to learn some C++.
I suggest you to go see USBIP project. This is available on Linux and Windows, but not clear for MAC. If you can get a VHCI-Controller driver installed for MAC, we can kick start USBIP for MAC.
Sounds quite like this product, a bit unsure if theirs works over wide-area networks though.
I have a general idea of how I'd go about it, but not any specifics. Basically, I'd use the platform's driver development kit to write a USB device emulator on the client machine. I'd then add a virtual device to that system called "Networked USB Host", or something similar that maintains an open port to listen for communication from the server and passes it on to your virtual USB device. IIRC, the Windows DDK comes with a USB simulation framework that might be able to help you with this.
On the server, you'd have to hook into the USB subsystem to send raw USB packets to the client machine. libpcap and wireshark have USB capturing facilities for that, but I'm not sure if this works with winpcap and the Windows version of wireshark as well.
EDIT: Look at this for cross-platform USB capture alternatives.
You can buy OSR USB learning kit: https://www.osronline.com/custom.cfm?name=index_fullframeset.cfm&pageURL=https://www.osronline.com/store/index.cfm
This is actually small USB device with known interface. Windows Driver Kit (WDK) contains sample KMDF driver for this device: http://www.microsoft.com/whdc/driver/wdk/
This is good starting point to learn Windows Drivers development, and USB drivers development specifically. However, it is still far away from your problem solution.
Can't you use some sort of Remote Desktop?

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