{"id":17,"date":"2011-03-30T19:40:50","date_gmt":"2011-03-30T19:40:50","guid":{"rendered":"http:\/\/..\/?p=17"},"modified":"2011-03-30T19:40:50","modified_gmt":"2011-03-30T19:40:50","slug":"usb-networking","status":"publish","type":"post","link":"https:\/\/blog.engine12.com\/?p=17","title":{"rendered":"USB Networking"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p><a href=\"..\/wp-content\/uploads\/2011\/03\/IMG_8304-1.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignright\" src=\"..\/wp-content\/uploads\/2011\/03\/IMG_8304-1-300x200.jpg\" alt=\"\" width=\"300\" height=\"200\" \/><\/a><\/p>\n<p>By using the USB networking features of Linux you can create a TCP\/IP network and achieve the same functionality that is given with an ethernet or 802.11 network.\u00a0 That is to say, you instantly get all of the network stack protocols such as\u00a0 ssh, ftp, http, etc.\u00a0 With USB networking you can easily add several new networking interfaces to a host machine.\u00a0 These new interfaces can be configured to the same network or can be configured as seperate networks.\u00a0 A USB network can also be bridged and shared with ethernet and 802.11 networks.<\/p>\n<p>I have a beagleboard rev. C4 with Ubuntu running on an 8 GB SD card.\u00a0 The beagleboard does not have an ethernet port or wifi chip, however, it does have both USB host and USB OTG ports.\u00a0 The goal was to connect the ZipIt to the beagleboard with USB and then bridge to the ZipIt&#8217;s wireless connection.\u00a0 By bridging the two networks, both the beagleboard and the ZipIt can utilize the wifi connection and access the web over the LAN.<\/p>\n<ol>\n<li>network a ZipIt Z2 to a beagleboard using USB<\/li>\n<li>create a bridge to the ZipIt&#8217;s wifi connection and share it with the beagleboard<\/li>\n<\/ol>\n<p>The beagleboard has the ability to act as both a USB host and a USB client.\u00a0 The connection being described in this post has the beagleboard assigned as the host and the ZipIt in USB client mode.\u00a0 The ZipIt can also act as the USB host, but unlike the beagleboard, it cannot be both at the same time.\u00a0 A <a title=\"anarsoul's ZipIt kernels\" href=\"http:\/\/downloads.tuxfamily.org\/linuxrx1950\/precompiled\/zipit\/\">kernel<\/a> that has been configured to put the ZipIt in USB client mode is a requirement.\u00a0 I compiled my own kernel using buildroot and the kernel sources from <a title=\"anarsoul's tree\" href=\"https:\/\/github.com\/anarsoul\/linux-2.6\/tree\/pxa27x-dev\">anarsoul&#8217;s tree<\/a> with this <a title=\"USB client kernel .config\" href=\"http:\/\/engine12.com\/files\/.config.03212011%28working%20usbc%20with%20beagle%29\">.config<\/a> and this additional <a title=\"kernel patch for USB client mode\" href=\"http:\/\/engine12.com\/files\/z2-udc.diff\">patch<\/a>, also provided by <a href=\"http:\/\/anarsoul.blogspot.com\/\">anarsoul<\/a>.\u00a0 At the time of this post, he has not released a compiled version of the USB client, I&#8217;m sure that if you poke him, he will be happy to help, otherwise I can also provide a binary.<\/p>\n<p>You will also need to create a <a href=\"http:\/\/mozzwald.com\/node\/60\">USB adapter<\/a> for the ZipIt.\u00a0 The USB wiring&#8211;&gt;pin connections are the same as those for the USB host cable, the only difference you may consider is a male end.\u00a0 The configuration details below can easily be adapted to work with a ZipIt to ZipIt, or a ZipIt to laptop connection.<\/p>\n<p>It is recommended to use the <a title=\"z2lite-rc8\" href=\"http:\/\/z2nix.net\/files\/z2sid\/z2lite-rc8.tar.bz2\">z2lite-rc8<\/a> userland by wicknix.\u00a0 This userland has the iptables already included.\u00a0 The usage of other userlands will need\u00a0 this package installed (i.e. z2sid-rc3).<\/p>\n<p>The additions needed to \/etc\/network\/interfaces for the beagleboard and ZipIt are as follows.<\/p>\n<p>beagleboard &#8211;&gt; \/etc\/network\/interfaces<\/p>\n<p style=\"padding-left: 30px\"><span style=\"color: #ff9900\">iface usb1 inet static <\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"color: #ff9900\">address 192.168.2.22<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"color: #ff9900\">netmask 255.255.255.0<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"color: #ff9900\">network 192.168.2.0<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"color: #ff9900\">gateway 192.168.2.12<\/span> (this is the IP assigned to the ZipIt)<\/p>\n<p>&nbsp;<\/p>\n<p>ZipIt\u00a0 &#8211;&gt; \/etc\/network\/interfaces<\/p>\n<p style=\"padding-left: 30px\"><span style=\"color: #ff9900\">auto usb0<\/span><br \/>\n<span style=\"color: #ff9900\"> iface usb0 inet static<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"color: #ff9900\">address 192.168.2.12<\/span><br \/>\n<span style=\"color: #ff9900\"> netmask 255.255.255.0<\/span><br \/>\n<span style=\"color: #ff9900\"> network 192.168.2.0<\/span><br \/>\n<span style=\"color: #ff9900\"> broadcast 192.168.2.255<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"color: #ff9900\">up echo 1 &gt; \/proc\/sys\/net\/ipv4\/ip_forward<\/span><br \/>\n<span style=\"color: #ff9900\"> up iptables -t nat -A POSTROUTING -o wlan0 -s 192.168.2.0\/24 -j MASQUERADE<\/span><br \/>\n<span style=\"color: #ff9900\"> up iptables -t nat -A PREROUTING -i wlan0 -p tcp &#8211;dport 3074 -j DNAT &#8211;to-destination 192.168.2.12<\/span><br \/>\n<span style=\"color: #ff9900\"> up iptables -A FORWARD -i wlan0 -d 192.168.2.12 -p tcp &#8211;dport 3074 -j ACCEPT<\/span><span style=\"color: #ff9900\"><br \/>\n<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"color: #ff9900\">down echo 0 &gt; \/proc\/sys\/net\/ipv4\/ip_forward<\/span><br \/>\n<span style=\"color: #ff9900\"> down iptables -t nat -D POSTROUTING -o wlan0 -s 192.168.2.0\/24 -j MASQUERADE<\/span><\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p>Boot the beagleboard and the ZipIt.\u00a0 Log in to the ZipIt and issue the following commands.<\/p>\n<p style=\"padding-left: 30px\">z2sid-rc3:~#:<span style=\"color: #ff9900\">modprobe g_ether<\/span><\/p>\n<p style=\"padding-left: 30px\">z2sid-rc3:~#:<span style=\"color: #ff9900\">ifdown usb0<\/span><\/p>\n<p style=\"padding-left: 30px\">z2sid-rc3:~#:<span style=\"color: #ff9900\">ifup usb0<\/span><\/p>\n<p>It&#8217;s assumed the ZipIt is already connected to a wireless AP and can access the web.\u00a0 Please note that you configure and connect the ZipIt to the wireless AP as normal.\u00a0 The ZipIt&#8217;s USB cable can now be plugged into the beagleboard&#8217;s USB hub.\u00a0 That should be it.\u00a0 Open your beagleboard&#8217;s web browser and try to access the web.<\/p>\n<h2>Troubleshooting:<\/h2>\n<p>Networking problems can arise from many sources.\u00a0 The problem may be with the hardware, software, environment, configuration, etc., and can often be a combination of the possibilities.\u00a0 Here&#8217;s a few tips for troubleshooting problems.<\/p>\n<p>Start with establishing a ping signal.\u00a0 It is best to clear any rules in the iptables that could prevent a response from the ping request.<\/p>\n<p style=\"padding-left: 30px\">z2sid-rc3:~#:<span style=\"color: #ff9900\">iptables -L <\/span> &#8211;&gt; lists all the rules for the &#8216;firewall&#8217;<\/p>\n<p style=\"padding-left: 30px\">z2sid-rc3:~#:<span style=\"color: #ff9900\">iptables -F<\/span> &#8211;&gt; clears all the rules for the &#8216;firewall&#8217;.\u00a0 Should be the same as if a firewall was not up.<\/p>\n<p>With USB networking the first thing to check of course would be the USB connection.\u00a0 This can be done with a userland tool called ethtool.\u00a0 The ethtool package can be found in most repositories, including those of Ubuntu.\u00a0 If you are using a buildroot based userland such as z2lite you may need to build the ethtool package yourself.\u00a0 The z2lite-rc8 package has the needed userland tools for creating the network bridge.<\/p>\n<p style=\"padding-left: 30px\">z2sid-rc3:~#:<span style=\"color: #ff9900\">ethool usb0<\/span> &#8211;&gt; should return Link Detected: yes<\/p>\n<p style=\"padding-left: 30px\">z2sid-rc3:~#:<span style=\"color: #ff9900\">ethtool -i usb0<\/span> &#8211;&gt; returns info about the driver and firmware.\u00a0 Look for driver: g_ether.<\/p>\n<p style=\"padding-left: 30px\">z2sid-rc3:~#:<span style=\"color: #ff9900\">ping 192.168.2.22<\/span> &#8211;&gt; looking for a ping response of\u00a0 ~ 2 ms<\/p>\n<p>Once you have a ping response you can then start adding rules to the iptables that will bridge the USB network and the ZipIts wifi connection.<\/p>\n<p>&nbsp;<\/p>\n<p>Links:<\/p>\n<p><a title=\"anarsoul's ZipIt kernels\" href=\"http:\/\/downloads.tuxfamily.org\/linuxrx1950\/precompiled\/zipit\/\">http:\/\/downloads.tuxfamily.org\/linuxrx1950\/precompiled\/zipit\/<\/a><\/p>\n<p><a title=\"anarsoul's tree\" href=\"https:\/\/github.com\/anarsoul\/linux-2.6\/tree\/pxa27x-dev\">https:\/\/github.com\/anarsoul\/linux-2.6\/tree\/pxa27x-dev<\/a><\/p>\n<p><a title=\"how to make a USB cable for the ZipIt\" href=\"http:\/\/mozzwald.com\/node\/60\">http:\/\/mozzwald.com\/node\/60<\/a><\/p>\n<p><a title=\"wicknix's z2lite\" href=\"http:\/\/hostwork.com\/users\/matt\/zipitz2\/\">http:\/\/hostwork.com\/users\/matt\/zipitz2\/<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; By using the USB networking features of Linux you can create a TCP\/IP network and achieve the same functionality that is given with an ethernet or 802.11 network.\u00a0 That is to say, you instantly get all of the network stack protocols such as\u00a0 ssh, ftp, http, etc.\u00a0 With USB networking you can easily add <a href='https:\/\/blog.engine12.com\/?p=17'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"image","meta":[],"categories":[2],"tags":[3,12,13],"_links":{"self":[{"href":"https:\/\/blog.engine12.com\/index.php?rest_route=\/wp\/v2\/posts\/17"}],"collection":[{"href":"https:\/\/blog.engine12.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.engine12.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.engine12.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.engine12.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=17"}],"version-history":[{"count":0,"href":"https:\/\/blog.engine12.com\/index.php?rest_route=\/wp\/v2\/posts\/17\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.engine12.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=17"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.engine12.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=17"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.engine12.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=17"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}