close
http://www.linuxidc.com/Linux/2011-03/33483.htm
硬件平台:飛思卡爾MX258開發板
操作系統:Linux2.6.31
WIFI: RT2860 USB WIFI模組
交叉編譯環境:gcc version 4.1.2
調試步驟:
第一步:測試USB HOST接口
在menuconfig中將USB HOST設置為內核模式:
重新編譯內核後啟動開發板,插入U盤並掛載:
mount /dev/sda1 /tmp
ls /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
拷備到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.xxx" 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
第六步:將USB WIFI模組插到開發板的USB HOST端口,將rt3070sta.ko文件複製到文件系統的/tmp目錄,重啟開發板,進入文件系統後加載驅動:
cd /tmp
insmod rt3070sta.ko
這時會提示如下信息:
root@freescale ~$ cd /tmp
root@freescale /tmp$ insmod rt3070sta.ko
rtusb init rt2870 --->
=== pAd = c49eb000, size = 509592 ===
<-- RTMPAllocTxRxRingMemory, Status=0
<-- RTMPAllocAdapterBlock, Status=0
usbcore: registered new interface driver rt2870
root@freescale /tmp$
第七步:配置無線網卡
首先檢測開發板的網絡設備:
ifconfig
可以看到這時只有eth0和lo兩個網絡信號,使用如下命令設置無線網卡的網絡地址:
ifconfig ra0 192.168.1.5
打印信息如下:
root@freescale /tmp$ ifconfig ra0 192.168.1.5
(Efuse for 3062/3562/3572) Size=0x2d [2d0-2fc]
RTMP_TimerListAdd: add timer obj c4a32d88!
RTMP_TimerListAdd: add timer obj c4a32db4!
RTMP_TimerListAdd: add timer obj c4a32de0!
RTMP_TimerListAdd: add timer obj c4a32d5c!
RTMP_TimerListAdd: add timer obj c4a32cd8!
RTMP_TimerListAdd: add timer obj c4a32d04!
RTMP_TimerListAdd: add timer obj c49fd91c!
RTMP_TimerListAdd: add timer obj c49ece5c!
RTMP_TimerListAdd: add timer obj c49ece90!
RTMP_TimerListAdd: add timer obj c49fd9b4!
RTMP_TimerListAdd: add timer obj c49fd8c4!
RTMP_TimerListAdd: add timer obj c49fd984!
-->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
MCS Set = ff 00 00 00 01
<==== rt28xx_init, Status=0
0x1300 = 00064300
root@freescale /tmp$
再使用ifconfig查看網絡設備:
root@freescale /tmp$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:04:9F:00:EB:33
inet addr:172.18.2.133 Bcast:172.18.255.255 Mask:255.255.0.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3182 errors:0 dropped:0 overruns:0 frame:0
TX packets:1380 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3079209 (2.9 MiB) TX bytes:227540 (222.2 KiB)
Base address:0xa000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 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:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
ra0 Link encap:Ethernet HWaddr 00:E0:61:37:D0:10
inet addr:192.168.1.5 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:631 errors:0 dropped:0 overruns:0 frame:0
TX packets:83 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:92470 (90.3 KiB) TX bytes:8736 (8.5 KiB)
root@freescale /tmp$
可以看到這時多了一組ra0設備,它就是無線網卡的相關信息。
第八步:下載並編譯無線網絡工具wireless_tools.29.tar.gz
tar zxf wireless_tools.29.tar.gz
cd wireless_tools.29
修改makefile,修改部分如下:
## Compiler to use (modify this for cross compile).
CC = arm-none-linux-gnueabi-gcc
## Other tools you need to modify for cross compile (static lib only).
AR = arm-none-linux-gnueabi-ar
RANLIB = arm-none-linux-gnueabi-ranlib
修改後make,成功後會在當前目錄生成iwspy,iwpriv,iwlist以及iwconfig等文件。我們只需將這四個文件拷備到NFS文件系統的sbin目錄,然後將當前目錄的libiw.so.29庫文件拷到NFS文件系統的lib目錄,無線網絡工具即安裝完成。
如果編譯一切正常,將會在\RT3070_Linux_STA\os\linux目錄下生成rt3070sta.ko文件。
第六步:將USB WIFI模組插到開發板的USB HOST端口,將rt3070sta.ko文件複製到文件系統的/tmp目錄,重啟開發板,進入文件系統後加載驅動:
cd /tmp
insmod rt3070sta.ko
這時會提示如下信息:
root@freescale ~$ cd /tmp
root@freescale /tmp$ insmod rt3070sta.ko
rtusb init rt2870 --->
=== pAd = c49eb000, size = 509592 ===
<-- RTMPAllocTxRxRingMemory, Status=0
<-- RTMPAllocAdapterBlock, Status=0
usbcore: registered new interface driver rt2870
root@freescale /tmp$
第七步:配置無線網卡
首先檢測開發板的網絡設備:
ifconfig
可以看到這時只有eth0和lo兩個網絡信號,使用如下命令設置無線網卡的網絡地址:
ifconfig ra0 192.168.1.5
打印信息如下:
root@freescale /tmp$ ifconfig ra0 192.168.1.5
(Efuse for 3062/3562/3572) Size=0x2d [2d0-2fc]
RTMP_TimerListAdd: add timer obj c4a32d88!
RTMP_TimerListAdd: add timer obj c4a32db4!
RTMP_TimerListAdd: add timer obj c4a32de0!
RTMP_TimerListAdd: add timer obj c4a32d5c!
RTMP_TimerListAdd: add timer obj c4a32cd8!
RTMP_TimerListAdd: add timer obj c4a32d04!
RTMP_TimerListAdd: add timer obj c49fd91c!
RTMP_TimerListAdd: add timer obj c49ece5c!
RTMP_TimerListAdd: add timer obj c49ece90!
RTMP_TimerListAdd: add timer obj c49fd9b4!
RTMP_TimerListAdd: add timer obj c49fd8c4!
RTMP_TimerListAdd: add timer obj c49fd984!
-->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
MCS Set = ff 00 00 00 01
<==== rt28xx_init, Status=0
0x1300 = 00064300
root@freescale /tmp$
再使用ifconfig查看網絡設備:
root@freescale /tmp$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:04:9F:00:EB:33
inet addr:172.18.2.133 Bcast:172.18.255.255 Mask:255.255.0.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3182 errors:0 dropped:0 overruns:0 frame:0
TX packets:1380 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3079209 (2.9 MiB) TX bytes:227540 (222.2 KiB)
Base address:0xa000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 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:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
ra0 Link encap:Ethernet HWaddr 00:E0:61:37:D0:10
inet addr:192.168.1.5 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:631 errors:0 dropped:0 overruns:0 frame:0
TX packets:83 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:92470 (90.3 KiB) TX bytes:8736 (8.5 KiB)
root@freescale /tmp$
可以看到這時多了一組ra0設備,它就是無線網卡的相關信息。
第八步:下載並編譯無線網絡工具wireless_tools.29.tar.gz
tar zxf wireless_tools.29.tar.gz
cd wireless_tools.29
修改makefile,修改部分如下:
## Compiler to use (modify this for cross compile).
CC = arm-none-linux-gnueabi-gcc
## Other tools you need to modify for cross compile (static lib only).
AR = arm-none-linux-gnueabi-ar
RANLIB = arm-none-linux-gnueabi-ranlib
修改後make,成功後會在當前目錄生成iwspy,iwpriv,iwlist以及iwconfig等文件。我們只需將這四個文件拷備到NFS文件系統的sbin目錄,然後將當前目錄的libiw.so.29庫文件拷到NFS文件系統的lib目錄,無線網絡工具即安裝完成。
iwlist ra0 scanning
這時如果設備周邊有無線信號,將會搜索出這些信號並打印出來,例如:
dBm
Encryption key:on
Bit Rates:54 Mb/s
IE: WPA Version 1
Group Cipher : TKIP
Pairwise Ciphers (2) : CCMP TKIP
Authentication Suites (1) : PSK
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : TKIP
Pairwise Ciphers (2) : CCMP TKIP
Authentication Suites (1) : PSK
Cell 23 - Address: 00:25:5E:1E:38:5A
Protocol:802.11b/g
ESSID:"ChinaNet-UWfq"
Mode:Managed
Frequency:2.412 GHz (Channel 1)
Quality=26/100 Signal level=-79 dBm Noise level=-74 dBm
Encryption key:on
Bit Rates:54 Mb/s
IE: WPA Version 1
Group Cipher : TKIP
Pairwise Ciphers (1) : TKIP
Authentication Suites (1) : PSK
IE: Unknown: DD0E0050F204104A0001101044000102
Cell 24 - Address: 00:25:5E:1D:2F:FF
Protocol:802.11b/g
ESSID:"ChinaNet-eSpK"
Mode:Managed
Frequency:2.437 GHz (Channel 6)
Quality=42/100 Signal level=-73 dBm Noise level=-75 dBm
Encryption key:on
Bit Rates:54 Mb/s
IE: WPA Version 1
Group Cipher : TKIP
Pairwise Ciphers (1) : TKIP
Authentication Suites (1) : PSK
IE: Unknown: DD0E0050F204104A0001101044000102
root@freescale /tmp$
這時如果設備周邊有無線信號,將會搜索出這些信號並打印出來,例如:
dBm
Encryption key:on
Bit Rates:54 Mb/s
IE: WPA Version 1
Group Cipher : TKIP
Pairwise Ciphers (2) : CCMP TKIP
Authentication Suites (1) : PSK
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : TKIP
Pairwise Ciphers (2) : CCMP TKIP
Authentication Suites (1) : PSK
Cell 23 - Address: 00:25:5E:1E:38:5A
Protocol:802.11b/g
ESSID:"ChinaNet-UWfq"
Mode:Managed
Frequency:2.412 GHz (Channel 1)
Quality=26/100 Signal level=-79 dBm Noise level=-74 dBm
Encryption key:on
Bit Rates:54 Mb/s
IE: WPA Version 1
Group Cipher : TKIP
Pairwise Ciphers (1) : TKIP
Authentication Suites (1) : PSK
IE: Unknown: DD0E0050F204104A0001101044000102
Cell 24 - Address: 00:25:5E:1D:2F:FF
Protocol:802.11b/g
ESSID:"ChinaNet-eSpK"
Mode:Managed
Frequency:2.437 GHz (Channel 6)
Quality=42/100 Signal level=-73 dBm Noise level=-75 dBm
Encryption key:on
Bit Rates:54 Mb/s
IE: WPA Version 1
Group Cipher : TKIP
Pairwise Ciphers (1) : TKIP
Authentication Suites (1) : PSK
IE: Unknown: DD0E0050F204104A0001101044000102
root@freescale /tmp$
文章標籤
全站熱搜
留言列表