将无线网卡插入任何可以识别USB的机器,此处将360随身WIFI插入虚拟机中。通过以下命令查看VID和PID号。可得出使用的是联发科的MT7601U芯片。
rd@rd-virtual-machine:~/sda3/4310$ lsusbBus 001 Device 002: ID 148f:760b Ralink Technology, Corp. MT7601U Wireless AdapterBus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hubBus 002 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB HubBus 002 Device 002: ID 0e0f:0003 VMware, Inc. Virtual MouseBus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
随后进入联发科官网下载其驱动,
/products/connectivity-and-networking/broadband-wifi
或者
/detail/pchl33/7424755
通过阅读README_STA_usb文件,了解到需要分别修改os/linux/config.mk文件和Makefile文件。
修改如下25 # i.e. wpa_supplicant -Dralink26 HAS_WPA_SUPPLICANT=y272829 # Support Native WpaSupplicant forNetwork Maganger30 # i.e. wpa_supplicant -Dwext31 HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=y添加如下1093 ifeq ($(PLATFORM),pxa16X)1094ifneq (,$(findstring 2.4,$(LINUX_SRC)))1095 # Linux 2.41096 CFLAGS := -D__KERNEL__ -I$(LINUX_SRC)/include -O2 -fomit-frame-pointer -fno-strict-aliasing-fno-common -pipe -mpreferred-stack-boundary=2 -march=arm -DMODULE -DMODVERSIONS -include $(LINUX_SRC)/include/linux/modversions.h $(WFLAGS)1097 export CFLAGS1098else1099 # Linux 2.61100 EXTRA_CFLAGS := $(WFLAGS)1101endif1102 endif
使其支持NetworkManager or wpa_supplicant wext functions
接着修改makefile文件。
添加如下代码
31 PLATFORM = pxa16X105 ifeq ($(PLATFORM),pxa16X)106 LINUX_SRC = /home/rd/sda3/4434te/linux-2.6.28.mt4000107 CROSS_COMPILE = /buildroot/build_arm/staging_dir/bin/arm-linux-108 endif
修改完毕后直接make。
如果报如下错误则:
sta_cfg.c:5766:85: error: macro "__DATE__" might prevent reproducible builds [-Werror=date-time]snprintf(extra, size, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );^sta/sta_cfg.c:5766:95: error: macro "__TIME__" might prevent reproducible builds [-Werror=date-time]snprintf(extra, size, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
按下面修改。
这个是gcc编译时加了-Werror 参数导致的
你去linux内核源码根目录下找makefile文件
搜索makefile中关键词werror
一共有4行,把这四行整行全部注释掉就好了。
查找-Werror 去掉下面4段文本
-Werror-implicit-function-declaration \
,-Werror=implicit-int
,-Werror=strict-prototypes
,-Werror=date-time
再make,
又报错
/home/ssr/文档/DPO_MT7601U_LinuxSTA_3.0.0.4_0913/os/linux/../../os/linux/rt_linux.c:1121:20: error: incompatible types when assigning to type ‘int’ from type ‘kuid_t’pOSFSInfo->fsuid = current_fsuid();^/home/ssr/文档/DPO_MT7601U_LinuxSTA_3.0.0.4_0913/os/linux/../../os/linux/rt_linux.c:1122:20: error: incompatible types when assigning to type ‘int’ from type ‘kgid_t’pOSFSInfo->fsgid = current_fsgid();
于是按照另外的帖子
把rt_linux.c里面报错的那里:
current_fsuid() 跟 current_fsgid()改成:
current_fsuid().val
current_fsgid().val
参考网址
/forum.php?mod=viewthread&tid=4164172
如果还有如下错误:
error: ‘struct net_device’ has no member named ‘wireless_handlers’错误
因为内核在编译的时候CONFIG_WIRELESS_EXT这个选项没有选择,选择该选项后重新编译内核镜像或者模块即可修正该错误。
参考:/linux/all/203517/
再make,应该没有错误了。
编译完成后,会在os/linux/目录下出现mt7601Usta.ko文件
rd@rd-virtual-machine:~/sda3/mt7601/DPO_MT7601U_LinuxSTA_3.0.0.4_0913$ ls -alth os/linux/mt7601Usta.ko-rw-r--r-- 1 root root 12M 6月 29 15:05 os/linux/mt7601Usta.ko
发现太大了,这是使用指定的交叉编译工具如:
arm-none-linux-gnueabi-strip -S os/linux/mt7601Usta.ko就小多le。
rd@rd-virtual-machine:~/sda3/mt7601/DPO_MT7601U_LinuxSTA_3.0.0.4_0913$ ls -alth os/linux/mt7601Usta.ko-rw-r--r-- 1 rd rd 954K 6月 29 15:17 os/linux/mt7601Usta.ko
至此编译完成。
将编译好的驱动放置开发板中。
insmod mt7601Usta.ko
出现Unknown symbol skb_push等错误
修改如下:
上面有关于cfg80211报错说明是cfg80211的内核相关配置没有配置上
如下配置: — Networking support
-*- Wireless ---><*> cfg80211 - wireless configuration API <*> Generic IEEE 802.11 Networking Stack (mac80211)
上面有关于usb方面的错误应该配置usb驱动
<*> Support for Host-side USB<*> USB Monitor <*> USB Wireless Device Management support
注意另一篇文章提到的内核匹配的问题,主要是编译内核时候,内核相应做了改变,这时候驱动也需要重新进行编译。切记!!!
参考:
/jzzjsy/article/details/12440519
重新编译移植后:
insmod mt7601Usta.ko [ 14.962494] rtusb init rt2870 --->[ 14.966209] usbcore: registered new interface driver rt2870
总算没有错误了。但出现没有识别到wlan0的情况。
修改common/rtusb_dev_id.c文件。添加支持此无线网卡的ID。
{USB_DEVICE(0x148f,0x760b)},/* 360 Wifi 2 Gen
参考网址:
/question/1513867760733910940.html
然后:
insmod 模块
# insmod home/mt7601Usta.ko [ 31.222925] rtusb init rt2870 --->[ 31.226409] ===>rt2870_probe()![ 31.229549] --> RTMPAllocAdapterBlock[ 31.234475] [ 31.234482] [ 31.234489] === pAd = c57de000, size = 845688 ===[ 31.234499] [ 31.243671] --> RTMPAllocTxRxRingMemory[ 31.249336] <-- RTMPAllocTxRxRingMemory, Status=0[ 31.254994] <-- RTMPAllocAdapterBlock, Status=0[ 31.259526] NumEndpoints=8[ 31.262261] BULK IN MaxPacketSize = 512[ 31.266093] EP address = 0x84[ 31.269052] BULK IN MaxPacketSize = 512[ 31.272913] EP address = 0x85[ 31.275877] BULK OUT MaxPacketSize = 512[ 31.279799] EP address = 0x 8 [ 31.282963] BULK OUT MaxPacketSize = 512[ 31.286882] EP address = 0x 4 [ 31.290019] BULK OUT MaxPacketSize = 512[ 31.293968] EP address = 0x 5 [ 31.297108] BULK OUT MaxPacketSize = 512[ 31.301062] EP address = 0x 6 [ 31.304203] BULK OUT MaxPacketSize = 512[ 31.308123] EP address = 0x 7 [ 31.311288] BULK OUT MaxPacketSize = 512[ 31.315207] EP address = 0x 9 [ 31.318347] RTMP_COM_IoctlHandle():pAd->BulkOutEpAddr=0x8[ 31.323779] RTMP_COM_IoctlHandle():pAd->BulkOutEpAddr=0x4[ 31.329178] RTMP_COM_IoctlHandle():pAd->BulkOutEpAddr=0x5[ 31.334606] RTMP_COM_IoctlHandle():pAd->BulkOutEpAddr=0x6[ 31.340008] RTMP_COM_IoctlHandle():pAd->BulkOutEpAddr=0x7[ 31.345439] RTMP_COM_IoctlHandle():pAd->BulkOutEpAddr=0x9[ 31.350873] STA Driver version-3.0.0.3[ 31.354993] -->MT7601_Init():[ 31.358124] Chip specific bbpRegTbSize=0![ 31.362170] Chip VCO calibration mode = 0![ 31.366491] NVM is EFUSE[ 31.369019] Efuse Size=0x1d [Range:1e0-1fc] [ 31.373329] Endpoint(8) is for In-band Command[ 31.377768] Endpoint(4) is for WMM0 AC0[ 31.381643] Endpoint(5) is for WMM0 AC1[ 31.385476] Endpoint(6) is for WMM0 AC2[ 31.389316] Endpoint(7) is for WMM0 AC3[ 31.393180] Endpoint(9) is for WMM1 AC0[ 31.397012] Endpoint(84) is for Data-In[ 31.400882] Endpoint(85) is for Command Rsp[ 31.405063] Allocate a net device with private data size=0![ 31.410671] The name of the new ra interface is ra0...[ 31.415813] RtmpOSNetDevAttach()--->[ 31.419968] <---RtmpOSNetDevAttach(), ret=0[ 31.424206] <===rt2870_probe()![ 31.427564] usbcore: registered new interface driver rt2870# ifconfig -aeth0Link encap:Ethernet HWaddr 66:55:44:33:22:10 BROADCAST MULTICAST MTU:1500 Metric:1RX packets:0 errors:0 dropped:0 overruns:0 frame:0TX packets:0 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)Interrupt:22 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0UP LOOPBACK RUNNING MTU:16436 Metric:1RX packets:0 errors:0 dropped:0 overruns:0 frame:0TX packets:0 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)ra0 Link encap:Ethernet HWaddr 00:00:00:00:00:00 BROADCAST MULTICAST MTU:1500 Metric:1RX packets:0 errors:0 dropped:0 overruns:0 frame:0TX packets:0 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
识别到了网卡。
接下来:
ifconfig ra0 up/u013286409/article/details/49025679[ 259.973609] <---RTUSBCmdThread[ 259.976688] Terminate the task(RtmpTimerTask) with pid(356)![ 259.982396] <---RtmpTimerQThread[ 260.015738] !!! rt28xx init fail !!![ 260.019313] rt28xx_open return fail!ifconfig: SIOCSIFFLAGS: Operation not permitted
启动网卡时出现错误。
解决办法将将.dat文件拷贝
sudo mkdir -p 4310_root_release/etc/Wireless/RT2870STA/sudo cp -p ../mt7601/mt7601_4/RT2870STA.dat 4310_root_release/etc/Wireless/RT2870STA/
继续做如下:
insmod home/mt7601Usta.ko
ifconfig ra0 up
iwlist ra0 scanning 无线AP热点扫描。
接下来移植两个工具wireless工具 和wpa工具参考:
wireless工具 :
https://hewlettpackard.github.io/wireless-tools/Tools.html
libiw.so.29动态库被wireless工具所需要 放进/lib文件夹中
wpa工具:
/farsight/article/details/5660878
/haomcu/article/details/7267672
移植成功后:
wpa_passphrase Guest abc26585555 >> /etc/wpa_supplicant.confwpa_supplicant -B -i ra0 -D wext -c /etc/wpa_supplicant.conf
通过iwpriv ra0 connStatus查看连接状态。
ifconfig ra0 192.168.236.88 netmask 255.255.255.0
route add default gw 192.168.236.1
配置网卡信息完成后。
首先关闭本地网卡,再启动wifi网卡
#ifconfig eth0 down (如果非同一ip段,不需要关闭)
ifconfig ra0 up
如果启动网卡后,会不断出现错误:BIRIdx(1): RXDMALen not multiple of 4.[43507], BulkInBufLen = 416)
修改./MODULE/include/iface/rtmp_usb.h问题就能够解决掉。
#define RXBULKAGGRE_SIZE 12 该为8
注:调试过程中可以调整bug等级输出打印信息。os/linux/rt_linux.c:54:ULONG RTDebugLevel = RT_DEBUG_TRACE;
如果在pc上可以直接修改:
Sovled with the form of /etc/network/interfacesauto loiface lo inet loopbackauto wlan0iface wlan0 inet manualwpa-driver nl80211wpa-roam /etc/wpa_supplicant.confiface default inet dhcpReboot,go surfing now.
如果觉得《移植无线网卡驱动至开发板(PXA16x)》对你有帮助,请点赞、收藏,并留下你的观点哦!