{"id":1508,"date":"2016-05-03T17:39:30","date_gmt":"2016-05-03T09:39:30","guid":{"rendered":"http:\/\/kaoru.tech\/?p=1508"},"modified":"2016-05-03T23:38:19","modified_gmt":"2016-05-03T15:38:19","slug":"how-to-use-usb-device-networking","status":"publish","type":"post","link":"http:\/\/kaoru.tech:7000\/wordpress\/?p=1508","title":{"rendered":"How to use USB device networking"},"content":{"rendered":"<h1>Kernel Configuration<\/h1>\n<p><a href=\"http:\/\/kaoru.tech\/wp-content\/uploads\/2016\/05\/Gadget-Ethernet-Kernel-Config.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1532\" src=\"http:\/\/kaoru.tech\/wp-content\/uploads\/2016\/05\/Gadget-Ethernet-Kernel-Config.png\" alt=\"Gadget Ethernet Kernel Config\" width=\"675\" height=\"900\" srcset=\"http:\/\/kaoru.tech:7000\/wordpress\/wp-content\/uploads\/2016\/05\/Gadget-Ethernet-Kernel-Config.png 675w, http:\/\/kaoru.tech:7000\/wordpress\/wp-content\/uploads\/2016\/05\/Gadget-Ethernet-Kernel-Config-225x300.png 225w\" sizes=\"auto, (max-width: 675px) 100vw, 675px\" \/><\/a><\/p>\n<h1>On Embedded\u00a0Target<\/h1>\n<h2>Insmod Drivers<\/h2>\n<p>After that, you will see a new usb ethernet adapter by &#8216;ifconfig -a&#8217;<\/p>\n<pre lang=\"bash\" class=\"\"># create mod.sh file and input followed command\r\n\r\n#\/bin\/sh\r\n\r\ninsmod mii.ko\r\ninsmod usbnet.ko\r\ninsmod cdc_ether.ko\r\ninsmod configfs.ko\r\ninsmod libcomposite.ko\r\ninsmod u_ether.ko\r\ninsmod usb_f_ecm.ko\r\ninsmod usb_f_rndis.ko\r\ninsmod g_ether.ko\r\n\r\n# chmod +x mod.sh\r\n# .\/mod.sh\r\nusbcore: registered new interface driver cdc_ether\r\nusing random self ethernet address\r\nusing random host ethernet address\r\nusb0: HOST MAC d6:b4:53:eb:f9:c9\r\nusb0: MAC ee:1d:ce:8f:be:f0\r\nusing random self ethernet address\r\nusing random host ethernet address\r\ng_ether gadget: Ethernet Gadget, version: Memorial Day 2008\r\ng_ether gadget: g_ether ready\r\n \r\n# ifconfig usb0\r\nusb0 Link encap:Ethernet HWaddr EE:1D:CE:8F:BE:F0 \r\n BROADCAST MULTICAST MTU:1500 Metric:1\r\n RX packets:0 errors:0 dropped:0 overruns:0 frame:0\r\n TX packets:0 errors:0 dropped:0 overruns:0 carrier:0\r\n collisions:0 txqueuelen:1000 \r\n RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)<\/pre>\n<h2>Assign ethernet adapter &#8216;usb0&#8217; with IP address<\/h2>\n<pre lang=\"bash\" class=\"\"># ifconfig usb0 10.100.2.1\r\nIPv6: ADDRCONF(NETDEV_UP): usb0: link is not ready\r\n# ifconfig usb0 \r\nusb0      Link encap:Ethernet  HWaddr EE:1D:CE:8F:BE:F0  \r\n          inet addr:10.100.2.1  Bcast:10.255.255.255  Mask:255.0.0.0\r\n          UP BROADCAST MULTICAST  MTU:1500  Metric:1\r\n          RX packets:0 errors:0 dropped:0 overruns:0 frame:0\r\n          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0\r\n          collisions:0 txqueuelen:1000 \r\n          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)\r\n<\/pre>\n<h2>Connect Target to Host with a USB cable<\/h2>\n<p>You will see Windows notice found a new hardware and try to search and install driver.<\/p>\n<p><a href=\"http:\/\/kaoru.tech\/wp-content\/uploads\/2016\/05\/RNDIS-Ethernet-Gadget-Driver-installing.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1514 alignnone\" src=\"http:\/\/kaoru.tech\/wp-content\/uploads\/2016\/05\/RNDIS-Ethernet-Gadget-Driver-installing.png\" alt=\"RNDIS-Ethernet Gadget Driver installing\" width=\"536\" height=\"214\" srcset=\"http:\/\/kaoru.tech:7000\/wordpress\/wp-content\/uploads\/2016\/05\/RNDIS-Ethernet-Gadget-Driver-installing.png 536w, http:\/\/kaoru.tech:7000\/wordpress\/wp-content\/uploads\/2016\/05\/RNDIS-Ethernet-Gadget-Driver-installing-300x120.png 300w\" sizes=\"auto, (max-width: 536px) 100vw, 536px\" \/><\/a><\/p>\n<h1>On Host Platform<\/h1>\n<p>Because there is no associated device driver on Windows, so we use a virtual PC to validate it.<\/p>\n<h2>Connect it to Virtual PC<br \/>\n<a href=\"http:\/\/kaoru.tech\/wp-content\/uploads\/2016\/05\/Netchip-on-VMware.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1515 alignnone\" src=\"http:\/\/kaoru.tech\/wp-content\/uploads\/2016\/05\/Netchip-on-VMware.png\" alt=\"Netchip on VMware\" width=\"788\" height=\"555\" srcset=\"http:\/\/kaoru.tech:7000\/wordpress\/wp-content\/uploads\/2016\/05\/Netchip-on-VMware.png 788w, http:\/\/kaoru.tech:7000\/wordpress\/wp-content\/uploads\/2016\/05\/Netchip-on-VMware-300x211.png 300w, http:\/\/kaoru.tech:7000\/wordpress\/wp-content\/uploads\/2016\/05\/Netchip-on-VMware-768x541.png 768w\" sizes=\"auto, (max-width: 788px) 100vw, 788px\" \/><\/a><\/h2>\n<p>And we will see kernel print such as<\/p>\n<pre lang=\"bash\" class=\"\">$ dmesg \r\n[21467.922243] usb 1-2: new high-speed USB device number 6 using xhci_hcd\r\n[21468.268184] usb 1-2: New USB device found, idVendor=0525, idProduct=a4a2\r\n[21468.268188] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0\r\n[21468.268208] usb 1-2: Product: RNDIS\/Ethernet Gadget\r\n[21468.268209] usb 1-2: Manufacturer: Linux 3.14.38+ with 2184000.usb\r\n[21468.305193] cdc_subset: probe of 1-2:1.0 failed with error -22\r\n[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\r\n<\/pre>\n<p>And system\u00a0recognized a new ethernet adapter<\/p>\n<pre lang=\"bash\" class=\"\"># ifconfig usb0\r\nusb0      Link encap:Ethernet  HWaddr d6:b4:53:eb:f9:c9  \r\n          BROADCAST MULTICAST  MTU:1500  Metric:1\r\n          RX packets:0 errors:0 dropped:0 overruns:0 frame:0\r\n          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0\r\n          collisions:0 txqueuelen:1000 \r\n          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)\r\n<\/pre>\n<p>On the other hand, the Target will detect link is ready, you will see message such as below on console<\/p>\n<pre lang=\"bash\" class=\"\">g_ether gadget: high-speed config #1: CDC Ethernet (ECM)\r\nIPv6: ADDRCONF(NETDEV_CHANGE): usb0: link becomes ready\r\n<\/pre>\n<p>Assign USB ethernet adapter with IP address<\/p>\n<pre class=\"lang:default decode:true\"># ifconfig usb0 10.100.2.2\r\n# ifconfig usb0\r\nusb0 Link encap:Ethernet HWaddr EE:1D:CE:8F:BE:F0 \r\n inet addr:10.100.2.1 Bcast:10.255.255.255 Mask:255.0.0.0\r\n UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1\r\n RX packets:0 errors:0 dropped:0 overruns:0 frame:0\r\n TX packets:8 errors:0 dropped:0 overruns:0 carrier:0\r\n collisions:0 txqueuelen:1000 \r\n RX bytes:0 (0.0 B) TX bytes:648 (648.0 B)<\/pre>\n<h1>Check connection between Target and Host with USB cable<\/h1>\n<p>You can ping the other IP address such as<\/p>\n<pre class=\"lang:sh decode:true \"># ping 10.100.2.2\r\nPING 10.100.2.2 (10.100.2.2): 56 data bytes\r\n64 bytes from 10.100.2.2: seq=0 ttl=64 time=4.380 ms\r\n64 bytes from 10.100.2.2: seq=1 ttl=64 time=2.317 ms\r\n64 bytes from 10.100.2.2: seq=2 ttl=64 time=1.850 ms\r\n64 bytes from 10.100.2.2: seq=3 ttl=64 time=2.368 ms\r\n^C\r\n--- 10.100.2.2 ping statistics ---\r\n4 packets transmitted, 4 packets received, 0% packet loss\r\nround-trip min\/avg\/max = 1.850\/2.728\/4.380 ms<\/pre>\n<h1>Reference<\/h1>\n<ul>\n<li><a href=\"https:\/\/developer.ridgerun.com\/wiki\/index.php\/How_to_use_USB_device_networking\">https:\/\/developer.ridgerun.com\/wiki\/index.php\/How_to_use_USB_device_networking<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Kernel Configuration On Embedded\u00a0Target Insmod Drivers After that, you will see a new usb ethernet adapter by &#8216;ifconfig -a&#8217; # create mod.sh file and input followed command #\/bin\/sh insmod mii.ko&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[14],"tags":[154,275,276],"class_list":["post-1508","post","type-post","status-publish","format-standard","hentry","category-embedded","tag-ethernet","tag-usb-device","tag-usb-gadget"],"_links":{"self":[{"href":"http:\/\/kaoru.tech:7000\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1508","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/kaoru.tech:7000\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/kaoru.tech:7000\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/kaoru.tech:7000\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/kaoru.tech:7000\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1508"}],"version-history":[{"count":7,"href":"http:\/\/kaoru.tech:7000\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1508\/revisions"}],"predecessor-version":[{"id":1537,"href":"http:\/\/kaoru.tech:7000\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1508\/revisions\/1537"}],"wp:attachment":[{"href":"http:\/\/kaoru.tech:7000\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1508"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/kaoru.tech:7000\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1508"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/kaoru.tech:7000\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1508"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}