Author Topic: Using the gadget drivers in an embedded Linux system...  (Read 7114 times)

st2000

  • Member
  • ***
  • Posts: 44
Using the gadget drivers in an embedded Linux system...
« on: February 19, 2014, 07:03:51 pm »
Hi,

Is there a better place to talk about the gadget drivers and how to make a Linux computer act like a USB PERIPHERAL (aka DEVICE)?

My questions for now are basic.  For instance, given most Linux boxes have several USB port, how do you run something like the gadget g_serail.ko on a specific port?  Or am I looking at this all wrong?

-thanks

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Using the gadget drivers in an embedded Linux system...
« Reply #1 on: February 19, 2014, 09:31:16 pm »
Every USB communication is between a host computer and a USB device. The hardware interface and programming differs for host and device ports.

A typical Linux PC has USB host ports.

To use the gadget driver, you need a USB device port or an OTG port configured to function as a device port.

The BeagleBoard and some other Linux embedded systems have OTG ports and can use the gadget driver.

st2000

  • Member
  • ***
  • Posts: 44
Re: Using the gadget drivers in an embedded Linux system...
« Reply #2 on: February 19, 2014, 11:06:51 pm »
Quote
To use the gadget driver, you need a USB device port...
So, there is no way one can use a USB Type A Socket as a USB DEVICE.  Even if you modify it some how?  I don't think I'll be forced to try - but it would be nice to know what if anything can be done.
Quote
... or an OTG port configured to function as a device port.
Yes, yes, but how do you configure it as a device port?  I plugged in a cable to an OTG micro connector.  I verified that pin 4 of the cable was not shorted to ground.  This should signal the embedded Linux computer (a TI.COM OMAP board) that this USB port is to be a USB DEVICE.   But when I plugged the other end of the USB cable (Standard Type A Plug) into another Linux computer (which should be playing the part of USB HOST) it reported "nothing".  I was using the "lsusb" command.
Quote
The BeagleBoard and some other Linux embedded systems have OTG ports and can use the gadget driver.
The OMAP board I am using has 2 Type A USB 2.0 Sockets, 1 USB 2.0 micro Socket, 1 USB 3.0 micro Socket.  If I did an "modprobe g_multi.ko" to install the Gadget Multiple USB DEVICE driver - well - I don't see how to tell it which physical USB port is to be used as the DEVICE USB port.  It would be helpful to see the step-by-step for setting up, say, a USB Serial DEVICE on a specific physical USB port on an embedded Linux box.

-thanks

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Using the gadget drivers in an embedded Linux system...
« Reply #3 on: February 23, 2014, 09:06:09 pm »

So, there is no way one can use a USB Type A Socket as a USB DEVICE.  Even if you modify it some how?  I don't think I'll be forced to try - but it would be nice to know what if anything can be done.

No, the hardware is different.


Yes, yes, but how do you configure it as a device port?  I plugged in a cable to an OTG micro connector.  I verified that pin 4 of the cable was not shorted to ground.  This should signal the embedded Linux computer (a TI.COM OMAP board) that this USB port is to be a USB DEVICE.   But when I plugged the other end of the USB cable (Standard Type A Plug) into another Linux computer (which should be playing the part of USB HOST) it reported "nothing".  I was using the "lsusb" command.

You need to load a gadget driver on the device with modprobe.

On the BeagleBoard with Angstrom, you can use

cd /sys/devices/platform/musb_hdrc
cat mode

to find out if an OTG port has switched to device mode. I don't know if your board has that or something similar.


The OMAP board I am using has 2 Type A USB 2.0 Sockets, 1 USB 2.0 micro Socket, 1 USB 3.0 micro Socket.  If I did an "modprobe g_multi.ko" to install the Gadget Multiple USB DEVICE driver - well - I don't see how to tell it which physical USB port is to be used as the DEVICE USB port.  It would be helpful to see the step-by-step for setting up, say, a USB Serial DEVICE on a specific physical USB port on an embedded Linux box.


modprobe loads the driver. The descriptors the device returns on enumeration determine the device function.

st2000

  • Member
  • ***
  • Posts: 44
Re: Using the gadget drivers in an embedded Linux system...
« Reply #4 on: February 24, 2014, 12:00:12 pm »
Quote
Quote
Yes, yes, but how do you configure it as a device port?
You need to load a gadget driver on the device with modprobe.
That worked!  This particular embedded Linux board is running Ubuntu and was compiled with Gadget enabled/available.  When I did a "modprobe g_serial" I found Gadget supporting a PERIPHERAL(DEVICE) USB on the board's Mini OTG USB port.

I think what I would really like to know is where you tell Gadget how to set its self up when you do a, for instance, "modprobe g_serial".  I have a sneaking suspicion that one does this "configuration magic" at compile time - not at modprobe time.

-thanks

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Using the gadget drivers in an embedded Linux system...
« Reply #5 on: February 24, 2014, 01:50:16 pm »
For OTG ports, the port should configure itself as a device port on detecting insertion of a micro-B plug.

modprobe loads the g_serial driver to support the device function.

If that answers your question...