360WIFI2无线网卡移植 -MT7601U移植
2016-07-25 22:47
1046 查看
软件环境:虚拟机ubuntu12.04
硬件环境:360WIFI2无线网卡
EasyARM-i.MX280A: 64m sdram 128M nandflash 运行官方提供的Linux-2.6.35.3内核linux wpa_supplicant版本0.7.3(官方内核自带)
MT7601U驱动下载:http://download.csdn.net/detail/andylauren/9585949
先说一下为什么我要移植MT7601U,因为上一篇文章移植了一个腾达811M的usb网卡,发现无线网卡使用真是方便,手上还有一个360wifi2,所以就想移植一下,看看是不是一样能用呢。手上弄到一个新的开发板,EasyARM-i.MX280A,这个开发板是ARM9的芯片,但是是最便宜的开发板,之需要99元。后来经过不懈的努力终于成功了!我的360wifi在开发板上正常工作,能够上网,能够挂载nfs,下面就按照我从开始到最终移植的过程说一下,并把我在移植的过程中遇到的问题也说明一下,希望能够对后人有帮助。
首先说一下如何知道360wifi2的网卡芯片是什么才能去下载驱动移植,先把网卡插在ubuntu上,ubuntu不能识别,然后使用lsusb命令查看usb的id
然后第二种方法,一个字,拆,当然先不用真拆,先上网看看有没有人拆解的图片,真的找到了,使用的是MT7601UN芯片。
有了上一个腾达的网卡移植经验这次就简单很多。
然后我们下载MT7601U驱动的源码,下载地址在我这篇博客开始的地方。首先把文件解压到linux目录中,
修改驱动源码根目录下的Makefile
#PLATFORM=PC
PLATFORM=SMDK
ifeq ($(PLATFORM),SMDK)
LINUX_SRC = /home/linux/sys/linux-3.0.1/(内核源码路径,内核需要被编译过)
CROSS_COMPILE = /home/linux/sys/arm-gcc-4.3.2/bin/arm-linux-(交叉编译工具链路径)
endif
默认的驱动是不支持360WIFI2的,可能是360为了只能让360自己的驱动好用特别定制的ID号,所以需要在驱动ID列表中增加360WIFI的ID。
在common目录中的,rtusb_dev_id.c中增加。
在
{USB_DEVICE(0x148f,0x7601)}, /* MT 6370 */
下面加一行
{USB_DEVICE(0x148f,0x760b)}, /* 360 Wifi2 */
这个时候就可以进行make了,生成mt7601Usta.ko。
不知道为什么,这个网卡不需要将bin文件拷贝就可以运行。
需要修改wpa_supplicant的wpa_supplicant.conf文件,这个文件在开发板的/etc/wpa_supplicant.conf路径下。
这里说一下wpa_supplicant
wpa_supplicant主要是用来支持WEP,WPA/WPA2和WAPI无线协议和加密认证的,由于linux本身并不支持WPA的加密,所以需要移植wpa_supplicant来使wifi能够连接WPA加密的无线路由上,简单的说,wpa_supplicant就是WiFi驱动和用户的中转站外加对协议和加密认证的支持。由于ok6410的3.0.1内核已经移植好了wpa_supplicant的0.7.3版本,所以对于wpa_supplicant的移植这里就不做讲解。
接着说wpa_supplicant.conf文件的内容,这里的问题我也是解决了很久。官方给的例程是这样的
ctrl_interface=/var/run/wpa_supplicant
network={
ssid="max" //填写无线网络的的用户名
key_mgmt=WPA-PSK
proto=WPA
pairwise=TKIP
group=TKIP
psk="1234567890" //填写密码
}
我使用这个模板出现了skip WPA IE - PTK cipher mismatch这个问题,在找到路由之后,提示密码错误,后来查看了路由器发现原来密码也有几种加密方式。TKIP和AES两种,上面的写法就是被固定为TKIP方式,TKIP方式的带宽很低,所以现在都采用的是AES方式加密,在wpa_supplicant中AES加密方式对应的是CCMP,也就是需要把TKIP改为CCMP,这个我没有验证过,我使用的是下面的方法,不声明使用的是哪种加密方式,让wpa_supplicant去自适应。
ctrl_interface=/var/run/wpa_supplicant
update_config=1
network={
ssid="mingzi"
key_mgmt=WPA-PSK
psk="mimamimamima"
}
我使用这个配置成功的连接了AES加密方式 的路由器。
然后我们将驱动加载进内核
insmod mt7601Usta.ko
然后可以使用
wpa_supplicant -ira0 -Dwext -c/etc/wpa_supplicant.conf -dd &
wpa_supplicant -ira0 -Dwext -c/etc/wpa_supplicant.conf &
这两条指令中的任意一个,-dd的会输出更过的信息。
在出现
这时候需要禁用有线网卡eth0。如果使用的是nfs挂载的文件系统建议最后禁用有线网卡,因为一旦禁用就没有文件系统了,开发板就没办法操作了。
ifconfig eth0 down
这时候无线网卡还没有ip,可以使用静态分配的方式
ifconfig ra0 192.168.1.20
如果路由器支持动态分配也可以使用动态分配
udhcpc -i ra0
之后会返回
udhcpc (v1.13.3) started
Sending discover...
Sending select for 192.168.1.104...
Lease of 192.168.1.104 obtained, lease time 7200
deleting routers
route: SIOCDELRT: No such process
adding dns 10.10.0.1
adding dns 124.207.160.106
表示分配IP成功,到这里我们的腾达无线网卡就已经可以正常使用了,想做什么都可以,完全和有线是一样的。
但是在2.6的内核下有一个提示一直打印
RtmpUSBNullFrameKickOut - Send NULL Frame @24 Mbps...
这个需要更改printk的打印等级才能更改,如何更改printk的打印等级可以在我的这篇博客中了解http://blog.csdn.net/andylauren/article/details/51504125
下面是我的终端打印信息
其他错误解决:
/os/linux/sta_ioctl.c:2225: error: unknown field 'private' specified in initializer
/os/linux/sta_ioctl.c:2226: error: unknown field 'num_private' specified in initializer
/os/linux/sta_ioctl.c:2228: error: unknown field 'num_private_args' specified in initializer
问题原因:是因为在配置内核的时候,没有选择支持802.11的无线设备驱动。
解决办法:重新配置编译指定的Linux Kernel,make menuconfig
Device Drivers --->
[*] Network device support --->
[*] Wireless LAN --->
<*> IEEE 802.11 for Host AP (Prism2/2.5/3 and WEP/TKIP/CCMP)
重新编译内核,并开发板也要重新下载内核,然后驱动也要重新编译,要保持和编译过的kernel移植,包括编译器版本。
硬件环境:360WIFI2无线网卡
EasyARM-i.MX280A: 64m sdram 128M nandflash 运行官方提供的Linux-2.6.35.3内核linux wpa_supplicant版本0.7.3(官方内核自带)
MT7601U驱动下载:http://download.csdn.net/detail/andylauren/9585949
先说一下为什么我要移植MT7601U,因为上一篇文章移植了一个腾达811M的usb网卡,发现无线网卡使用真是方便,手上还有一个360wifi2,所以就想移植一下,看看是不是一样能用呢。手上弄到一个新的开发板,EasyARM-i.MX280A,这个开发板是ARM9的芯片,但是是最便宜的开发板,之需要99元。后来经过不懈的努力终于成功了!我的360wifi在开发板上正常工作,能够上网,能够挂载nfs,下面就按照我从开始到最终移植的过程说一下,并把我在移植的过程中遇到的问题也说明一下,希望能够对后人有帮助。
首先说一下如何知道360wifi2的网卡芯片是什么才能去下载驱动移植,先把网卡插在ubuntu上,ubuntu不能识别,然后使用lsusb命令查看usb的id
linux@ubuntu:/tftpboot$ lsusb Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 002 Device 002: ID 0e0f:0003 VMware, Inc. Virtual Mouse Bus 002 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub Bus 001 Device 002: ID 0930:6545 Toshiba Corp. Kingston DataTraveler 102 Flash Drive / HEMA Flash Drive 2 GB / PNY Attache 4GB Stick Bus 001 Device 003: ID 148f:760b Ralink Technology, Corp.其中148f:760b就是360wifi2的ID,然后根据这个ID去网上搜是哪个网卡,但是万万没想到,没有搜到。
然后第二种方法,一个字,拆,当然先不用真拆,先上网看看有没有人拆解的图片,真的找到了,使用的是MT7601UN芯片。
有了上一个腾达的网卡移植经验这次就简单很多。
然后我们下载MT7601U驱动的源码,下载地址在我这篇博客开始的地方。首先把文件解压到linux目录中,
修改驱动源码根目录下的Makefile
#PLATFORM=PC
PLATFORM=SMDK
ifeq ($(PLATFORM),SMDK)
LINUX_SRC = /home/linux/sys/linux-3.0.1/(内核源码路径,内核需要被编译过)
CROSS_COMPILE = /home/linux/sys/arm-gcc-4.3.2/bin/arm-linux-(交叉编译工具链路径)
endif
默认的驱动是不支持360WIFI2的,可能是360为了只能让360自己的驱动好用特别定制的ID号,所以需要在驱动ID列表中增加360WIFI的ID。
在common目录中的,rtusb_dev_id.c中增加。
在
{USB_DEVICE(0x148f,0x7601)}, /* MT 6370 */
下面加一行
{USB_DEVICE(0x148f,0x760b)}, /* 360 Wifi2 */
这个时候就可以进行make了,生成mt7601Usta.ko。
不知道为什么,这个网卡不需要将bin文件拷贝就可以运行。
需要修改wpa_supplicant的wpa_supplicant.conf文件,这个文件在开发板的/etc/wpa_supplicant.conf路径下。
这里说一下wpa_supplicant
wpa_supplicant主要是用来支持WEP,WPA/WPA2和WAPI无线协议和加密认证的,由于linux本身并不支持WPA的加密,所以需要移植wpa_supplicant来使wifi能够连接WPA加密的无线路由上,简单的说,wpa_supplicant就是WiFi驱动和用户的中转站外加对协议和加密认证的支持。由于ok6410的3.0.1内核已经移植好了wpa_supplicant的0.7.3版本,所以对于wpa_supplicant的移植这里就不做讲解。
接着说wpa_supplicant.conf文件的内容,这里的问题我也是解决了很久。官方给的例程是这样的
ctrl_interface=/var/run/wpa_supplicant
network={
ssid="max" //填写无线网络的的用户名
key_mgmt=WPA-PSK
proto=WPA
pairwise=TKIP
group=TKIP
psk="1234567890" //填写密码
}
我使用这个模板出现了skip WPA IE - PTK cipher mismatch这个问题,在找到路由之后,提示密码错误,后来查看了路由器发现原来密码也有几种加密方式。TKIP和AES两种,上面的写法就是被固定为TKIP方式,TKIP方式的带宽很低,所以现在都采用的是AES方式加密,在wpa_supplicant中AES加密方式对应的是CCMP,也就是需要把TKIP改为CCMP,这个我没有验证过,我使用的是下面的方法,不声明使用的是哪种加密方式,让wpa_supplicant去自适应。
ctrl_interface=/var/run/wpa_supplicant
update_config=1
network={
ssid="mingzi"
key_mgmt=WPA-PSK
psk="mimamimamima"
}
我使用这个配置成功的连接了AES加密方式 的路由器。
然后我们将驱动加载进内核
insmod mt7601Usta.ko
然后可以使用
wpa_supplicant -ira0 -Dwext -c/etc/wpa_supplicant.conf -dd &
wpa_supplicant -ira0 -Dwext -c/etc/wpa_supplicant.conf &
这两条指令中的任意一个,-dd的会输出更过的信息。
在出现
root@EasyARM-iMX28x /# insmod mt7601Usta.ko rtusb init rt2870 ---> usbcore: registered new interface driver rt2870 root@EasyARM-iMX28x /# usb 1-1: new high speed USB device using fsl-ehci and address 2 usb 1-1: device v148f p760b is not supported ===>rt2870_probe()! --> RTMPAllocAdapterBlock === pAd = c4a44000, size = 841592 === --> RTMPAllocTxRxRingMemory <-- RTMPAllocTxRxRingMemory, Status=0 <-- RTMPAllocAdapterBlock, Status=0 NumEndpoints=8 BULK IN MaxPacketSize = 512 EP address = 0x84 BULK IN MaxPacketSize = 512 EP address = 0x85 BULK OUT MaxPacketSize = 512 EP address = 0x 8 BULK OUT MaxPacketSize = 512 EP address = 0x 4 BULK OUT MaxPacketSize = 512 EP address = 0x 5 BULK OUT MaxPacketSize = 512 EP address = 0x 6 BULK OUT MaxPacketSize = 512 EP address = 0x 7 BULK OUT MaxPacketSize = 512 EP address = 0x 9 RTMP_COM_IoctlHandle():pAd->BulkOutEpAddr=0x8 RTMP_COM_IoctlHandle():pAd->BulkOutEpAddr=0x4 RTMP_COM_IoctlHandle():pAd->BulkOutEpAddr=0x5 RTMP_COM_IoctlHandle():pAd->BulkOutEpAddr=0x6 RTMP_COM_IoctlHandle():pAd->BulkOutEpAddr=0x7 RTMP_COM_IoctlHandle():pAd->BulkOutEpAddr=0x9 STA Driver version-3.0.0.3 -->MT7601_Init(): Chip specific bbpRegTbSize=0! Chip VCO calibration mode = 0! NVM is EFUSE Efuse Size=0x1d [Range:1e0-1fc] Endpoint(8) is for In-band Command Endpoint(4) is for WMM0 AC0 Endpoint(5) is for WMM0 AC1 Endpoint(6) is for WMM0 AC2 Endpoint(7) is for WMM0 AC3 Endpoint(9) is for WMM1 AC0 Endpoint(84) is for Data-In Endpoint(85) is for Command Rsp Allocate a net device with private data size=0! Allocate net device ops success! The name of the new ra interface is ra0... RtmpOSNetDevAttach()---> <---RtmpOSNetDevAttach(), ret=0 <===rt2870_probe()! RtmpUSBNullFrameKickOut - Send NULL Frame @24 Mbps...
这时候需要禁用有线网卡eth0。如果使用的是nfs挂载的文件系统建议最后禁用有线网卡,因为一旦禁用就没有文件系统了,开发板就没办法操作了。
ifconfig eth0 down
这时候无线网卡还没有ip,可以使用静态分配的方式
ifconfig ra0 192.168.1.20
如果路由器支持动态分配也可以使用动态分配
udhcpc -i ra0
之后会返回
udhcpc (v1.13.3) started
Sending discover...
Sending select for 192.168.1.104...
Lease of 192.168.1.104 obtained, lease time 7200
deleting routers
route: SIOCDELRT: No such process
adding dns 10.10.0.1
adding dns 124.207.160.106
表示分配IP成功,到这里我们的腾达无线网卡就已经可以正常使用了,想做什么都可以,完全和有线是一样的。
但是在2.6的内核下有一个提示一直打印
RtmpUSBNullFrameKickOut - Send NULL Frame @24 Mbps...
这个需要更改printk的打印等级才能更改,如何更改printk的打印等级可以在我的这篇博客中了解http://blog.csdn.net/andylauren/article/details/51504125
下面是我的终端打印信息
root@EasyARM-iMX28x /# ifconfig lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:2 errors:0 dropped:0 overruns:0 frame:0 TX packets:2 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:272 (272.0 B) TX bytes:272 (272.0 B) ra0 Link encap:Ethernet HWaddr 00:87:46:0E:2B:D7 inet addr:192.168.1.106 Bcast:192.168.1.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:3498 errors:0 dropped:0 overruns:0 frame:0 TX packets:84 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:846648 (826.8 KiB) TX bytes:16798 (16.4 KiB) root@EasyARM-iMX28x /# RtmpUSBNullFrameKickOut - Send NULL Frame @24 Mbps... root@EasyARM-iMX28x /# root@EasyARM-iMX28x /# root@EasyARM-iMX28x /# RtmpUSBNullFrameKickOut - Send NULL Frame @24 Mbps... RtmpUSBNullFrameKickOut - Send NULL Frame @24 Mbps... root@EasyARM-iMX28x /# root@EasyARM-iMX28x /# pRtmpUSBNullFrameKickOut - Send NULL Frame @24 Mbps... ing 192.168.1.1 PING 192.168.1.1 (192.168.1.1): 56 data bytes 64 bytes from 192.168.1.1: seq=0 ttl=64 time=2.032 ms 64 bytes from 192.168.1.1: seq=1 ttl=64 time=1.188 ms 64 bytes from 192.168.1.1: seq=2 ttl=64 time=1.156 ms 64 bytes from 192.168.1.1: seq=3 ttl=64 time=7.906 ms 64 bytes from 192.168.1.1: seq=4 ttl=64 time=2.656 ms 64 bytes from 192.168.1.1: seq=5 ttl=64 time=2.125 ms RtmpUSBNullFrameKickOut - Send NULL Frame @24 Mbps... 64 bytes from 192.168.1.1: seq=6 ttl=64 time=3.375 ms 64 bytes from 192.168.1.1: seq=7 ttl=64 time=1.594 ms 64 bytes from 192.168.1.1: seq=8 ttl=64 time=1.188 ms 64 bytes from 192.168.1.1: seq=9 ttl=64 time=1.125 ms 64 bytes from 192.168.1.1: seq=10 ttl=64 time=1.188 ms 64 bytes from 192.168.1.1: seq=11 ttl=64 time=1.531 ms 64 bytes from 192.168.1.1: seq=12 ttl=64 time=241.937 ms 64 bytes from 192.168.1.1: seq=13 ttl=64 time=1.125 ms 64 bytes from 192.168.1.1: seq=14 ttl=64 time=1.094 ms 64 bytes from 192.168.1.1: seq=15 ttl=64 time=1.156 ms RtmpUSBNullFrameKickOut - Send NULL Frame @24 Mbps... 64 bytes from 192.168.1.1: seq=16 ttl=64 time=1.156 ms --- 192.168.1.1 ping statistics --- 17 packets transmitted, 17 packets received, 0% packet loss round-trip min/avg/max = 1.094/16.090/241.937 ms到这里就结束了,下载再提供一个开机自启动的脚本文件
#!/bin/sh insmod mt7601Usta.ko&&wpa_supplicant -ira0 -Dwext -c/etc/wpa_supplicant.conf & sleep 40&&udhcpc -i ra0&&ifconfig eth0 down这个脚本是在最后才关闭有线网卡,所以即使使用nfs挂载根文件系统也可以。其中有一个sleep 40是等待无线驱动加载和无线网卡连接路由的时间,这个需要根据自己的实际情况去更改。
其他错误解决:
/os/linux/sta_ioctl.c:2225: error: unknown field 'private' specified in initializer
/os/linux/sta_ioctl.c:2226: error: unknown field 'num_private' specified in initializer
/os/linux/sta_ioctl.c:2228: error: unknown field 'num_private_args' specified in initializer
问题原因:是因为在配置内核的时候,没有选择支持802.11的无线设备驱动。
解决办法:重新配置编译指定的Linux Kernel,make menuconfig
Device Drivers --->
[*] Network device support --->
[*] Wireless LAN --->
<*> IEEE 802.11 for Host AP (Prism2/2.5/3 and WEP/TKIP/CCMP)
重新编译内核,并开发板也要重新下载内核,然后驱动也要重新编译,要保持和编译过的kernel移植,包括编译器版本。
相关文章推荐
- 360.狗改不了吃屎?
- 每日安全资讯:360 浏览器批准 Google 六项入根申请
- 网信办约谈360doc个人图书馆限期整改
- 如何解决双网卡冲突
- 无线网卡安装DIY
- 网卡安装常见问题精解
- 用双网卡实现三机互联
- 批处理获取网卡名称的代码(附修改IP、网关、DNS脚本)
- vbs Windows系统改变或修改网卡的MAC地址的脚本与软件第1/2页
- JScript中调用ActiveX获取访客网卡MAC地址实现代码
- 提高10/100M网卡传输速率的设置方法
- freebsd网卡安装与dhcp配置方法
- 把jQuery的each(callback)方法移植到c#中
- IIS 服务器的备份和移植技巧
- python实现360皮肤按钮控件示例
- python和pyqt实现360的CLable控件
- 360通用php防护代码(使用操作详解)
- 360浏览器文本框获得焦点后被android软键盘遮罩该怎么办
- 解析libcurl在android下的移植、编译与测试
- Python脚本实现网卡流量监控