rt3070无线网卡移植到开发板
Rt3070无线网卡AP功能移植到GEC210
一、平台
开发板:GEC210
无线网卡:RT3070
主机:VMWare--Ubuntu 10.04 LTS
内核版本:linux-2.6.35.7
编译器:arm-linux-gcc-4.5.1
所需源码:2010_0203_RT3070_SoftAP_v2.4.0.1_DPA.bz2 、 linux-2.6.35.7-gec-v2.0.tar.bz2
二、linux内核移植
1、解压内核源码linux-2.6.35.7-gec.bz2到任意目录:
#tar –jxvf linux-3.6.35.7-gec.bz2
2、进入源码目录,复制配置文件:
#cp GEC210_LINUX_CONFIG .config (注意是config前有个‘.’)
3、运行图形化配置内核把ralink支持去掉:
#make menuconfig
Device Driversà
Network device supportà
Wierless LANà
< >Ralink driver support //去掉不要
4、编译内核、制作镜像并烧写(参考烧写手册):
#make
#mkimage –n ‘linux-2.6.35.7-gec’ -A arm -O linux -T kernel -C none -a 0x30008000 -e 0x30008040 -d zImage uImage
(提示:可参考顶层目录的make.sh脚本命令)
二、修改配置无线网卡驱动源码
1、解压2010_0203_RT3070_SoftAP_v2.4.0.1_DPA.bz2压缩包
#tar jxvf 2010_0203_RT3070_SoftAP_v2.4.0.1_DPA.bz2
进入2010_0203_RT3070_SoftAP_v2.4.0.1_DPA目录
#cd 2010_0203_RT3070_SoftAP_v2.4.0.1_DPA
2、修改Makefile文件,修改为IXP平台、指定内核源码路径和编译链。在2010_0203_RT3070_SoftAP_v2.4.0.1_DPA.bz2驱动中,有三个文件夹,分别为MODULE、NETIF、UTIL,在这三个文件中均有Makefile,所有的Makefile都需要如下修改(“-”表示删除的行,“+”表示添加的行):
RT28xx_MODE = AP
TARGET = LINUX
CHIPSET = 3070
-PLATFORM = PC
+PLATFORM = IXP
………
ifeq ($(PLATFORM),IXP)
-Linux_SRC = /project………..
-CROSS_COMPILE = arm-linux-
+LINUX_SRC = /home/gec/linux-2.6.35.7-gec //内核源码绝对路径
+CROSS_COMPILE = arm-linux-
endif
3、修改config.mk文件。把大端模式去掉,改为小端模式。分别修改以下文件:源码顶层目录config.mk、MODULE/os/linux/config.mk、NETIF/os/linux/config.mk、UTIL/os/linux/config.mk。
ifeq ($(PLATFORM),IXP)
5、 WFLAGS += -DRT_BIG_ENDIAN
+#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)
#也就是把句末的“-mbig-endian”删除
EXTRA_CFLAGS := -v $(WFLAGS) –I$(RT28xx_DIR)/include
export CFLAGS
endif
4、修改UTIL/os/linux/rt_usb_util.c
因为linux 2.6.35.7内核没有 “usb_buffer_alloc”和“usb_buffer_free”这两函数,会提示错误:
/home/2010_0203_RT3070_SoftAP_v2.4.0.1_DPA/UTIL/os/linux/../../os/linux/rt_usb_util.c:126:2: error: implicit declaration of function ‘usb_buffer_alloc’
/home/2010_0203_RT3070_SoftAP_v2.4.0.1_DPA/UTIL/os/linux/../../os/linux/rt_usb_util.c:136:2: error: implicit declaration of function ‘usb_buffer_free’
故更改函数为:
usb_alloc_coherent(dev,size,mem_flags,dma);
usb_free_coherent(dev,size,addr,dma);
5、修改NETIF/os/linux/usb_main_dev.c
#gedit NETIF/os/linux/usb_main_dev.c
21 MODULE_AUTHOR("Paul Lin <paul_lin@ralinktech.com>");
22 MODULE_DESCRIPTION("RT2870 Wireless Lan Linux Driver");
23 MODULE_LICENSE("GPL");
三、编译驱动代码
1、回到2010_0203_RT3070_SoftAP_v2.4.0.1_DPA目录下,如果只是用#make编译的话,会提示“Fix it to use EXTRA_CFLAGA”错误。正确进行编译:
# make ARCH=arm KBUILD_NOPEDANTIC=1
编译完成之后,便产生了如下文件:
MODULE/os/linux/rt3070ap.ko
NETIF/os/linux/rtnet3070ap.ko
UTIL/os/linux/rtutil3070ap.ko
5、把以下四个文件拷贝到开发板里
MODULE/os/linux/rt3070ap.ko
NETIF/os/linux/rtnet3070ap.ko
UTIL/os/linux/rtutil3070ap.ko
MODULE/RT2870AP.dat(此文件为建立AP的配置文件,如果需要,可以修改一下)
四、使用AP网络
1、创建/etc/Wireless/RT2870AP/和/lib/modules/相应目录(注意大写)
#mkdir -p /etc/Wireless/RT2870AP/
#mkdir /lib/modules/
(1)把RT2870AP.dat拷贝到/etc/Wireless/RT2870AP/,其他的文件拷贝到/lib/modules/
#cp RT2870AP.dat /etc/Wireless/RT2870AP/
#cp rt3070ap.ko /lib/modules/
#cp rtnet3070ap.ko /lib/modules/
#cp rtutil3070ap.ko /lib/modules/
(2)依次插入相应的模块
#cd /lib/modules/
#insmod rtutil3070ap.ko
#insmod rt3070ap.ko
#insmod rtnet3070ap.ko
终端打印信息:
[ 210.682163] rtusb init --->
[ 210.682693]
[ 210.682696]
[ 210.682699] === pAd = e0991000, size = 420792 ===
[ 210.682703]
[ 210.683007] <-- RTMPAllocAdapterBlock, Status=0
[ 210.690004] usbcore: registered new interface driver rt2870
(3)模块都插入成功后,查看网卡
#ifconfig –a
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)
(4)启动路由功能并配置IP(注意不要跟有线网卡冲突了)
#ifconfig ra0 192.168.0.23
[ 405.588942] 1. Phy Mode = 9
[ 405.588971] 2. Phy Mode = 9
[ 405.588999] NVM is Efuse and its size =2d[2d0-2fc]
[ 405.666218] 3. Phy Mode = 9
[ 405.709848] MCS Set = ff 00 00 00 01
[ 405.738218] SYNC - BBP R4 to 20MHz.l
[ 406.141218] SYNC - BBP R4 to 20MHz.l
[ 406.543717] SYNC - BBP R4 to 20MHz.l
[ 406.949843] SYNC - BBP R4 to 20MHz.l
[ 407.352466] SYNC - BBP R4 to 20MHz.l
[ 407.754466] SYNC - BBP R4 to 20MHz.l
[ 408.156841] SYNC - BBP R4 to 20MHz.l
[ 408.559216] SYNC - BBP R4 to 20MHz.l
[ 409.175224] Main bssid = 00:e0:4c:d8:11:5c
[ 409.175265] <==== rt28xx_init, Status=0
[ 409.176845] 0x1300 = 00064320
#iwconfig ra0
ra0 RTWIFI SoftAP ESSID:"RT2860AP" Nickname:""
Mode:Managed Channel=11 Access Point: 00:E0:4C:D8:11:5C
Bit Rate=150 Mb/s
至此,一个默认的名为RT2860AP的网络就建立起来了,相关参数的修改可在RT2860AP.dat文件中完成,只要手机和电脑设置静态IP(同一网段)就可以连上网络了
2、可以通过以下命令卸载模块:
#ifconfig ra0 down
#rmmod rtnet3070ap
#rmmod rt3070ap
#rmmod rtutil3070ap
(提示:如不能卸载,请检查/lib/modules/2.6.35.7-GEC210文件夹是否存在)
相关源码和文件下载链接: http://download.csdn.net/detail/klcf0220/5888185