LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 01-17-2010, 02:20 PM   #1
JonathanWilson
Member
 
Registered: Aug 2009
Location: Ilkeston, England
Distribution: ubuntu, xp, embeded
Posts: 79

Rep: Reputation: 1
USB host to device "passthrough"


This is more of a theoretical question than a "how do I" one. Depending on the answers then I may post further or decide I just dont have the know how, lol.

If I buy a Mini2440v2 development board (Arm920) that has both USB host and USB device ports, is it possible to "passthrough" devices plugged into the host port to the device port?

My reasoning is... If I build a device using this board and a usb touchscreen plugged into the host port and then plug the resulting device into a PC via the device port (PC is now host to my device) I'd like to allow the touchscreen to be seen by the pc, as well as any internal storage and/or any usb drives or other devices plugged into my device.

eg:

MYDevice ARM board (Contains/is linked to...)
USB touchscreen
USB external disk
Internal Flash drive
External USB Keyboard.

When MYDevice is plugged into the PC, the PC should be able to see and access/use all the bits as if they were directly plugged into the PC's USB.

Having searched the web, this is not something like USB OTG or Host/device switching... instead its more about faking the USB return devices. As MyDevice will always be a client to the PC, yet on its own a host to the other devices.
 
Old 01-19-2010, 08:41 AM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
I believe what you want to learn about is the USB Gadget API. A Google search yields numerous good starting references.
--- rod.
 
Old 01-20-2010, 05:54 AM   #3
JonathanWilson
Member
 
Registered: Aug 2009
Location: Ilkeston, England
Distribution: ubuntu, xp, embeded
Posts: 79

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by theNbomr View Post
I believe what you want to learn about is the USB Gadget API. A Google search yields numerous good starting references.
--- rod.
Thanks for that, thats just what I needed to know.

After looking I think it is do-able and quite simple in concept, if not the actual code.

Now all I have to do is learn C and update my knowledge from years ago, before i went into as/400 application programming.

I'm guessing the other parts I need to study are USBCORE for the host side, and a few device drivers to see how it all hangs together.
 
Old 05-21-2013, 03:38 PM   #4
sleonard
LQ Newbie
 
Registered: May 2013
Posts: 1

Rep: Reputation: Disabled
@JW, did you get this working? I am looking at doing a similar USB passthrough with our ARM embedded system.
 
Old 05-22-2013, 06:27 AM   #5
JonathanWilson
Member
 
Registered: Aug 2009
Location: Ilkeston, England
Distribution: ubuntu, xp, embeded
Posts: 79

Original Poster
Rep: Reputation: 1
Sadly my knowledge of C was not up to this in the end.

However what I did manage was a little bit more of "if it could it would do it this way" overview.

http://usbip.sourceforge.net/

The documentation (down the page a bit) shows how usb over ip works.

What I would have done is when my device (server) was plugged into the pc the pc would load the usbdriver for my device, this would be exactly the same as the usb-ip VCHI except instead of usb over ip, it would be usb over usb.

1) Where something in my device was connected via usb, it would work exactly as shown in the usb-ip diagram creating a stub driver. eg. a usb keyboard plugged into my device.

2) Where something was not connected via usb, eg. a hard drive or a virtual keyboard on the screen, it would create a _fake_ stub driver of an already known usb device and would then translate the usb requests to the real (hard drive) or virtual (keyboard) device.

For item 2, I'm not sure how much work would be involved as I'm a little unsure how usb works at this point... my guestimate is that its no more than an end to end wrapper over the underlying hardwares native data/control types, the thinking behind this guess is because a usb hard drive can have a different hard drive (size/make) connected and it still works so there must be an abstraction between the usb type/make and the underlying physical hardware type. (a)

eg. diskrequest-seek>wrapped usbSoftwareControl>PhysicalUsb>----wire---->PhysicalUsb>un-rapped usbHardwareControl>diskrequest-seek>physicalHD

If the above is true, then the fake stub would strip away the usb controlling data (request) to get at the raw device command, and then send that command to the devices hardware stack, get the resulting data, wrap it back into usb control data (result) and then send it over the usb.


I did also think about this a little further... when an item of hardware in the server (mydevice) was in passthrough mode it may also be needed exclusively for that device at times. If the mydevice was a notepad with a screen, and a virtual keyboard, there might be times when the keyboard was needed for the notepad itself, say the notepad was running an email client, when a new mail message pops up hitting a special combination of keys on the virtual keyboard would cause the keyboard to no longer send data via the stub driver, the driver would however stay active and connected to the vhci, it would still receive the key presses it would just not send them on... another special combination of keys would then cause the driver to once again send data to the pc.


(a) this abstraction is not however complete, a usb harddrive does not return a controler type (ie sata) it returns a device type (hd) if you plug in a CD drive into a usb harddrive (by opening it and taking out the tiny PCB and connecting that to the cd player + power cord) it does not work as HD commands, not CD commands are sent... that said I see no reason why the writer of the usb driver could not have written a slightly more abstract driver that would first query the device attached to the usb, then initiate the correct device in the usb/device interface such as "this is a hd" or "this is a XX type cd/dvd drive"
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
detect usb device insert/remove and get device node from "C" program ebinjose Linux - Embedded & Single-board computer 4 04-29-2012 08:26 AM
"Unable to open USB device "usb://hp/LaserJet%201000": No such device" lordshipmayhem Mandriva 2 08-08-2004 04:56 PM
USB storage device works in 2.4 not 2.6 "no device error" critch Linux - Hardware 4 05-18-2004 11:13 AM
./MAKEDEV usb error - dont know hot to make device "usb" Zero-0-Effect Linux From Scratch 4 04-10-2004 07:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 06:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration