全部博文(610)
分类:
2012-09-24 11:44:52
原文地址:Linux下的WIFI驱动RT3070的编译移植 作者:pengtgimust
Wi-Fi Linux驱动移植
软硬件平台如下:
开发板:FL2440, Linux内核版本-2.6.12
宿主机:ASUS PC, redhat 9.0
网卡:雷凌 Ralink rt3070 v1.0
驱动源码:2009_0525_RT3070_Linux_STA_v2.1.1.0
交叉编译器:arm-linux-gcc 3.4.1
1、雷凌官网下载源码。
2、解压驱动源码。
#tar jxvf 2009_0525_RT3070_Linux_STA_v2.1.1.0.bz2
3、/usr/src/2009_0525_RT3070_Linux_STA_v2.1.1.0/os/linux 中的config.mk文件需要修改如下:
#cd /os/linux/
#vi config.mk
HAS_WPA_SUPPLICANT=y
#endif // WPA_SUPPLICANT_SUPPORT //
#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
# Support Native WpaSupplicant for Network Maganger
HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=n
4、去掉 os/linux/config.mk 中的 -Wpointer-sign 标志,可能是编译器不支持
5、linux内核的makefile需要修改:export KBUILD_BUILDHOST := $(SUBARCH)
ARCH ?= arm
CROSS_COMPILE ?=/usr/src/local/arm/3.4.1/bin/arm-linux-
中CROSS_COMPILE ?=/usr/src/local/arm/3.4.1/bin/arm-linux-
改为:
CROSS_COMPILE ?=/usr/src/usr/local/arm/3.4.1/bin/arm-linux-
6、/usr/src/2009_0525_RT3070_Linux_STA_v2.1.1.0中的Makefile中所要修改如下:
#PLATFORM: Target platform
PLATFORM = PC 目标平台选择PC
ifeq ($(PLATFORM),PC)
# Linux 2.6
LINUX_SRC = /usr/src/linux-2.6.12 内核源所在位置
# Linux 2.4 Change to your local setting
#LINUX_SRC = /usr/src/linux-2.4
LINUX_SRC_MODULE=/lib/modules/$(shelluname-r)/kernel/drivers/net/wireless/
CROSS_COMPILE= /usr/src/usr/local/arm/3.4.1/bin/arm-linux- 交叉编译器所在的位置
Endif
7、make。
#cd 2009_0525_RT3070_Linux_STA_v2.1.1.0
#make通过,在2011_0107_RT3070_RT3370_Linux_STA_v2.5.0.1_DPO/os/linux目录下生成了rt3070sta.ko,也就是RT3070的驱动了
8、把驱动和相关文件拷到板子上相应目录下,注意这里对 RT2870STA.dat 要用 dos2unix 先转一下。
#dos2unix RT2870STA/RT2870STA.dat
把RT2870STA.dat拷贝到/etc/Wireless/RT2870STA目录下
#chmod +x /etc/Wireless/RT2870STA/RT2870STA.dat
把rt2870.bin usb固件拷贝到 /lib/firmware 此路径有严格要求
#cp common/rt2870.bin /lib/firmware/
把rt3070sta.ko拷贝到目标系统的 /usr/ 目录下
#cp rt3070sta.ko /usr/
9、挂载驱动:insmod /usr/rt3070sta.ko
显示
rtusb init --->
=== pAd = c4b01000, size =$465920 ===
<-- RTMPAllocAdapterBlock, Status=0
usbcore: registered new driver rt2870
加载成功
#ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:12:34:56:80:49
inet addr:172.20.182.92 Bcast:172.20.255.255 Mask:255.255.0.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errorw:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:51 Base address:0x8300
lo Link encap:Local Loopback
LOOPBACK MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions: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:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 ,0.0 B) TX bytes:0 (0.0 B)
可以查看到ra0设备的存在
启动无线:
#ifconfig ra0 up
显示
<-- RTMPAllocTxRxRingMemory, Status=0
-->RTUSBVenderReset
<--RTUSBVenderReset
Key1Str is Invalid key length(0) or Type(0)
Key2Str is Invalid key length(0) or Type(0)
Key3Str is Invalid key length(0) or Type(0)
Key4Str is Invalid key length(0) or Type(0)
1. Phy Mode = 9
2. Phy Mode = 9
NVM is Efuse and its size$=2d[2d0-2fc]
3. Phy Mode = 9
RTMPSetPhyMode: channel is out of range, use first channel=1
MCS Set = ff 00 00 00 01
<==== rt28xx_init, Status=0
0x1300 = 00064300
启动成功!
下一步需要移植wireless tools 进行联网和配置。
移植环境:
主机操作系统:redhat 9.0
目标系统:FL2440 内核 linux-2.6.28
交叉编译器:arm-linux-gcc 3.4.1
wireless_tools版本:wireless_tools.29.tar.bz2
1.下载wireless_tools.29.tar.gz
2.解压:#tar zxvf wireless_tools.29.tar.gz
3.修改makefile
PREFIX = /home/leo/wirelesstoolsout
CC = /usr/src/usr/local/arm/3.4.1/bin/arm-linux-gcc
AR = /usr/src/usr/local/arm/3.4.1/bin/arm-linux-ar
RANLIB = /usr/src/usr/local/arm/3.4.1/bin/arm-linux-ranlib
4. 交叉编译:
#cd wireless_tools.29
#make
#make install
5. 复制文件到ARM开发板
拷贝libiw.so.29文件到目标系统/lib/
拷贝用到的几个程序到目标系统的 /bin/ 目录下就可以了
iwpriv、iwconfig、iwlist, iwevent, iwspy
至此wireless_tools移植完成
6. 设置 ip地址及子网掩码:
# ifconfig ra0 172.31.13.229 netmask 255.255.254.0
7. 扫描无线网络
# iwlist ra0 scan
===>rt_ioctl_giwscan. 14(14) BSS returned, data->length = 1526
ra0 Scan completed :
Cell 01 - Address: 00:23:89:08:02:10
Protocol:802.11b/g
ESSID:"IMUST"
Mode:Managed
Channel:1
Quality:42/100 Signal level:-73 dBm Noise level:-115 dBm
Encryption key:off
Bit Rates:18 Mb/s
Cell 02 - Address: 00:23:89:DC:35:B0
Protocol:802.11b/g
ESSID:"IMUST"
Mode:Managed
Channel:1
Quality:42/100 Signal level:-73 dBm Noise level:-115 dBm
Encryption key:off
Bit Rates:18 Mb/s
Cell 03 - Address: 00:23:89:DC:38:90
Protocol:802.11b/g
ESSID:"IMUST"
Mode:Managed
Ghannel:1
Quality:89/100 Signal level:-55 dBm Noise level:-115 dBm
Encryption key:off
Bit Rates:18 Mb/s
(显示以上信息说明模块已经正常工作,内蒙古科技大学的无线网络服务区别号为 IMUST,该接入点没有加密。)
8. 设置ESSID
# iwconfig ra0 ESSID IMUST
至此成功接入校园的无线网络!
小结:无限网卡的主要做用就是寻找wifi热点并与目标热点进行物理连接。从而为数据的传输建好了一个通路。由于墙壁的阻挡,所以有信号衰减的问题,在传输监控视频图像时有些延迟。因为学校的无线网络是开放式的,所以不需要对网卡进行WPA加密。