[连载]RT3070STA 驱动移植
移植环境:
主机操作系统:Ubantu10.10
目标系统:at91sam9m10内核linux-2.6.30
交叉编译器:arm-none-linux-gnueabi-
驱动版本:2011_0107_RT3070_RT3370_Linux_STA_v2.5.0.1_DPO
Networkingsupport
Wireless
-*-Wirelessextensions
[*]Wirelessextensions sysfs files
DeviceDrivers
Networkdevice support
WierlessLAN
[*]WirelessLAN(IEEE 802.11)
<M>Ralinkdriver support
1.下载RT3070驱动源码
版本:2011_0107_RT3070_RT3370_Linux_STA_v2.5.0.1_DPO
download: 下载页面
选到 T8070/RT3070/RT3370/RT5370/RT5372USB 这个然后随便输入名字和邮箱即可下载。
2.RT3070驱动修改
解压 tar-zxvf 2011_0107_RT3070_RT3370_Linux_STA_v2.5.0.1_DPO.tar.gz
进入RT3070_Linux_STA目录,看到有一个README_STA_usb文件,里面介绍了如何加载该驱动,先浏览一下
2.1 先设好环境变量
exportPATH=/usr/local/arm/arm-2007q1/bin:$PATH
2.2 makefile修改 (-为去掉设置,+为新加的设置)
#vimakefile
-#PLATFORM = PC
+ PLATFORM = IXP
#(选用的是IXP)
ifeq($(PLATFORM),IXP)
-LINUX_SRC = /project/stable/Gmtek/snapgear-uclibc/linux-2.6.x
-CROSS_COMPILE = arm-linux-
+ LINUX_SRC = /home/rpf413/at91/linux/linux-2.6.30
+ CROSS_COMPILE = /usr/local/arm/arm-2007q1/bin/arm-none-linux-gnueabi-
endif
2.3 /os/linux/config.mk修改
#cd/os/linux/
#vi config.mk
#Support Wpa_Supplicant
- HAS_WPA_SUPPLICANT=n
+HAS_WPA_SUPPLICANT=y
#Support Native WpaSupplicant for Network Maganger
-HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=n
+HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=y
ifeq($(PLATFORM),IXP)
- WFLAGS +=-DRT_BIG_ENDIAN
#加这个选项,模块运行时显示出错,CPU不能工作
endif
ifeq($(PLATFORM),IXP)
-CFLAGS := -v -D__KERNEL__ -DMODULE -I$(LINUX_SRC)/include-I$(RT28xx_DIR)/include -mbig-endian -Wall -Wstrict-prototypes-Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -Uarm -fno-common-pipe -mapcs-32 -D__LINUX_ARM_ARCH__=5 -mcpu=xscale -mtune=xscale-malignment-traps -msoft-float $(WFLAGS)
-EXTRA_CFLAGS := -v $(WFLAGS) -I$(RT28xx_DIR)/include -mbig-endian
+EXTRA_CFLAGS := -v $(WFLAGS) -I$(RT28xx_DIR)/include
exportCFLAGS
endif
3、 编译源码
make通过,在2011_0107_RT3070_RT3370_Linux_STA_v2.5.0.1_DPO/os/linux目录下生成了rt3070sta.ko,也就是RT3070的驱动了
makeKBUILD_NOPEDANTIC=1
4. 拷贝驱动到目标系统
把RT2870STA.dat拷贝到/etc/Wireless/RT2870STA目录下
把rt3070sta.ko拷贝到/xxx/目录下xxx自定
5.加载驱动模块
insmod/xxx/rt3070sta.ko
出现以下错误
insmod:error inserting 'rt3070sta.ko': -1 Unknown symbol inmodule
rt3070sta: Unknown symbol usb_alloc_urb
rt3070sta:Unknown symbol usb_free_urb
rt3070sta: Unknown symbolusb_register
rt3070sta: Unknown symbol usb_put_dev
rt3070sta:Unknown symbol usb_get_dev
rt3070sta: Unknown symbolusb_submit_urb
rt3070sta: Unknown symbolusb_control_msg
rt3070sta: Unknown symbolusb_deregister
rt3070sta: Unknown symbol usb_kill_urb
rt3070sta:Unknown symbol usb_buffer_free
rt3070sta: Unknown symbolusb_buffer_alloc
insmod: cannot insert `rt3070sta.ko': Unknownsymbol in module (-1): No such file or directory
原因未加载USB驱动
请修改UTIL/os/linux/usb_main_dev.c文件,在文件的开头加上如下一行程序:
MODULE_LICENSE(“GPL”)
重新编译:
MakeARCH=armCROSS_COMPILE=/usr/local/arm/arm-2007q1/bin/arm-none-linux-gnueabi-
5.3 然后再加载rt3070sta.ko
手动添加:/etc/Wireless/RT2870STA/RT2870STA.dat
insmod/xxx/rt3070sta.ko
显示
rtusbinit rt2870 --->
===pAd = d1af4000, size = 514424 ===
<--RTMPAllocTxRxRingMemory, Status=0
<-- RTMPAllocAdapterBlock,Status=0
usbcore: registered new driver rt2870
加载成功
#ifconfig-a 可以查看到ra0设备的存在
若无密码或密码为WEP加密,则此时可以启动无线,若密码为WPA加密,则需移植wpa_supplicant,往后再说移植
6.无密码或密码为WEP加密:
6.1 启动无线
#ifconfigra0 up
(Efusefor 3062/3562/3572) Size=0x2d [2d0-2fc]
RTMP_TimerListAdd: addtimer obj d1b3c620!
RTMP_TimerListAdd: add timer objd1b3c650!
RTMP_TimerListAdd: add timer objd1b3c680!
RTMP_TimerListAdd: add timer objd1b3c5f0!
RTMP_TimerListAdd: add timer objd1b3c560!
RTMP_TimerListAdd: add timer objd1b3c590!
RTMP_TimerListAdd: add timer objd1b06b94!
RTMP_TimerListAdd: add timer objd1af5f54!
RTMP_TimerListAdd: add timer objd1af5f8c!
RTMP_TimerListAdd: add timer objd1b06c38!
RTMP_TimerListAdd: add timer objd1b06b34!
RTMP_TimerListAdd: add timer objd1b06c04!
-->RTUSBVenderReset
<--RTUSBVenderReset
Key1Stris Invalid key length(0) or Type(0)
Key2Str is Invalid keylength(0) or Type(0)
Key3Str is Invalid key length(0) orType(0)
Key4Str is Invalid key length(0) or Type(0)
1. Phy Mode= 5
2. Phy Mode = 5
phy mode> Error! The chip does notsupport 5G band 5!
RTMPSetPhyMode: channel is out of range, usefirst channel=1
(Efuse for 3062/3562/3572) Size=0x2d [2d0-2fc]
3.Phy Mode = 9
MCS Set = ff 00 00 00 01
<==== rt28xx_init,Status=0
0x1300 = 00064300
启动成功
6.2 设置ip
#ifconfigra0 192.168.50.166 netmask 255.255.255.0
6.3 扫描无线网络
#iwlistra0 scan
===>rt_ioctl_giwscan.9(9) BSS returned, data->length = 1476
ra0 Scancompleted :
Cell01 - Address:F0:7D:68:96:A6:C2
Protocol:802.11b/g/n
ESSID:"dlinktf"
Mode:Managed
Frequency:2.412GHz (Channel 1)
Quality=18/100 Signallevel=-83 dBm Noise level=-92dBm
Encryptionkey:on
BitRates:54 Mb/s
Cell02 - Address:F4:EC:38:55:AF:BC
Protocol:802.11b/g/n
ESSID:"visview"
Mode:Managed
Frequency:2.427GHz (Channel 4)
Quality=18/100 Signallevel=-83 dBm Noise level=-91dBm
Encryptionkey:off
BitRates:54 Mb/s
显示以上信息说明模块已经正常工作
6.4 设置SSID和WEP加密算法
可以参考里面的iwpriv_usage.txt进行配置,
6.4.1 无密码
ConfigSTA to link with AP which is OPEN/NONE(Authentication/Encryption)
1.iwpriv ra0 set NetworkType=Infra
2. iwpriv ra0 setAuthMode=OPEN
3. iwpriv ra0 set EncrypType=NONE
4. iwpriv ra0set SSID="AP's SSID"
6.4.2 WEP加密算法
iwprivra0 set NetworkType=Infra
iwpriv ra0 set AuthMode=SHARED
iwprivra0 set EncrypType=WEP
iwpriv ra0 set DefaultKeyID=1
iwpriv ra0set Key1="AP's wep key"
iwpriv ra0 set SSID="AP'sSSID"
设置完一会,等网络连接好就可以了。
WPA加密详见openssl驱动移植,wpa_supplicant驱动移植。
RT3070wifi驱动的相关文章
bridge-utils驱动移植(2011-06-0314:54:38)
wpa_supplicant驱动移植(2011-06-0314:24:17)
Openss驱动移植(2011-06-0314:14:02)
wireless_tools移植(2011-06-0313:40:09)
[首篇]Linux无线WIFI模块驱动移植(基于RT3070)(2011-06-0312:00:29)
RT3070wifi驱动的全部文章
http://blog168.chinaunix.net/space.php?uid=7406469&do=blog&id=353430