当前位置:   article > 正文

Linux内核配置——使用USB转网络功能_linux usb转网口配置

linux usb转网口配置

1.需求描述

      有时候在进行嵌入式开发中,目标板或者待开发的产品板子没有RJ45网口,这个时候又需要目标板能够与PC之间有网络连接,便于文件传输和其他网络功能使用,那么这个时候如果目标板有USB接口,也可以让其具备网络功能。

2.硬件模块

需要一个usb转网络模块,如下图所示:

3.开启相关配置

USB相关配置:

CONFIG_USB:

Prompt: Support for Host-side USB                                        |  
  |   Location:                                                              |  
  |     -> Device Drivers                                                    |  
  |       -> USB support (USB_SUPPORT [=y])  

 CONFIG_USB配置kernel相关源码:

  1. kernel/drivers/usb/core
  2. 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相关源码:

  1. kernel/drivers/usb/dwc2
  2. 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相关源码:

  1. kernel/drivers/net/usb
  2. 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

4.板端现象

接上usb转网络设备后:

  1. # [34890.278234] usb 1-1: new high-speed USB device number 3 using dwc2
  2. [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节点:

  1. # ifconfig -a
  2. bleth0 Link encap:Ethernet HWaddr CC:D8:43:21:DD:F0
  3. inet addr:192.168.80.55 Bcast:192.168.80.255 Mask:255.255.255.0
  4. UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
  5. RX packets:25801 errors:0 dropped:1 overruns:0 frame:0
  6. TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
  7. collisions:0 txqueuelen:1000
  8. RX bytes:3185513 (3.0 MiB) TX bytes:180 (180.0 B)
  9. eth0 Link encap:Ethernet HWaddr 00:6F:00:01:05:4C
  10. BROADCAST MULTICAST MTU:1500 Metric:1
  11. RX packets:0 errors:0 dropped:0 overruns:0 frame:0
  12. TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
  13. collisions:0 txqueuelen:1000
  14. RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
  15. lo Link encap:Local Loopback
  16. inet addr:127.0.0.1 Mask:255.0.0.0
  17. UP LOOPBACK RUNNING MTU:65536 Metric:1
  18. RX packets:0 errors:0 dropped:0 overruns:0 frame:0
  19. TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
  20. collisions:0 txqueuelen:1
  21. RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

使用uhcpc命令,获取局域网内ip地址,并可以ping通局域网ip地址:

  1. # udhcpc eth0
  2. udhcpc (v1.22.1) started
  3. [35048.802148] asix 1-1:1.0 eth0: link down
  4. Sending discover...
  5. [35050.723127] asix 1-1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1
  6. Sending discover...
  7. Sending select for 172.17.150.144...
  8. Lease of 172.17.150.144 obtained, lease time 86202
  9. deleting routers
  10. adding dns 172.17.210.100
  11. adding dns 172.17.210.101
  12. #
  13. #
  14. #
  15. # ping 172.17.151.10
  16. PING 172.17.151.10 (172.17.151.10): 56 data bytes
  17. 64 bytes from 172.17.151.10: seq=0 ttl=128 time=1.093 ms
  18. 64 bytes from 172.17.151.10: seq=1 ttl=128 time=0.754 ms
  19. 64 bytes from 172.17.151.10: seq=2 ttl=128 time=0.766 ms
  20. 64 bytes from 172.17.151.10: seq=3 ttl=128 time=0.685 ms
  21. 64 bytes from 172.17.151.10: seq=4 ttl=128 time=0.688 ms
  22. --- 172.17.151.10 ping statistics ---
  23. 5 packets transmitted, 5 packets received, 0% packet loss
  24. round-trip min/avg/max = 0.685/0.797/1.093 ms

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号