C1+ USB OTG Ethernet Gadget

Moderators: odroid, mdrjr

C1+ USB OTG Ethernet Gadget

Unread postby crick » Thu May 10, 2018 7:50 pm

Hi,

I am trying to configure the C1+ USB OTG Ethernet Gadget to behave in a similar way to the Beaglebone Black. Basically if you plug it into a PC (Linux or Windows) it will automatically issue the host PC interface with an IP address and it would be able to connect to a web server on the C1+.

However I am unable to get even a simple connection established between the C1+ and a linux host PC, following the same instructions as in the Feb 2014 Odroid magazine article concerning the OTG Gadget. (https://magazine.odroid.com/wp-content/uploads/ODROID-Magazine-201402.pdf#page=16)

C1+ upon loading g_ether module:
Code: Select all
$ modprobe g_ether
$ dmesg
...
[  518.357441] g_ether gadget: using random host ethernet address
[  518.358127] usb0: MAC ee:20:fd:7e:38:ce
[  518.358139] usb0: HOST MAC ce:45:33:03:64:b8
[  518.358226] g_ether gadget: Ethernet Gadget, version: Memorial Day 2008
[  518.358242] g_ether gadget: g_ether ready
[  518.491876] USB RESET
[  518.618911] USB RESET
[  518.757373] g_ether gadget: high-speed config #1: CDC Ethernet (ECM)


Host PC after connecting USB cable:
Code: Select all
$ dmesg
...
[920299.663128] cdc_ether 3-3:1.0 usb0: register 'cdc_ether' at usb-0000:00:14.0-3, CDC Ethernet Device, ce:45:33:03:64:b8
[920299.669082] cdc_ether 3-3:1.0 enp0s20u3: renamed from usb0


Setting IP address on C1+:
Code: Select all
$ ip addr add 192.168.100.1/24 dev usb0
$ ip link set dev usb0 up
$ ip addr
...
usb0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether ee:20:fd:7e:38:ce brd ff:ff:ff:ff:ff:ff
    inet 192.168.100.1/24 scope global usb0
       valid_lft forever preferred_lft forever
    inet6 fe80::ec20:fdff:fe7e:38ce/64 scope link
       valid_lft forever preferred_lft forever
$ ip route
192.168.100.0/24 dev usb0  proto kernel  scope link  src 192.168.100.1


Setting IP Address on Host PC:
Code: Select all
$ ip addr add 192.168.100.2/24 dev enp0s20u3
$ ip link set dev enp0s20u3 up             
$ ip addr
...
enp0s20u3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether ce:45:33:03:64:b8 brd ff:ff:ff:ff:ff:ff
    inet 192.168.100.2/24 scope global enp0s20u3
       valid_lft forever preferred_lft forever
    inet6 fe80::2686:a9e:889b:3632/64 scope link
       valid_lft forever preferred_lft forever
$ ip route
...
192.168.100.0/24 dev enp0s20u3 proto kernel scope link src 192.168.100.2


Trying to ping in either direction results in "Destination Host Unreachable", however the number of "RX Packets" on the interface increments with each ping. Doing the same exact steps with an ethernet cable between the C1+ and the host PC works as expected, can ping and SSH from both directions.

Does anyone have any advice on how to get the Ethernet over USB connection set up properly?
crick
 
Posts: 7
Joined: Thu Jul 06, 2017 11:55 pm
languages_spoken: english
ODROIDs: C0, C1+, XU4

Re: C1+ USB OTG Ethernet Gadget

Unread postby odroid » Fri May 11, 2018 3:48 am

The MAC address seems to be wrong. Refer this thread.
viewtopic.php?f=111&t=29323
User avatar
odroid
Site Admin
 
Posts: 27688
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: C1+ USB OTG Ethernet Gadget

Unread postby crick » Fri May 11, 2018 7:08 pm

Thanks for your response @odroid.

It's my understanding that the gadget creates two MAC addresses for both ends of the connection when it is loaded. The HOST MAC is assigned to the interface on the Host PC which is what happens for me. Strangely in the Odroid Magazine article, the interface on the Host PC is different to the one created by the gadget.

Thanks for pointing out that thread. I've done the following steps to get the diagnostic info @mad_ady asked for in that thread:

C1+ Setup (loaded g_ether with fixed host and device MAC addresses):
Code: Select all
$ modprobe g_ether host_addr=00:11:22:33:44:55 dev_addr=00:55:44:33:22:11
$ dmesg
...
[  303.559766] usb0: MAC 00:55:44:33:22:11
[  303.559848] usb0: HOST MAC 00:11:22:33:44:55
[  303.562882] g_ether gadget: Ethernet Gadget, version: Memorial Day 2008
[  303.569421] g_ether gadget: g_ether ready
$ ifconfig usb0 192.168.100.1 netmask 255.255.255.0 up
$ ifconfig usb0
usb0      Link encap:Ethernet  HWaddr 00:55:44:33:22:11 
          inet addr:192.168.100.1  Bcast:192.168.100.255  Mask:255.255.255.0
          inet6 addr: fe80::255:44ff:fe33:2211/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1214 (1.1 KiB)  TX bytes:328 (328.0 B)


Host PC:
Code: Select all
$ dmesg
...
[1003251.833148] cdc_ether 3-4:1.0 eth0: register 'cdc_ether' at usb-0000:00:14.0-4, CDC Ethernet Device, 00:11:22:33:44:55
[1003251.839890] cdc_ether 3-4:1.0 enp0s20u4: renamed from eth0
$ ifconfig enp0s20u4 192.168.100.2 netmask 255.255.255.0 up
$ ifconfig enp0s20u4
enp0s20u4: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.100.2  netmask 255.255.255.0  broadcast 192.168.100.255
        inet6 fe80::5790:5116:375c:54dd  prefixlen 64  scopeid 0x20<link>
        ether 00:11:22:33:44:55  txqueuelen 1000  (Ethernet)
        RX packets 6  bytes 384 (384.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14  bytes 2751 (2.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


C1+ tcpdump while pinging from Host PC:
Code: Select all
HOST:
$ ping -c 5 192.168.100.1
PING 192.168.100.1 (192.168.100.1) 56(84) bytes of data.
From 192.168.100.2 icmp_seq=1 Destination Host Unreachable
From 192.168.100.2 icmp_seq=2 Destination Host Unreachable
From 192.168.100.2 icmp_seq=3 Destination Host Unreachable
From 192.168.100.2 icmp_seq=4 Destination Host Unreachable
From 192.168.100.2 icmp_seq=5 Destination Host Unreachable

C1+:
tcpdump -n -i usb0
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on usb0, link-type EN10MB (Ethernet), capture size 262144 bytes
09:58:30.872680 ARP, Request who-has 0.0.0.0 (03:00:65:74:68:30) tell 192.168.9.0, length 28
09:58:31.879960 ARP, Request who-has 255.255.255.255 (ff:ff:ff:ff:ff:ff) tell 192.168.255.255, length 28
09:58:32.893302 ARP, Request who-has 0.0.0.0 (03:00:75:73:62:30) tell 192.168.9.0, length 28
09:58:33.907047 ARP, Request who-has 255.255.255.255 (ff:ff:ff:ff:ff:ff) tell 192.168.255.255, length 28
09:58:34.920007 ARP, Request who-has 255.255.255.255 (ff:ff:ff:ff:ff:ff) tell 192.168.255.255, length 28
09:58:35.933324 ARP, Request who-has 255.2.0.0 (44:ff:fe:33:22:11) tell 192.168.2.85, length 28


Host tcpdump while pinging from C1+:
Code: Select all
C1+:
$ ping -c 5 192.168.100.2
PING 192.168.100.2 (192.168.100.2) 56(84) bytes of data.
From 192.168.100.1 icmp_seq=1 Destination Host Unreachable
From 192.168.100.1 icmp_seq=2 Destination Host Unreachable
From 192.168.100.1 icmp_seq=3 Destination Host Unreachable
From 192.168.100.1 icmp_seq=4 Destination Host Unreachable
From 192.168.100.1 icmp_seq=5 Destination Host Unreachable

--- 192.168.100.2 ping statistics ---
5 packets transmitted, 0 received, +5 errors, 100% packet loss, time 4006ms

HOST:
$ tcpdump -n -i enp0s20u4
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on enp0s20u4, link-type EN10MB (Ethernet), capture size 262144 bytes
10:50:42.219078 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:11:22:33:44:55, length 363
10:50:49.190801 ARP, Request who-has 192.168.100.2 tell 192.168.100.1, length 28
10:50:49.190853 ARP, Reply 192.168.100.2 is-at 00:11:22:33:44:55, length 28
10:50:50.186780 ARP, Request who-has 192.168.100.2 tell 192.168.100.1, length 28
10:50:50.186808 ARP, Reply 192.168.100.2 is-at 00:11:22:33:44:55, length 28
10:50:51.186751 ARP, Request who-has 192.168.100.2 tell 192.168.100.1, length 28
10:50:51.186782 ARP, Reply 192.168.100.2 is-at 00:11:22:33:44:55, length 28
10:50:52.195897 ARP, Request who-has 192.168.100.2 tell 192.168.100.1, length 28
10:50:52.195927 ARP, Reply 192.168.100.2 is-at 00:11:22:33:44:55, length 28
10:50:53.186776 ARP, Request who-has 192.168.100.2 tell 192.168.100.1, length 28
10:50:53.186808 ARP, Reply 192.168.100.2 is-at 00:11:22:33:44:55, length 28
10:50:54.186729 ARP, Request who-has 192.168.100.2 tell 192.168.100.1, length 28
10:50:54.186777 ARP, Reply 192.168.100.2 is-at 00:11:22:33:44:55, length 28


To me the ARP requests from the C1+ pinging the host look correct but in the other direction they make no sense with non-existant hosts like 192.168.9.0 and 192.168.2.85 making requests.

I do not know very much about networking. Do you know what this signifies?
crick
 
Posts: 7
Joined: Thu Jul 06, 2017 11:55 pm
languages_spoken: english
ODROIDs: C0, C1+, XU4

Re: C1+ USB OTG Ethernet Gadget

Unread postby crick » Mon May 14, 2018 10:35 pm

Could someone else with a C1+ please try the following steps to see if they are getting the same behavior?

On the C1+ (Micro USB end of OTG cable plugged in):
Code: Select all
$ modprobe g_ether
$ ifconfig usb0 192.168.100.1 netmask 255.255.255.0 up


On the host (with USB Type A end of OTG cable plugged in):
Code: Select all
// check the host picked up the interface and get the name
$ dmesg
...
[1003251.833148] cdc_ether 3-4:1.0 eth0: register 'cdc_ether' at usb-0000:00:14.0-4, CDC Ethernet Device, 00:11:22:33:44:55
[1003251.839890] cdc_ether 3-4:1.0 enp0s20u4: renamed from eth0
$ ifconfig <interface name> 192.168.100.2 netmask 255.255.255.0 up
$ ping 192.168.100.1
crick
 
Posts: 7
Joined: Thu Jul 06, 2017 11:55 pm
languages_spoken: english
ODROIDs: C0, C1+, XU4

Re: C1+ USB OTG Ethernet Gadget

Unread postby mad_ady » Tue May 15, 2018 12:42 am

I'll try to test it next week, when i'm reunited with my C1. If anyone can test sooner, then great!
User avatar
mad_ady
 
Posts: 3637
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2


Return to Issues

Who is online

Users browsing this forum: No registered users and 1 guest