Chinaunix首页 | 论坛 | 博客
  • 博客访问: 77966
  • 博文数量: 25
  • 博客积分: 416
  • 博客等级: 一等列兵
  • 技术积分: 205
  • 用 户 组: 普通用户
  • 注册时间: 2011-11-23 21:01
文章分类

全部博文(25)

文章存档

2013年(8)

2012年(17)

我的朋友

分类:

2012-07-20 10:54:02

前段时间搞了一下RT73与wpa_supplicant,调通了,无论是什么加密方式和认证类型,RT73都可以良好的工作。可又由于RT73停产了,被迫要使用RT3070。刚开始我以为应该和RT73差不多,果不其然,用法十分接近,但是也有一点点区别的。

1.首先RT73使用的是rausb0表示的,而RT3070使用ra0表示。

2.RT3070的驱动差不多是RT73的两倍多。

3.另外,在使用wpa_supplicant上也有点小区别,主要是wpa_supplicant版本的问题。

下面,我就说一下我的使用过程,希望可以帮助到大家!

首先是驱动的编译,从网上下了好多RT3070的驱动,都没交叉编译过去,只有2009_1106_RT3070_Linux_STA_V2.1.1.0.bz2这一版本的编译过去了,呵呵!

交叉编译过程:

1.tar -jxvf 2009_1106_RT3070_Linux_STA_V2.1.1.0.bz2

2. cd 2009_1106_RT3070_Linux_STA_V2.1.1.0

3.vi makefile


 

点击(此处)折叠或打开

  1. #PLATFORM: Target platform
  2. #PLATFORM = PC
  3. PLATFORM = 5VT
  4. #PLATFORM = IKANOS_V160
  5. #PLATFORM = IKANOS_V180
  6. #PLATFORM = SIGMA
  7. #PLATFORM = SIGMA_8622
  8. #PLATFORM = INIC
  9. #PLATFORM = STAR
  10. #PLATFORM = IXP
  11. #PLATFORM = INF_TWINPASS
  12. #PLATFORM = INF_DANUBE
  13. #PLATFORM = BRCM_6358
  14. #PLATFORM = INF_AMAZON_SE
  15. #PLATFORM = CAVM_OCTEON
  16. #PLATFORM = CMPC
  17. #PLATFORM = RALINK_2880

点击(此处)折叠或打开

  1. ifeq ($(PLATFORM),5VT)
  2. LINUX_SRC = /home/Hi3511_VSSDK_V1.1.2.2/pub/kbuild-FULL_REL
  3. CROSS_COMPILE = arm-hismall-linux-
  4. endif


 

4.cd os/linux

5.vi config.mk


 

点击(此处)折叠或打开

  1. #ifdef WPA_SUPPLICANT_SUPPORT
  2. # Support Wpa_Supplicant
  3. HAS_WPA_SUPPLICANT=y
  4. #endif // WPA_SUPPLICANT_SUPPORT //

  5. #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
  6. # Support Native WpaSupplicant for Network Maganger
  7. HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=y
  8. #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //


 

6.cd ../../common

vi rtusb_io.c:


 

点击(此处)折叠或打开

  1. if (ret < 0) {
  2.     //DBGPRINT(RT_DEBUG_OFF, ("#/n"));
  3.                 RTMPusecDelay(5000);
  4.             }


 

否则,加载驱动后会一直打印"#",很烦!!!!!

7.cd ../../..

8.make

这时,应该就编译通过了。在2009_1106_RT3070_Linux_STA_V2.1.1.0/os/linux目录下生成了rt3070sta.ko,也就是RT3070的驱动了。

9.把RT2870STA.dat拷贝到/etc/Wireless/RT2870STA目录下

加载驱动过程

insmod rt3070sta.ko

看一下打印消息:


 

点击(此处)折叠或打开

  1. rtusb init --->


  2. === pAd = ca901000, size = 465920 ===

  3. <-- RTMPAllocAdapterBlock, Status=0
  4. usbcore: registered new driver rt2870


 

iwconfig看一下


 

点击(此处)折叠或打开

  1. ra0 RT2870 Wireless ESSID:""
  2.           Mode:Auto Frequency=2.412 GHz
  3.           Link Quality=10/100 Signal level:-256 dBm Noise level:-143 dBm
  4.           Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
  5.           Tx excessive retries:0 Invalid misc:0 Missed beacon:0


 

注意wireless_tools之前要移植到开发板上!

接下来就是wpa_supplicant的交叉编译,这个比较麻烦,在这里就不详细说明了,给个网址给大家,我也是参考着做的:

http://blog.csdn.net/farsight2009/archive/2010/06/10/5660878.aspx

不过,我使用的是0.6.10这个版本,其他版本我都没用起来!

由于这个版本比较高,上述网址中的


 

点击(此处)折叠或打开

  1. #cp ../2009_0713_RT73_Linux_STA_Drv1.1.0.3/WPA_Supplicant-0.5.8/driver_ralink.* ./
  2.         #cp ../2009_0713_RT73_Linux_STA_Drv1.1.0.3/WPA_Supplicant-0.5.8/driver.h ./
  3.         #cp ../2009_0713_RT73_Linux_STA_Drv1.1.0.3/WPA_Supplicant-0.5.8/events.c ./
  4.         #cp ../2009_0713_RT73_Linux_STA_Drv1.1.0.3/WPA_Supplicant-0.5.8/wpa_supplicant.c ./
  5.         #cp ../2009_0713_RT73_Linux_STA_Drv1.1.0.3/WPA_Supplicant-0.5.8/wpa_supplicant_i.h ./
  6.         #cp ../2009_0713_RT73_Linux_STA_Drv1.1.0.3/WPA_Supplicant-0.5.8/defconfig ./
  7.         #cp ../2009_0713_RT73_Linux_STA_Drv1.1.0.3/WPA_Supplicant-0.5.8/drivers.c ./
  8.         #cp ../2009_0713_RT73_Linux_STA_Drv1.1.0.3/WPA_Supplicant-0.5.8/Makefile ./


 

这些部分就可以略去了,不用做了,呵呵!

顺利地话,就可以在wpa_supplicant-0.6.10/wpa_supplicant下生成wpa_supplicant了!接着就是把wpa_supplicant拷贝到开发板中。

关于wpa_supplicant的使用:

1.把wpa_supplicant.conf拷贝到/etc目录下,当然要根据情况修改wpa_supplicant.conf的内容了!

这里我提供一个我修改的模板,屡试不爽!


 

点击(此处)折叠或打开

  1. ctrl_interface=/var/run/wpa_supplicant
  2. network={
  3.     ssid="XXXXXX"
  4.     scan_ssid=1
  5.     key_mgmt=WPA-EAP WPA-PSK IEEE8021X NONE    
  6.     pairwise=TKIP CCMP    
  7.     group=CCMP TKIP WEP104 WEP40    
  8.     psk="XXXXXX"
  9. }


 

其中XXXXXX要替换成相应的ssid和密码!无论是什么加密方式和认证类型,都搞定!WEP除外,因为WEP加密比较简单,在后面会提到,呵呵!!!

2.mkdir -p /var/run/wpa_supplicant

3.最后就是用命令

 wpa_supplicant -B -ira0 -c /etc/wpa_supplicant.conf -Dwext

看一下超级终端的打印:


 

点击(此处)折叠或打开

  1. <-- RTMPAllocTxRxRingMemory, Status=0
  2. -->RTUSBVenderReset
  3. <--RTUSBVenderReset
  4. Key1Str is Invalid key length(0) or Type(0)
  5. Key2Str is Invalid key length(0) or Type(0)
  6. Key3Str is Invalid key length(0) or Type(0)
  7. Key4Str is Invalid key length(0) or Type(0)
  8. 1. Phy Mode = 9
  9. 2. Phy Mode = 9
  10. NVM is Efuse and its size =2d[2d0-2fc]
  11. 3. Phy Mode = 9
  12. RTMPSetPhyMode: channel is out of range, use first channel=1
  13. MCS Set = ff 00 00 00 01
  14. <==== rt28xx_init, Status=0
  15. 0x1300 = 00064300
  16. /mnt $ ===>rt_ioctl_giwscan. 4(4) BSS returned, data->length = 447
  17. ==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x8b04] (Channel=1)


 

 

这过程可能要花费几秒钟!

接着ifconfig一下它的ip,ping一下无线路由器,应该能ping通的。

当然,这些都是让RT3070工作在managed模式下的,工作在ad-hoc模式下的配置跟简单,不需要使用wpa_supplicant!

可以参考里面的iwpriv_usage.txt进行配置,我配置了一下,发现其中有几种情况配置不成功,这里我把配置成功的罗列下来:


 

点击(此处)折叠或打开

  1. ===========================================================================
  2. Config STA to link with AP which is SHARED/WEP(Authentication/Encryption)
  3.     1. iwpriv ra0 set NetworkType=Infra
  4.     2. iwpriv ra0 set AuthMode=SHARED
  5.     3. iwpriv ra0 set EncrypType=WEP
  6.     4. iwpriv ra0 set DefaultKeyID=1
  7.     5. iwpriv ra0 set Key1="AP's wep key"
  8.     6. iwpriv ra0 set SSID="AP's SSID"
  9. ===========================================================================
  10. Config STA to link with AP which is OPEN/WEP(Authentication/Encryption)
  11.     1. iwpriv ra0 set NetworkType=Infra
  12.     2. iwpriv ra0 set AuthMode=OPEN
  13.     3. iwpriv ra0 set EncrypType=WEP
  14.     4. iwpriv ra0 set DefaultKeyID=1
  15.     5. iwpriv ra0 set Key1="AP's wep key"
  16.     6. iwpriv ra0 set SSID="AP's SSID"
  17. ===========================================================================
  18. Config STA to link with AP which is OPEN or SHARED/WEP(Authentication/Encryption)
  19.     1. iwpriv ra0 set NetworkType=Infra
  20.     2. iwpriv ra0 set AuthMode=WEPAUTO
  21.     3. iwpriv ra0 set EncrypType=WEP
  22.     4. iwpriv ra0 set DefaultKeyID=1
  23.     5. iwpriv ra0 set Key1="AP's wep key"
  24.     6. iwpriv ra0 set SSID="AP's SSID"
  25. ===========================================================================
  26. Config STA to create/link as adhoc mode, which is OPEN/NONE(Authentication/Encryption)
  27.     1. iwpriv ra0 set NetworkType=Adhoc
  28.     2. iwpriv ra0 set AuthMode=OPEN
  29.     3. iwpriv ra0 set EncrypType=NONE
  30.     4. iwpriv ra0 set SSID="Adhoc's SSID"
  31. ===========================================================================
  32. Config STA to create/link as adhoc mode, which is OPEN/WEP(Authentication/Encryption)
  33.     1. iwpriv ra0 set NetworkType=Adhoc
  34.     2. iwpriv ra0 set AuthMode=OPEN
  35.     3. iwpriv ra0 set EncrypType=WEP
  36.     4. iwpriv ra0 set DefaultKeyID=1
  37.     5. iwpriv ra0 set Key1="AP's wep key"
  38.     6. iwpriv ra0 set SSID="Adhoc's SSID"
  39. ===========================================================================
  40. Config STA to create/link as adhoc mode, which is SHARED/WEP(Authentication/Encryption)
  41.     1. iwpriv ra0 set NetworkType=Adhoc
  42.     2. iwpriv ra0 set AuthMode=SHARED
  43.     3. iwpriv ra0 set EncrypType=WEP
  44.     4. iwpriv ra0 set DefaultKeyID=1
  45.     5. iwpriv ra0 set Key1="AP's wep key"
  46.     6. iwpriv ra0 set SSID="Adhoc's SSID"
  47. ===========================================================================
  48. Config STA to create/link as adhoc mode, which is OPEN or SHARED/WEP(Authentication/Encryption)
  49.     1. iwpriv ra0 set NetworkType=Adhoc
  50.     2. iwpriv ra0 set AuthMode=WEPAUTO
  51.     3. iwpriv ra0 set EncrypType=WEP
  52.     4. iwpriv ra0 set DefaultKeyID=1
  53.     5. iwpriv ra0 set Key1="AP's wep key"
  54.     6. iwpriv ra0 set SSID="Adhoc's SSID"

=============================The End==============================

 

==========================================================================================================

小弟不才,自己创建的一个qq群!主要探讨linux C语言,shell脚本,驱动开发等等,欢迎大家加入,首先声明,本人水平很菜。。。。呵呵
QQ:213622826

==========================================================================================================

阅读(1104) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~