赞
踩
有时候在进行嵌入式开发中,目标板或者待开发的产品板子没有RJ45网口,这个时候又需要目标板能够与PC之间有网络连接,便于文件传输和其他网络功能使用,那么这个时候如果目标板有USB接口,也可以让其具备网络功能。
需要一个usb转网络模块,如下图所示:
USB相关配置:
CONFIG_USB:
Prompt: Support for Host-side USB |
| Location: |
| -> Device Drivers |
| -> USB support (USB_SUPPORT [=y])
CONFIG_USB配置kernel相关源码:
- kernel/drivers/usb/core
- kernel/drivers/usb/core/usbcore.c
CONFIG_USB_DWC2:
Prompt: DesignWare USB2 DRD Core Support |
| Location: |
| -> Device Drivers || -> USB support (USB_SUPPORT [=y])
CONFIG_USB_DWC2_HOST:
Prompt: Host only mode |
| Location: |
| -> Device Drivers |
| -> USB support (USB_SUPPORT [=y]) |
| -> DesignWare USB2 DRD Core Support (USB_DWC2 [=m]) |
| -> DWC2 Mode Selection (<choice> [=y])
CONFIG_USB_DWC2配置kernel相关源码:
- kernel/drivers/usb/dwc2
- kernel/drivers/usb/dwc2/dwc2.c
CONFIG_USB_USBNET:
Prompt: Multi-purpose USB Networking Framework |
| Location: |
| -> Device Drivers |
| -> Network device support (NETDEVICES [=y]) |
| -> USB Network Adapters (USB_NET_DRIVERS [=m])CONFIG_USB_NET_AX8817X:
Prompt: ASIX AX88xxx Based USB 2.0 Ethernet Adapters |
| Location: |
| -> Device Drivers |
| -> Network device support (NETDEVICES [=y]) |
| -> USB Network Adapters (USB_NET_DRIVERS [=m]) |
| -> Multi-purpose USB Networking Framework (USB_USBNET [=m])
CONFIG_USB_USBNET, CONFIG_USB_NET_AX8817X配置kernel相关源码:
- kernel/drivers/net/usb
- kernel/drivers/net/usb/asix.c
CONFIG_INGENIC_INNOPHY:
Prompt: Ingenic usb phy(INNO) implemented. |
| Location: |
| -> Device Drivers |
| -> USB support (USB_SUPPORT [=y]) |
| -> USB Physical Layer drivers |
| -> Ingenic usb Phy selects (<choice> [=y])
CONFIG_INGENIC_INNOPHY配置kernel相关源码:
kernel/drivers/usb/phy/phy-ingenic-inno.c
接上usb转网络设备后:
- # [34890.278234] usb 1-1: new high-speed USB device number 3 using dwc2
-
- [root@Zeratul:~]# [34891.320513] asix 1-1:1.0 eth0: register 'asix' at usb-13500000.otg-1, ASIX AX88772B USB 2.0 Ethernet, 00:6f:00:01:05:4c
ifconfig -a命令查看网卡节点,新增出现了eth0节点:
- # ifconfig -a
- bleth0 Link encap:Ethernet HWaddr CC:D8:43:21:DD:F0
- inet addr:192.168.80.55 Bcast:192.168.80.255 Mask:255.255.255.0
- UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
- RX packets:25801 errors:0 dropped:1 overruns:0 frame:0
- TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
- collisions:0 txqueuelen:1000
- RX bytes:3185513 (3.0 MiB) TX bytes:180 (180.0 B)
-
- eth0 Link encap:Ethernet HWaddr 00:6F:00:01:05:4C
- 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)
-
- lo Link encap:Local Loopback
- inet addr:127.0.0.1 Mask:255.0.0.0
- UP LOOPBACK RUNNING MTU:65536 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:1
- RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
使用uhcpc命令,获取局域网内ip地址,并可以ping通局域网ip地址:
- # udhcpc eth0
- udhcpc (v1.22.1) started
- [35048.802148] asix 1-1:1.0 eth0: link down
- Sending discover...
- [35050.723127] asix 1-1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1
- Sending discover...
- Sending select for 172.17.150.144...
- Lease of 172.17.150.144 obtained, lease time 86202
- deleting routers
- adding dns 172.17.210.100
- adding dns 172.17.210.101
- #
- #
- #
- # ping 172.17.151.10
- PING 172.17.151.10 (172.17.151.10): 56 data bytes
- 64 bytes from 172.17.151.10: seq=0 ttl=128 time=1.093 ms
- 64 bytes from 172.17.151.10: seq=1 ttl=128 time=0.754 ms
- 64 bytes from 172.17.151.10: seq=2 ttl=128 time=0.766 ms
- 64 bytes from 172.17.151.10: seq=3 ttl=128 time=0.685 ms
- 64 bytes from 172.17.151.10: seq=4 ttl=128 time=0.688 ms
-
- --- 172.17.151.10 ping statistics ---
- 5 packets transmitted, 5 packets received, 0% packet loss
- round-trip min/avg/max = 0.685/0.797/1.093 ms
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。