在uClinux上安装madwifi驱动

在uClinux上安装madwifi驱动

早年写的笔记,压箱底了,翻出来晒晒

 

目             录

在uClinux上安装mawifi驱动... 1

实验环境... 1

在uClinux2.4下编译安装madwifi2

1. 配置uClinux2.4内核... 2

2. 修改,编译madwifi驱动... 5

3. 安装驱动,配置开发板... 6

在uClinux2.6下编译安装madwifi8

1. 配置uClinux2.6内核... 8

2. 修改,编译madwifi驱动... 10

3. 安装驱动,配置开发板... 10

驱动编译的摸索过程... 13

1. 开始准备软件... 13

2. 开始编译... 14

3. 修改源文件... 17

4. 编译madwifi20060631. 24

5.编译madwifi20060631的tools29

6. 安装配置madwifi20060631. 31

7. 编译madwifi总结... 32

 

实验环境

u  IXP425DP(P720 板) 266Mhz 64M ram16M flash

u  Vmware6.5, 2CPU.

u  FC4: kernel 2.6.11-1.1369_FC4smp(FC6 也行),安装在虚拟机上

u  arm-linux-tools-20051123.tar.gz:gcc 3.4.4 编译器

u  snapgear-3.5.0.tar.gz: snapgear 发布的uClinux 包

u  snapgear-modules-20071004.sh: snapgear 发布的uClinux 包

u  BSD_ixp400AccessLibrary-2_4.zip: IXP 网卡驱动

u  IPL_ixp400NpeLibrary-2_4.zip: IXP 网卡驱动补丁

u  Kernel files in /home/linuxuser/snapgear

u  Madwifi在/home/linuxuser/P720/madwifi/madwifi-0.9.4

 

在uClinux2.4下编译安装madwifi

1. 配置uClinux2.4内核

从sourceforge上可以下载madwifi-0.9.4s,解开后可以发现INSTALL文件,里面对内核有几项要求:

/**************************************/

-Wireless Extensions support (14 or later, 17 preferred) - option

  CONFIG_NET_RADIO in kernel .config file.

 

-Sysctl support - option CONFIG_SYSCTL in kernel .config file.

 

-Crypto API support - option CONFIG_CRYPTO in kernel .config file (AES

  support is used if present, otherwise the AES-CCMPcipher module falls

  back to a private implementation).

-        gcc of same version that was used to compile thekernel.

/**************************************/

       那么必须进行重新编译内核了。

Sysctl是内核中默认的,这里修改Crypto和WirelessExtensions support。另外为了能够配置无线网络,必须选上iwconfig等工具。

    首先按照<移植uClinux2.4到IX425DP>一章讲述的方法配置其他选项,下面讲述Crypto和WirelessExtensions support的方法。

 

1.  在menuconfig中选择Cryptographicoptions->Cryptographic API。

截图如下,按图中选中即可。

2.  在menuconfig中选择network devicesupport->wireless LAN(non-hamradio)即可,这样就打开了Wireless Extensions support。

截图如下,按图中选中即可。

 

 

3. 在CustomizeVendor/User Settings, 选择networkapplications->wireless tools support.会多出来几个选项如iwconfig,都选上再说。

选择完成之后使用make dep, make重新编译内核。

 

2. 修改,编译madwifi驱动

       步骤如下;

1.     打开madwifi-0.9.4/hal/public/xscale-be-elf.inc,找到

COPTS+=-march=armv4 -mbig-endian -fno-strict-aliasing -fno-common -mapcs-32 \

    -mtune=xscale  -mshort-load-bytes

去掉-march=armv4,修改为

COPTS+=-mbig-endian -fno-strict-aliasing -fno-common -mapcs-32 \

    -mtune=xscale  -mshort-load-bytes

 

2.     打开madwifi-0.9.4/Makefile.inc找到COPTS+=  -Werror,删除之。

3.     打开madwifi-0.9.4/tools/makefile将

CC =$(USER_CROSS_COMPILE)gcc

替换为

UCGCC =/home/linuxuser/snapgear/tools/ucfront-gcc

CC = $(UCGCC)$(USER_CROSS_COMPILE)gcc

另外在CFLAGS=  -g -O2 –Wall后面加上CFLAGS+=-mbig-endian

 

4.     编译驱动。

进入madwifi-0.9.4/文件夹下执行如下命令

exportPATH=$PATH:/home/linuxuser/usr/local/bin

Make clean

makeKERNELPATH=/home/linuxuser/snapgear/linux-2.4.x CROSS_COMPILE=arm-linux-

这里KERNELPATH=/home/linuxuser/snapgear/linux-2.4.x是uclinux-2.4.x内核源码的路径,CROSS_COMPILE=arm-linux-是交叉编译器的名字。/home/linuxuser/usr/local/bin是交叉编译器的路径。检查编译的安装请参照前面几章的内容。

3. 安装驱动,配置开发板

编译完的文件分为两个部分,一部分是driver,一部分是tools。假设uClinux内核编译完成之后,zImage和ramdisk文件已经复制到到/tftpboot下。这时候执行如下命令:

 

#cd /home/linuxuser/P720/madwifi/madwifi-0.9.4

#rm -rfoutputdriver

#mkdiroutputdriver

#cp -f  ./ath/ath_pci.o                           ./outputdriver

#cp -f  ./ath_hal/ath_hal.o                       ./outputdriver

#cp -f  ./net80211/wlan.o                         ./outputdriver

#cp -f  ./net80211/wlan_wep.o                   ./outputdriver

#cp -f  ./net80211/wlan_tkip.o                  ./outputdriver

#cp -f  ./net80211/wlan_ccmp.o                  ./outputdriver

#cp -f  ./net80211/wlan_xauth.o                   ./outputdriver

#cp -f  ./net80211/wlan_acl.o                   ./outputdriver

#cp -f  ./net80211/wlan_scan_ap.o               ./outputdriver

#cp -f  ./net80211/wlan_scan_sta.o              ./outputdriver

#cp -f  ./ath_rate/onoe/ath_rate_onoe.o         ./outputdriver

#cp -f  ./ath_rate/amrr/ath_rate_amrr.o           ./outputdriver

#cp -f  ./ath_rate/sample/ath_rate_sample.o       ./outputdriver

 

#rm -rf./outputdriver/tools

#mkdir./outputdriver/tools

 

#cp -f./tools/80211debug                        ./outputdriver/tools

#cp -f./tools/80211stats                        ./outputdriver/tools

#cp -f./tools/athchans                          ./outputdriver/tools

#cp -f./tools/athctrl                           ./outputdriver/tools

#cp -f./tools/athdebug                           ./outputdriver/tools

#cp -f./tools/ath_info                          ./outputdriver/tools

#cp -f./tools/athkey                            ./outputdriver/tools

#cp -f./tools/athstats                          ./outputdriver/tools

#cp -f ./tools/wlanconfig                         ./outputdriver/tools

 

#umount tmp

#rm -rf tmp

#mkdir tmp

#rm -framdisk.gz

#rm -f ramdisk

#cp -f/tftpboot/ramdisk.gz ramdisk.gz

#gunzip ramdisk

#mount -o loopramdisk tmp

#mkdir -p./tmp/lib/modules/2.4.32-uc0/kernel/drivers/net/madwifi

#mkdir -p./tmp/home/wifitools

#cp -f./outputdriver/*.o ./tmp/lib/modules/2.4.32-uc0/kernel/drivers/net/madwifi

#cp -f./outputdriver/tools/* ./tmp/home/wifitools

#umount tmp

#gzip ramdisk

#cp -framdisk.gz /tftpboot/ramdisktest.gz

这样以后ramdisk下已经包含了驱动和工具。把zImage和ramdisk下载到开发板,开发板启动完成后如下执行命令:

#cd/lib/modules/2.4.32-uc0/kernel/drivers/net/madwifi

#insmod wlan.o

#insmodath_hal.o

#insmodath_rate_sample.o

#insmodwlan_scan_ap.o

#insmodwlan_scan_sta.o

#insmodath_pci.o autocreate=ap

#cd/home/wifitools

#./wlanconfigath create wlandev wifi0 wlanmode ap

#iwconfig ath1channel 6

#iwconfig ath1essid "ryanp720"

#ifconfig ath1 10.0.0.1up

 

有的uClinux版本会导致segmentSegmentation fault,那么请按照madwifi上的方法修改源代码,或者换成别的版本。

 

 

在uClinux2.6下编译安装madwifi

1. 配置uClinux2.6内核

先根据“移植uclinux2.6 到IX425DP”一章配置内核。其中Sysctl是内核中默认的,Crypto和WirelessExtensions support在“移植uclinux2.6 到IX425DP”一章已经配置好了。

在本章因为madwifi的和配置无线网络,必须选上iwconfig等工具。下面讲讲配置方法。

 

首先在终端输入make menuconfig

 

       1.在菜单中选择菜单选择linux-2.6.x / CustomizeKernel Settings / Customize Module Settings / Customize Vendor/User Settings.

       2. CustomizeKernel Settings 和Customize Module Settings菜单其实都不用修改,直接跳过

       3. 第三次出来的菜单是Customize Vendor/User Settings, 选择network applications->wireless tools support. 选中之后会多出几个选项,都是网络配置用的工具,一起选上。

 

保存之后输入make命令编译内核。

2. 修改,编译madwifi驱动

       按照kernel2.4的方法修改madwifi驱动。唯一不同的是修改KERNELPATH=/home/linuxuser/snapgear/linux-2.4.x

KERNELPATH=/home/linuxuser/snapgear/linux-2.6.x

       最终进入madwifi的文件夹下在terminal执行命令如下

exportPATH=$PATH:/home/linuxuser/usr/local/bin

Make clean

makeKERNELPATH=/home/linuxuser/snapgear/linux-2.6.x CROSS_COMPILE=arm-linux-

 

3. 安装驱动,配置开发板

编译完的文件分为两个部分,一部分是driver,一部分是tools。假设uClinux内核编译完成之后,zImage和ramdisk文件已经复制到到/tftpboot下。这时候执行如下命令:

#cd /home/linuxuser/P720/madwifi/madwifi-0.9.4

#make clean

#makeKERNELPATH=/home/linuxuser/snapgear/linux-2.6.x/ CROSS_COMPILE=arm-linux-

 

#rm -rfoutputdriver

#mkdiroutputdriver

 

#cp -f  ./ath/ath_pci.ko                           ./outputdriver

#cp -f  ./ath_hal/ath_hal.ko                       ./outputdriver

#cp -f  ./net80211/wlan.ko                         ./outputdriver

#cp -f  ./net80211/wlan_wep.ko                  ./outputdriver

#cp -f  ./net80211/wlan_tkip.ko                 ./outputdriver

#cp -f  ./net80211/wlan_ccmp.ko                 ./outputdriver

#cp -f  ./net80211/wlan_xauth.ko                     ./outputdriver

#cp -f  ./net80211/wlan_acl.ko                  ./outputdriver

#cp -f  ./net80211/wlan_scan_ap.ko              ./outputdriver

#cp -f  ./net80211/wlan_scan_sta.ko             ./outputdriver

#cp -f  ./ath_rate/onoe/ath_rate_onoe.ko            ./outputdriver

#cp -f  ./ath_rate/amrr/ath_rate_amrr.ko           ./outputdriver

#cp -f  ./ath_rate/sample/ath_rate_sample.ko       ./outputdriver

 

#rm -rf./outputdriver/tools

#mkdir./outputdriver/tools

 

#cp -f./tools/80211debug                        ./outputdriver/tools

#cp -f./tools/80211stats                        ./outputdriver/tools

#cp -f./tools/athchans                          ./outputdriver/tools

#cp -f./tools/athctrl                           ./outputdriver/tools

#cp -f./tools/athdebug                          ./outputdriver/tools

#cp -f./tools/ath_info                          ./outputdriver/tools

#cp -f./tools/athkey                            ./outputdriver/tools

#cp -f./tools/athstats                          ./outputdriver/tools

#cp -f./tools/wlanconfig                        ./outputdriver/tools

#umount tmp

#rm -rf tmp

#mkdir tmp

#rm -framdisk.gz

#rm -f ramdisk

#cp -f/tftpboot/ramdisk.gz ramdisk.gz

#gunzip ramdisk

#mount -o loopramdisk tmp

#mkdir -p./tmp/lib/modules/2.6.19-uc1/kernel/drivers/net/madwifi

#mkdir -p./tmp/home/wifitools

#cp -f./outputdriver/*.ko ./tmp/lib/modules/2.6.19-uc1/kernel/drivers/net/madwifi

 

#cp -f./outputdriver/tools/* ./tmp/home/wifitools

#umount tmp

#gzip ramdisk

#cp -framdisk.gz /tftpboot/ramdisktest.gz

 

 

这样行的ramdisk下已经包含了驱动和工具。把zImage和ramdisk下载到开发板,开发板启动完成后如下执行命令:

 

#cd/lib/modules/2.6.19-uc1/kernel/drivers/net/madwifi

#insmod wlan.ko

#insmodath_hal.ko

#insmodath_rate_sample.ko

#insmod wlan_scan_ap.ko

#insmodwlan_scan_sta.ko

#insmodath_pci.ko autocreate=ap

#cd/home/wifitools

#./wlanconfigath create wlandev wifi0 wlanmode ap

#iwconfig ath1channel 6

#iwconfig ath1essid "ryanp720"

#ifconfig ath1 10.0.0.1up

 

板子上应该打印如下信息:

# cd/lib/modules/2.6.19-uc1/kernel/drivers/net/madwifi

# insmod wlan.ko

wifi0 wlanmodeap

iwconfig ath1channel 6

iwconfig ath1essidwlan: 0.9.4

 "ryanp720"

ifconfig ath1 10.0.0.1up

# insmodath_hal.ko

ath_hal: modulelicense 'Proprietary' taints kernel.

ath_hal: 0.9.18.0(AR5210, AR5211, AR5212, RF5111, RF5112, RF2413, RF5413, REGOPS_FUNC)

# insmodath_rate_sample.ko

ath_rate_sample:1.2 (0.9.4)

# insmodwlan_scan_ap.ko

# insmodwlan_scan_sta.ko

# insmodath_pci.ko autocreate=ap

ath_pci: 0.9.4

PCI: enablingdevice 0000:00:02.0 (0340 -> 0342)

wifi0: 11a rates: 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps36Mbps 48Mbps 54Mbps

wifi0: 11brates: 1Mbps 2Mbps 5.5Mbps 11Mbps

wifi0: 11g rates: 1Mbps 2Mbps 5.5Mbps 11Mbps 6Mbps9Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps

wifi0: turboArates: 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps

wifi0: turboGrates: 6Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps

wifi0: H/Wencryption support: WEP AES AES_CCM TKIP

wifi0: mac 5.9phy 4.3 radio 3.6

wifi0: Use hwqueue 1 for WME_AC_BE traffic

wifi0: Use hwqueue 0 for WME_AC_BK traffic

wifi0: Use hwqueue 2 for WME_AC_VI traffic

wifi0: Use hwqueue 3 for WME_AC_VO traffic

wifi0: Use hwqueue 8 for CAB traffic

wifi0: Use hwqueue 9 for beacons

wifi0: Atheros5212: mem=0x48000000, irq=27

# cd /home/wifitools

# ./wlanconfigath create wlandev wifi0 wlanmode ap

ath1

# iwconfig ath1channel 6

# iwconfig ath1essid "ryanp720"

# ifconfig ath1 10.0.0.1up

# iwconfig

lo        no wireless extensions.

 

wifi0     no wireless extensions.

 

ath0      IEEE 802.11g  ESSID:""  Nickname:""

          Mode:Master  Channel:0 Access Point: 00:00:00:00:00:00 

          Bit Rate:0kb/s   Tx-Power:19 dBm   Sensitivity=1/1 

          Retry:off   RTS thr:off  Fragment thr:off

          Encryption key:off

          Power Management:off

         

ath1      IEEE 802.11g  ESSID:"ryanp720"  Nickname:""

          Mode:Master  Frequency:2.437GHz  Access Point: 06:16:16:1C:68:5B 

          Bit Rate:0kb/s   Tx-Power:19 dBm   Sensitivity=1/1 

          Retry:off   RTS thr:off  Fragment thr:off

          Encryption key:off

          Power Management:off

 

到此开发板已经启动完成,AP也启动了,其中iwconfig ath1 channel 6

中使用ath1的原因是./wlanconfig athcreate wlandev wifi0 wlanmode ap之后会打印提示ath1,表明使用的是ath1作为AP。这个时候用笔记本上的无线网卡就可以搜索到“ryanp720”的AP在信道6上。

 

驱动编译的摸索过程

1. 开始准备软件

网上搜索得到madwifi的有madwifi-0.9.4s和madwifi-20060331。madwifi-20060331是从http://madwifi.org/Downloads/拿下来的。经过比较软件查看,madwifi-0.9.4s明显的日期比madwifi-20060331靠后,所以认定madwifi-20060331比较旧一点,那么就用madwifi-0.9.4s做实验。

       下载解压到/home/linuxuser/P720/madwifi/madwifi-0.9.4,参看INSTALL和README文件,其中INSTALL讲到要使用

makeKERNELPATH=/home/linuxuser/snapgear/linux-2.4.x CROSS_COMPILE=arm-linux-

就可以编译了,并且提醒每次编译前记得clean。于是写了简单的可执行文本makemadwifi.txt,内容如下’

Make clean

makeKERNELPATH=/home/linuxuser/snapgear/linux-2.4.x CROSS_COMPILE=arm-linux-

2. 开始编译

[root@localhostmadwifi-0.9.4]# ./makemadwifi.txt

Checkingrequirements... ok.

Checking kernelconfiguration... FAILED

Please enablewireless extensions.

make: ***[configcheck] Error 1

这个是提示没有kernelconfiguration的时候没有选中wirelessextensions。于是重新编译uClinux。Make menuconfig勾上内核配置中进入如下选项,选上wireless LAN(non-harmradio), 截图和帮助如下:

 

其实在INSTALL文件里面已经提到过这件事情,配置完后还有crypto选项,Sysctl选项。Sysctl选项一般默认选上了,crypto选项如下:

配置完后在make dep,make就能编译完内核了。

 

如果没有配置crypto,会在编译的时候出现如下错误:

#./makemadwifi.txt

Checkingrequirements... ok.

Checking kernelconfiguration... FAILED

Please enablecrypto API.

make: ***[configcheck] Error 1

 

 

TIPs:

在这里讲讲INSTALL文件:里面清楚的讲到config的宏。如果在makemenuconfig的时候不容易看到,可以在/home/linuxuser/snapgear/linux-2.4.x的.config文件找到,.config是隐藏的,需要显示隐藏文件。比如查看CONFIG_CRYPTO,如果开始没有看到,在.config文件里查找,肯定能找到,发现kernel hacking附近,记得以前看过这个选项,那么在menuconfig的时候在kernel hacking附近找CRYPTO的选项就行了

 

INSTALL文件的需要注意的内容如下

/*****************************************************/

Requirements

------------

 

- Configured kernel sources of the targetkernel.  Some Linux

 distributions provide headers, makefiles and configuration data - it

 should suffice.

 

- Wireless Extensions support (14 or later,17 preferred) - option

 CONFIG_NET_RADIO in kernel .config file.

 

- Sysctl support - option CONFIG_SYSCTL inkernel .config file.

 

- Crypto API support - option CONFIG_CRYPTOin kernel .config file (AES

 support is used if present, otherwise the AES-CCMP cipher module falls

 back to a private implementation).

 

- gcc of same version that was used tocompile the kernel.  At least

 make sure that the first two version numbers or the compiler are the

 same (e.g. it's OK to use gcc 3.4.6to compile MadWifi if the kernel

  wascompiled by gcc 3.4.2).  Ignoring this rule will cause "Invalid

 module format" errors during module load.

/*****************************************************/

3. 修改源文件

       内核编译完之后,继续执行makemadwifi.txt编译驱动。发现如下错误:

 

/*****************************************************/

arm-linux-gcc-mbig-endian -D__KERNEL__ -I/home/linuxuser/snapgear/linux-2.4.x/include -Wall-Wstrict-prototypes -Wno-trigraphs -O -fno-strict-aliasing -fno-common -Uarm-fno-common -pipe -mapcs-32 -D__LINUX_ARM_ARCH__=5 -mcpu=xscale -mtune=xscale-malignment-traps -msoft-float -Uarm -DMODULE -include ./../include/compat.h -I./../include -I./.. -I./../ath_hal-I./../hal -I./../net80211 -DATH_PCI -Werror -DAH_BYTE_ORDER=AH_BIG_ENDIAN-march=armv4 -mbig-endian -fno-strict-aliasing-fno-common -mapcs-32 -mtune=xscale -DATH_SUPERG_FF=1 -DATH_SUPERG_DYNTURBO=1-DATH_TURBO_SCAN=1 -DATH_SUPERG_XR=1 -DOPT_AH_H=\"./../hal/public/xscale-be-elf.opt_ah.h\"-nostdinc -iwithprefix include -DKBUILD_BASENAME=if_ath  -DEXPORT_SYMTAB -o if_ath.o -c if_ath.c

if_ath.c:1:warning: switch -mcpu=xscale conflicts with -march= switch

make[3]:*** [if_ath.o] Error 1

/*****************************************************/

查看Makefile文件,发现COPTS+= -DATH_PCI 和-DOPT_AH_H=\"./../hal/public/xscale-be-elf.opt_ah.h在madwifi/madwifi-0.9.4/ath/Makefile里面找到,并且在这两个定义之间有include$(TOP)/Makefile.inc,说明-march=armv4很可能是Makefile.inc引入的,进去看看。里面有关于arch和target的一项是

# Determine architecture of the kernel.

include $(TOP)/scripts/get_arch.mk

export ARCH

 

# Determine TARGET

include $(TOP)/ath_hal/ah_target.inc

export TARGET

get_arch.mk里面没有什么线索,只好找到ah_target.inc里有一项

TARGET-$(CONFIG_CPU_XSCALE) = xscale-$(ENDIAN)-elf

这个接下去也找不到什么东西。

 

实在找不到-march=armv4的来源而且担心是宏生成,所以找AH_BYTE_ORDER和AH_BIG_ENDIAN比较靠谱。终于在整个\madwifi-0.9.4全文搜索AH_BYTE_ORDER=AH_BIG_ENDIAN,找到在madwifi-0.9.4/hal/public/xscale-be-elf.inc里找到:

COPTS+= -DAH_BYTE_ORDER=AH_BIG_ENDIAN

COPTS+=-march=armv4 -mbig-endian -fno-strict-aliasing -fno-common -mapcs-32 \

    -mtune=xscale  -mshort-load-bytes

显然这个就是-march=armv4的来源,不明白为什么有这个选项,而且考虑到编译选项是给编译器使用的,现在使用的编译器arm-linux-tools-20051123.tar.gz完全能够理解-mcpu=xscale而且成功编译内核,看起来-mcpu=xscale和-march=armv4都是为了说明CPU架构的,那么显然为了编译只能选择-mcpu=xscale,去掉-march=armv4。但是担心源码里面使用-march=armv4做了什么特殊的操作,于是搜索madwifi-0.9.4全工程,没有发现代码使用-march=armv4,都是一些.inc文件使用。应该可以放心的去掉这个选项。

 

Make clean之后重新编译,发生如下错误:

-o ah_os.o -cah_os.c

ah_os.c: Infunction `ath_hal_reg_write':

ah_os.c:335:warning: passing arg 2 of `__writel' makes integer from pointer without a cast

ah_os.c: Infunction `ath_hal_reg_read':

ah_os.c:344:warning: passing arg 1 of `__readl' makes integer from pointer without a cast

make[3]: ***[ah_os.o] Error 1

 

查看ah_os.c:335,发现是_OS_REG_WRITE。可是前面两个只不过是warning,错误在哪儿,另外检查全部的编译打印信息结果。搜索error,除了两个warning后面的error,没有别的的error,显然不对劲。编译选项中就只有-Werror,这个选项是用来发现warning就当error的,很明显这个不行,想办法去掉。而且__writel,__readl读写寄存器是要进行强制类型转换的,一般是把整数转化为绝对地址,不能算错误。全文搜索-Werror,准备删除。这次编译的全部打印信息如下,可以用来验证摸索过程。

 

./makemadwifi.txt

Checkingrequirements... ok.

Checking kernelconfiguration... ok.

for i in ath/ath_hal/ ath_rate/ net80211/; do \

                make -C $i || exit 1; \

        done

make[1]:Entering directory `/home/linuxuser/P720/madwifi/madwifi-0.9.4/ath'

make -C/home/linuxuser/snapgear/linux-2.4.x SUBDIRS=/home/linuxuser/P720/madwifi/madwifi-0.9.4/athmodules

make[2]:Entering directory `/home/linuxuser/snapgear/linux-2.4.x'

make -C  /home/linuxuser/P720/madwifi/madwifi-0.9.4/athCFLAGS="-D__KERNEL__ -I/home/linuxuser/snapgear/linux-2.4.x/include -Wall-Wstrict-prototypes -Wno-trigraphs -O -fno-strict-aliasing -fno-common -Uarm-fno-common -pipe -mapcs-32 -D__LINUX_ARM_ARCH__=5 -mcpu=xscale -mtune=xscale-malignment-traps -msoft-float -Uarm -DMODULE " MAKING_MODULES=1 modules

make[3]:Entering directory `/home/linuxuser/P720/madwifi/madwifi-0.9.4/ath'

arm-linux-gcc-mbig-endian -D__KERNEL__ -I/home/linuxuser/snapgear/linux-2.4.x/include -Wall-Wstrict-prototypes -Wno-trigraphs -O -fno-strict-aliasing -fno-common -Uarm-fno-common -pipe -mapcs-32 -D__LINUX_ARM_ARCH__=5 -mcpu=xscale -mtune=xscale-malignment-traps -msoft-float -Uarm -DMODULE -include ./../include/compat.h -I./../include -I./.. -I./../ath_hal-I./../hal -I./../net80211 -DATH_PCI -Werror -DAH_BYTE_ORDER=AH_BIG_ENDIAN-mbig-endian -fno-strict-aliasing -fno-common -mapcs-32 -mtune=xscale-DATH_SUPERG_FF=1 -DATH_SUPERG_DYNTURBO=1 -DATH_TURBO_SCAN=1 -DATH_SUPERG_XR=1-DOPT_AH_H=\"./../hal/public/xscale-be-elf.opt_ah.h\" -nostdinc-iwithprefix include -DKBUILD_BASENAME=if_ath -DEXPORT_SYMTAB -o if_ath.o -c if_ath.c

arm-linux-gcc-mbig-endian -D__KERNEL__ -I/home/linuxuser/snapgear/linux-2.4.x/include -Wall-Wstrict-prototypes -Wno-trigraphs -O -fno-strict-aliasing -fno-common -Uarm-fno-common -pipe -mapcs-32 -D__LINUX_ARM_ARCH__=5 -mcpu=xscale -mtune=xscale-malignment-traps -msoft-float -Uarm -DMODULE -include ./../include/compat.h -I./../include -I./.. -I./../ath_hal-I./../hal -I./../net80211 -DATH_PCI -Werror -DAH_BYTE_ORDER=AH_BIG_ENDIAN-mbig-endian -fno-strict-aliasing -fno-common -mapcs-32 -mtune=xscale -DATH_SUPERG_FF=1-DATH_SUPERG_DYNTURBO=1 -DATH_TURBO_SCAN=1 -DATH_SUPERG_XR=1-DOPT_AH_H=\"./../hal/public/xscale-be-elf.opt_ah.h\" -nostdinc-iwithprefix include -DKBUILD_BASENAME=if_ath_pci  -DEXPORT_SYMTAB -o if_ath_pci.o -cif_ath_pci.c

arm-linux-ld -EB-EB -o ath_pci.o -r if_ath.o if_ath_pci.o

make[3]: Leavingdirectory `/home/linuxuser/P720/madwifi/madwifi-0.9.4/ath'

make[2]: Leavingdirectory `/home/linuxuser/snapgear/linux-2.4.x'

make[1]: Leavingdirectory `/home/linuxuser/P720/madwifi/madwifi-0.9.4/ath'

make[1]:Entering directory `/home/linuxuser/P720/madwifi/madwifi-0.9.4/ath_hal'

make -C/home/linuxuser/snapgear/linux-2.4.xSUBDIRS=/home/linuxuser/P720/madwifi/madwifi-0.9.4/ath_halmodules

make[2]:Entering directory `/home/linuxuser/snapgear/linux-2.4.x'

make -C  /home/linuxuser/P720/madwifi/madwifi-0.9.4/ath_halCFLAGS="-D__KERNEL__ -I/home/linuxuser/snapgear/linux-2.4.x/include -Wall-Wstrict-prototypes -Wno-trigraphs -O -fno-strict-aliasing -fno-common -Uarm-fno-common -pipe -mapcs-32 -D__LINUX_ARM_ARCH__=5 -mcpu=xscale -mtune=xscale-malignment-traps -msoft-float -Uarm -DMODULE " MAKING_MODULES=1 modules

make[3]:Entering directory `/home/linuxuser/P720/madwifi/madwifi-0.9.4/ath_hal'

arm-linux-gcc-mbig-endian -D__KERNEL__ -I/home/linuxuser/snapgear/linux-2.4.x/include -Wall-Wstrict-prototypes -Wno-trigraphs -O -fno-strict-aliasing -fno-common -Uarm-fno-common -pipe -mapcs-32 -D__LINUX_ARM_ARCH__=5 -mcpu=xscale -mtune=xscale-malignment-traps -msoft-float -Uarm -DMODULE -include ./../include/compat.h -I./../include -I./../ath_hal -I./../hal-Werror -DAH_BYTE_ORDER=AH_BIG_ENDIAN -mbig-endian -fno-strict-aliasing-fno-common -mapcs-32 -mtune=xscale -DATH_SUPERG_FF=1 -DATH_SUPERG_DYNTURBO=1-DATH_TURBO_SCAN=1 -DATH_SUPERG_XR=1 -DOPT_AH_H=\"./../hal/public/xscale-be-elf.opt_ah.h\"-nostdinc -iwithprefix include -DKBUILD_BASENAME=ah_os  -DEXPORT_SYMTAB -o ah_os.o -c ah_os.c

ah_os.c: Infunction `ath_hal_reg_write':

ah_os.c:335:warning: passing arg 2 of `__writel' makes integer from pointer without a cast

ah_os.c: Infunction `ath_hal_reg_read':

ah_os.c:344:warning: passing arg 1 of `__readl' makes integer from pointer without a cast

make[3]: ***[ah_os.o] Error 1

make[3]: Leavingdirectory `/home/linuxuser/P720/madwifi/madwifi-0.9.4/ath_hal'

make[2]: ***[_mod_/home/linuxuser/P720/madwifi/madwifi-0.9.4/ath_hal]Error 2

make[2]: Leavingdirectory `/home/linuxuser/snapgear/linux-2.4.x'

make[1]: ***[all] Error 2

make[1]: Leavingdirectory `/home/linuxuser/P720/madwifi/madwifi-0.9.4/ath_hal'

make: *** [modules]Error 1

       对整个madwifi-0.9.4文件夹全文搜索,发现只有madwifi-0.9.4/Makefile.inc里面有-Werror的定义,原文为COPTS+=     -Werror,删除之。

       重新clean再编译,发生如下错误。

make[1]:Entering directory `/home/linuxuser/P720/madwifi/madwifi-0.9.4/tools'

arm-linux-gcc -oathstats -g -O2 -Wall -I. -I../hal -I..-I../ath  athstats.c

/home/linuxuser/usr/local/bin/../lib/gcc/arm-linux/3.4.4/../../../../arm-linux/bin/ld:cannot find /usr/local/arm-linux/lib/libc.so.6

collect2: ldreturned 1 exit status

 

/libc.so.6在编译应用程序一章讲过,是因为使用uClibc的原因。而且看文件路径madwifi-0.9.4/tools想必tools是应用程序,那显然要使用ucfront-gcc。查看makefile文件加上ucfront-gcc 。tools文件夹下面找到makefile,有如下关于编译器的语句:

 

USER_CROSS_COMPILE?= $(CROSS_COMPILE)

STRIP ?=$(USER_CROSS_COMPILE)strip

CC =$(USER_CROSS_COMPILE)gcc

all:    $(ALL)

 

athstats:athstats.c

    $(CC) -o athstats $(ALL_CFLAGS) -I$(TOP)/ath$(LDFLAGS) athstats.c

修改CC =$(USER_CROSS_COMPILE)gcc为以下语句:

UCGCC =/home/linuxuser/snapgear/tools/ucfront-gcc

CC = $(UCGCC)$(USER_CROSS_COMPILE)gcc

 

修改完gcc后重新编译发生如下错误

/home/linuxuser/snapgear/tools/ucfront-gccarm-linux-gcc -o athstats -g -O2 -Wall -I.-I../hal -I.. -I../ath  athstats.c

/home/linuxuser/snapgear/uClibc/lib/libc.so:could not read symbols: File in wrong format

collect2: ldreturned 1 exit status

这个应用程序也在../hal等文件夹include,那些应该是内核驱动模块的文件夹,使用file文件查看,确实module都已经编译完成了,

File结果如下:

[root@localhostdriver_file]# file *.*

ath_hal.o:         ELF 32-bit MSB relocatable, ARM,version 1 (ARM), not stripped

ath_pci.o:         ELF 32-bit MSB relocatable, ARM,version 1 (ARM), not stripped

ath_rate_amrr.o:   ELF 32-bit MSB relocatable, ARM, version 1(ARM), not stripped

ath_rate_onoe.o:   ELF 32-bit MSB relocatable, ARM, version 1(ARM), not stripped

ath_rate_sample.o:ELF 32-bit MSB relocatable, ARM, version 1 (ARM), not stripped

wlan_acl.o:        ELF 32-bit MSB relocatable, ARM,version 1 (ARM), not stripped

wlan_ccmp.o:       ELF 32-bit MSB relocatable, ARM, version1 (ARM), not stripped

wlan.o:            ELF 32-bit MSB relocatable, ARM,version 1 (ARM), not stripped

wlan_scan_ap.o:    ELF 32-bit MSB relocatable, ARM, version 1(ARM), not stripped

wlan_scan_sta.o:   ELF 32-bit MSB relocatable, ARM, version 1(ARM), not stripped

wlan_tkip.o:       ELF 32-bit MSB relocatable, ARM, version1 (ARM), not stripped

wlan_wep.o:        ELF 32-bit MSB relocatable, ARM,version 1 (ARM), not stripped

wlan_xauth.o:      ELF 32-bit MSB relocatable, ARM, version1 (ARM), not stripped

应该没有问题。检查编译选项,既然编译器也对,ulibc也对,format的错误也许是endian的问题,加上-mbig-endian试试。

打开/madwifi-0.9.4/tools/makefile

CFLAGS= -g -O2 –Wall后面加上CFLAGS+=-mbig-endian

Clean之后重新编译,搞定。使用file命令检查文件属性:

80211debug:      ELF 32-bit MSB executable, ARM, version 1(ARM), for GNU/Linux 2.0.0, dynamically linked (usesshared libs), for GNU/Linux 2.0.0, not stripped

80211debug.c:    ASCII English text

80211stats:      ELF 32-bit MSB executable, ARM, version 1(ARM), for GNU/Linux 2.0.0, dynamically linked (usesshared libs), for GNU/Linux 2.0.0, not stripped

80211stats.c:    ASCII English text

athchans:        ELF 32-bit MSB executable, ARM, version1 (ARM), for GNU/Linux 2.0.0, dynamicallylinked (uses shared libs), for GNU/Linux 2.0.0, not stripped

athchans.c:      ASCII English text

athctrl:         ELF 32-bit MSB executable, ARM,version 1 (ARM), for GNU/Linux 2.0.0,dynamically linked (uses shared libs), for GNU/Linux 2.0.0, not stripped

athctrl.c:       ASCII English text

athdebug:        ELF 32-bit MSB executable, ARM, version1 (ARM), for GNU/Linux 2.0.0, dynamicallylinked (uses shared libs), for GNU/Linux 2.0.0, not stripped

athdebug.c:      ASCII English text

ath_info:        ELF 32-bit MSB executable, ARM, version1 (ARM), for GNU/Linux 2.0.0, dynamicallylinked (uses shared libs), for GNU/Linux 2.0.0, not stripped

ath_info.c:      ASCII C program text

athkey:          ELF 32-bit MSB executable, ARM,version 1 (ARM), for GNU/Linux 2.0.0,dynamically linked (uses shared libs), for GNU/Linux 2.0.0, not stripped

athkey.c:        ASCII English text

athstats:        ELF 32-bit MSB executable, ARM, version1 (ARM), for GNU/Linux 2.0.0, dynamicallylinked (uses shared libs), for GNU/Linux 2.0.0, not stripped

athstats.c:      ASCII English text

Makefile:        ASCII English text

man:             directory

wireless_copy.h:ASCII C program text

wlanconfig:      ELF 32-bit MSB executable, ARM, version 1(ARM), for GNU/Linux 2.0.0, dynamically linked (usesshared libs), for GNU/Linux 2.0.0, not stripped

wlanconfig.c:    ASCII English text

文件格式正确,没有问题。

 

4. 在开发板上实验

       开始在uClinux2.4上开发的。下载到开发板上上运行出现以下情况:

# insmod ath_pciautocreate=ap

Using/lib/modules/2.4.32-uc0/kernel/drivers/net/madwifi/ath_pci.o

ath_pci: 0.9.4

Unable to handlekernel paging request at virtual address 4bff8004

pgd = c0ec4000

[4bff8004]*pgd=00000000, *pmd = 00000000

Internal error:Oops: f5

CPU: 0

pc :[<c4899224>]    lr : [<c48ac92c>]    Not tainted

sp :c0ec9de8  ip : 00000000  fp : c0ec9e08

r10:c039e000  r9 : c039e160  r8 : 00000013

r7 :c0ec9e90  r6 : 00004004  r5 : 00000023 r4 : c03a0000

r3 :4bff0000  r2 : ff013020  r1 : 00008004 r0 : c03a0000

Flags: nzCv  IRQs on FIQs on  Mode SVC_32  Segment user

Control:39FF  Table: 00EC4000  DAC: 00000015

Process insmod(pid: 31, stack limit = 0xc0ec8368)

Stack:(0xc0ec9de8 to 0xc0eca000)

9de0:                   00000014 c48ac92c 00000000 c03a0000 00000001 c0ec9e24

9e00: c0ec9e0c c48aca48 c48ac898 c039f8e8 c03a0000 c03a0000 c0ec9e5c c0ec9e28

9e20: c48a948cc48aca1c c0ec9e90 00000000 000001f0 c039f8e800001760 c48e82c8

9e40: c039e160 00000013 c039e160 c039e000 c0ec9e70 c0ec9e60 c48996dc c48a9458

9e60: c0ec9e90 00000000 c0ec9e74 c489907cc4899614 c0ec9e90 c48d51d4 c0ec9e90

9e80: c0ec9ea2 0000003f c02f2000 00000001 c0267e00 0000001b c48d7508 c039e000

9ea0: c02f2000 c039e160 00000013 4bff0000 c48e856c 4bff0000 00000007 c48e56bc

9ec0: c039e000 00000000 c0ec9e08 c48e8734 c48e856c c02f2000 00000000 c0267d60

9ee0: c48ea000 00000007 c00d46fc c02f2000 c48e8734 c01806d800000000 c00d4768

9f00: ffffffea c48d5000 c017b400 000778d8 c48e5938 c0051800 c0d43000 c0d43000

9f20: c0d45000 00000060 c48d3000 c48d506000013c78 0000000000000000 00000000

9f40: 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000

9f60: 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000

9f80: 00000000 0000000e 000778d8 c48d5000 00000080 c0043724 c0ec80000004aeb0

9fa0: 00000000 c0043560 0000000e c00434dc00046dd0 000778d8 00000000 c48e584c

9fc0: 0000000e000778d8 c48d5000 c48e8760 00046f98 c48e62a8 0004aeb0 c48e8818

9fe0: 4005c42cbfffdb4c 0002554c 4005c43820000010 00046dd0 51535755 f09ad515

Backtrace:

Function enteredat [<c48ac88c>] from [<c48aca48>]

 r6 = 00000001 r5 = C03A0000  r4 = 00000000

Function enteredat [<c48aca10>] from [<c48a948c>]

 r6 = C03A0000  r5 = C03A0000  r4 = C039F8E8

Function enteredat [<c48a944c>] from [<c48996dc>]

Function enteredat [<c4899608>] from [<c489907c>]

Code: e24dd004e2413901 e3530a0125903014 (27930001)

Segmentationfault

这个是madwifi的bug,可以在查找到修正的方法。使用2.6内核的时候工作完全正常

 

4. 编译madwifi20060631

       由于在在madwifi的bug库里面发现修改的地方比较多,所以希望在uClinux2.4上尝试别的madwifi版本。这里选择了madwifi20060631。这个是能在madwifi.net上找到最新的版本,madwifi0.94是在sourceforg上能找到的最新版本。

       下载madwifi20060631后解压到

/home/linuxuser/P720/madwifi/madwifi-20060331。

       因为担心和madwifi0.94有同样的问题,修改xscale-be-elf,去掉-march=armv4. 但是没有找到COPTS+= -Werror。

另外修改/home/linuxuser/P720/madwifi/madwifi-20060331/tools/Makefile。这和madwifi0.94有些不一样。

all:    ${ALL}

athstats:athstats.c

    ${CC} -o athstats ${CFLAGS} -I../ath${LDFLAGS} athstats.c

all:    ${ALL}

CC=/home/linuxuser/snapgear/tools/ucfront-gccarm-linux-gcc

athstats:athstats.c

    ${CC} -o athstats ${CFLAGS} -I../ath${LDFLAGS} athstats.c

再在CFLAGS= ${INCS}–g后面添加CFLAGS+=-mbig-endian。执行编译。

 

根据/home/linuxuser/P720/madwifi/madwifi-20060331/INSTALL说明文件,需要设置TARGET,TOOLPREFIX,KERNELPATH,所以执行如下命令:

#makeKERNELPATH=/home/linuxuser/snapgear/linux-2.4.x TOOLPREFIX=arm-linux-TARGET="xscale-be-elf"

发生如下错误:

make -C /home/linuxuser/snapgear/linux-2.4.xSUBDIRS=/home/linuxuser/P720/madwifi/madwifi-20060331/ath_halMODVERDIR=/home/linuxuser/P720/madwifi/madwifi-20060331/ath_hal/../symbolsmodules

make[2]: Entering directory`/home/linuxuser/snapgear/linux-2.4.x'

make -C /home/linuxuser/P720/madwifi/madwifi-20060331/ath_halCFLAGS="-D__KERNEL__ -I/home/linuxuser/snapgear/linux-2.4.x/include  -Wall -Wstrict-prototypes -Wno-trigraphs -O2-fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2-fno-unit-at-a-time -DMODULE " MAKING_MODULES=1 modules

make[3]: Entering directory`/home/linuxuser/P720/madwifi/madwifi-20060331/ath_hal'

arm-linux-gcc -D__KERNEL__-I/home/linuxuser/snapgear/linux-2.4.x/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing-fno-common -pipe -mpreferred-stack-boundary=2 -fno-unit-at-a-time -DMODULE  -include ./../include/compat.h -I./../include-I./../hal -I./../hal/linux -I./../hal/public -I./../ath_hal -I./..-DAH_BYTE_ORDER=AH_BIG_ENDIAN -DAH_REGOPS_FUNC -mbig-endian-fno-strict-aliasing -fno-common -mapcs-32 -mtune=xscale  -malignment-traps -msoft-float -mfp=2-nostdinc -iwithprefix include -DKBUILD_BASENAME=ah_osdep  -DEXPORT_SYMTAB -o ah_osdep.o -c ah_osdep.c

cc1: error: invalid option`preferred-stack-boundary=2'

make[3]: *** [ah_osdep.o] Error 1

make[3]: Leaving directory`/home/linuxuser/P720/madwifi/madwifi-20060331/ath_hal'

make[2]: ***[_mod_/home/linuxuser/P720/madwifi/madwifi-20060331/ath_hal] Error 2

make[2]: Leaving directory`/home/linuxuser/snapgear/linux-2.4.x'

make[1]: *** [all] Error 2

make[1]: Leaving directory`/home/linuxuser/P720/madwifi/madwifi-20060331/ath_hal'

make: *** [all] Error 1

 

google了一下,说'preferred-stack-boundary=2' is an i386-specific option。既然这样,说明编译器的选项可能出了问题,而且有些选项是xscale-be-elf带来的,证明这个include  xscale-be-elf的对的。那么可以肯定的是KERNELPATH带来的一些东西。而一般来讲,这些文件在KERNELPATH/arch/arm里面。既然不对,加上ARCH=arm选项试试。执行

make ARCH=armKERNELPATH=/home/linuxuser/snapgear/linux-2.4.x TOOLPREFIX=arm-linux-TARGET="xscale-be-elf"

 

发生错误如下:

make ARCH=armKERNELPATH=/home/linuxuser/snapgear/linux-2.4.x TOOLPREFIX=arm-linux-TARGET="xscale-be-elf"

Checking if allrequirements are met... ok.

mkdir -p./symbols

for i in./ath_hal ath_rate/sample ./net80211 ./ath; do \

                make -C $i || exit 1; \

        done

make[1]:Entering directory `/home/linuxuser/P720/madwifi/madwifi-20060331/ath_hal'

cp./../hal/linux/ah_osdep.c ah_osdep.c

uudecode./../hal/public/xscale-be-elf.hal.o.uu

cp./../hal/public/xscale-be-elf.opt_ah.h opt_ah.h

make -C/home/linuxuser/snapgear/linux-2.4.xSUBDIRS=/home/linuxuser/P720/madwifi/madwifi-20060331/ath_halMODVERDIR=/home/linuxuser/P720/madwifi/madwifi-20060331/ath_hal/../symbolsmodules

make[2]:Entering directory `/home/linuxuser/snapgear/linux-2.4.x'

make -C /home/linuxuser/P720/madwifi/madwifi-20060331/ath_halCFLAGS="-D__KERNEL__ -I/home/linuxuser/snapgear/linux-2.4.x/include -Wall-Wstrict-prototypes -Wno-trigraphs -O -fno-strict-aliasing -fno-common -Uarm-fno-common -pipe -mapcs-32 -D__LINUX_ARM_ARCH__=5 -march=armv4 -Wa,-mxscale-mtune=strongarm -malignment-traps -msoft-float -Uarm -DMODULE "MAKING_MODULES=1 modules

make[3]:Entering directory `/home/linuxuser/P720/madwifi/madwifi-20060331/ath_hal'

arm-linux-gcc-D__KERNEL__ -I/home/linuxuser/snapgear/linux-2.4.x/include -Wall-Wstrict-prototypes -Wno-trigraphs -O -fno-strict-aliasing -fno-common -Uarm-fno-common -pipe -mapcs-32 -D__LINUX_ARM_ARCH__=5 -march=armv4 -Wa,-mxscale-mtune=strongarm -malignment-traps -msoft-float -Uarm -DMODULE  -include ./../include/compat.h -I./../include-I./../hal -I./../hal/linux -I./../hal/public -I./../ath_hal -I./.. -DAH_BYTE_ORDER=AH_BIG_ENDIAN-DAH_REGOPS_FUNC -mbig-endian -fno-strict-aliasing -fno-common -mapcs-32-mtune=xscale  -malignment-traps-msoft-float -mfp=2 -nostdinc -iwithprefix include-DKBUILD_BASENAME=ah_osdep -DEXPORT_SYMTAB -o ah_osdep.o -c ah_osdep.c

Assemblermessages:

Error: use ofold and new-style options to set CPU type

make[3]: ***[ah_osdep.o] Error 1

make[3]: Leavingdirectory `/home/linuxuser/P720/madwifi/madwifi-20060331/ath_hal'

make[2]: ***[_mod_/home/linuxuser/P720/madwifi/madwifi-20060331/ath_hal] Error 2

make[2]: Leavingdirectory `/home/linuxuser/snapgear/linux-2.4.x'

make[1]: ***[all] Error 2

make[1]: Leavingdirectory `/home/linuxuser/P720/madwifi/madwifi-20060331/ath_hal'

make: *** [all]Error 1

上面错误提示提示中说到use of old and new-style options to setCPU type,这个应该和-mcpu=xscale或者-march=armv4。检查果然发现有-march=armv4。但是刚才已经修改过xscale-be-elf,不应该出现的,至少在madwifi0.94里面没有这个现象,只能追踪-march=armv4的来源了。检查发现-march=armv4是CFLAGS带进来的。

CFLAGS="-D__KERNEL__-I/home/linuxuser/snapgear/linux-2.4.x/include -Wall -Wstrict-prototypes-Wno-trigraphs -O -fno-strict-aliasing -fno-common -Uarm -fno-common -pipe-mapcs-32 -D__LINUX_ARM_ARCH__=5 -march=armv4 -Wa,-mxscale -mtune=strongarm-malignment-traps -msoft-float -Uarm -DMODULE "

       这样只能用在makefile里面加上@echo追踪CFLAGS的来源。搜索整个madwifi20060631文件夹,竟然没有一处,说明肯定从别的地方带进来的。检查madwifi2006063文件夹下的Makefile和Makefile.inc和xscale-be-elf.inc。

       xscale-be-elf.inc没有发现线索。

       在Makefile.inc里面发现:

# KERNELCONF isthe name of the file that holds the configuration

# of the targetkernel.

KERNELCONF ?=   ${KERNELPATH}/.config

       .config不会包含make定义。

       另外madwifi-20060331/Makefile也没有包括很多的编译选项。根据打印信息

make -C/home/linuxuser/snapgear/linux-2.4.xSUBDIRS=/home/linuxuser/P720/madwifi/madwifi-20060331/ath_halMODVERDIR=/home/linuxuser/P720/madwifi/madwifi-20060331/ath_hal/../symbolsmodules

得知,第一个编译的是madwifi-20060331/ath_hal,那么先看看madwifi-20060331/ath_hal的makefile,发现上面这句话刚好对应:

all:    ah_osdep.c hal.o opt_ah.h

    $(MAKE) -C $(KERNELPATH) SUBDIRS=$(shellpwd) MODVERDIR=$(shell pwd)/${SYMBOLSDIR} modules

先在这里设置@echo来显示CFLAGS,修改上面的语句如下:

all:

    @echo "MAKE = ${MAKE}"

    @echo "CFLAGS = ${CFLAGS}"

    @echo "KERNELPATH = ${KERNELPATH}"

    $(MAKE) -C $(KERNELPATH) SUBDIRS=$(shellpwd) MODVERDIR=$(shell pwd)/${SYMBOLSDIR} modules

 

结果打印出来的消息和上次一样。选项还有一个来源就是,因为刚才加入了ARCH=arm,是KERNELPATH/arch/arm里面带来的。检查/home/linuxuser/snapgear/linux-2.4.x/arch/arm/。

查看/home/linuxuser/snapgear/linux-2.4.x/arch/arm/makefile,搜索-march=armv4,一共有两处,其中有一处是这样的

ifeq($(GCC_VERSION),3)

  # The -march=armv5te doesn't seem to reallyenable XScale features... Why?

  #arch-$(CONFIG_CPU_XSCALE)    :=-D__LINUX_ARM_ARCH__=5 -march=armv5te

  arch-$(CONFIG_CPU_XSCALE)     :=-D__LINUX_ARM_ARCH__=5 -mcpu=xscale

else

  #arch-$(CONFIG_CPU_XSCALE)     :=-D__LINUX_ARM_ARCH__=5 -march=armv4-Wa,-mxscale

  arch-$(CONFIG_CPU_XSCALE)     :=-D__LINUX_ARM_ARCH__=5 -mcpu=xscale

endif

 

其中红色部分的选项和错误信息里的选项完全匹配,那么应该肯定就是它了。

似乎GCC_VERSION检查失误,认为GCC_VERSION不等于3,但是在编译的时候出现的编译器是arm-linux-gcc。终端输入arm-linux-gcc,有如下结果。

# arm-linux-gcc-v

Reading specsfrom /home/linuxuser/usr/local/bin/../lib/gcc/arm-linux/3.4.4/specs

Configured with:../configure --target=arm-linux --disable-shared --prefix=/usr/local--with-headers=/home/gerg/new-wave.ixdp425/linux-2.4.x/include --with-gnu-as--with-gnu-ld --enable-multilib

Thread model:posix

gcc version 3.4.4

在makefile里面找到$(GCC_VERSION)的赋值语句如下

GCC_VERSION := $(shell $(CROSS_COMPILE)gcc  -v 2>&1 | grep version | cut -f3 -d' '| cut -f1 -d.)

这样的话编译选项应该选择的是应该$(GCC_VERSION)=3部分的选项,为了验证这个想法,将上面红色部分

  #arch-$(CONFIG_CPU_XSCALE)     :=-D__LINUX_ARM_ARCH__=5 -march=armv4-Wa,-mxscale

改为

arch-$(CONFIG_CPU_XSCALE)     :=-D__LINUX_ARM_ARCH__=5 -mcpu=xscale

       这样应该效果上和$(GCC_VERSION)=3一样了。

 

执行如下命令:

#make clean

#make ARCH=armKERNELPATH=/home/linuxuser/snapgear/linux-2.4.x TOOLPREFIX=arm-linux-TARGET="xscale-be-elf".

编译通过,没有问题。问题的根源就找到了,就是GCC版本判断的问题。把/home/linuxuser/snapgear/linux-2.4.x/arch/arm/makefile恢复成原来的样子。找到$(GCC_VERSION)的赋值语句:

GCC_VERSION := $(shell $(CROSS_COMPILE)gcc  -v 2>&1 | grep version | cut -f3 -d' '| cut -f1 -d.)

用来修改

将原来的语句

all: configcheck

    mkdir -p ${SYMBOLSDIR}

    for i in ${DIRS}; do \

        $(MAKE) -C $$i || exit 1; \

    done

修改成

GCC_VERSION:=$(shell $(CROSS_COMPILE)gcc  -v2>&1 | grep version | cut -f3 -d' ' | cut -f1 -d.)

all: configcheck

    @echo "GCC = $(CROSS_COMPILE)gcc"

    @echo "GCC_VERSION =$(GCC_VERSION)"

    mkdir -p ${SYMBOLSDIR}

    for i in ${DIRS}; do \

        $(MAKE) -C $$i || exit 1; \

    Done

 

重新执行命令make ARCH=armKERNELPATH=/home/linuxuser/snapgear/linux-2.4.x TOOLPREFIX=arm-linux-TARGET="xscale-be-elf"

输出如下:

# make ARCH=armKERNELPATH=/home/linuxuser/snapgear/linux-2.4.x TOOLPREFIX=arm-linux-TARGET="xscale-be-elf"

Checking if allrequirements are met... ok.

GCC = gcc

GCC_VERSION = 4

mkdir -p./symbols

for i in./ath_hal ath_rate/sample ./net80211 ./ath; do \

                make -C $i || exit 1; \

        done

make[1]:Entering directory `/home/linuxuser/P720/madwifi/madwifi-20060331/ath_hal'

到此已经非常的明了。原来$(CROSS_COMPILE)gcc就是FC6的gcc,版本当然为4。看样子madwifi-20060331的INSTALL说明文件也根本不可靠,至少说明没有验证过IX425DP。

在make命令里面加入CROSS_COMPILE=arm-linux-的定义。输入如下命令

make ARCH=armCROSS_COMPILE=arm-linux- KERNELPATH=/home/linuxuser/snapgear/linux-2.4.xTOOLPREFIX=arm-linux- TARGET="xscale-be-elf"

       结果编译通过,完全没有问题。下载到板子运行。

       根据文档上讲只需要insmod ath_pci.o就可以了,实际上会出现很多错误。另外文档上讲到的模块名字和数量都不对,得自己看。

Using ath_pci.o

insmod:unresolved symbol ieee80211_beacon_update

insmod:unresolved symbol ieee80211_ioctl_siwretry

insmod:unresolved symbol ieee80211_announce

insmod:unresolved symbol ieee80211_ioctl_giwessid

       必须先insmod其他的模块才可以运行起来。

 

5.编译madwifi20060631的tools

默认的make并不编译tools,需要作出修改。单独使用madwifi-20060331/tools/makefile进行编译。

使用命令为make ARCH=arm KERNELPATH=/home/linuxuser/snapgear/linux-2.4.x TOOLPREFIX=arm-linux-TARGET="xscale-be-elf"

出现如下错误:

[root@localhosttools]# make ARCH=arm KERNELPATH=/home/linuxuser/snapgear/linux-2.4.x TOOLPREFIX=arm-linux-TARGET="xscale-be-elf"

arm-linux-gcc -oathstats -include ./../include/compat.h -I./../include -I.-I./../hal -I./../hal/linux -I../ath_hal -I../net80211 -I.. -g -I../ath  athstats.c

/home/linuxuser/usr/local/bin/../lib/gcc/arm-linux/3.4.4/../../../../arm-linux/bin/ld:cannot find /usr/local/arm-linux/lib/libc.so.6

collect2: ldreturned 1 exit status

make: ***[athstats] Error 1

这个很明显就是arm-linux-gcc前面没有加上/home/linuxuser/snapgear/tools/ucfront-gcc,tools作为应用程序,必须使用ulibc。修改madwifi-20060331/tools/makefile。加入中间红色的部分。

 

all:    ${ALL}

CC=/home/linuxuser/snapgear/tools/ucfront-gccarm-linux-gcc

athstats:athstats.c

    ${CC} -o athstats ${CFLAGS} -I../ath${LDFLAGS} athstats.c

80211stats:80211stats.c

    ${CC} -o 80211stats ${CFLAGS} ${LDFLAGS}80211stats.c

athkey: athkey.c

    ${CC} -o athkey ${CFLAGS} ${LDFLAGS}athkey.c

修改完保存编译

[root@localhosttools]# make ARCH=arm KERNELPATH=/home/linuxuser/snapgear/linux-2.4.x TOOLPREFIX=arm-linux-TARGET="xscale-be-elf"

/home/linuxuser/snapgear/tools/ucfront-gccarm-linux-gcc -o athstats -include ./../include/compat.h -I./../include -I. -I./../hal -I./../hal/linux -I../ath_hal -I../net80211-I.. -g -I../ath  athstats.c

/home/linuxuser/snapgear/uClibc/lib/libc.so:could not read symbols: File in wrong format

collect2: ldreturned 1 exit status

make: ***[athstats] Error 1

 

这个情况以前分析过了,是因为endian的问题。加入-mbig-endian。编译完成,利用file命令检查,格式都是

ELF 32-bit MSBexecutable, ARM, version 1 (ARM), for GNU/Linux 2.0.0,dynamically linked (uses shared libs), for GNU/Linux 2.0.0, not stripped

没有问题。

 

6. 安装配置madwifi20060631

下载到板子上后执行命令

 

# insmod wlan

Using /lib/modules/2.4.32-uc0/kernel/drivers/net/madwifi/wlan.o

wlan: 0.8.6.0(EXPERIMENTAL)

# insmod ath_hal

Using /lib/modules/2.4.32-uc0/kernel/drivers/net/madwifi/ath_hal.o

ath_hal: 0.9.14.9(AR5210, AR5211, AR5212, RF5111, RF5112, RF2413, REGOPS_FUNC)

# insmod ath_rate_sample

Using /lib/modules/2.4.32-uc0/kernel/drivers/net/madwifi/ath_rate_sample.o

ath_rate_sample: 1.2

#

#

# insmod ath_pci countrycode=840

Using /lib/modules/2.4.32-uc0/kernel/drivers/net/madwifi/ath_pci.o

ath_pci: 0.9.6.0(EXPERIMENTAL)

Build date: Mar 31 2009

Debugging version (IEEE80211)

ath0: 11arates: 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps

ath0: 11b rates: 1Mbps 2Mbps 5.5Mbps 11Mbps

ath0: 11grates: 1Mbps 2Mbps 5.5Mbps 11Mbps 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps 36Mbps48Mbps 54Mbps

ath0: turboA rates: 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps36Mbps 48Mbps 54Mbps

ath0: turboG rates: 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps36Mbps 48Mbps 54Mbps

ath0: H/W encryption support: WEP AES AES_CCM TKIP

ath0: mac 5.9 phy 4.3 radio 3.6

ath0: Use hw queue 1 for WME_AC_BE traffic

ath0: Use hw queue 0 for WME_AC_BK traffic

ath0: Use hw queue 2 for WME_AC_VI traffic

ath0: Use hw queue 3 for WME_AC_VO traffic

ath0: Use hw queue 8 for CAB traffic

ath0: Use hw queue 9 for beacons

Debugging version (ATH)

ath0: Atheros 5212: mem=0x4bff0000, irq=27

- 00:1d:0f:42:f6:a600:1d:0f:42:f6:a6    3  +58 54M   ess wep! "skyphy"

 - 00:0a:eb:e2:84:38 00:0a:eb:e2:84:38   6   +28 54M   ess  wep! "54Mb"

 -00:1b:11:fe:13:c4 00:1b:11:fe:13:c4  10   +13 54M   ess  wep! "dlink"

 - 00:1d:0f:6f:25:da00:1d:0f:6f:25:da   3    +2 54M   ess  wep! "EA-DC"

 

 

 

 

 

madwifi-20060331里面根本没有wlanconfig,无法设置成AP模式。看起来tools文件夹下面的并不属于madwifi的一部分,而是另外的release。对比检查madwifi0.94里面的svn标记

$Id: 80211debug.c 1849 2006-12-08 17:20:08Zproski $

下面是madwifi-20060331

$FreeBSD:src/tools/tools/ath/80211stats.c,v 1.2 2003/12/07 21:38:28 sam Exp $

看起来madwifi-20060331很旧的样子。

       在板子上可以通过80211debug提供的命令扫描到环境中其他的AP,但是因为madwifi-20060331缺少WLAN配置工具,就没有进一步的实验。

#ieee80211_cancel_scan: end passive scan

ath0: notify scandone

        macaddr          bssid         chan rssi rate flag  wep  essid

 - 00:1d:0f:42:f6:a600:1d:0f:42:f6:a6    3  +58 54M   ess wep! "skyphy"

 - 00:0a:eb:e2:84:3800:0a:eb:e2:84:38    6  +28 54M   ess wep! "54Mb"

 - 00:1b:11:fe:13:c4 00:1b:11:fe:13:c4   10  +13 54M   ess wep! "dlink"

 - 00:1d:0f:6f:25:da 00:1d:0f:6f:25:da    3   +2 54M   ess wep! "EA-DC"

ieee80211_reset_scan:scan set: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 42, 44, 48, 50, 52, 56,58, 60, 64, 149, 152, 153, 157, 160, 161, 165 start chan 3

ieee80211_next_scan:chan 3->4

 

       另外还遇到一个invalid option`short-load-bytes'的问题,搜索之后发现是编译器的问题.

 

参考资料如下:

 

/******************************************************/

编译器:arm-linux-3.4.1

    出现以下错误

cc1: error: invalid option `short-load-bytes'
make: *** [entry.o] 错误 1

 

Error: use ofold and new-style options to set CPU type

cc1: error:invalid option `short-load-bytes'

 

 

如果改用2.95.3则不会出现该问题。原因是高版本的编译器不支持-mshort-load-bytes选项,改为-malignment-traps即可。

/******************************************************/

7. 编译madwifi总结

       最常见的几个问题:

1.     绝对不要完全相信readme,其中madwifi1.26的README里面有这么一句话

CAVEAT:  This file doesn't lie, but is a bit old andneeds to be rewritten. 基于linux的开发现状,能说这句话已经算是够客气了。

2.     ARCH=arm在记得定义,这个也许会减少不少麻烦。其中make的很多选项就在KERNELPATH/arch/arm/makefile里面。

3.     CROSS_COMPILE只要有可能就加上。重复的相同定义不要紧,如果出了错再去排查就不划算了、

4.     编译的时候不外乎是uclibc,endian,cpu arch的问题。

ARCH=arm,CROSS_COMPILE,KERNELPATH这类的定义任何时候都加上没有问题。

cpu arch报错的信息就是-mcpu=xscale conflict,old new cpu等。解决的方法就是搜索冲突定义。加上ARCH=arm之类的东西

endian的报错信息就是invalid format, 解决的方法就是用-mbig-endian

uclibc的报错信息就是could not readsymbols: File in wrong format,libc.so之类。解决的方法就是用ucfront-gcc。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值