嵌入式Linux USB WIFI驅動的移植__Linux

來源:互聯網
上載者:User

硬體平台:飛思卡爾MX258開發板

作業系統:Linux2.6.31

WIFI:    RT2860 USB WIFI模組

交叉編譯環境:gcc version 4.1.2

 

調試步驟:

第一步:測試USB HOST介面

在menuconfig中將USB HOST設定為核心模式:

 

重新編譯核心後啟動開發板,插入隨身碟並掛載:

mount /dev/sda1 /tmp

ls /tmp

可以看到隨身碟已經正常掛載,測試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模組,我們這裡仍然可以定義PLATFORM為RALINK_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_CFLAGS為CFLAGS,這裡需要修改為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,不可設定為armv5t或armv5,否則出現如下錯誤:

  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]#

第五步:make

如果編譯一切正常,將會在/RT3070_Linux_STA/os/linux目錄下產生rt3070sta.ko檔案。

第六步:將USB WIFI模組插到開發板的USB HOST連接埠,將rt3070sta.ko

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.