USB Ethernet gadget issues, has anyone seen this before?

Hi all,

I’m having an issue with the usb ethernet gadget that I haven’t been able to figure out. When I plug the beagle bone in I see the usb0 device on the host, but I never get 192.168.7.1 from the dhcp server on the bone. And what’s weird is that if I configure it to use that address manually, ‘jon@host-machine$ sudo ifconfig usb0 192.168.7.1’, it will work fine for roughly 5 minutes then it’ll lose the address and I have to run that command again. I’ve posted some of the diagnostic info below, but nothing really jumps out as being wrong to me…

There’s another tidbit that may or may not help: the usb0 ethernet gadget was broken like this until I installed the 3.2.21 kernel and modules with the Xenomai patch. After that it worked fine but then it went back to this broken behavior a short while later (couple of days with frequent use.) I can’t remember doing anything that might have caused this…

Information from the bone:

root@beaglebone:~# dmesg | grep usb0
[ 0.183094] musb-ti81xx musb-ti81xx: musb0, board_mode=0x13, plat_mode=0x3
[ 0.870226] usb0: MAC 8e:52:c3:4b:26:07
[ 0.870244] usb0: HOST MAC 06:54:91:9a:f3:ac
[ 15.698074] ADDRCONF(NETDEV_UP): usb0: link is not ready

root@beaglebone:~# ifconfig usb0
usb0 Link encap:Ethernet HWaddr 8E:52:C3:4B:26:07
inet addr:192.168.7.2 Bcast:192.168.7.3 Mask:255.255.255.252
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)

root@beaglebone:~# ps -A | grep dhcp
261 ? 00:00:00 udhcpd

On the host side of things:

jon@ubuntu:~$ dmesg | grep usb0
[44342.158162] cdc_ether 1-2:1.0: usb0: register ‘cdc_ether’ at usb-0000:02:03.0-2, CDC Ethernet Device, 96:f4:7e:c8:d2:52
[44352.598445] usb0: no IPv6 routers present
[44401.591566] usb0: no IPv6 routers present
[44449.298639] usb0: no IPv6 routers present
[44497.134423] usb0: no IPv6 routers present
[44841.048077] usb0: no IPv6 routers present
[44889.369691] usb0: no IPv6 routers present
[44936.726581] usb0: no IPv6 routers present
[44985.223845] usb0: no IPv6 routers present

jon@ubuntu:~$ ifconfig usb0
usb0 Link encap:Ethernet HWaddr 06:54:91:9a:f3:ac
inet6 addr: fe80::454:91ff:fe9a:f3ac/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:14 errors:0 dropped:0 overruns:0 frame:0
TX packets:62 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1634 (1.6 KB) TX bytes:13312 (13.3 KB)

jon@ubuntu:~$ sudo tcpdump -i usb0 | grep DHCP
tcpdump: WARNING: usb0: no IPv4 address assigned
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on usb0, link-type EN10MB (Ethernet), capture size 65535 bytes
22:24:52.216767 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from 06:54:91:9a:f3:ac (oui Unknown), length 300
22:24:55.028805 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from 06:54:91:9a:f3:ac (oui Unknown), length 300
22:25:00.800569 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from 06:54:91:9a:f3:ac (oui Unknown), length 300
22:25:08.425915 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from 06:54:91:9a:f3:ac (oui Unknown), length 300
22:25:20.380182 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from 06:54:91:9a:f3:ac (oui Unknown), length 300
22:25:35.421184 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from 06:54:91:9a:f3:ac (oui Unknown), length 300
22:25:40.190817 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from 06:54:91:9a:f3:ac (oui Unknown), length 300
22:25:43.067199 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from 06:54:91:9a:f3:ac (oui Unknown), length 300

It looks like udhcpd isn’t responding to the host’s requests. But the fact that it can’t even keep a static address confuses me even more. If anyone’s seen anything like this, I’d really appreciate any input on what you did to fix it.

Thanks
-JonRW

Hi,

Not seen like this before but there was another error with me using a usb to ethernet gadget. It was not recognizing the adapter. The cause found out was that the driver (MCS7830) didn’t get compiled. Manually compiling the MCS7830 module and inserting it worked.

Coming to your issue, you said its a usb to ethernet gadget. I guess it should it appear as eth0 and not usb0. USB0 should be for networking over USB using the cdc-ether driver.
Another notable thing is the ifconfig shows broadcast address set to 192.168.1.3 and mask shows 255.255.255.252 It should be 192.168.1.255 and 255.255.255.0 respectively? It may not matter as it looks that you are using only the last two bits.

Usually whenever I configure my USB to ethernet gadget on beagleboard (not bone), I do it like this:

ifconfig eth0 192.168.1.102 up

This assigns ip address 192.168.1.102 and automatically uses broadcast as 192.168.1.255 and mask as 255.255.255.0

Another possibility may be that some other device on your network is also using the same IP address due to either static assignment or DHCP. Have you tried to set a different IP address to the bone?

Your DHCP server is on the bone or it is the client? Is this DHCP server itself creating some issue? Try not using this DHCP server then.

Hope it helps.

Experts, please correct if I am wrong…

Thanks,

I call it the ethernet gadget because thats what VMWare player calls it. I do believe it is the cdc-ether driver though. You might be on to something about the broadcast address though. The beaglebone is using a subnet with two bits which leaves .1 and .2 for hosts, I don’t think .0 is valid and .3 is reserved for broadcast. That could explain why dhcp isn’t working, the host is asking for an address on by broadcasting the BOOTP packet to .255 which to the beagle bone (running the dhcp server) looks like an address way outside its subnet. I’ll try setting the host up to use the proper subnet and report back. Thanks Gopal!

Side questions for any networking gurus, how is dhcp supposed to work if the hosts don’t agree on the subnet mask?

-Jon

Actually I remember, DHCP is layer 2, it broadcasts to FF:FF:FF:FF:FF:FF which is the link layer broadcast address. Maybe the mismatched subnet masks was causing the adapter to lose it address too, that would explain why it wasn’t working with a manually configured IP as well.

-Jon

Setting up the static address with the correct subnet mask solved the resetting problem. Thanks for pointing that out, sometimes you just need another pair of eyes.

-Jon

Hi,
The beaglebone appears as usb0 when connected. However, we will have to configure the network for usb0.

Edit the /etc/network/interfaces on your computer (add the following):


*auto usb0*
<i>allow-hotplug usb0
iface usb0 inet static
        address 192.168.1.1
        netmask 255.255.255.0</i>
*        network 192.168.1.0*
<i>        up iptables -A POSTROUTING -t nat -s 192.168.1.0/24 -j MASQUERADE
        up echo 1 > /proc/sys/net/ipv4/ip_forward
        down iptables -D POSTROUTING -t nat -s 192.168.1.0/24 -j MASQUERADE</i>
The last three lines are for forwarding the IP packets to the beaglebone.
On the terminal type the following command:
*sudo ifconfig usb0 192.168.1.1 netmask 255.255.255.0 up*

Log into the beaglebone using:
*sudo screen /dev/ttyUSB1 115200*

If no message appears on the screen, press the reset button on the beaglebone.
Log in as **root.** Edit **/etc/network/interfaces** by adding the following:

*auto usb0*
*iface usb0 inet static*
 *address 192.168.1.2*
 *netmask 255.255.255.0*
 *network 192.168.1.0*
 *gateway 192.168.1.1*
On the terminal type: **ifconfig usb0 192.168.1.2 netmask 255.255.255.0**
**/sbin/route add default gw 192.168.1.1**

Open a new terminal on your computer, restart network manager (**sudo service network-manager restart**) and use ssh command:
**ssh 192.168.1.2 -l root** or **ssh 192.168.1.2 -l ubuntu.**

This worked for me. You can find more information on: http://wiki.openmoko.org/wiki/Usb_networking.

-Hemaroop