将ARM4412开发板配置成USB网卡,并且使用USB通过Ubuntu上网
生活随笔
收集整理的這篇文章主要介紹了
将ARM4412开发板配置成USB网卡,并且使用USB通过Ubuntu上网
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
注:以下配置在三星s4手機也成功測試通過,可以ping通外網ip和域名,但是瀏覽器不能上網。
1. 開發板4412 linux內核配置 4412需要安裝USB Gadget驅動g_ether.ko(drivers/usb/gadget/ether.c) 來進行通訊。g_ether.ko在配置菜單位置如下: │ -> Device Drivers │ │ -> USB support (USB_SUPPORT [=y]) │ │ -> USB Gadget Support (USB_GADGET [=y]) │ │ -> USB Gadget Drivers (?[=y]) │ │ ->?Ethernet Gadget (with CDC Ethernet support)?
make后下載到開發板。(注:可以以模塊或是靜態編譯的方式來配置,靜態編譯方式測試通過。)
開發板通過USB連接到電腦后,在PC端Ubuntu下輸入ifconfig 便可看到usb0的網絡接口:
2. 4412開發板配置: 在超級終端下輸入 1)設置接口:ifconfig usb0 192.168.2.2(注意不能和eth0的ip處于同一網段) 2)配置網關:route add default gw 192.168.2.1 3)設置DNS: vi /etc/resolv.conf,修改成 nameserver 114.114.114.114 注:能ping外網ip但不能ping域名基本都是DNS沒有設置好。 另注:三星S4通過setprop無法ping外網域名,只有修改nameserver才可以ping通。
3. PC端Ubuntu設置: sysctl -w net.ipv4.ip_forward=1 iptables -A FORWARD -i usb0 -o eth0 -j ACCEPT iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE ifconfig usb0 192.168.2.1 netmask 255.255.255.0
命令依次的含義是:打開IP轉發,允許usb0到eth0的包通過防火墻,在服務器上設置了對于客戶端的NAT,設置usb0網卡的ip地址
4. 4412 開發板ping外網測試 注:這里需要確保pc以及連上外網。 ping www.youku.com
5. 開發板和Ubuntu互ping 開發板和Ubuntu相互ping通只需設置以下兩項即可,不需要上述2、3繁瑣步驟: 4412開發板:ifconfig usb0 192.168.2.2 Ubuntu:ifconfig usb0 192.168.2.1 Ubuntu下ping開發板測試結果:
6. 參考: 1.Android手機通過USB數據線共享Linux電腦網絡(internet傳輸) 2.Linux手機如何通過usbnet訪問internet 3.Linux 下使用USB 網絡-精華
7. 附usbview 4412開發板USB配置詳情: Manufacturer: Linux 3.0.15 with s3c-udc Speed: 480Mb/s (high) USB Version: 2.00 Device Class: 02(comm.) Device Subclass: 00 Device Protocol: 00 Maximum Default Endpoint Size: 64 Number of Configurations: 2 Vendor Id: 0525 Product Id: a4a2 Revision Number: 3.26
Config Number: 2 Number of Interfaces: 2 Attributes: c0 MaxPower Needed: 2mA
Interface Number: 0 Name: Alternate Number: 0 Class: 02(comm.) Sub Class: 02 Protocol: ff Number of Endpoints: 1
Endpoint Address: 83 Direction: in Attribute: 3 Type: Int. Max Packet Size: 8 Interval: 32ms
Interface Number: 1 Name: Alternate Number: 0 Class: 0a(data ) Sub Class: 00 Protocol: 00 Number of Endpoints: 2
Endpoint Address: 82 Direction: in Attribute: 2 Type: Bulk Max Packet Size: 512 Interval: 0ms
Endpoint Address: 01 Direction: out Attribute: 2 Type: Bulk Max Packet Size: 512 Interval: 0ms
Config Number: 1 Number of Interfaces: 2 Attributes: c0 MaxPower Needed: 2mA
Interface Number: 0 Name: cdc_ether Alternate Number: 0 Class: 02(comm.) Sub Class: 06 Protocol: 00 Number of Endpoints: 1
Endpoint Address: 83 Direction: in Attribute: 3 Type: Int. Max Packet Size: 16 Interval: 32ms
Interface Number: 1 Name: cdc_ether Alternate Number: 0 Class: 0a(data ) Sub Class: 00 Protocol: 00 Number of Endpoints: 0
Interface Number: 1 Name: cdc_ether Alternate Number: 1 Class: 0a(data ) Sub Class: 00 Protocol: 00 Number of Endpoints: 2
Endpoint Address: 82 Direction: in Attribute: 2 Type: Bulk Max Packet Size: 512 Interval: 0ms
Endpoint Address: 01 Direction: out Attribute: 2 Type: Bulk Max Packet Size: 512 Interval: 0ms
1. 開發板4412 linux內核配置 4412需要安裝USB Gadget驅動g_ether.ko(drivers/usb/gadget/ether.c) 來進行通訊。g_ether.ko在配置菜單位置如下:
2. 4412開發板配置: 在超級終端下輸入 1)設置接口:ifconfig usb0 192.168.2.2(注意不能和eth0的ip處于同一網段) 2)配置網關:route add default gw 192.168.2.1 3)設置DNS: vi /etc/resolv.conf,修改成 nameserver 114.114.114.114 注:能ping外網ip但不能ping域名基本都是DNS沒有設置好。 另注:三星S4通過setprop無法ping外網域名,只有修改nameserver才可以ping通。
3. PC端Ubuntu設置: sysctl -w net.ipv4.ip_forward=1 iptables -A FORWARD -i usb0 -o eth0 -j ACCEPT iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE ifconfig usb0 192.168.2.1 netmask 255.255.255.0
命令依次的含義是:打開IP轉發,允許usb0到eth0的包通過防火墻,在服務器上設置了對于客戶端的NAT,設置usb0網卡的ip地址
4. 4412 開發板ping外網測試 注:這里需要確保pc以及連上外網。 ping www.youku.com
5. 開發板和Ubuntu互ping 開發板和Ubuntu相互ping通只需設置以下兩項即可,不需要上述2、3繁瑣步驟: 4412開發板:ifconfig usb0 192.168.2.2 Ubuntu:ifconfig usb0 192.168.2.1 Ubuntu下ping開發板測試結果:
6. 參考: 1.Android手機通過USB數據線共享Linux電腦網絡(internet傳輸) 2.Linux手機如何通過usbnet訪問internet 3.Linux 下使用USB 網絡-精華
7. 附usbview 4412開發板USB配置詳情: Manufacturer: Linux 3.0.15 with s3c-udc Speed: 480Mb/s (high) USB Version: 2.00 Device Class: 02(comm.) Device Subclass: 00 Device Protocol: 00 Maximum Default Endpoint Size: 64 Number of Configurations: 2 Vendor Id: 0525 Product Id: a4a2 Revision Number: 3.26
Config Number: 2 Number of Interfaces: 2 Attributes: c0 MaxPower Needed: 2mA
Interface Number: 0 Name: Alternate Number: 0 Class: 02(comm.) Sub Class: 02 Protocol: ff Number of Endpoints: 1
Endpoint Address: 83 Direction: in Attribute: 3 Type: Int. Max Packet Size: 8 Interval: 32ms
Interface Number: 1 Name: Alternate Number: 0 Class: 0a(data ) Sub Class: 00 Protocol: 00 Number of Endpoints: 2
Endpoint Address: 82 Direction: in Attribute: 2 Type: Bulk Max Packet Size: 512 Interval: 0ms
Endpoint Address: 01 Direction: out Attribute: 2 Type: Bulk Max Packet Size: 512 Interval: 0ms
Config Number: 1 Number of Interfaces: 2 Attributes: c0 MaxPower Needed: 2mA
Interface Number: 0 Name: cdc_ether Alternate Number: 0 Class: 02(comm.) Sub Class: 06 Protocol: 00 Number of Endpoints: 1
Endpoint Address: 83 Direction: in Attribute: 3 Type: Int. Max Packet Size: 16 Interval: 32ms
Interface Number: 1 Name: cdc_ether Alternate Number: 0 Class: 0a(data ) Sub Class: 00 Protocol: 00 Number of Endpoints: 0
Interface Number: 1 Name: cdc_ether Alternate Number: 1 Class: 0a(data ) Sub Class: 00 Protocol: 00 Number of Endpoints: 2
Endpoint Address: 82 Direction: in Attribute: 2 Type: Bulk Max Packet Size: 512 Interval: 0ms
Endpoint Address: 01 Direction: out Attribute: 2 Type: Bulk Max Packet Size: 512 Interval: 0ms
總結
以上是生活随笔為你收集整理的将ARM4412开发板配置成USB网卡,并且使用USB通过Ubuntu上网的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 苹果7plus访问限制在哪
- 下一篇: ubuntu下安装android ndk