How to use USB device networking

From RidgeRun Developer Connection
Revision as of 10:08, 6 June 2011 by Tfischer (Talk | contribs)

Jump to: navigation, search

The Linux USB gadget sub-system supports USB device functionality, including USB networking.

Configure hardware for USB OTG or USB device support

Depending on your hardware, you can use either USB OTG or USB device to enable support for USB networking.

Build USB Ethernet network gadget driver

The USB Ethernet network gadget driver caused the device to appear to be a USB network dongle when connected to a host computer. Generally it is best to build USB gadget drivers as modules instead of building them into the kernel so you can unload one and load another.

Symbol: USB_ETH [=m]
   Prompt: Ethernet Gadget (with CDC Ethernet support)
     Defined at drivers/usb/gadget/Kconfig:628
     Depends on: <choice> && NET
       -> Kernel configuration
         -> Device Drivers
           -> USB support (USB_SUPPORT [=y])
             -> USB Gadget Support (USB_GADGET [=y])
               -> USB Gadget Drivers (<choice> [=m])

Build and install the kernel to the target hardware.

Load USB Ethernet network gadget driver

After booting the target hardware to a shell prompt, run:

modprobe g_ether

and you should see output similar to:

g_ether gadget: using random self ethernet address
g_ether gadget: using random host ethernet address
usb0: MAC be:b5:85:ef:48:33
usb0: HOST MAC 1a:b2:c3:43:8a:6e
g_ether gadget: Ethernet Gadget, version: Memorial Day 2008
g_ether gadget: g_ether ready

You can then verify the usb0 network interface exists:

ifconfig usb0

with output similar to:

usb0      Link encap:Ethernet  HWaddr BE:B5:85:EF:48:33  
          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)