转载链接:http://blog.csdn.net/sdecat/article/details/7514576
随着88W8686芯片的停产,原来产品的sdio wifi模块需要考虑更新换代了,88w8787是marvell目前力推的wifi、蓝牙和FM三合一的模块,无论是功能、性能、功耗还是CPU占用率都是8686望尘莫及的。为了方便方案验证,这边先做了块通用SDIO接口的8787网卡。由于8787芯片还算比较新,linux的驱动配套支持方面远远没有之前8686的方便。查看了一下linux的内核源码,发现8787的驱动是从linux-3.0版本才开始正式合入内核主线版本的,不巧我的FLX6410板子的内核版本还只停留在2.6.38这个久经考验的稳定版本当中,一时半会还不想升级到3.0以上的内核版本当中,咋办呢?硬着头皮把3.0以上的8787驱动移植到2.6.38内核,郁闷,由于新内核cfg802.11的接口改动太多,最终无功而返。花了几天时间上网放狗搜索,终于找到了希望,原来这个世界上已经存在了一个大名鼎鼎的wireless backport项目,他的名字叫compat-wireless,真是相见恨晚呀!
说起compat-wrieless,他的本事可大呢,目前已经能把最新内核当中包含的wireless驱动和蓝牙驱动搬到2.6.24及以上的内核当中使用,对于想使用新的wifi和蓝牙设备又不能或者不想升级内核的兄弟来说,那无疑是个莫大的福音。
闲话少说,直切正题。要使用compat-wireless,首先得到compat-wireless的网站上下载个stable版本的compat-wireless,这里选了3.2.5-1的版本。接着解压,查看README文件,发现这个世界原来可以这么简单!对于FLX6410这个可以自己给自己原生编译内核的ARM11平台,要做的就是在compat-wireless的源码目录下执行make && make install 然后就是等着编译和安装完成。新的驱动程序会全部安装到/lib/modules/2.6.38.2/updates目录当中。然后重启系统,插入8787网卡,出现如下打印:
root@ArmCat:~# uname -a
Linux ArmCat 2.6.38.2 #203 PREEMPT Wed Apr 18 21:03:43 HKT 2012 armv6l GNU/Linux
root@ArmCat:~# mmc0: new high speed SDIO card at address 0001
bus: 'mmc': driver_probe_device: matched device mmc0:0001 with driver mmcblk
bus: 'sdio': add driver btmrvl_sdio
bus: 'sdio': driver_probe_device: matched device mmc0:0001:2 with driver btmrvlo
Bluetooth: vendor=0x2df, device=0x911a, class=255, fn=2
Registering platform device 'regulatory.0'. Parent at platform
Succeed!
cfg80211: Calling CRDA to update world regulatory domain
bus: 'sdio': add driver mwifiex_sdio
bus: 'sdio': driver_probe_device: matched device mmc0:0001:1 with driver mwifieo
mwifiex_sdio mmc0:0001:1: WLAN FW already running! Skip FW download
mwifiex_sdio mmc0:0001:1: WLAN FW is active
mwifiex_sdio mmc0:0001:1: driver_version = mwifiex 1.0 (14.57.5.p44)
用iwconfig 命令查看一下:
root@ArmCat:~# iwconfig
lo no wireless extensions.
eth0 no wireless extensions.
mlan0 IEEE 802.11bgn ESSID:off/any
Mode:Managed Access Point: Not-Associated
Retry long limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:on
root@ArmCat:~#
呵呵,8787的网卡设备已经出来,就是mlan0了。 接入AP试试:
root@ArmCat:~# ifup mlan0
Internet Systems Consortium DHCP Client 4.1.1-P1
Copyright 2004-2010 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/mlan0/cc:52:af:d6:1c:39
Sending on LPF/mlan0/cc:52:af:d6:1c:39
Sending on Socket/fallback
DHCPDISCOVER on mlan0 to 255.255.255.255 port 67 interval 7
cfg80211: Calling CRDA for country: CN
DHCPDISCOVER on mlan0 to 255.255.255.255 port 67 interval 20
cfg80211: Calling CRDA to update world regulatory domain
cfg80211: Calling CRDA to update world regulatory domain
DHCPDISCOVER on mlan0 to 255.255.255.255 port 67 interval 10
cfg80211: Calling CRDA for country: CN
DHCPDISCOVER on mlan0 to 255.255.255.255 port 67 interval 13
cfg80211: Calling CRDA to update world regulatory domain
DHCPDISCOVER on mlan0 to 255.255.255.255 port 67 interval 11
DHCPOFFER from 192.168.1.1
DHCPREQUEST on mlan0 to 255.255.255.255 port 67
DHCPACK from 192.168.1.1
bound to 192.168.1.32 -- renewal in 33915 seconds.
root@ArmCat:~# iwconfig
lo no wireless extensions.
eth0 no wireless extensions.
mlan0 IEEE 802.11bgn ESSID:"wireless"
Mode:Managed Frequency:2.437 GHz Access Point: 30:87:30:DB:FC:5D
Bit Rate=18 Mb/s
Retry long limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:on
Link Quality=23/70 Signal level=-87 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
root@ArmCat:~# ifconfig
eth0 Link encap:Ethernet HWaddr 00:22:12:34:56:90
inet addr:192.168.111.35 Bcast:192.168.111.255 Mask:255.255.255.0
inet6 addr: fe80::222:12ff:fe34:5690/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:281 errors:0 dropped:0 overruns:0 frame:0
TX packets:277 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:27119 (26.4 KiB) TX bytes:39541 (38.6 KiB)
Interrupt:111 Base address:0xa000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:560 (560.0 B) TX bytes:560 (560.0 B)
mlan0 Link encap:Ethernet HWaddr cc:52:af:d6:1c:39
inet addr:192.168.1.32 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::ce52:afff:fed6:1c39/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:17 errors:0 dropped:0 overruns:0 frame:0
TX packets:30 errors:16 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3504 (3.4 KiB) TX bytes:6165 (6.0 KiB)
自动获取IP成功,mlan0的IP为192.168.1.32。 ping测试一下看看:
root@ArmCat:~# ping 192.168.1.1 -s 1400
PING 192.168.1.1 (192.168.1.1) 1400(1428) bytes of data.
1408 bytes from 192.168.1.1: icmp_req=1 ttl=64 time=9.36 ms
1408 bytes from 192.168.1.1: icmp_req=2 ttl=64 time=12.3 ms
1408 bytes from 192.168.1.1: icmp_req=3 ttl=64 time=20.0 ms
1408 bytes from 192.168.1.1: icmp_req=4 ttl=64 time=18.3 ms
1408 bytes from 192.168.1.1: icmp_req=5 ttl=64 time=18.4 ms
1408 bytes from 192.168.1.1: icmp_req=6 ttl=64 time=20.0 ms
1408 bytes from 192.168.1.1: icmp_req=7 ttl=64 time=21.5 ms
1408 bytes from 192.168.1.1: icmp_req=8 ttl=64 time=18.5 ms
1408 bytes from 192.168.1.1: icmp_req=9 ttl=64 time=12.5 ms
1408 bytes from 192.168.1.1: icmp_req=10 ttl=64 time=12.8 ms
^C
--- 192.168.1.1 ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 9023ms
rtt min/avg/max/mdev = 9.367/16.414/21.576/3.977 ms
Bingo,8787的wifi驱动到此搞定!蓝牙呢? 用hciconfig命令看看:
root@ArmCat:~# hciconfig -a
hci0: Type: BR/EDR Bus: SDIO
BD Address: CC:52:AF:D6:1C:3A ACL MTU: 1021:7 SCO MTU: 120:6
UP RUNNING PSCAN
RX bytes:1365 acl:0 sco:0 events:35 errors:0
TX bytes:1494 acl:0 sco:0 commands:34 errors:0
Features: 0xff 0xee 0x8f 0xfe 0x9b 0xff 0x79 0x87
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV3
Link policy:
Link mode: SLAVE ACCEPT
Name: 'ArmCat-0'
Class: 0x4a0100
Service Classes: Networking, Capturing, Telephony
Device Class: Computer, Uncategorized
HCI Version: 2.1 (0x4) Revision: 0x8300
LMP Version: 2.1 (0x5) Subversion: 0x810
Manufacturer: Marvell Technology Group Ltd. (72)
蓝牙的hci0接口也正常出来了,接下来扫描一下附近的蓝牙设备看看:
root@ArmCat:~# hcitool scan
Scanning ...
00:19:63:4B:7B:FC m600i
root@ArmCat:~#
哈哈,蓝牙驱动也OK了,大功告成!
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
调试总结:
1、compat-wireless这个伟大的工程将在旧内核上使用新的无线设备变成了可能;
2、原生编译确实是个好东西,能把很多复杂的编译问题简单化,或者说能把本来简单却又被交叉编译搞复杂的问题恢复到原来简单的面目;
3、对于大部分不具备原生编译条件的6410板子,只能通过修改Makefile之类的一步步探索如何进行交叉编译compat-wireless了,后续摸索成功后将总结出在X86上给6410交叉编译compat-wireless的方法说明。