Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bridge USB host to device

Tags:

c++

c

linux

usb

In a nutshell, I'm developing an embedded system that requires, amongst other things, a bridge from a USB host port to a device port (this is just a first step, later the information transmitted will be filtered and altered).

Considering that this is basically a USB snooper/sniffer I figured that someone should have written a module capable of this, but my search has proven futile.

So, to the question: What's the simplest way to redirect a USB host to a USB device in Linux? The data must be identical, all descriptors and endpoints must match. It must be Linux friendly, I can code in C/C++ and have some experience with coding kernel modules, drivers, etc.

like image 632
user1783395 Avatar asked Oct 29 '12 16:10

user1783395


People also ask

What is USB bridging?

A USB bridge is a device that implements a fixed-function bridge between one USB port and one or two other mass storage device ports.

What is the difference between USB to device and USB TO host?

The USB “TO DEVICE” port is for connecting USB flash drives or other external USB devices to the instrument. The USB “TO HOST” port is specifically for connecting to a computer, smart device, or other host. USB memory devices cannot be connected to the USB “TO HOST” port.

What is OTG host mode?

USB On-The-Go (OTG) is a standardized specification that allows a device to read data from a USB device without requiring a PC. With an OTG cable, the device itself becomes the USB host. You can do a lot over an OTG connection, like connecting a USB flash drive or a video game controller to your phone.

What does it mean USB TO host?

A device that can serve as a “master” USB device, to which other “client” peripherals can be attached, is referred to as a “USB host.” Computers are USB hosts by default.


1 Answers

I found previous work at http://www.elinux.org/BeagleBoard/GSoC/2010_Projects/USBSniffer

The simplest way to redirect a USB host to a USB device in Linux is in my opinion to use both the Linux' peripheral USB stack and Linux' gadget USB stack. Those stacks take care of the low level, so your code should only concern high level interfacing between those two stacks. Added bonus is that the sniffer (via usbmon) will come for almost free.

As that way will be dealing with the Linux kernel, it must be Linux friendly. The interface to both stacks is (at least) available in C. So, your conditions are met.

like image 106
Bart Dopheide Avatar answered Sep 28 '22 16:09

Bart Dopheide