Difference between revisions of "Category:How to - usb"

From Gumstix User Wiki
Jump to: navigation, search
(Undo revision 1284 by 211.151.91.147 (Talk))
m (fixed links)
 
(15 intermediate revisions by 4 users not shown)
Line 1: Line 1:
Please contribute your knowledge to the gumstix community
+
Note: if you have issues with USB not resuming properly after a suspend on Overo, please see [http://old.nabble.com/Update-on-Overo-EHCI-issues-td27617583.html#a27617583 this] forum post.
 +
==USBNet with Overo==
 +
 
 +
The OTG USB port on the Overo expansion boards support USB networking. To enable this, the OTG port needs to be configured as a USB peripheral or gadget. The default kernels from Gumstix have the OTG port configured to act as a USB host.
 +
 
 +
The procedure for changing the configuration requires rebuilding your kernel, so you should first be comfortable with [http://www.gumstix.net/Setup-and-Programming/view/Overo-Setup-and-Programming/Setting-up-a-build-environment/111.html setting up a build environment] and building images for your Overo.
 +
 
 +
The following steps assume you are using a recent snapshot of the gumstix-oe git tree and are going to use kernel version 2.6.31 or greater. Though this procedure currently does not work with 2.6.39, as there are some inconsistencies between linux-omap3_2.6.39.bb recipe and the configuration (.config/defconfig) file shipped by default. See note below for more info on 2.6.39.
 +
 
 +
The gumstix recipes for these kernels have a variable that allows you to specify how the OTG usb port is configured.
 +
 
 +
Gumstix Overos use the linux-omap3 kernels by default. You can check which kernel version you'll be working with this way:
 +
 
 +
$ cd ${OVEROTOP}
 +
$ bitbake --show-versions | grep linux-omap3
 +
linux-omap3                            0:2.6.34-r81
 +
 
 +
So the recipe file in this case would be ${OVEROTOP}/org.openembedded.dev/recipes/linux/linux-omap3_2.6.34.bb.
 +
 
 +
You'll see a line in there
 +
 
 +
MUSB_MODE ?= "host"
 +
 
 +
There are three valid values for MUSB_MODE: "host", "peripheral" or "otg".
 +
 
 +
You could change the MUSB_MODE assignment directly in the recipe, but a better way to do this is to modify your local.conf file and add a MUSB_MODE variable.
 +
 
 +
The ?= assignment means "host" will be assigned to MUSB_MODE only if it does not already have a value which it will if you give it one in local.conf.
 +
 
 +
The local.conf file is found here ${OVEROTOP}/build/conf/local.conf.
 +
 
 +
Add the line
 +
 
 +
MUSB_MODE = "peripheral"
 +
 
 +
or
 +
 
 +
MUSB_MODE = "otg" 
 +
 
 +
depending on your preference.
 +
 
 +
===Note on 2.6.39===
 +
 
 +
There is currently an inconsistency between the recipe linux-omap3_2.6.39.bb and the default configuration (.config/defconfig) shipped, see [http://old.nabble.com/linux-omap3-2.6.39-build-failure-in-overo-2011.03-branch-td32094095.html this post] and [http://old.nabble.com/Re%3A-Thumbo-in-Gadget-mode-and-USBNet-p32171580.html this other post]. The latter, together with [[Kernel_Reconfiguration]], is what worked for me.
 +
 
 +
==Rebuild your kernel==
 +
 
 +
$ cd ${OVEROTOP}
 +
$ bitbake -c clean linux-omap3
 +
$ bitbake linux-omap3
 +
 
 +
 
 +
And then rebuild your rootfs since the drivers available in /lib/modules will have changed.
 +
 
 +
$ bitbake omap3-console-image   
 +
 
 +
Change omap3-console-image to whatever image you use.
 +
 
 +
 
 +
Install the new kernel and rootfs the way you normally would using either a
 +
[http://www.gumstix.net/Setup-and-Programming/view/Overo-Setup-and-Programming/Creating-a-bootable-microSD-card/111.html microSD card]
 +
or by copying to [http://www.gumstix.net/Setup-and-Programming/view/Overo-Setup-and-Programming/Writing-images-to-onboard-nand/111.html onboard nand].
 +
 
 +
 +
Once you have booted the new system, you still need to load the g_ether driver since it was built as a module.
 +
 
 +
You can add g_ether to /etc/modules if you always want it to load at boot.
 +
 
 +
root@overo# modbprobe g_ether
 +
g_ether gadget: using random self ethernet address
 +
g_ether gadget: using random host ethernet address
 +
usb0: MAC d6:2c:8f:d9:51:32
 +
usb0: HOST MAC f2:99:dc:4c:cb:7a
 +
g_ether gadget: Ethernet Gadget, version: Memorial Day 2008
 +
g_ether gadget: g_ether ready
 +
 
 +
root@overo:~# ifconfig -a
 +
lo      Link encap:Local Loopback
 +
        inet addr:127.0.0.1  Mask:255.0.0.0
 +
        inet6 addr: ::1/128 Scope:Host
 +
        UP LOOPBACK RUNNING  MTU:16436  Metric:1
 +
        RX packets:0 errors:0 dropped:0 overruns:0 frame:0
 +
        TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
 +
        collisions:0 txqueuelen:0
 +
        RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
 +
 +
usb0    Link encap:Ethernet  HWaddr D6:2C:8F:D9:51:32
 +
        BROADCAST MULTICAST  MTU:1500  Metric:1
 +
        RX packets:0 errors:0 dropped:0 overruns:0 frame:0
 +
        TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
 +
        collisions:0 txqueuelen:1000
 +
        RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
 +
 
 +
 
 +
Configure the usb0 interface the way you would any other.
 +
 
 +
For example
 +
 
 +
root@overo:~# ifconfig usb0 192.168.20.2 netmask 255.255.255.0
 +
 
 +
If you then plug the usb OTG cable into a host computer ready for usb networking you'll get a console message
 +
 
 +
g_ether gadget: high speed config #1: CDC Ethernet (ECM)
 +
 
 +
The rest is all standard Linux networking.

Latest revision as of 11:22, 2 August 2011

Note: if you have issues with USB not resuming properly after a suspend on Overo, please see this forum post.

USBNet with Overo

The OTG USB port on the Overo expansion boards support USB networking. To enable this, the OTG port needs to be configured as a USB peripheral or gadget. The default kernels from Gumstix have the OTG port configured to act as a USB host.

The procedure for changing the configuration requires rebuilding your kernel, so you should first be comfortable with setting up a build environment and building images for your Overo.

The following steps assume you are using a recent snapshot of the gumstix-oe git tree and are going to use kernel version 2.6.31 or greater. Though this procedure currently does not work with 2.6.39, as there are some inconsistencies between linux-omap3_2.6.39.bb recipe and the configuration (.config/defconfig) file shipped by default. See note below for more info on 2.6.39.

The gumstix recipes for these kernels have a variable that allows you to specify how the OTG usb port is configured.

Gumstix Overos use the linux-omap3 kernels by default. You can check which kernel version you'll be working with this way:

$ cd ${OVEROTOP}
$ bitbake --show-versions | grep linux-omap3
linux-omap3                            0:2.6.34-r81 

So the recipe file in this case would be ${OVEROTOP}/org.openembedded.dev/recipes/linux/linux-omap3_2.6.34.bb.

You'll see a line in there

MUSB_MODE ?= "host"

There are three valid values for MUSB_MODE: "host", "peripheral" or "otg".

You could change the MUSB_MODE assignment directly in the recipe, but a better way to do this is to modify your local.conf file and add a MUSB_MODE variable.

The ?= assignment means "host" will be assigned to MUSB_MODE only if it does not already have a value which it will if you give it one in local.conf.

The local.conf file is found here ${OVEROTOP}/build/conf/local.conf.

Add the line

MUSB_MODE = "peripheral"

or

MUSB_MODE = "otg"  

depending on your preference.

Note on 2.6.39

There is currently an inconsistency between the recipe linux-omap3_2.6.39.bb and the default configuration (.config/defconfig) shipped, see this post and this other post. The latter, together with Kernel_Reconfiguration, is what worked for me.

Rebuild your kernel

$ cd ${OVEROTOP}
$ bitbake -c clean linux-omap3
$ bitbake linux-omap3


And then rebuild your rootfs since the drivers available in /lib/modules will have changed.

$ bitbake omap3-console-image    

Change omap3-console-image to whatever image you use.


Install the new kernel and rootfs the way you normally would using either a microSD card or by copying to onboard nand.


Once you have booted the new system, you still need to load the g_ether driver since it was built as a module.

You can add g_ether to /etc/modules if you always want it to load at boot.

root@overo# modbprobe g_ether
g_ether gadget: using random self ethernet address
g_ether gadget: using random host ethernet address
usb0: MAC d6:2c:8f:d9:51:32
usb0: HOST MAC f2:99:dc:4c:cb:7a
g_ether gadget: Ethernet Gadget, version: Memorial Day 2008
g_ether gadget: g_ether ready
root@overo:~# ifconfig -a
lo      Link encap:Local Loopback
        inet addr:127.0.0.1  Mask:255.0.0.0
        inet6 addr: ::1/128 Scope:Host
        UP LOOPBACK RUNNING  MTU:16436  Metric:1
        RX packets:0 errors:0 dropped:0 overruns:0 frame:0
        TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
        collisions:0 txqueuelen:0
        RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

usb0    Link encap:Ethernet  HWaddr D6:2C:8F:D9:51:32
        BROADCAST MULTICAST  MTU:1500  Metric:1
        RX packets:0 errors:0 dropped:0 overruns:0 frame:0
        TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
        collisions:0 txqueuelen:1000
        RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)


Configure the usb0 interface the way you would any other.

For example

root@overo:~# ifconfig usb0 192.168.20.2 netmask 255.255.255.0

If you then plug the usb OTG cable into a host computer ready for usb networking you'll get a console message

g_ether gadget: high speed config #1: CDC Ethernet (ECM)

The rest is all standard Linux networking.

Pages in category "How to - usb"

The following 3 pages are in this category, out of 3 total.