嵌入式Linux USB WIFI驱动的移植

小微分享驿站 2011-03-17

硬件平台:飞思卡尔MX258开发板

操作系统:Linux2.6.31

WIFI    RT2860 USB WIFI模组

交叉编译环境:gcc version 4.1.2

 

调试步骤:

第一步:测试USB HOST接口

menuconfig中将USB HOST设置为内核模式:

嵌入式Linux USB WIFI驱动的移植

重新编译内核后启动开发板,插入U盘并挂载:

mount /dev/sda1 /tmp

ls /tmp

可以看到U盘已经正常挂载,测试USB HOST OK!

第二步:网上下载雷凌最新的USB驱动,

2011_0107_RT3070_RT3370_Linux_STA_v2[1].5.0.1_DPO.tar.bz2

拷备到Linux目录并解压:

tar  jxf  2011_0107_RT3070_RT3370_Linux_STA_v2[1].5.0.1_DPO.tar.bz2

由于上面名字很长,可以修改为简短的名字:

mv  2011_0107_RT3070_RT3370_Linux_STA_v2[1].5.0.1_DPO  RT3070_Linux_STA

第三步:进入RT3070_Linux_STA目录,看到有一个README_STA_usb文件,里面介绍了如何加载该驱动:

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

Build Instructions: 

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

 

1> $tar -xvzf DPB_RT2870_Linux_STA_x.x.x.x.tgz

    go to "./DPB_RT2870_Linux_STA_x.x.x.x" directory.

   

2> In Makefile

          set the "MODE = STA" in Makefile and chose the TARGET to Linux by set "TARGET = LINUX"

          define the linux kernel source include file path LINUX_SRC

          modify to meet your need.

 

3> In os/linux/config.mk

         define the GCC and LD of the target machine

         define the compiler flags CFLAGS

         modify to meet your need.

         ** Build for being controlled by NetworkManager or wpa_supplicant wext functions

            Please set 'HAS_WPA_SUPPLICANT=y' and 'HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=y'.

            => #>cd wpa_supplicant-x.x

            => #>./wpa_supplicant -Dwext -ira0 -c wpa_supplicant.conf -d

         ** Build for being controlled by WpaSupplicant with Ralink Driver

            Please set 'HAS_WPA_SUPPLICANT=y' and 'HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=n'.

            => #>cd wpa_supplicant-0.5.7

            => #>./wpa_supplicant -Dralink -ira0 -c wpa_supplicant.conf -d

 

4> $make

         # compile driver source code

         # To fix "error: too few arguments to function ˉiwe_stream_add_event"

           => $patch -i os/linux/sta_ioctl.c.patch os/linux/sta_ioctl.c

 

5> $cp RT2870STA.dat  /etc/Wireless/RT2870STA/RT2870STA.dat

   

6> load driver, go to "os/linux/" directory.

    #[kernel 2.4]

    #    $/sbin/insmod rt2870sta.o

    #    $/sbin/ifconfig ra0 inet YOUR_IP up

   

    #[kernel 2.6]

    #    $/sbin/insmod rt2870sta.ko

    #    $/sbin/ifconfig ra0 inet YOUR_IP up

 

7> unload driver   

    $/sbin/ifconfig ra0 down

         $/sbin/rmmod rt2870sta

这里go to "./DPB_RT2870_Linux_STA_x.x.x.x" directory.即我们刚解压的RT3070_Linux_STA目录。修改该目录下的makefile文件,以下只给出修改部分:

#PLATFORM = PC

PLATFORM = RALINK_2880

 

ifeq ($(PLATFORM), RALINK_2880)

LINUX_SRC = /home/lqm/share/G360/kernel_kfb

CROSS_COMPILE = /opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-

endif

ifeq ($(RT28xx_MODE),APSTA)

         cp -f $(RT28xx_DIR)/os/linux/rt$(CHIPSET)apsta.ko /tftpboot

ifeq ($(OSABL),YES)

         cp -f $(RT28xx_DIR)/os/linux/rtutil$(CHIPSET)apsta.ko /tftpboot

         cp -f $(RT28xx_DIR)/os/linux/rtnet$(CHIPSET)apsta.ko /tftpboot

endif

else

         cp -f $(RT28xx_DIR)/os/linux/rt$(CHIPSET)sta.ko /home/lqm/share/NFS/tmp

注意,虽然我们使用的是2860模组,我们这里仍然可以定义PLATFORMRALINK_2880,只要后面对应的编译环境正确就可以了。LINUX_SRC表示内核的目录,CORSS_COMPILE为交叉编译环境,最末一行为编译完后将生成的KO文件复制到NFS文件系统的tmp目录。

第四步:按照第三步README_STA_usb给出的提示,修改config.mk文件,这里也只给出修改部分:

# Support Wpa_Supplicant

HAS_WPA_SUPPLICANT=y

# Support Native WpaSupplicant for Network Maganger

HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=n

CC := /opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-gcc

LD := /opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-ld

ifeq ($(PLATFORM), RALINK_2880)

EXTRA_CFLAGS := -D__KERNEL__ -I$(LINUX_SRC)/include -I$(RT28xx_DIR)/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -Uarm -fno-common -pipe -D__LINUX_ARM_ARCH__=5 -march=armv5te -msoft-float -Uarm -DMODULE -DMODVERSIONS -include $(LINUX_SRC)/include/config/modversions.h $(WFLAGS)

export EXTRA_CFLAGS

endif

注意,这里CC为交叉编译环境,LD为交叉编译的链接。默认EXTRA_CFLAGSCFLAGS,这里需要修改为EXTRA_CFLAGS,否则编译时会提示如下错误:

scripts/Makefile.build:49: *** CFLAGS was changed in "/home/lqm/share/RT3070_Linux_STA/os/linux/Makefile". Fix it to use EXTRA_CFLAGS 停止。

LINUX_ARM_ARCH一定要设置为5-march一定要设置得和CPU匹配,由于这里为MX258,因此设置为armv5te,不可设置为armv5tarmv5,否则出现如下错误:

  CC [M]  /home/lqm/share/RT3070_Linux_STA/os/linux/../../os/linux/rt_main_dev.o

{standard input}: Assembler messages:

{standard input}:340: Error: selected processor does not support `pld [r5,#0]'

{standard input}:349: Error: selected processor does not support `pld [r5,#0]'

make[2]: *** [/home/lqm/share/RT3070_Linux_STA/os/linux/../../os/linux/rt_main_dev.o] 错误 1

make[1]: *** [_module_/home/lqm/share/RT3070_Linux_STA/os/linux] 错误 2

make[1]: Leaving directory `/home/lqm/share/G360/kernel_kfb'

make: *** [LINUX] 错误 2

[root@lqm RT3070_Linux_STA]#

相关推荐

ganyouxianjava / 0评论 2012-05-31