Table of Contents
Kernel Configuration
On Embedded Target
Insmod Drivers
After that, you will see a new usb ethernet adapter by ‘ifconfig -a’
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# create mod.sh file and input followed command #/bin/sh insmod mii.ko insmod usbnet.ko insmod cdc_ether.ko insmod configfs.ko insmod libcomposite.ko insmod u_ether.ko insmod usb_f_ecm.ko insmod usb_f_rndis.ko insmod g_ether.ko # chmod +x mod.sh # ./mod.sh usbcore: registered new interface driver cdc_ether using random self ethernet address using random host ethernet address usb0: HOST MAC d6:b4:53:eb:f9:c9 usb0: MAC ee:1d:ce:8f:be:f0 using random self ethernet address using random host ethernet address g_ether gadget: Ethernet Gadget, version: Memorial Day 2008 g_ether gadget: g_ether ready # ifconfig usb0 usb0 Link encap:Ethernet HWaddr EE:1D:CE:8F:BE:F0 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) |
Assign ethernet adapter ‘usb0’ with IP address
1 2 3 4 5 6 7 8 9 10 11 12 |
# ifconfig usb0 10.100.2.1 IPv6: ADDRCONF(NETDEV_UP): usb0: link is not ready # ifconfig usb0 usb0 Link encap:Ethernet HWaddr EE:1D:CE:8F:BE:F0 inet addr:10.100.2.1 Bcast:10.255.255.255 Mask:255.0.0.0 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) |
Connect Target to Host with a USB cable
You will see Windows notice found a new hardware and try to search and install driver.
On Host Platform
Because there is no associated device driver on Windows, so we use a virtual PC to validate it.
Connect it to Virtual PC

And we will see kernel print such as
1 2 3 4 5 6 7 8 9 10 |
$ dmesg [21467.922243] usb 1-2: new high-speed USB device number 6 using xhci_hcd [21468.268184] usb 1-2: New USB device found, idVendor=0525, idProduct=a4a2 [21468.268188] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [21468.268208] usb 1-2: Product: RNDIS/Ethernet Gadget [21468.268209] usb 1-2: Manufacturer: Linux 3.14.38+ with 2184000.usb [21468.305193] cdc_subset: probe of 1-2:1.0 failed with error -22 [21468.334040] cdc_ether 1-2:1.0 usb0: register 'cdc_ether' at usb-0000:03:00.0-2, CDC Ethernet Device, d6:b4:53:eb:f9:c9 |
And system recognized a new ethernet adapter
1 2 3 4 5 6 7 8 9 |
# ifconfig usb0 usb0 Link encap:Ethernet HWaddr d6:b4:53:eb:f9:c9 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) |
On the other hand, the Target will detect link is ready, you will see message such as below on console
1 2 3 4 |
g_ether gadget: high-speed config #1: CDC Ethernet (ECM) IPv6: ADDRCONF(NETDEV_CHANGE): usb0: link becomes ready |
Assign USB ethernet adapter with IP address
1 2 3 4 5 6 7 8 9 10 11 |
# ifconfig usb0 10.100.2.2 # ifconfig usb0 usb0 Link encap:Ethernet HWaddr EE:1D:CE:8F:BE:F0 inet addr:10.100.2.1 Bcast:10.255.255.255 Mask:255.0.0.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:8 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:648 (648.0 B) |
Check connection between Target and Host with USB cable
You can ping the other IP address such as
1 2 3 4 5 6 7 8 9 10 11 12 |
# ping 10.100.2.2 PING 10.100.2.2 (10.100.2.2): 56 data bytes 64 bytes from 10.100.2.2: seq=0 ttl=64 time=4.380 ms 64 bytes from 10.100.2.2: seq=1 ttl=64 time=2.317 ms 64 bytes from 10.100.2.2: seq=2 ttl=64 time=1.850 ms 64 bytes from 10.100.2.2: seq=3 ttl=64 time=2.368 ms ^C --- 10.100.2.2 ping statistics --- 4 packets transmitted, 4 packets received, 0% packet loss round-trip min/avg/max = 1.850/2.728/4.380 ms |