USB無(wú)線網(wǎng)卡的Linux驅(qū)動(dòng)移植
⑥ 將安裝目錄下的iwconfig、iwlist等下載到目標(biāo)板。主要使用的命令及功能:
◆ iwconfig,回車,查看所有無(wú)線網(wǎng)卡;
◆ iwconfig wlan0,查看wlan0;
◆ iwconfig wlan0 essid xx,配置網(wǎng)卡SSID為xx;
◆ iwlist wlan0 scan|grep ESSID,搜索周邊所有無(wú)線網(wǎng)卡的ESSID。
2.6 無(wú)線網(wǎng)卡測(cè)試
(1) 插入無(wú)線網(wǎng)卡,自動(dòng)安裝USB host驅(qū)動(dòng)
[root@(none) tmp]# uname a
Linux(none) 2.6.12h1940 #59 Tue May 3 13:12:53 CST 2011 armv4tl unknown
[root@(none) tmp]# usb 11:new full speed USB device using s3c2410ohci and address 4
usb 11: Product: RTL8188S WLAN Adapter
usb 11: Manufacturer: Manufacturer Realtek
usb 11: SerialNumber: 00e04c000001
(2) 加載模塊8712u.ko
insmod 8712u.ko
(3) 喚醒USB無(wú)線網(wǎng)卡驅(qū)動(dòng)
ifconfig wlan0 up
(4) 搜索周邊無(wú)線網(wǎng)絡(luò)
[root@(none) tmp]# iwlist wlan0 scan | grep ESSID
fwdbg: get survey cmd
fwdbg: survey done (00000005, 00000000)
ESSID: TPLINK_WSW
ESSID: TPLINK_717E24
ESSID: dlink
ESSID: newnav
ESSID: dgdz
(5) 配置wlan0的SSID
iwconfig wlan essid TPLINK_717E24
配置成功后利用iwconfig回顯:
[root@(none) tmp]# uname a
Linux (none) 2.6.12h1940 #59 Tue May 3 13:12:53 CST 2011 armv4tl unknown
[root@(none) tmp]# iwconfig wlan0
wlan0IEEE 802.11bg ESSID:TPLINK_717E24
Mode: Managed Frequency: 2.437 GHz Access Point: 00:25:86:71:7E:24
Bit Rate: 54 Mb/s
Encryption key:off
Power Management: off
Link Quality=52/100 Signal level=52/100 Noise level=0/100
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
(6) IP動(dòng)態(tài)分配
自動(dòng)申請(qǐng)動(dòng)態(tài)IP:
udhcpc i wlan0
顯示如下信息:
[root@(none) tmp]# uname a
Linux (none) 2.6.12h1940 #59 Tue May 3 13:12:53 CST 2011 armv4tl unknown
[root@(none) tmp]# udhcpc i wlan0
udhcpc (v0.9.9pre) started
udhcpc[490]: udhcpc (v0.9.9pre) started
Sending discover...
udhcpc[490]: Sending discover...
Sending select for 172.16.51.9...
udhcpc[490]: Sending select for 172.16.51.9...
Lease of 172.16.51.9 obtained, lease time 691200
udhcpc[490]: Lease of 172.16.51.9 obtained, lease time 691200
deleting routers
route: SIOC[ADD|DEL]RT: No such process
adding dns 61.153.216.99
adding dns 61.153.216.104
運(yùn)行ifconfig命令后,顯示最終配置:
[root@(none) tmp]# uname a
Linux (none) 2.6.12h1940 #59 Tue May 3 13:12:53 CST 2011 armv4tl unknown
[root@(none) tmp]# ifconfig wlan0
wlan0 Line encap: Ethernet HWaddr 00:0F:10:54:0E:1B
inet addr: 172.16.51.9 Bcast:172.16.255.255 Mask: 255.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:618 errors:0 dropped:0 overruns:0 frame:0
TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
(7) ping測(cè)試
ping測(cè)試時(shí)需要加c參數(shù)控制ping次數(shù),否則會(huì)一直不停測(cè)試,并且無(wú)法kill。
[root@(none) tmp]# ping c 2 172.16.51.9
PING 172.16.51.9 (172.16.51.9): 56 data bytes
64 bytes from 172.16.51.9: icmp_seq=0 ttl=64 time=1.4 ms
64 bytes from 172.16.51.9: icmp_seq=1 ttl=64 time=0.7 ms
---172.16.51.9 ping statistics 勃勃
2 packets transmitted, 2 packets received, 0% packet loss
roundtrip min/avg/max=0.7/1.0/1.4 ms
3 討論
在USB無(wú)線網(wǎng)卡驅(qū)動(dòng)移植過(guò)程中,將主要的文件netdevice.h、wireless.h、iw_handler.h、dev.c等進(jìn)行替換后,內(nèi)核已經(jīng)能編譯成功。將內(nèi)核下載并重啟開發(fā)板后,加載驅(qū)動(dòng)成功,并能利用iwlist搜索到周邊的WLAN網(wǎng)絡(luò)。在利用iwconfig給驅(qū)動(dòng)指定SSID時(shí)iwconfig引起內(nèi)核崩潰。初判原因不應(yīng)為wirelesstools程序。加入ip.h、icmp.h socket.h等文件后iwconfig指定SSID成功。最后進(jìn)行ping測(cè)試時(shí),出現(xiàn)ping 127.1和本機(jī)IP均失敗的情況。使用strace跟蹤ping執(zhí)行過(guò)程,發(fā)現(xiàn)recvfrom()函數(shù)參數(shù)傳遞錯(cuò)誤,替換neighbour.c af_netlink.c等文件后ping 127.1成功。
若系統(tǒng)內(nèi)核升級(jí)到Linux 2.6.30,驅(qū)動(dòng)能編譯通過(guò),但只要一發(fā)出ifconfig命令,內(nèi)核即崩潰。即使高版本內(nèi)核在移植時(shí)也有問(wèn)題,這些問(wèn)題需要進(jìn)一步研究。
linux相關(guān)文章:linux教程
評(píng)論