RT3070L_USB_WIFI网卡在GT2440开发板上的移植和使用(一)

前言:万事开头难!我!一个嵌入式小白,在这个xxx的时代,也打算开个博客记录我的嵌入式学习之路。第一篇就结合韦东山老师的关于无线网卡移植的课程,并搜索RT3070L移植过程,配合自己的GT2440开发板做的WiFi的移植。我手头有2个USB无线网卡。360_wifi3代和RT3070L。移植过程可谓是艰难险阻。感觉所有的问题都让我遇到了。也是自己学识太浅。几节的课程经过几周的努力总算是有点小收获了。有人说大牛的成长之路是善于总结。不管成不成的了大牛。咱就从善于总结开始吧。好多问题我也没太懂,有知道的不吝赐教的希望可以联系我。当然有想问我些问题的也可以联系。共同成长,共同进步吧!

                                                                                                                                                                     W.D.

                                                                                                                                                                     598323431@qq.com

                                                                                                                                                                     2020.3.31

1、我的开发环境:

    (1)RT3070L_USB_WIFI                USB/VID_13D3&PID_3273
    (2)开发板                                       GT2440
    (3)虚拟机                                       Ubuntu9.10 韦东山老师提供的。
    (4)uboot、kernel和rootfs               购买开发板时原厂带的烧录镜像,很老了。
    (5)内核源码                                    同样是原厂提供的。
    (6)驱动源码                                    RT3070_Linux_STA_V2.5.0.3-master.zip。也是网上搜索的。这个分享到CSDN了要点分                                                               吧。也方便我下载别人的。
    (7)iw工具(wireless tools)               iw-3.11.tar.bz2
    (8)wpa_supplicant                        wpa_supplicant-2.0.tar.gz

2、station模式驱动源码修改及编译
    2.1、确认USB的VID和PID    VID_13D3&PID_3273
    修改RT3070_Linux_STA_V2.5.0.3-master\common\rtusb_dev_id.c文件,确认有我的设备ID:
    /@######
        {USB_DEVICE(0x13D3,0x3273)}, /* AzureWave 3070 my wifi w.d.*/
    ######@/
    2.2、修改Makefile
    确认:
    RT28xx_MODE = STA
    TARGET = LINUX
    CHIPSET = 3070
    2.2.1、平台换成:三星。如果不是需要根据自己的平台修改。
    /@######
    PLATFORM = SMDK
    ######@/
    2.2.2、内核源码树路径和交叉工具链路径设置。根据自己的设置。
    /@######
    ifeq ($(PLATFORM),SMDK)
    #LINUX_SRC = /home/bhushan/itcenter/may28/linux-2.6-samsung
    #CROSS_COMPILE = /usr/local/arm/4.2.2-eabi/usr/bin/arm-linux-
    LINUX_SRC = /work/gt2440_system/opt/GTStudio/GT2440/linux-2.6.30.4
    CROSS_COMPILE = arm-linux-
    endif
    ######@/
    2.2.3、修改make选项:在ifeq ($(PLATFORM),DM6446)后面加一个SMDK的make选项。注意后面要加一个endif
    /@######
    ifeq ($(PLATFORM),DM6446)
        $(MAKE)  ARCH=arm CROSS_COMPILE=arm_v5t_le- -C  $(LINUX_SRC) SUBDIRS=$(RT28xx_DIR)/os/linux modules
    else
    ifeq ($(PLATFORM),SMDK)
        $(MAKE)  ARCH=arm CROSS_COMPILE=arm-linux- -C  $(LINUX_SRC) SUBDIRS=$(RT28xx_DIR)/os/linux modules
    else
    ifeq ($(PLATFORM),FREESCALE8377)
        $(MAKE) ARCH=powerpc CROSS_COMPILE=$(CROSS_COMPILE) -C  $(LINUX_SRC) SUBDIRS=$(RT28xx_DIR)/os/linux modules
    else
        $(MAKE) -C $(LINUX_SRC) SUBDIRS=$(RT28xx_DIR)/os/linux modules
    endif
    endif
    endif
    ######@/
    2.3、网卡名字的修改。我就不改了。这个无所谓吧。
    2.3.1、常用无线网卡名称:rax、wlanx
    2.3.2、修改include/rtmp_def.h文件
    #define INF_MAIN_DEV_NAME "ra"
    #define INF_MBSSID_DEV_NAME "ra"
    2.4、添加wpa_supplicant支持。修改RT3070_Linux_STA_V2.5.0.3-master\os\linux\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
    2.5、好了,可以编译了。拷贝到虚拟机来试一试吧。清理一下再编译
    make clean && make
    2.5.1、遇到了第一个问题,编译不通过,打印信息:
/@######
CC [M]  /work/gt2440_prj/zyp_RT3070/01_RT3070_driver/RT3070_Linux_STA_V2.5.0.3-master_OK/os/linux/../../chips/rtmp_chip.o
/work/gt2440_prj/zyp_RT3070/01_RT3070_driver/RT3070_Linux_STA_V2.5.0.3-master_OK/os/linux/../../chips/rtmp_chip.c: In function 'RtmpChipOpsHook':
/work/gt2440_prj/zyp_RT3070/01_RT3070_driver/RT3070_Linux_STA_V2.5.0.3-master_OK/os/linux/../../chips/rtmp_chip.c:470: error: implicit declaration of function 'RT33xx_Init'  这条是错误信息--W.D.
make[2]: *** [/work/gt2440_prj/zyp_RT3070/01_RT3070_driver/RT3070_Linux_STA_V2.5.0.3-master_OK/os/linux/../../chips/rtmp_chip.o] Error 1
make[1]: *** [_module_/work/gt2440_prj/zyp_RT3070/01_RT3070_driver/RT3070_Linux_STA_V2.5.0.3-master_OK/os/linux] Error 2
make[1]: Leaving directory `/work/gt2440_system/opt/GTStudio/GT2440/linux-2.6.30.4'
make: *** [LINUX] Error 2
######@/
    看问题是在“RT33xx_Init”函数中的声明不正确。分析问题解决。
    2.5.2、修改代码RT3070_Linux_STA_V2.5.0.3-master\chips\Rtmp_chip.c里的470行左右,网上查有如果不是确实没定义的话,会有两种情况会产生“implicit declaration of function”错误:
        (1)没有把函数所在的c文件生成.o目标文件
        (2)在函数所在的c文件中定义了,但是没有在与之相关联的.h文件中声明。开始没有,我添加了声明还是有错,分析应该是第一个原因。

不管什么原因了。反正我个小白也不用考虑移植性。能用就行了。用暴力方式解决吧。直接注释掉。。。
/@######
#ifdef RT30xx


    if (IS_RT30xx(pAd))
    {
        if (IS_RT3390(pAd));
            //RT33xx_Init(pAd);我们并不会编译这个函数所在的文件,也不会用到它,直接注释掉,简单粗暴^_^
        else
            RT30xx_Init(pAd);
    }
#endif /* RT30xx */
######@/
    2.5.3、继续编译生成驱动模块
    make clean && make
/@######
  LD [M]  /work/gt2440_prj/zyp_RT3070/01_RT3070_driver/RT3070_Linux_STA_V2.5.0.3-master_OK/os/linux/rt3070sta.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /work/gt2440_prj/zyp_RT3070/01_RT3070_driver/RT3070_Linux_STA_V2.5.0.3-master_OK/os/linux/rt3070sta.mod.o
  LD [M]  /work/gt2440_prj/zyp_RT3070/01_RT3070_driver/RT3070_Linux_STA_V2.5.0.3-master_OK/os/linux/rt3070sta.ko
make[1]: Leaving directory `/work/gt2440_system/opt/GTStudio/GT2440/linux-2.6.30.4'
cp -f /work/gt2440_prj/zyp_RT3070/01_RT3070_driver/RT3070_Linux_STA_V2.5.0.3-master_OK/os/linux/rt3070sta.ko /tftpboot
######@/
    生成01_RT3070_driver/RT3070_Linux_STA_V2.5.0.3-master_OK/os/linux/rt3070sta.ko就是驱动模块。从最后一行看我修改的Makefile还是有问题的。无所谓了。驱动文件是生成了。接下来安装驱动。

2.6、安装驱动:
    2.6.1、启动后挂接根文件系统。
    (1)在主机上确认文件系统的目录:cat /etc/exprots
/@######
/work/nfs_root *(rw,sync,no_root_squash)            
/work/nfs_root/first_fs   *(rw,sync,no_root_squash) 我的根文件系统的目录
######@/
    (2)在开发板上挂接根文件系统
    mount -t nfs -o nolock 192.168.15.15:/work/nfs_root/first_fs /mnt
    2.6.2、将驱动rt3070sta.ko和RT2870STA.dat拷贝到文件系统:
    cp os/linux/rt3070sta.ko /work/nfs_root/first_fs/gt2440_dev/mt3070_driver/
    cp RT2870STA.dat /work/nfs_root/first_fs/gt2440_dev/mt3070_driver/
    2.6.3、在开发板上安装驱动命令序列
    cd /mnt/gt2440_dev/mt3070_driver/        //进入驱动所在目录
    mkdir /etc/Wireless/RT2870STA/ -p        //创建配置文件路径,这个和驱动有关,驱动源码文档中也有介绍,不用深入研究。
    cp RT2870STA.dat  /etc/Wireless/RT2870STA/RT2870STA.dat                //复制配置文件
    cp * /myprj/rt3070l_usbwifi_driver/          //将驱动拷贝到我的开发板
    cd /myprj/rt3070l_usbwifi_driver/
    insmod rt2870sta.ko                                //加载驱动
/@######
rtusb init rt2870 --->
usbcore: registered new interface driver rt2870
######@/
/@###### 接上wifi网卡后
usb 1-1: USB disconnect, address 2
usb 1-1: new full speed USB device using s3c2410-ohci and address 3
usb 1-1: New USB device found, idVendor=13d3, idProduct=3273
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1: Product: 802.11 n WLAN
usb 1-1: Manufacturer: Ralink
usb 1-1: SerialNumber: 1.0
usb 1-1: configuration #1 chosen from 1 choice


=== pAd = c48f3000, size = 508592 ===

<-- RTMPAllocTxRxRingMemory, Status=0
<-- RTMPAllocAdapterBlock, Status=0
ra0 (usb): not using net_device_ops yet
######@/
    ifconfig -a       //查看是否有无线网卡
/@######
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)
######@/
    ifconfig ra0 up      //开启无线网卡
/@######
(Efuse for 3062/3562/3572) Size=0x2d [2d0-2fc] 
RTMP_TimerListAdd: add timer obj c493a8a0!
RTMP_TimerListAdd: add timer obj c493a8cc!
RTMP_TimerListAdd: add timer obj c493a8f8!
RTMP_TimerListAdd: add timer obj c493a874!
RTMP_TimerListAdd: add timer obj c493a7f0!
RTMP_TimerListAdd: add timer obj c493a81c!
RTMP_TimerListAdd: add timer obj c4905434!
RTMP_TimerListAdd: add timer obj c48f4c4c!
RTMP_TimerListAdd: add timer obj c48f4c80!
RTMP_TimerListAdd: add timer obj c49054cc!
RTMP_TimerListAdd: add timer obj c49053dc!
RTMP_TimerListAdd: add timer obj c490549c!
-->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 = 5
2. Phy Mode = 5
NVM is Efuse and its size =2d[2d0-2fc] 
phy mode> Error! The chip does not support 5G band 5!
RTMPSetPhyMode: channel is out of range, use first channel=1 
(Efuse for 3062/3562/3572) Size=0x2d [2d0-2fc] 
3. Phy Mode = 9
AntCfgInit: primary/secondary ant 0/1
MCS Set = ff 00 00 00 01
<==== rt28xx_init, Status=0
0x1300 = 00064300
######@/

这时我以为一切都顺风顺水了。很有点成就感。
很快就能完成这个小项目。没想到一切才刚刚开始。。。。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值