#History:2011-05-18
#Author:yingru
新增:
在内核添加对设置雷凌网卡参数的wireless tools的支持:
Make menuconfig:
Device Drivers --->
Network device support --->
Wireless LAN (non-hamradio) --->
[*] Wireless LAN drivers (non-hamradio)
& Wireless
Extensions
[*] Wireless Extension API over
RtNetlink
--- Obsolete Wireless cards
support
(pre-802.11)
<
> STRIP
(Metricom starmode radio
IP)
<
> USB ZD1201
based Wireless device
support
<
> IEEE 802.11
for H
由于天联三号的无线网卡总是出问题,实验室打算换一款网卡,初步决定用rt3070芯片的无线网卡。
在雷凌的官网下载了rt3070的linux下sta驱动。(从makefile判断,最新发布的sta驱动也可以修改作为ap驱动或者apsta驱动)
要将linux
PC机上驱动移植到dm365上,主要修改了makefile和config.mk以及源代码的一小处。
大致步骤可以参见驱动目录下的 README_STA_usb文档,但是这个文档讲得有些笼统。
makefile:
README_STA_usb文档中所述:
In Makefile
63 set the
"MODE = STA" in Makefile and chose the TARGET to Linux by set
"TARGET = LINUX"
64 define the
linux kernel source include file path LINUX_SRC
65 modify to
meet your need.
把MODE和TARGET修改掉。如果要编译AP或者APSTA的驱动,则MODE应相应地改掉。
内核目录,修改成dm365源码ti-davinci所在。
下面要改的是PLATFORM,默认的PALTFORM是PC,这里改成DM6446,一个是因为DM6446和其他平台选项相比,与DM365更接近,最重要的原因是,细看Makefile,其实这里选择平台完全是为了下面对应修改KERNEL_SRC和CROSS_COMPILE,如果选的别的平台,在后面对应平台的if语句下,把KERNEL_SRC和CROSS_COMPILE改成自己需要的就行了。还有,与平台相关的一个参数是CFLAGS,这个参数在os/linux/config.mk中修改,下面会详细说。
258 ifeq ($(PLATFORM),DM6446)
259 #LINUX_SRC = /home/fonchi/work/soc/ti-davinci
260 LINUX_SRC =
/home/yr/workdir/lsp/ti-davinci/linux-2.6.18_pro500
261 endif
如上,平台选的是dm6446,在对应的if语句里面把LINUX_SRC改成内核源代码所在目录。
另外有一个CHIPSET参数,在makefile中没有明确让用户修改,可以通过 make CHIPSET=3070
来传递参数进makefile,达到修改CHIPSET的目的。后来发现,在fedora14下,chipset设置成3070或2070都会报如下错误:implicit
declaration of function 'RT33xx_Init'
,改回5370,错误消失。。
makefile中的参数大概就修改这几处。
下面修改os/linux下的config.mk文件:
首先set 'HAS_WPA_SUPPLICANT=y' and
'HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=n'.
这是关于安全性的设置,没有细究。
再仔细看config.mk文件,下面有这样一段与平台有关的语句:
760 ifeq ($(PLATFORM),DM6446)
761 CFLAGS := -nostdinc -iwithprefix include
-D__KERNEL__ -I$(RT28xx_DIR )/include -I$(LINUX_SRC)/include
-Wall -Wstrict-prototypes -Wno-trigraphs -
fno-strict-aliasing
-fno-common -Os -fno-omit-frame-pointer -fno-omit-frame-
pointer -mapcs
-mno-sched-prolog -mlittle-endian -mabi=apcs-gnu -D__LINUX_AR
M_ARCH__=5 -march=armv5te
-mtune=arm9tdmi -msoft-float -Uarm -Wdeclaration-a
fter-statement -c -o
$(WFLAGS)
767 export CFLAGS
768 endif
这是相应平台下CFLAGS的设置。
第一次make前我没有修改这里。make到最后会报错,错误提示如下:
arm_v5t_le-ld: ERROR: Source object
/home/yr/3070/3070driver/os/linux/rt5370sta.mod.o has EABI version
4, but target /home/yr/3070/3070driver/os/linux/rt5370sta.ko has
EABI version 0
搜索了一下关于EABI的解释,是程序和C库之间的一个接口,这个错误的大概意思应该是我用EABI编译了交叉编译链,但是又去访问OABI连接的库,出问题了。
搜遍百度,有这样一篇排版烂到家的文章。。。
http://hi.baidu.com/ovum/blog/item/c1d3cd1e178a648687d6b6c7.html
名字还TMD叫【整理】,整理你妹啊。。排版都木有。。看到吐。。
下面是我贴的那篇神一样排版的文章:
什么是ABI ABI,application binary interface
(ABI),应用程序二进制接口。既然是接口,那就是某两种东西之间的沟通桥梁,此处有这些种情况: A。应用程序
操作系统; B。应用程序
(应用程序所用到的)库 C
。应用程序各个组件之间类似于API的作用是使得程序的代码间的兼容,ABI目的是使得程序的二进制(级别)的兼容。 2。什么是OABI 和
EABI OABI中的O,表示“Old”,“Lagacy”,旧的,过时的,OABI就是旧的/老的ABI。
EABI中的E,表示“Embedded”,是一种新的ABI。 EABI有时候也叫做GNU EABI。
OABI和EABI都是专门针对ARM的CPU来说的。 3。EABI的好处 / 为何要用EABI A。支持软件浮点和硬件实现浮点功能混用
B。系统调用的效率更高 C。后今后的工具更兼容 D。软件浮点的情况下,EABI的软件浮点的效率要比OABI高很多。
4。OABI和EABI的区别两种ABI在如下方面有区别: A。调用规则(包括参数如何传递及如何获得返回值)
B。系统调用的数目以及应用程序应该如何去做系统调用 C。目标文件的二进制格式,程序库等
D。结构体中的填充(padding/packing)和对齐。 E。 OABI: * ABI flags passed to
binutils: -mabi=apcs-gnu -mfpu=fpa * gcc -dumpmachine:
arm-unknown-linux * objdump -x for compiled binary: private flags =
2: [APCS-32] [FPA float format] [has entry point] * "file" on
compiled Debian binary: ELF 32-bit LSB executable, ARM, version 1
(ARM), for GNU/Linux 2.2.0, dynamically linked (uses shared libs),
for GNU/Linux 2.2.0, stripped * "readelf -h | grep Flags"" Flags:
0x0 EABI: * ABI flags passed by gcc to binutils: -mabi=aapcs-linux
-mfloat-abi=soft -meabi=4 * gcc -dumpmachine:
arm-unknown-linux-gnueabi * objdump -x for compiled binary: private
flags = 4000002: [Version4 EABI] [has entry point] * "file" on
compiled binary (under Debian): ELF 32-bit LSB executable, ARM,
version 1 (SYSV), for GNU/Linux 2.4.17, dynamically linked (uses
shared libs), for GNU/Linux 2.4.17, stripped * "readelf -h | grep
Flags"" Flags: 0x4000002, has entry point, Version4 EABI
【如何查看当前的库文件或者目标文件是EABI还是OABI】可以通过readelf -h查看: [crifan@linux-41lh
bch]$readelf -h a_eabi_object.obj ELF Header: Magic: 7f 45 4c 46 01
01 01 00 00 00 00 00 00 00 00 00 Class: ELF32 Data: 2's complement,
little endian Version: 1 (current) OS/ABI: UNIX - System V ABI
Version: 0 Type: REL (Relocatable file) Machine: ARM Version: 0x1
Entry point address: 0x0 Start of program headers: 0 (bytes into
file) Start of section headers: 42880 (bytes into file) Flags:
0x4000000, Version4 EABI Size of this header: 52 (bytes) Size of
program headers: 0 (bytes) Number of program headers: 0 Size of
section headers: 40 (bytes) Number of section headers: 12 Section
header string table index: 9 [crifan@linux-41lh bch]$readelf -h
a_oabi_object.obj ELF Header: Magic: 7f 45 4c 46 01 01 01 61 00 00
00 00 00 00 00 00 Class: ELF32 Data: 2's complement, little endian
Version: 1 (current) OS/ABI: ARM ABI Version: 0 Type: REL
(Relocatable file) Machine: ARM Version: 0x1 Entry point address:
0x0 Start of program headers: 0 (bytes into file) Start of section
headers: 46400 (bytes into file) Flags: 0x200, GNU EABI, software
FP Size of this header: 52 (bytes) Size of program headers: 0
(bytes) Number of program headers: 0 Size of section headers: 40
(bytes) Number of section headers: 24 Section header string table
index: 21
【提示】常见遇到的一些问题,我所知道的是,对于OABI的交叉编译器,比如arm-linux-gcc这一套工具,如果你当初是用oabi编译的,那么生成的整套工具链,也是oabi的,用oabi的工具链去编译和链接其他eabi的库,就会出问题,常常是在ld的时候,提示类似如下错误:
arm-linux-ld: error: Source object
drivers/mtd/bch/bch_4_s_noRomtable.obj has EABI version 0, but
target drivers/mtd/built-in.o has EABI version 4
其解决办法就是,用同一套去编译不同的文件和链接不同的库,比如都是用OABI或者都是用EABI,比如重新去编译一个EABI的交叉工具链,然后用这个EABI的工具链去编译你其他的文件。【参考】
1。ABI/EABI/OABI
http://blog.csdn.net/hongjiujing/archive/2008/07/21/2686556.aspx
2。Why ARM's EABI Matters
http://www.chineselinuxuniversity.net/articles/1255.shtml 3.[PDF]
The new arm ABI (EABI) and Debian armel port 下载此文件 (29 个页面)
4ArmEabiPort http://wiki.debian.org/ArmEabiPort
=========================华丽的分割线============================================================
于是回去看config.mk,果然CFLAGS里面有这样一小截:-mabi=apcs-gnu
我按照上面文章的提示,把这段改成
-mabi=aapcs-linux -mfloat-abi=soft
-meabi=4
然后保存,make,错误提示:不能识别-meabi=4是神马。
回来修改config.mk,既然原来只有-mabi=apcs-gnu,那么我只把-mabi=apcs-gnu改成-mabi=aapcs-linux先。
改完后,make,成功,生成rt5370sta.ko文件。
拷到开发板上,加载成功,但是会出现一些warning,这是对没有声明GPL
license的警告(开源``你们懂得)。
只要在源代码/os/linux/usb_main_dev.c下,加上MODULE_LICENSE("GPL");再重新make一下即可。insmod没有问题。
然后按照README_STA_usb文档完成后面的几步就可以了。
啊哈哈哈~~~~~
小小的成就感~~~~~