Board logo

标题: USB无线网卡的Linux驱动2 [打印本页]

作者: rise_ming    时间: 2013-3-31 09:00     标题: USB无线网卡的Linux驱动2

CC=/usr/local/arm/3.4.1/bin/armlinuxgcc
  修改第15行,设置ar交叉编译器:
AR=/usr/local/arm/3.4.1/bin/armlinuxar
  修改第16行,设置ranlib交叉编译器:
RANLIB=/usr/local/arm/3.4.1/bin/armlinuxranlib
③ 运行make命令。
④ 运行make install命令。可执行文件安装于/usr/local/wireless目录下。
⑤ 拷贝两个库libiw.so和libiw.so.29到文件系统/test/rootfs/lib目录下,运行chmod 777命令后重新生成压缩根文件rootfs.cramfs,并下载到ARM板。
⑥ 将安装目录下的iwconfig、iwlist等下载到目标板。主要使用的命令及功能:
◆ iwconfig,回车,查看所有无线网卡;
◆ iwconfig wlan0,查看wlan0;
◆ iwconfig wlan0 essid "xx",配置网卡SSID为xx;
◆ iwlist wlan0 scan|grep ESSID,搜索周边所有无线网卡的ESSID。

2.6 无线网卡测试

(1) 插入无线网卡,自动安装USB host驱动
[root@(none) tmp]# uname a
Linux(none) 2.6.12h1940 #59 Tue May 3 13:12:53 CST 2011 armv4tl unknown
[root@(none) tmp]# usb 11:new full speed USB device using s3c2410ohci and address 4
usb 11: Product: RTL8188S WLAN Adapter
usb 11: Manufacturer: Manufacturer Realtek
usb 11: SerialNumber: 00e04c000001

(2) 加载模块8712u.ko
  insmod 8712u.ko

(3) 唤醒USB无线网卡驱动
  ifconfig wlan0 up

(4) 搜索周边无线网络
[root@(none) tmp]# iwlist wlan0 scan | grep ESSID
fwdbg: get survey cmd
fwdbg: survey done (00000005, 00000000)
ESSID: "TPLINK_WSW"
ESSID: "TPLINK_717E24"
ESSID: "dlink"
ESSID: "newnav"
ESSID: "dgdz"

(5) 配置wlan0的SSID
  iwconfig wlan essid TPLINK_717E24
  配置成功后利用iwconfig回显:
[root@(none) tmp]# uname a
Linux (none) 2.6.12h1940 #59 Tue May 3 13:12:53 CST 2011 armv4tl unknown
[root@(none) tmp]# iwconfig wlan0
wlan0IEEE 802.11bg ESSID:"TPLINK_717E24"
  Mode: Managed Frequency: 2.437 GHz Access Point: 00:25:86:71:7E:24
  Bit Rate: 54 Mb/s
  Encryption keyff
  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动态分配
  自动申请动态IP:
udhcpc i wlan0
  显示如下信息:
[root@(none) tmp]# uname a
Linux (none) 2.6.12h1940 #59 Tue May 3 13:12:53 CST 2011 armv4tl unknown
[root@(none) tmp]# udhcpc i wlan0
udhcpc (v0.9.9pre) started
udhcpc[490]: udhcpc (v0.9.9pre) 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

  运行ifconfig命令后,显示最终配置:
[root@(none) tmp]# uname a
Linux (none) 2.6.12h1940 #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测试
  ping测试时需要加c参数控制ping次数,否则会一直不停测试,并且无法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
roundtrip min/avg/max=0.7/1.0/1.4 ms

3 讨论

  在USB无线网卡驱动移植过程中,将主要的文件netdevice.h、wireless.h、iw_handler.h、dev.c等进行替换后,内核已经能编译成功。将内核下载并重启开发板后,加载驱动成功,并能利用iwlist搜索到周边的WLAN网络。在利用iwconfig给驱动指定SSID时iwconfig引起内核崩溃。初判原因不应为wirelesstools程序。加入ip.h、icmp.h socket.h等文件后iwconfig指定SSID成功。最后进行ping测试时,出现ping 127.1和本机IP均失败的情况。使用strace跟踪ping执行过程,发现recvfrom()函数参数传递错误,替换neighbour.c af_netlink.c等文件后ping 127.1成功。

  若系统内核升级到Linux 2.6.30,驱动能编译通过,但只要一发出ifconfig命令,内核即崩溃。即使高版本内核在移植时也有问题,这些问题需要进一步研究。




欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) Powered by Discuz! 7.0.0