RT3070和wpa_supplicant

Published: 09 Aug 2013 Category: linux

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

  1. 首先RT73使用的是rausb0表示的,而RT3070使用ra0表示。
  2. RT3070的驱动差不多是RT73的两倍多。
  3. 另外,在使用wpasupplicant上也有点小区别,主要是wpasupplicant版本的问题。

下面,我就说一下我的使用过程,希望可以帮助到大家! 首先是驱动的编译,从网上下了好多RT3070的驱动,都没交叉编译过去,只有20091106RT3070LinuxSTA_V2.1.1.0.bz2这一版本的编译过去了,呵呵!

交叉编译过程:

  1. tar -jxvf 20091106RT3070LinuxSTA_V2.1.1.0.bz2
  2. cd 20091106RT3070LinuxSTA_V2.1.1.0
  3. vi makefile

修改如下:

    #PLATFORM: Target platform
    #PLATFORM = PC
    PLATFORM = 5VT
    #PLATFORM = IKANOS_V160
    #PLATFORM = IKANOS_V180
    #PLATFORM = SIGMA
    #PLATFORM = SIGMA_8622
    #PLATFORM = INIC
    #PLATFORM = STAR
    #PLATFORM = IXP
    #PLATFORM = INF_TWINPASS
    #PLATFORM = INF_DANUBE
    #PLATFORM = BRCM_6358
    #PLATFORM = INF_AMAZON_SE
    #PLATFORM = CAVM_OCTEON
    #PLATFORM = CMPC
    #PLATFORM = RALINK_2880  
    ifeq ($(PLATFORM),5VT)
    LINUX_SRC = /home/Hi3511_VSSDK_V1.1.2.2/pub/kbuild-FULL_REL
    CROSS_COMPILE = arm-hismall-linux-
    endif  
  1. cd os/linux
  2. vi config.mk

    #ifdef WPA_SUPPLICANT_SUPPORT
    #Support Wpa_Supplicant
    HAS_WPA_SUPPLICANT=y
    #endif // WPA_SUPPLICANT_SUPPORT //
    #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
    # Support Native WpaSupplicant for Network Maganger
    HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=y
    #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //  
    
  3. cd ../../common

    vi rtusb_io.c  
    
    if (ret < 0) {
        //DBGPRINT(RT_DEBUG_OFF, ("#/n"));
            RTMPusecDelay(5000);
        }  
    

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

  1. cd ../../..
  2. make 这时,应该就编译通过了。在20091106RT3070LinuxSTA_V2.1.1.0/os/linux目录下生成了rt3070sta.ko,也就是RT3070的驱动了。
  3. 把RT2870STA.dat拷贝到/etc/Wireless/RT2870STA目录下加载驱动过程

    insmod rt3070sta.ko
    

看一下打印消息:

    rtusb init --->


    === pAd = ca901000, size = 465920 ===

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

iwconfig看一下

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

注意wirelesstools之前要移植到开发板上! 接下来就是wpasupplicant的交叉编译,这个比较麻烦,在这里就不详细说明了,给个网址给大家,我也是参考着做的: http://blog.csdn.net/farsight2009/archive/2010/06/10/5660878.aspx 不过,我使用的是0.6.10这个版本,其他版本我都没用起来! 由于这个版本比较高,上述网址中的

    #cp ../2009_0713_RT73_Linux_STA_Drv1.1.0.3/WPA_Supplicant-0.5.8/driver_ralink.* ./
    #cp ../2009_0713_RT73_Linux_STA_Drv1.1.0.3/WPA_Supplicant-0.5.8/driver.h ./
    #cp ../2009_0713_RT73_Linux_STA_Drv1.1.0.3/WPA_Supplicant-0.5.8/events.c ./
    #cp ../2009_0713_RT73_Linux_STA_Drv1.1.0.3/WPA_Supplicant-0.5.8/wpa_supplicant.c ./
    #cp ../2009_0713_RT73_Linux_STA_Drv1.1.0.3/WPA_Supplicant-0.5.8/wpa_supplicant_i.h ./
    #cp ../2009_0713_RT73_Linux_STA_Drv1.1.0.3/WPA_Supplicant-0.5.8/defconfig ./
    #cp ../2009_0713_RT73_Linux_STA_Drv1.1.0.3/WPA_Supplicant-0.5.8/drivers.c ./
    #cp ../2009_0713_RT73_Linux_STA_Drv1.1.0.3/WPA_Supplicant-0.5.8/Makefile ./  

这些部分就可以略去了,不用做了,呵呵! 顺利地话,就可以在wpasupplicant-0.6.10/wpasupplicant下生成wpasupplicant了!接着就是把wpasupplicant拷贝到开发板中。 关于wpa_supplicant的使用:

  1. 把wpasupplicant.conf拷贝到/etc目录下,当然要根据情况修改wpasupplicant.conf的内容了!这里我提供一个我修改的模板,屡试不爽!

    ctrl_interface=/var/run/wpa_supplicant
    network={
        ssid="XXXXXX"
        scan_ssid=1
        key_mgmt=WPA-EAP WPA-PSK IEEE8021X NONE    
        pairwise=TKIP CCMP    
        group=CCMP TKIP WEP104 WEP40    
        psk="XXXXXX"
    }  
    

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

  1. mkdir -p /var/run/wpa_supplicant
  2. 最后就是用命令

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

看一下超级终端的打印:

    <-- 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
    /mnt $ ===>rt_ioctl_giwscan. 4(4) BSS returned, data->length = 447
    ==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x8b04] (Channel=1)  

这过程可能要花费几秒钟! 接着ifconfig一下它的ip,ping一下无线路由器,应该能ping通的。 当然,这些都是让RT3070工作在managed模式下的,工作在ad-hoc模式下的配置跟简单,不需要使用wpasupplicant! 可以参考里面的iwprivusage.txt进行配置,我配置了一下,发现其中有几种情况配置不成功,这里我把配置成功的罗列下来:

    ===========================================================================
    Config STA to link with AP which is SHARED/WEP(Authentication/Encryption)
        1. iwpriv ra0 set NetworkType=Infra
        2. iwpriv ra0 set AuthMode=SHARED
        3. iwpriv ra0 set EncrypType=WEP
        4. iwpriv ra0 set DefaultKeyID=1
        5. iwpriv ra0 set Key1="AP's wep key"
        6. iwpriv ra0 set SSID="AP's SSID"
    ===========================================================================
    Config STA to link with AP which is OPEN/WEP(Authentication/Encryption)
        1. iwpriv ra0 set NetworkType=Infra
        2. iwpriv ra0 set AuthMode=OPEN
        3. iwpriv ra0 set EncrypType=WEP
        4. iwpriv ra0 set DefaultKeyID=1
        5. iwpriv ra0 set Key1="AP's wep key"
        6. iwpriv ra0 set SSID="AP's SSID"
    ===========================================================================
    Config STA to link with AP which is OPEN or SHARED/WEP(Authentication/Encryption)
        1. iwpriv ra0 set NetworkType=Infra
        2. iwpriv ra0 set AuthMode=WEPAUTO
        3. iwpriv ra0 set EncrypType=WEP
        4. iwpriv ra0 set DefaultKeyID=1
        5. iwpriv ra0 set Key1="AP's wep key"
        6. iwpriv ra0 set SSID="AP's SSID"
    ===========================================================================
    Config STA to create/link as adhoc mode, which is OPEN/NONE(Authentication/Encryption)
        1. iwpriv ra0 set NetworkType=Adhoc
        2. iwpriv ra0 set AuthMode=OPEN
        3. iwpriv ra0 set EncrypType=NONE
        4. iwpriv ra0 set SSID="Adhoc's SSID"
    ===========================================================================
    Config STA to create/link as adhoc mode, which is OPEN/WEP(Authentication/Encryption)
        1. iwpriv ra0 set NetworkType=Adhoc
        2. iwpriv ra0 set AuthMode=OPEN
        3. iwpriv ra0 set EncrypType=WEP
        4. iwpriv ra0 set DefaultKeyID=1
        5. iwpriv ra0 set Key1="AP's wep key"
        6. iwpriv ra0 set SSID="Adhoc's SSID"
    ===========================================================================
    Config STA to create/link as adhoc mode, which is SHARED/WEP(Authentication/Encryption)
        1. iwpriv ra0 set NetworkType=Adhoc
        2. iwpriv ra0 set AuthMode=SHARED
        3. iwpriv ra0 set EncrypType=WEP
        4. iwpriv ra0 set DefaultKeyID=1
        5. iwpriv ra0 set Key1="AP's wep key"
        6. iwpriv ra0 set SSID="Adhoc's SSID"
    ===========================================================================
    Config STA to create/link as adhoc mode, which is OPEN or SHARED/WEP(Authentication/Encryption)
        1. iwpriv ra0 set NetworkType=Adhoc
        2. iwpriv ra0 set AuthMode=WEPAUTO
        3. iwpriv ra0 set EncrypType=WEP
        4. iwpriv ra0 set DefaultKeyID=1
        5. iwpriv ra0 set Key1="AP's wep key"
        6. iwpriv ra0 set SSID="Adhoc's SSID"