今天将rt3070wifi模块安装到海思3515开发板上,需要移植驱动程序。下面就移植过程做一下笔记
首先下载源码,可以到我的资源中下载http://download.csdn.net/detail/alangdangjia/5430273
其次准备好你想要移植的开发板的系统的内核源码,并且是编译过的,因为编译过之后,里面会产生config文件,这个在下面驱动的编译时是需要的。
然后解压,选择其中一个就可以,现在是使用的rt3070这个目录下的驱动
到driver2.5_1010下面,修改Makefile文件,
我选择的是5VT平台,这个没有太大的关系,你选择哪个,就修改一下那个对应的交叉编译环境就可以了,
找到5VT下面的内核路径,和交叉编译器路径,修改如下:
- ifeq ($(PLATFORM),5VT)
- LINUX_SRC = /var/Hi3515/Hi3515_SDK_V1.0.8.0/source/os/linux-2.6.24
- CROSS_COMPILE = /opt/hisi-linux/x86-arm/gcc-3.4.3-uClibc-0.9.28/arm-hisi-linux/bin/
然后修改os/linux目录下的config.mk文件
也是找到5VT对应的那部分,将CFLAGS修改为EXTRA_CFLAGS,并且去掉-Wno-pointer-sign选项,因为海思提供的交叉编译环境不支持这个选项,修改后如下:
- ifeq ($(PLATFORM),5VT)
- #CFLAGS := -D__KERNEL__ -I$(LINUX_SRC)/include -I$(RT28xx_DIR)/include -mlittle-endian -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -O3 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-omit-frame-pointer -mapcs -mno-sched-prolog -mabi=apcs-gnu -mno-thumb-interwork -D__LINUX_ARM_ARCH__=5 -march=armv5te -mtune=arm926ej-s --param max-inline-insns-single=40000 -Uarm -Wdeclaration-after-statement -Wno-pointer-sign -DMODULE $(WFLAGS)
- EXTRA_CFLAGS := -D__KERNEL__ -I$(LINUX_SRC)/include -I$(RT28xx_DIR)/include -mlittle-endian -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -O3 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-omit-frame-pointer -mapcs -mno-sched-prolog -mabi=apcs-gnu -mno-thumb-interwork -D__LINUX_ARM_ARCH__=5 -march=armv5te -mtune=arm926ej-s --param max-inline-insns-single=40000 -Uarm -Wdeclaration-after-statement -DMODULE $(WFLAGS)
- export EXTRA_CFLAGS
- endif
之所以要修改CFLAGS就是为了防止报如下的错误:
- scripts/Makefile.build:46: *** CFLAGS was changed in "/var/Hi3515/Hi3515_SDK_V1.0.8.0/source/os/linux/Makefile". Fix it to use EXTRA_CFLAGS. Stop.
当然我在网上看到有人通过另一种方式解决的,就是在make的时候添加KBUILD_NOPEDANTIC=1选项,如下
make ARCH=arm KBUILD_NOPEDANTIC=1
这样就不会提示上面的错误。但是我在通过使用这个选项的时候,虽然CFLAGS的错误不报了,但是编译的文件发生了很多处错误,所以还是修改成了EXTRA_CFLAGS。
然后就可以make了,一般来说,这样就已经可以了。
但是在我编译的过程中,出现了一个gcc报的错误:
- /var/Hi3515/2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO/os/linux/../../common/cmm_info.c: In function `RTMPCommSiteSurveyData':
- /var/Hi3515/2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO/os/linux/../../common/cmm_info.c:2370: internal compiler error: in verify_local_live_at_start, at flow.c:546
- Please submit a full bug report,
- with preprocessed source if appropriate.
- Send email to arm-gnu@codesourcery.com for instructions.
RTMPCommSiteSurveyData函数下面的内容全部屏蔽掉。这样做是有风险的:因为你不知道这个函数是干什么的,万一影响到了驱动,那么你虽然编译通过了,但是驱动根本不能工作,但是没办法,还是试了一下,万一正常呢,就算是解决了。
另外还有一种方法,就是将这个函数修改一下,而不是全部屏蔽,这个方法貌似更佳靠谱一些,我后来是采用的修改的方法,修改如下:
- #define LINE_LEN (4+33+20+23+9+7+3) // Channel+SSID+Bssid+Security+Signal+WiressMode+NetworkType
- #ifdef CONFIG_STA_SUPPORT
- #endif // CONFIG_STA_SUPPORT //
- VOID RTMPCommSiteSurveyData(
- IN PSTRING msg,
- IN PBSS_ENTRY pBss)
- {
- INT Rssi = 0;
- UINT Rssi_Quality = 0;
- NDIS_802_11_NETWORK_TYPE wireless_mode;
- CHAR Ssid[MAX_LEN_OF_SSID +1];
- STRING SecurityStr[32] = {0};
- NDIS_802_11_ENCRYPTION_STATUS ap_cipher = Ndis802_11EncryptionDisabled;
- NDIS_802_11_AUTHENTICATION_MODE ap_auth_mode = Ndis802_11AuthModeOpen;
- memset(Ssid, 0 ,(MAX_LEN_OF_SSID +1));
- //Channel
- sprintf(msg+strlen(msg),"%-4d", pBss->Channel);
- //SSID
- memcpy(Ssid, pBss->Ssid, pBss->SsidLen);
- Ssid[pBss->SsidLen] = '\0';
- sprintf(msg+strlen(msg),"%-33s", Ssid);
- //BSSID
- sprintf(msg+strlen(msg),"%02x:%02x:%02x:%02x:%02x:%02x ",
- pBss->Bssid[0],
- pBss->Bssid[1],
- pBss->Bssid[2],
- pBss->Bssid[3],
- pBss->Bssid[4],
- pBss->Bssid[5]);
- //Security
- if ((Ndis802_11AuthModeWPA <= pBss->AuthMode) &&
- (pBss->AuthMode <= Ndis802_11AuthModeWPA1PSKWPA2PSK))
- {
- if (pBss->AuthModeAux == Ndis802_11AuthModeWPANone)
- {
- ap_auth_mode = pBss->AuthMode;
- if (pBss->WPA.PairCipherAux == Ndis802_11WEPDisabled)
- ap_cipher = pBss->WPA.PairCipher;
- else
- ap_cipher = Ndis802_11Encryption4Enabled;
- }
- else if (pBss->AuthModeAux == Ndis802_11AuthModeOpen)
- {
- ap_auth_mode = pBss->AuthMode;
- if ((ap_auth_mode == Ndis802_11AuthModeWPA) ||
- (ap_auth_mode == Ndis802_11AuthModeWPAPSK))
- {
- if (pBss->WPA.PairCipherAux == Ndis802_11WEPDisabled)
- ap_cipher = pBss->WPA.PairCipher;
- else
- ap_cipher = Ndis802_11Encryption4Enabled;
- }
- else if ((ap_auth_mode == Ndis802_11AuthModeWPA2) ||
- (ap_auth_mode == Ndis802_11AuthModeWPA2PSK))
- {
- if (pBss->WPA2.PairCipherAux == Ndis802_11WEPDisabled)
- ap_cipher = pBss->WPA2.PairCipher;
- else
- ap_cipher = Ndis802_11Encryption4Enabled;
- }
- }
- else if ((pBss->AuthMode == Ndis802_11AuthModeWPAPSK) ||
- (pBss->AuthMode == Ndis802_11AuthModeWPA2PSK))
- {
- if ((pBss->AuthModeAux == Ndis802_11AuthModeWPAPSK) ||
- (pBss->AuthModeAux == Ndis802_11AuthModeWPA2PSK))
- ap_auth_mode = Ndis802_11AuthModeWPA1PSKWPA2PSK;
- else
- ap_auth_mode = pBss->AuthMode;
- if (pBss->WPA.PairCipher != pBss->WPA2.PairCipher)
- ap_cipher = Ndis802_11Encryption4Enabled;
- else if ((pBss->WPA.PairCipher == pBss->WPA2.PairCipher) &&
- (pBss->WPA.PairCipherAux != pBss->WPA2.PairCipherAux))
- ap_cipher = Ndis802_11Encryption4Enabled;
- else if ((pBss->WPA.PairCipher == pBss->WPA2.PairCipher) &&
- (pBss->WPA.PairCipherAux == pBss->WPA2.PairCipherAux) &&
- (pBss->WPA.PairCipherAux != Ndis802_11WEPDisabled))
- ap_cipher = Ndis802_11Encryption4Enabled;
- else if ((pBss->WPA.PairCipher == pBss->WPA2.PairCipher) &&
- (pBss->WPA.PairCipherAux == pBss->WPA2.PairCipherAux) &&
- (pBss->WPA.PairCipherAux == Ndis802_11WEPDisabled))
- ap_cipher = pBss->WPA.PairCipher;
- }
- else if ((pBss->AuthMode == Ndis802_11AuthModeWPA) ||
- (pBss->AuthMode == Ndis802_11AuthModeWPA2))
- {
- if ((pBss->AuthModeAux == Ndis802_11AuthModeWPA) ||
- (pBss->AuthMode == Ndis802_11AuthModeWPA2))
- ap_auth_mode = Ndis802_11AuthModeWPA1WPA2;
- else
- ap_auth_mode = pBss->AuthMode;
- if (pBss->WPA.PairCipher != pBss->WPA2.PairCipher)
- ap_cipher = Ndis802_11Encryption4Enabled;
- else if ((pBss->WPA.PairCipher == pBss->WPA2.PairCipher) &&
- (pBss->WPA.PairCipherAux != pBss->WPA2.PairCipherAux))
- ap_cipher = Ndis802_11Encryption4Enabled;
- else if ((pBss->WPA.PairCipher == pBss->WPA2.PairCipher) &&
- (pBss->WPA.PairCipherAux == pBss->WPA2.PairCipherAux) &&
- (pBss->WPA.PairCipherAux != Ndis802_11WEPDisabled))
- ap_cipher = Ndis802_11Encryption4Enabled;
- else if ((pBss->WPA.PairCipher == pBss->WPA2.PairCipher) &&
- (pBss->WPA.PairCipherAux == pBss->WPA2.PairCipherAux) &&
- (pBss->WPA.PairCipherAux == Ndis802_11WEPDisabled))
- ap_cipher = pBss->WPA.PairCipher;
- }
- sprintf(SecurityStr, "%s/%s", GetAuthMode((CHAR)ap_auth_mode), GetEncryptType((CHAR)ap_cipher));
- }
- else
- {
- ap_auth_mode = pBss->AuthMode;
- ap_cipher = pBss->WepStatus;
- if (ap_cipher == Ndis802_11WEPDisabled)
- sprintf(SecurityStr, "NONE");
- else if (ap_cipher == Ndis802_11WEPEnabled)
- sprintf(SecurityStr, "WEP");
- else
- sprintf(SecurityStr, "%s/%s", GetAuthMode((CHAR)ap_auth_mode), GetEncryptType((CHAR)ap_cipher));
- }
- sprintf(msg+strlen(msg), "%-23s", SecurityStr);
- // Rssi
- Rssi = (INT)pBss->Rssi;
- if (Rssi >= -50)
- Rssi_Quality = 100;
- else if (Rssi >= -80) // between -50 ~ -80dbm
- Rssi_Quality = (UINT)(24 + ((Rssi + 80) * 26)/10);
- else if (Rssi >= -90) // between -80 ~ -90dbm
- Rssi_Quality = (UINT)(((Rssi + 90) * 26)/10);
- else // < -84 dbm
- Rssi_Quality = 0;
- sprintf(msg+strlen(msg),"%-9d", Rssi_Quality);
- // Wireless Mode
- wireless_mode = NetworkTypeInUseSanity(pBss);
- if (wireless_mode == Ndis802_11FH ||
- wireless_mode == Ndis802_11DS)
- sprintf(msg+strlen(msg),"%-7s","11b");
- else if (wireless_mode == Ndis802_11OFDM5)
- sprintf(msg+strlen(msg),"%-7s","11a");
- else if (wireless_mode == Ndis802_11OFDM5_N)
- sprintf(msg+strlen(msg),"%-7s","11a/n");
- else if (wireless_mode == Ndis802_11OFDM24)
- sprintf(msg+strlen(msg),"%-7s","11b/g");
- else if (wireless_mode == Ndis802_11OFDM24_N)
- sprintf(msg+strlen(msg),"%-7s","11b/g/n");
- else
- sprintf(msg+strlen(msg),"%-7s","unknow");
- //Network Type
- if (pBss->BssType == BSS_ADHOC)
- sprintf(msg+strlen(msg),"%-3s"," Ad");
- else
- sprintf(msg+strlen(msg),"%-3s"," In");
- sprintf(msg+strlen(msg),"\n");
- return;
- }
将这个函数改写之后,是去掉了最后一个参数,所以在调用的地方,也需要修改,大概是在2387行,改成
RTMPCommSiteSurveyData(msg, pBss);
然后在编译即可了。
更改之后,编译通过,然后
通过在开发板中将配置文件和驱动文件拷贝过去
cp RT2870STA.dat /etc/Wireless/RT2870STA/RT2870STA.dat
cp os/linux/rt3070sta.ko /usr/rt3070sta.ko
然后加载驱动
insmod /usr/rt3070sta.ko
会看到一些信息:
- rtusb init rt2870 --->
- === pAd = c4945000,size = 513120 ===
- <-- RTMPAllocTxRxRingMemory,Status=0
- <-- RTMPAllocAdapterBlock,Status=0
- usbcore: registered new interface driver rt2870
代表加载成功,然后可以通过ifconfig -a查看是否含有ra0网卡,如果有,代表已经加载成功了
下一步要启动网卡,
ifconfig ra0 up
会出现一些提示信息,代表你当前的设置什么的:
(Efuse for 3062/3562/3572) Size=0x2d [2d0-2fc]
RTMP_TimerListAdd: add timer obj c498d5a8!
RTMP_TimerListAdd: add timer obj c498d5d4!
RTMP_TimerListAdd: add timer obj c498d600!
RTMP_TimerListAdd: add timer obj c498d57c!
RTMP_TimerListAdd: add timer obj c498d4f8!
RTMP_TimerListAdd: add timer obj c498d524!
RTMP_TimerListAdd: add timer obj c4957b3c!
RTMP_TimerListAdd: add timer obj c4946f24!
RTMP_TimerListAdd: add timer obj c4946f58!
RTMP_TimerListAdd: add timer obj c4957bd4!
RTMP_TimerListAdd: add timer obj c4957ae4!
RTMP_TimerListAdd: add timer obj c4957ba4!
-->RTUSBVenderReset
<--RTUSBVenderReset
RTMPSetProfileParameters::(CountryRegion=60)
RTMPSetProfileParameters::(SSID=JeffWu)
RTMPSetProfileParameters::(Channel=1)
RTMPSetProfileParameters::(PhyMode=4)
RTMPSetProfileParameters::(TxPower=100)
RTMPSetProfileParameters::(AuthMode=0)
RTMPSetProfileParameters::(EncrypType=1)
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)
RTMPSetProfileParameters :: (AutoRoaming=1)
RTMPSetProfileParameters :: (RoamThreshold=-72 dBm)
RTMPSetProfileParameters :: (BeaconLostTime=400 )
%%%%%%%%%%%%
1. Phy Mode = 4
2. Phy Mode = 4
NVM is Efuse and its size =2d[2d0-2fc]
(Efuse for 3062/3562/3572) Size=0x2d [2d0-2fc]
3. Phy Mode = 4
< ==== rt28xx_init, Status=0
0x1300 = 00073200
但是在我第一次加载时候,提示一个错误“
BIRIdx(6): RXDMALen not multiple of 4.[258], BulkInBufLen = 276)
BIRIdx(0): RXDMALen not multiple of 4.[257], BulkInBufLen = 272)
BIRIdx(3): RXDMALen not multiple of 4.[258], BulkInBufLen = 276)
GetPacketFromRxRing():pRxWIMPDUtotalByteCount(1281) large than RxDMALen(24)
BIRIdx(6): RXDMALen not multiple of 4.[257], BulkInBufLen = 280)
BIRIdx(0): RXDMALen not multiple of 4.[257], BulkInBufLen = 272)
BIRIdx(1): RXDMALen not multiple of 4.[258], BulkInBufLen = 276)
类似的信息不停的往出挑,这时因为DMA缓冲区设置的太大了,所以需要修改文件,从新编译驱动,修改驱动中的includ/iface/rtmp_usb.h文件
找到开头部分的#define RXBULKAGGRE_SIZE 12,将12修改为6,就可以解决了,这个数值越小,相对而言,网卡的性能越差一些,具体差多少我也不清楚。
更改完之后,重新编译,成功运行。
下面转载一下其他网友的文章
Linux Hi3515重新开始 (2)rt3070驱动移植
2013-02-22 15:20:48| 分类:HI3515学习| 标签:hi3515|字号大中小订阅
http://rpf413.blog.163.com/blog/static/45563760201161132158913/
无线网卡为RT3070,驱动分为STA驱动和SoftAP驱动两种,STA驱动支持无线网卡工作在STA模式下,而SoftAP的驱动支持无线网卡工作在软AP的模式下,可以作为一个软的接入点。STA驱动为2010_0831_RT3070_Linux_STA_v2.3.0.0_DPO.bz2。SoftAP的驱动是:2010_0203_RT3070_SoftAP_v2.4.0.1_DPA.bz2。需要移植STA驱动和SoftAP驱动,两款驱动的移植步骤差不多。下边首先对STA驱动进行移植。
1、编译驱动的预操作:编译arm版本的内核源码。(大致一样)
从tiny6410的光碟中获取内核源码,此内核源码已经经过友善之臂的移植,可以直接编译移植入tiny6410中。
cp linux-2.6.38-20110718.tar.gz/usr/src/kernels/
cd /usr/src/kernels
tar -zxvf linux-2.6.38-20110718.tar.gz
cd linux-2.6.38
cp config_mini6410_n43 .config
make menuconfig
进入内核配置界面,内核配置中需要做的修改如下:
[*] Networking support--->
[*] Wireless--->
<*> cfg80211 - wireless configuration API
[*] Wireless extensions sysfs files
<*> Generic IEEE 802.11 Networking Stack(mac80211)
Device Drivers--->
[*]Network device support--->
[*] Wireless LAN--->
<*> IEEE 802.11 for Host AP (Prism2/2.5/3 andWEP/TKIP/CCMP)
[*] Support downloading firmware images withHost AP driver
[*] Support for non-volatile firmwaredownload
<M> Ralink driver support--->
<M> Ralink rt27xx/rt28xx/rt30xx (USB) support
然后make,编译通过后会在arch/arm/boot/目录下生成可烧写入开发板的zImage内核镜像。
2:编译rt3070模块的驱动
解压tar -zxvf 2011_0107_RT3070_RT3370_Linux_STA_v2.5.0.1_DPO.tar.gz
修改原有的Makefile文件如下(只给出需要修改的部分,“-”表示删除的行,“+”表示添加的行):
+#Makefile for RT3070 on MBC-SAM9G45 +#2010_11_13 by liyi RT28xx_MODE = STA TARGET = LINUX CHIPSET = 3070 -PLATFORM = PC +PLATFORM = IXP
ifeq ($(PLATFORM),IXP) -LINUX_SRC = /project -CROSS_COMPILE = arm-linux- +LINUX_SRC = /hisi/Hi3515_SDK_V1.0.8.0/source/os/linux-2.6.24 +CROSS_COMPILE =arm-hismall-linux- endif |
修改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
ifeq ($(PLATFORM),IXP) - WFLAGS += -DRT_BIG_ENDIAN +#WFLAGS += -DRT_BIG_ENDIAN endif
ifeq ($(PLATFORM),IXP) EXTRA_CFLAGS := -v $(WFLAGS) -I$(RT28xx_DIR)/include endif
ifeq ($(PLATFORM),IXP)
- CFLAGS := -v -D__KERNEL__ -DMODULE -I$(LINUX_SRC)/include -I$(RT28xx_DIR)/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -Uarm -fno-common -pipe -mapcs-32 -D__LINUX_ARM_ARCH__=5 -mcpu=xscale -mtune=xscale -malignment-traps -msoft-float $(WFLAGS)
- EXTRA_CFLAGS := -v $(WFLAGS) -I$(RT28xx_DIR)/include
- export CFLAGS - + endif |
ifeq ($(PLATFORM),IXP)
- WFLAGS += -DRT_BIG_ENDIAN
#加这个选项,模块运行时显示出错,CPU不能工作
endif
在修改驱动config.mk文件的时候,红色修改部分没有给全,应该是把CFLAGS和EXTRA_FLAGS中的-mbig-endian选项去掉,因为在ARM中采用的小端模式!
修改完成以后,通过以下命令编译:
make ARCH=arm KBUILD_NOPEDANTIC=1 |
如果不加KBUILD_NOPEDANTIC=1将出现CFLAGS was changed in …. Fix it to use EXTRA_CFLAGS的错误,编译不能通过。编译完成后,会在os/linux文件夹中生成rt3070sta.ko的驱动模块。
会报如下错误:
/home/cabbage/Desktop/rt3070/os/linux/../../chips/rtmp_chip.c:In function 'RtmpChipOpsHook':
/home/cabbage/Desktop/rt3070/os/linux/../../chips/rtmp_chip.c:470:error: implicit declaration of function 'RT33xx_Init'
make[2]: ***[/home/cabbage/Desktop/rt3070/os/linux/../../chips/rtmp_chip.o] Error 1
make[1]: ***[_module_/home/cabbage/Desktop/rt3070/os/linux] Error 2
make[1]: Leaving directory`/usr/src/kernels/linux-2.6.38'
make: *** [LINUX] Error 2
在网上查到似乎是因为改变了CHIPSET所导致的错误。修改chips/目录下的rtmp_chip.c文件,定位到470行,修改后如下:
#ifdef RT30xx
if (IS_RT30xx(pAd))
{
if (IS_RT3390(pAd))
;//RT33xx_Init(pAd);
else
RT30xx_Init(pAd);
}
#endif /* RT30xx */
3、烧写内核和加载驱动
将之前编译好的zImage镜像通过dnw烧写入开发板中,将rt3070sta.ko和驱动源码目录下的RT2870STA.dat两个文件通过nfs或者sd卡下载到开发板中,RT2870STA.dat放入/etc/Wireless/RT2870STA/目录下,rt3070sta.ko放入任意合适的目录,我放在了/usr下。
mkdir –p /etc/Wireless/RT2870STA/
cp RT2870STA.dat / etc/Wireless/RT2870STA/
cp rt3070sta.ko /usr
加载驱动
insmod /usr/rt3070sta.ko
rtusb init rt2870 --->
=== pAd = d1502000, size = 513400 ===
<-- RTMPAllocTxRxRingMemory, Status=0
<-- RTMPAllocAdapterBlock, Status=0
usbcore: registered new interface driver rt2870
然后可以通过ifconfig –a可以看到系统已经正确识别网卡,名称为ra0。
ifconfig –a
ra0 Link encap:EthernetHWaddr 00:00:00:00:00:00
BROADCAST MULTICASTMTU:1500Metric: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 d1549ba8!
RTMP_TimerListAdd: add timer obj d1549bd8!
RTMP_TimerListAdd: add timer obj d1549c08!
RTMP_TimerListAdd: add timer obj d1549b78!
RTMP_TimerListAdd: add timer obj d1549ae8!
RTMP_TimerListAdd: add timer obj d1549b18!
RTMP_TimerListAdd: add timer obj d151471c!
RTMP_TimerListAdd: add timer obj d1503edc!
RTMP_TimerListAdd: add timer obj d1503f14!
RTMP_TimerListAdd: add timer obj d15147c0!
RTMP_TimerListAdd: add timer obj d15146bc!
RTMP_TimerListAdd: add timer obj d151478c!
-->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
至此网卡驱动移植成功。但是如果需要让网卡连接入目前常见的WPA加密的网络,还需要移植wpa_supplicant工具。
另外还有一个名为wireless_tools的辅助工具,可以用它来检索在网卡所在的环境中存在的无线网络,如果对于要连接入的无线网络的ssid和相关信息已经清楚,可以不用移植,不过这个工具的移植很简单。
4、移植wireless_tools
源码下载地址:http://download.csdn.net/detail/colwer/4515005#comment(这个地址里的资源跟描述不一致……)
tar zxvf wireless_tools.29.tar.gz
cd wireless_tools.29
vim Makefile
PREFIX = /usr/local/wirelesstool
CC =/usr/local/FriendlyARM/toolschain/4.5.1/bin/arm-linux-gcc
AR =/usr/local/FriendlyARM/toolschain/4.5.1/bin/arm-linux-ar
RANLIB =/usr/local/FriendlyARM/toolschain/4.5.1/bin/arm-linux-ranlib
make
make install
在/usr/local/wirelesstool/lib目录下找到libiw.so.29,下载到开发板的/lib/目录下;/usr/local/wirelesstool/sbin目录下找到iwpriv、iwconfig、iwlist, iwevent, iwspy等命令,下载到开发板的/usr/sbin目录下。这时就应该可以使用这些命令通过网卡搜索到环境中的无线网络。
ifconfig ra0 up
iwlist ra0 scan
Cell 06 - Address: 38:83:45:E5:CB:3E
Protocol:802.11b/g/n
ESSID:"idart-wlan311"
Mode:Managed
Frequency:2.437 GHz (Channel 6)
Quality=100/100Signal level=-43 dBmNoise level=-92 dBm
Encryption key:on
Bit Rates:22.5 Mb/s
IE: WPA Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
IE: Unknown: DD0E0050F204104A0001101044000102
Cell 07 - Address: 58:66:BA:EE:DB:40
Protocol:802.11b/g/n
ESSID:"ChinaNet"
Mode:Managed
Frequency:2.437 GHz (Channel 6)
Quality=42/100Signal level=-73 dBmNoise level=-76 dBm
Encryption key:off
Bit Rates:54 Mb/s
Cell 08 - Address: 58:66:BA:EE:DB:41
Protocol:802.11b/g/n
ESSID:"SYSUWLAN"
Mode:Managed
Frequency:2.437 GHz (Channel 6)
Quality=37/100Signal level=-75 dBmNoise level=-78 dBm
Encryption key:off
Bit Rates:54 Mb/s
至此wireliss_tools移植成功。
设置ESSID 实验室的无线网络没有密码因此可以直接设置联网
# iwconfig ra0 ESSID Mywifi
此时已经可以ping同其他电脑了!!!!!!!!
下面移植的工具我一直没有成功,提示错误,因此目前还没有解决有密码的wifi网络问题!!
/ $ wpa_supplicant -B -irausb0 -c /etc/wpa_supplicant.conf -Dralink
/usr/sbin/wpa_supplicant: /usr/sbin/wpa_supplicant: 1: Syntax error: "(" unexpected
5、移植wpa_supplicant
源码下载地址:http://hostap.epitest.fi/wpa_supplicant/
它的移植还需要openssl,下载地址:http://www.openssl.org/source/
我使用的是wpa_supplicant-0.6.10和openssl-0.9.8e。
将两个包解压后,需要为opensll打上wpa的补丁,然后交叉编译
cp wpa_supplicant-0.6.10/patches/openssl-0.9.8e-tls-extensions.patch openssl-0.9.8e/
cd openssl-0.9.8e
mkdir /usr/local/ssl
vim Makefile
INSTALLTOP=/usr/local/ssl
OPENSSLDIR=/usr/local/ssl
……
CC= arm-linux-gcc
AR= arm-linux- ar $(ARFLAGS) r
RANLIB= arm-linux-ranlib
make
make install
在/usr/local/ssl目录下安装了ssl库。
然后进入到wpa_supplicant的目录,修改配置文件和Makefile
cd ../wpa_supplicant-0.6.10/wpa_supplicant
cp defconfig .config
vim .config
# Uncomment following two lines and fix the paths if you have installed OpenSSL
# or GnuTLS in non-default location
CFLAGS += -I/usr/local/ssl/include
LIBS += -L/usr/local/ssl/lib
vim Makefile
#ifndef CC
CC=arm-linux-gcc
#endif
然后make,便可以在当前目录下得到需要的wpa_supplicant工具
将wpa_supplicant和配置文件wpa_supplicant.conf下载到开发板中,wpa_supplicant替换掉原本开发板/usr/sbin/目录下的wpa_supplicant,wpa_supplicant.conf放在/etc目录下,对wpa_supplicant.conf文件进行编辑:
ctrl_interface=/var/run/wpa_supplicant
network={
ssid="idart-wlan311"
scan_ssid=1
key_mgmt=WPA-EAP WPA-PSK IEEE8021X NONE
pairwise=TKIP CCMP
group=CCMP TKIP WEP104 WEP40
psk="XXXXXXXX"
}
其中的psk为无线网的密码
然后把文件末尾提供的一些example全部删除,否则在使用wpa_supplicant时会报一些类型无法识别的错误。
最后进行测试,测试之前要关闭有线网卡eth0,原因是如果不关闭的话在之后添加默认路由时会被设置为有线网卡的默认路由,这个应该有别的解决方法,不过我没有仔细去查。
ifconfig eth0 down
ifconfig ra0 up
ifconfig ra0 192.168.1.248 netmask 255.255.255.0
route add default gw 192.168.1.1
wpa_supplicant -B -ira0 -c /etc/wpa_supplicant.conf –Dwext
===>rt_ioctl_giwscan. 28(28) BSS returned, data->length = 3351
==>rt_ioctl_siwfreq::SIOCSIWFREQ(Channel=6)
RTMP_TimerListAdd: add timer obj d15785c4!
6、ping通外网
ping www.google.com
Rcv Wcid(1) AddBAReq
Start Seq = 00000000
RTMP_TimerListAdd: add timer obj d157a5e4!
PING www.google.com (74.125.128.106): 56 data bytes
64 bytes from 74.125.128.106: seq=0 ttl=40 time=86.383 ms
64 bytes from 74.125.128.106: seq=1 ttl=40 time=84.996 ms
64 bytes from 74.125.128.106: seq=2 ttl=40 time=102.010 ms
64 bytes from 74.125.128.106: seq=3 ttl=40 time=86.005 ms
^C
--- www.google.com ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 84.996/89.848/102.010 ms
另一篇:
History:2011-10-25
Author:yr
雷凌系列网卡驱动移植后的调试工作记录:
为了支持多块wifi网卡同时在板子上启动,需要修改驱动源代码的参数。
假设板子上有3块网卡,都作为AP端使用,加载移植好的驱动后,分别驱动出ra0,ra1,ra2三个接口。
ifconfig ra0 up 成功,ifconfig ra1 up 时 提示:
<-- ERROR in Alloc TX TxContext[3] HTTX_BUFFER !!
<-- RTMPAllocTxRxRingMemory, Status=3
ERROR!!! RTMPAllocDMAMemory failed, Status[=0x00000003]
!!! rt28xx Initialized fail !!!
ifconfig: SIOCSIFFLAGS: Operation not permitted
修改MODULE NETIF UTIL三个目录下的include/os/rt_linux.h中BULKAGGRE_SIZE参数,将100改为60,可以成功启动ra0 和 ra1 但是ra2启动失败。继续减小这一参数值,到30后,三快都可以启动成功。
ifconfig rax up时若提示BIRIdx(0): RXDMALen not multiple of 4.[38539], BulkInBufLen = 172,说明DMA空间不够下一块网卡加载了,需要继续减小,但是应该会影响性能。
////////////////////////////////下面内容转载自一技术帖回复///////////////////////////////////
该网卡驱动需要使用DMA内存,而且还挺大(没记错的话有200k左右),出错的原因是驱动申请DMA内存失败。
解决办法:
1. 先确定系统可用于DMA的内存有多大,其他驱动是否用得差不多了。
2. 如果不能修改系统DMA内存大小,那么
3. 修改rt2870驱动rtmp_usb.h将BULKAGGRE_ZISE宏改小一些,比如(60)
在网上看到的。
http://www.61ic.com/code/redirect.php?fid=170&tid=18751&goto=nextoldset
http://blog.csdn.net/bbandxq521/archive/2010/11/09/5997419.aspx
如果再次出现一些error的话:
[99] RtmpOSFileOpen(): Error 2 opening /etc/Wireless/RT2870STA/RT2870STA.dat
[99] Open file "/etc/Wireless/RT2870STA/RT2870STA.dat" failed!
[99] 1. Phy Mode = 0
[99] ERROR!!! NICReadRegParameters failed, Status[=0x00000001]
[99] usb 1-1: RtmpTimerTask timed out on ep0in len=4/4
[99] usb 1-1: wpa_supplicant timed out on ep0in len=4/4
[99] ---> RTMPFreeTxRxRingMemory
[99] <--- RTMPFreeTxRxRingMemory
[99] !!! rt28xx Initialized fail !!!
[99] rt28xx_open return fail!
如果是PC机,请参考驱动包里的sta_ate_iwpriv_usage.txt文件。里面有这样的英文:
=======================================================================
CONFIGURATION:
====================
RT2870 driver can be configured via following interfaces,
i.e. (i)"iwconfig" command, (ii)"iwpriv" command, (iii) configuration file
i) iwconfig comes with kernel.
ii) iwpriv usage, please refer to file "iwpriv_usage.txt" for details.
iii)modify configuration file "RT2870STA.dat" in /etc/Wireless/RT2870STA/RT2870STA.dat.
Configuration File : RT2870STA.dat
---------------------------------------
# Copy this file to /etc/Wireless/RT2870STA/RT2870STA.dat
# This file is a binary file and will be read on loading rt.o module.
#
# Use "vi RT2870STA.dat" to modify settings according to your need.
#
# 1.) set NetworkType to "Adhoc" for using Adhoc-mode, otherwise using Infrastructure
# 2.) set Channel to "0" for auto-select on Infrastructure mode
# 3.) set SSID for connecting to your Accss-point.
# 4.) AuthMode can be "WEPAUTO", "OPEN", "SHARED", "WPAPSK", "WPA2PSK", "WPANONE"
# 5.) EncrypType can be "NONE", "WEP", "TKIP", "AES"
# for more information refer to the Readme file.
#
因为我是做嵌入式的,为了省事,就将RT2870STA.dat直接固话到嵌入式设备里。然后修改路径就OK了。路径在/include/os/rt_linux.h里。
#define STA_PROFILE_PATH "/etc/Wireless/RT2870STA/RT2870STA.dat"
前段时间搞了一下RT73与wpa_supplicant,调通了,无论是什么加密方式和认证类型,RT73都可以良好的工作。可又由于RT73停产了,*要使用RT3070。刚开始我以为应该和RT73差不多,果不其然,用法十分接近,但是也有一点点区别的。
1.首先RT73使用的是rausb0表示的,而RT3070使用ra0表示。
2.RT3070的驱动差不多是RT73的两倍多。
3.另外,在使用wpa_supplicant上也有点小区别,主要是wpa_supplicant版本的问题。
下面,我就说一下我的使用过程,希望可以帮助到大家!
首先是驱动的编译,从网上下了好多RT3070的驱动,都没交叉编译过去,只有2009_1106_RT3070_Linux_STA_V2.1.1.0.bz2这一版本的编译过去了,呵呵!
交叉编译过程:
1.tar -jxvf 2009_1106_RT3070_Linux_STA_V2.1.1.0.bz2
2. cd 2009_1106_RT3070_Linux_STA_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
4.cd os/linux
5.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 //
6.cd ../../common
vi rtusb_io.c:
- if (ret < 0) {
- //DBGPRINT(RT_DEBUG_OFF, ("#/n"));
- RTMPusecDelay(5000);
- }
否则,加载驱动后会一直打印"#",很烦!!!!!
7.cd ../../..
8.make
这时,应该就编译通过了。在2009_1106_RT3070_Linux_STA_V2.1.1.0/os/linux目录下生成了rt3070sta.ko,也就是RT3070的驱动了。
9.把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
注意wireless_tools之前要移植到开发板上!
接下来就是wpa_supplicant的交叉编译,这个比较麻烦,在这里就不详细说明了,给个网址给大家,我也是参考着做的:
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 ./
- 本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/farsight2009/archive/2010/06/10/5660878.aspx
这些部分就可以略去了,不用做了,呵呵!
顺利地话,就可以在wpa_supplicant-0.6.10/wpa_supplicant下生成wpa_supplicant了!接着就是把wpa_supplicant拷贝到开发板中。
关于wpa_supplicant的使用:
1.把wpa_supplicant.conf拷贝到/etc目录下,当然要根据情况修改wpa_supplicant.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加密比较简单,在后面会提到,呵呵!!!
2.mkdir -p /var/run/wpa_supplicant
3.最后就是用命令
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模式下的配置跟简单,不需要使用wpa_supplicant!
可以参考里面的iwpriv_usage.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"
=============================The End==============================
==========================================================================================================
发现做达芬奇平台有很多qq交流群,但是海思平台的QQ交流群却很少,至少我在网上没有找到,于是我打算创建一个。
小弟自从毕业已经搞海思的平台有2年半了,刚开始主要做上层,做过一个流媒体播放器,可以在手机上观看实时视频。转向做驱动也有接近2年的时间了,想创建一个群用于交流,没有其他什么意思,希望志同道合的朋友们用于加入,踊跃发言!谢谢!最后注明QQ群号码:
213622826
==========================================================================================================