Monday, January 25, 2010

Ethernet over USB-OTG for BeagleBoard

Once Beagleboard is up and running with Angstrom OS and a serial port connectivity , we next turn to get ethernet connectivity over the USB OTG cable.

You will need a USB Type-A to USB Type-A mini connector for this purpose.

Configuring in the BeagleBoard
After you have logged in as root, go to directory /lib/modules/2.6.29-omap1/kernel/drivers/usb/gadget .
In this you will find a driver named g_ether.ko. At this point of time issue command

root@beagleboard:/lib/modules/2.6.29-omap1/kernel/drivers/usb/gadget# lsmod
Module Size Used by
g_ether 29376 0
ircomm_tty 36148 0
ircomm 21292 1 ircomm_tty
irda 186816 2 ircomm_tty,ircomm
ipv6 275228 12

This will tell you the driver currently loaded. If you don't find the module g_ether in the above output, then you need to load this driver to enable Ethernet over USB OTG.

root@beagleboard:/lib/modules/2.6.29-omap1/kernel/drivers/usb/gadget# insmod g_ether.ko
[ 218.496032] g_ether gadget: using random self ethernet address
[ 218.503570] g_ether gadget: using random host ethernet address
[ 218.534881] usb0: MAC 26:25:a1:4e:cf:55
[ 218.565948] ADDRCONF(NETDEV_UP): usb0: link is not ready
[ 218.572082] usb0: HOST MAC ae:c2:3b:52:78:5a
[ 218.587066] g_ether gadget: Ethernet Gadget, version: Memorial Day 2008
[ 218.627716] g_ether gadget: g_ether ready
[ 218.632476] musb_hdrc musb_hdrc: MUSB HDRC host driver
[ 218.654815] musb_hdrc musb_hdrc: new USB bus registered, assigned bus number 2
[ 218.694671] usb usb2: configuration #1 chosen from 1 choice
[ 218.722137] hub 2-0:1.0: USB hub found
[ 218.739471] hub 2-0:1.0: 1 port detected

This will load the driver.

Now go back to root and configure the Ethernet connection of your BeagleBoard.
In the BeagleBoard Validation site it is adviced that the IP address be set to 192.168.1.1 and netmask be set to 255.255.255.0 , we do this here

root@beagleboard:/# ifconfig 192.168.1.1 netmask 255.255.255.0

Configuring Your System

[root@shubham shubham]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:19:B9:5F:09:A2
inet addr:10.2.36.221 Bcast:10.2.36.255 Mask:255.255.255.0
inet6 addr: fe80::219:b9ff:fe5f:9a2/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:113982 errors:0 dropped:0 overruns:0 frame:0
TX packets:28358 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:35000144 (33.3 MiB) TX bytes:5238712 (4.9 MiB)
Interrupt:17

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:24 errors:0 dropped:0 overruns:0 frame:0
TX packets:24 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1520 (1.4 KiB) TX bytes:1520 (1.4 KiB)

wlan0 Link encap:Ethernet HWaddr 00:19:D2:BC:26:38
UP 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)

wmaster0 Link encap:UNSPEC HWaddr 00-19-D2-BC-26-38-A1-D1-00-00-00-00-00-00-00-00
UP BROADCAST RUNNING 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)

This will show you the network devices active, here we don't see a USB0(which will represent the connection to BeagleBoard )
Once you have configured the connection in BeagleBoard , then issue 'ifconfig' command , you will find one more device

usb0 Link encap:Ethernet HWaddr 4A:00:09:5E:78:15
inet6 addr: fe80::4800:9ff:fe5e:7815/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2056 (2.0 KiB) TX bytes:670 (670.0 b)

Now configure this device by the command

[root@shubham shubham]# ifconfig usb0 192.168.1.5 netmask 255.255.255.0

This will lead to an Ethernet over USB OTG being established, to test your connection ping any of the devices.

[root@shubham shubham]# ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.536 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.482 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.479 ms
64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=0.354 ms
64 bytes from 192.168.1.1: icmp_seq=5 ttl=64 time=0.355 ms
^C
--- 192.168.1.1 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4882ms
rtt min/avg/max/mdev = 0.354/0.441/0.536/0.074 ms

This checks that you connection is good.
You can send file to-and-fro BeagleBoard – your System using ssh command like :

[root@shubham shubham]# ssh test.txt root@192.168.1.1:




..

6 comments:

  1. Thanks, reading your post gave me an idea for a project I have in mind:

    BeagleBoard Gateway :D

    Thanks, really!

    Regards

    ReplyDelete
  2. hi my name is Luis Im trying to vnc to my beagle board I found your guide quite complete, however eerytime I try to issue the "insmod g_ether.ko" command i get an error like this

    "insmod: error inserting 'g_ether.ko': -1 Device or resource busy"

    I been trying everything however im new to unix i cant find the solution in any forum if you have any thoughts about what to do next please let me know

    please leave an email at filoteo_2000@hotmail.com

    ill really appreciate it thankyou !

    ReplyDelete
  3. Hi, could you tell how to save these settings in both machines (beagleboard and workstation) such that when we restart the systems the settings are working again?

    ReplyDelete
  4. What would be the best bytes/per sec you could get on this?
    I copied a file using scp and the best I could get was 5megbytes per sec.

    ReplyDelete
  5. Hi,
    In order to install the module g_ether.ko, I had to remove the module g_mass_storage first. That is I typed in the Beaglebone terminal:

    rmmod g_mass_storage

    and then:

    insmod g_ether.ko. Now, the Ethernet-over-USB is working just fine.

    ReplyDelete
  6. enable an OTG connection, you must either use an OTG cable to connect the devices or, for directly connected devices, one of them must be physically configured to mimic the OTG cable connection. It might be clearer to think of the later configuration as two USB devices connected with a zero length OTG Cable.

    ReplyDelete