RT3070驱动移植

无线网卡为RT3070,驱动分为STA驱动和SoftAP驱动两种,STA驱动支持无线网卡工作在STA模式下,而SoftAP的驱动支持无线网卡工作在软AP的模式下,可以作为一个软的接入点。STA驱动为2010_0831_RT3070_Linux_STA_v2.3.0.0_DPO.bz2SoftAP的驱动是:2010_0203_RT3070_SoftAP_v2.4.0.1_DPA.bz2。需要移植STA驱动和SoftAP驱动,两款驱动的移植步骤差不多。下边首先对STA驱动进行移植。

 

STA驱动的移植

 

#tar jxvf 2010_0831_RT3070_Linux_STA_v2.3.0.0_DPO.bz2

cd 2010_0831_RT3070_Linux_STA_v2.3.0.0_DPO

修改原有的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 = /home/Embest_SAM9G45/linux-2.6.30

+CROSS_COMPILE = /usr/local/arm2007q1/bin/arm-none-linux-gnueabi-

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

修改完成以后,通过以下命令编译:

make ARCH=arm KBUILD_NOPEDANTIC=1

如果不加KBUILD_NOPEDANTIC=1将出现CFLAGS was changed in …. Fix it to use EXTRA_CFLAGS的错误,编译不能通过。编译完成后,会在os/linux文件夹中生成rt3070sta.ko的驱动模块。此模块通过下载工具可以下载到/mnt目录。

在驱动目录下新建一个文件夹Wireless/RT2870STA,将RT2870STA.dat复制进Wireless/RT2870STAm目录下,同时将此文件夹拷贝进开发板。从超级终端进入开发板目录/mnt使用以下命令将Wireless文件夹拷贝到/etc目录下,将rt3070sta.ko拷贝进/home/root用户目录下:

#cp /mnt/Wireless /usr –r

#cp /mnt/rt3070sta.ko /home/root

打开root目录,加载驱动模块:

#cd /home/root

#insmod rt3070sta.ko

如果加载出现一下错误:

#insmod rt3070sta.ko

insmod: error inserting 'rt3070sta.ko': -1 Unknown symbol in module

#dmesg | grep rt3070

[ 2443.154486] rt2070ap: Unknown symbol usb_alloc_urb

[ 2443.154628] rt2070ap: Unknown symbol usb_free_urb

[ 2443.155032] rt2070ap: Unknown symbol usb_register_driver

[ 2443.155324] rt2070ap: Unknown symbol usb_put_dev

[ 2443.155439] rt2070ap: Unknown symbol usb_get_dev

[ 2443.155652] rt2070ap: Unknown symbol usb_submit_urb

[ 2443.156164] rt2070ap: Unknown symbol usb_control_msg

[ 2443.156553] rt2070ap: Unknown symbol usb_deregister

[ 2443.157013] rt2070ap: Unknown symbol usb_kill_urb

[ 2443.157116] rt2070ap: Unknown symbol usb_buffer_free

[ 2443.157443] rt2070ap: Unknown symbol find_vpid

[ 2443.157675] rt2070ap: Unknown symbol usb_buffer_alloc

则需要在文件os/linux/usb_main_dev.c文件的开头加上如下一行代码:

MODULE_LICENSE(“GPL”);

然后重新编译、重新加载,即可得到正确的结果。

ifconfig  -a命令查看网络,如果加载成功,不会有任何提示,同时可以查看到ra0设备的存在。

加载上模块过后,可以用相关命令设置无线网卡。命令包括iwpriviwconfigiwlistifconfig等。比如设置无线网卡地址为192.168.1.5

ifconfig ra0 192.168.1.5

设置无线网络模式为ad-hoc模式:

iwpriv ra0 set NetworkType=Adhoc

设置SSID名为isn313

iwconf ra0 essid isn313

查看无线网络:

iwlist ra0 scanning

SoftAP驱动移植

解压驱动2010_0203_RT3070_SoftAP_v2.4.0.1_DPA.bz2,然后进入目录:

tar jxvf 2010_0203_RT3070_SoftAP_v2.4.0.1_DPA.bz2

cd 2010_0203_RT3070_SoftAP_v2.4.0.1_DPA

修改Makefile如下(“-”表示删除的行,“+”表示添加的行):

+#Makefile for RT3070 on MBC-SAM9G45

+#2010_11_13 by liyi

RT28xx_MODE = AP

TARGET = LINUX

CHIPSET = 3070

-PLATFORM = PC

+PLATFORM = IXP

………

ifeq ($(PLATFORM),IXP)

-Linux_SRC = /project………..

-CROSS_COMPILE = arm-linux-

+LINUX_SRC = /home/Embest_SAM9G45/linux-2.6.30

+CROSS_COMPILE = /usr/local/arm2007q1/bin/arm-none-linux-gnueabi-

endif

注意,在2010_0203_RT3070_SoftAP_v2.4.0.1_DPA.bz2驱动中,有三个文件夹,分别为MODULENETIFUTIL,在这三个文件中均有Makefile,所有的Makefile都需要如上修改,同样,三个文件夹中的config.mk文件也都需要修改。

修改config.mk配置文件。

ifeq ($(PLATFORM),IXP)

- WFLAGS += -DRT_BIG_ENDIAN

+#WFLAGS += -DRT_BIG_ENDIAN

endif

 

ifeq ($(PLATFORM),IXP)

#WFLAGS += -DRT_BIG_ENDIAN

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

 

对不起,在修改驱动config.mk文件的时候,红色修改部分没有给全,应该是把CFLAGS和EXTRA_FLAGS中的-mbig-endian选项去掉,因为在ARM中采用的小端模式!特此更正!

 

 

所有的config.mk都修改好以后,通过以下命令进行编译:

make ARCH=arm KBUILD_NOPEDANTIC=1

如果编译不能通过,请检查是否所有的文件夹中的Makefileconfig.mk都已经修改。编译通过后,将在三个文件夹中分别生成三个可加载模块:rt3070ap.kortutil3070ap.kortnet3070ap.ko。通过USB接口将这三个模块和rt2870ap.dat文件下载到开发板目录下。并将文件移动到相应位置:

#mkdir /etc/Wireless/

#mkdir /etc/Wireless/RT2870AP/

#cp /mnt/rt2870ap.dat /etc/Wireless/RT2870AP/RT2870AP.dat

#cp /mnt/rt3070ap.ko /home/root

#cp /mnt/rtutil3070ap.ko /home/root

#cp /mnt/rtnet3070ap.ko /home/root

第三行中,在RT2870AP文件夹中的.dat文件名必须是大写的,否则模块将无法读取。

移动好后,进入root目录并加载模块:

#cd /home/root

#insmod rtutil3070ap.ko

#insmod rt3070ap.ko

#insmod rtnet3070ap.ko

#ifconfig ra0 up

此处,加载模块一定要按此顺序加载,否则将出现以下错误(用dmesg函数可查看相关错误信息):

#insmod rt3070sta.ko

insmod: error inserting 'rt3070sta.ko': -1 Unknown symbol in module

#dmesg | grep rt3070

 

[ 1011.612979] rt3070ap: Unknown symbol rausb_buffer_free

[ 1011.613153] rt3070ap: Unknown symbol RtmpOSTaskNotifyToExit

[ 1011.613410] rt3070ap: Unknown symbol rausb_buffer_alloc

[ 1011.613536] rt3070ap: Unknown symbol RTMPFreeNdisPacket

[ 1011.613692] rt3070ap: Unknown symbol AdapterBlockAllocateMemory

[ 1011.613816] rt3070ap: Unknown symbol RTMP_IndicateMediaState

[ 1011.614106] rt3070ap: Unknown symbol RTMP_SetPeriodicTimer

[ 1011.614241] rt3070ap: Unknown symbol os_alloc_mem

[ 1011.614373] rt3070ap: Unknown symbol ClonePacket

[ 1011.614505] rt3070ap: Unknown symbol RTDebugLevel

[ 1011.614646] rt3070ap: Unknown symbol announce_802_3_packet

[ 1011.614780] rt3070ap: Unknown symbol Sniff2BytesFromNdisBuffer

 [ 1011.614916] rt3070ap: Unknown symbol RTMP_OS_Add_Timer

[ 1011.615043] rt3070ap: Unknown symbol rausb_submit_urb

[ 1011.615167] rt3070ap: Unknown symbol RTMP_AllocateFragPacketBuffer

[ 1011.615292] rt3070ap: Unknown symbol rausb_alloc_urb

[ 1011.615491] rt3070ap: Unknown symbol RtmpOSNetPktAlloc

[ 1011.615616] rt3070ap: Unknown symbol VLAN_8023_Header_Copy

[ 1011.615739] rt3070ap: Unknown symbol RTMP_OS_Mod_Timer

[ 1011.615863] rt3070ap: Unknown symbol os_free_mem

[ 1011.616005] rt3070ap: Unknown symbol rausb_control_msg

[ 1011.616079] rt3070ap: Unknown symbol duplicate_pkt_with_TKIP_MIC

[ 1011.616079] rt3070ap: Unknown symbol duplicate_pkt_with_VLAN

[ 1011.616079] rt3070ap: Unknown symbol DuplicatePacket

[ 1011.616079] rt3070ap: Unknown symbol RtmpOSTaskCustomize

[ 1011.616079] rt3070ap: Unknown symbol RTMP_OS_Del_Timer

[ 1011.616079] rt3070ap: Unknown symbol rausb_free_urb

[ 1011.616079] rt3070ap: Unknown symbol get_netdev_from_bssid

[ 1011.616079] rt3070ap: Unknown symbol hex_dump

[ 1011.616079] rt3070ap: Unknown symbol RtmpOSFileOpen

[ 1011.616079] rt3070ap: Unknown symbol RTMPFreeAdapter

[ 1011.616079] rt3070ap: Unknown symbol RtmpOSFSInfoChange

[ 1011.616079] rt3070ap: Unknown symbol wlan_802_11_to_802_3_packet

[ 1011.618201] rt3070ap: Unknown symbol RTMP_GetCurrentSystemTime

[ 1011.618341] rt3070ap: Unknown symbol RTMPAllocateNdisPacket

[ 1011.618498] rt3070ap: Unknown symbol RTMPSendWirelessEvent

[ 1011.618621] rt3070ap: Unknown symbol RTMPL2FrameTxAction

[ 1011.618747] rt3070ap: Unknown symbol rausb_kill_urb

[ 1011.618899] rt3070ap: Unknown symbol RTMP_OS_Init_Timer

[ 1011.619022] rt3070ap: Unknown symbol RTMPusecDelay

[ 1011.619147] rt3070ap: Unknown symbol update_os_packet_info

[ 1011.619312] rt3070ap: Unknown symbol RtmpOSFileRead

[ 1011.619517] rt3070ap: Unknown symbol RtmpOSFileClose

[ 1011.619641] rt3070ap: Unknown symbol RTMP_QueryPacketInfo

[ 1011.619764] rt3070ap: Unknown symbol RtmpOSFileWrite

在加载过程中若出现以下错误:

[421.461365] rt3070ap: module license 'RALINK' taints kernel.

[421.461723] Disabling lock debugging due to kernel taint

请修改UTIL/os/linux/usb_main_dev.c文件,在文件的开头加上如下一行程序:

MODULE_LICENSE(“GPL”)

重新编译:

#make clean

#make KBUILD_NOPEDANTIC=1

然后再重新下载,按顺序加载模块即可成功。

模块加载成功后,用一下命令可查看相关信息:

#ifconfig –a

eth0      Link encap:Ethernet  HWaddr 3A:1F:34:08:54:54

          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)

          Interrupt:25 Base address:0xc000

 

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:8 errors:0 dropped:0 overruns:0 frame:0

          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:576 (576.0 B)  TX bytes:576 (576.0 B)

 

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)

#iwconfig ra0

ra0       RTWIFI SoftAP  ESSID:"RT2860AP"  Nickname:""

          Mode:Managed  Channel=11  Access Point: 00:0C:43:41:6F:A6

          Bit Rate=150 Mb/s

ifconfig命令设定ra0IP地址:

#ifconfig ra0 192.168.1.1

ra0       Link encap:Ethernet  HWaddr 00:0C:43:41:6F:A6

          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0

          UP BROADCAST RUNNING 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:121922 (119.0 KiB)  TX bytes:9072 (8.8 KiB)

至此,一个默认的名为RT2860AP的网络就建立起来了。用iwconfig命令可修改网络的相关参数。如:

#iwconfig ra0 set SSID=”RT_AP”

#iwconfig ra0

ra0       RTWIFI SoftAP  ESSID:"RT_AP"  Nickname:""

          Mode:Managed  Channel=11  Access Point: 00:0C:43:41:6F:A6

          Bit Rate=150 Mb/s

结束后,可以通过以下命令卸载模块:

#ifconfig ra0 down

#rmmod rtnet3070ap.ko

#rmmod rt3070ap.ko

#rmmod rtutil3070ap.ko

Logo

更多推荐