移植IXP驱动到uClinux2008

移植IXP驱动到uClinux2008

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


目录

移植IXP驱动到uClinux2008. 1

实验环境... 1

配置,编译uClinux2.4(20080808)... 2

配置编译IXP驱动... 5

编译Intel_IXP400_Access_Library. 5

给Intel_IXP400_Access_Library打补丁... 5

修改OemMake.mk文件... 6

修改makefile文件... 6

修改IxEthDBSymbols.c. 7

加入autoconf.h. 7

加入.config. 9

执行编译... 11

编译IXP以太网驱动... 11

集成IXP驱动到ramdisk. 13

在IXP425上启动IXP网卡... 14

配置,编译uClinux2.6(20080808)... 14

配置编译IXP驱动... 17

编译Intel_IXP400_Access_Library. 17

修改makefile. 17

修改IxOsal.h. 24

修改IxLinuxInit.c. 24

修改/IxOsalOs.h. 24

执行编译... 26

编译IXP以太网驱动... 27

集成IXP驱动到ramdisk. 29

在IXP425上启动IXP网卡... 29

 

 

实验环境

u  IXDP425 266Mhz 64M ram16M flash

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

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

u  uClinux-dist-20080808.tar.bz2

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

u  Kernel files in /home/linuxuser/snapgear

u  编译器在/home/linuxuser/usr/

u  GPL_ixp400LinuxEthernetDriverPatch-1_7.zip

u  BSD_ixp400AccessLibrary-2_4.zip

u  IPL_ixp400NpeLibrary-2_4.zip

 

配置,编译uClinux2.4(20080808)

Snpagear3.5里已经集成了IXP网卡驱动。但是Snpagear3.5里集成的软件包都很陈旧,许多软件需要重新下载新版本编译。而新版的uclinux20080808里面有比较新的软件,所以将IXP网卡驱动移植到uclinux20080808可以检查其他软件包移植的工作量。

首先将uClinux-dist-20080808.tar.bz2解压到/home/linuxuser/uClinux-dist,这时应该可以看到/home/linuxuser/uClinux-dist/linux-2.6.x等目录。

 

1.     执行如下命令:

#cd /home/linuxuser/uClinux-dist

#make clean

#make menuconfig

 

因为是首次执行make menuconfig,可能会提示没有默认的config文件,那么按crtl-c退出。这时候会产生一个默认.config。第二次执行make menuconfig就能进入菜单。

2.     选择Vendor/Product Selection--> Vendor (Intel)/ Intel Products(IXDP425)

3.     在Kernel/Library/Defaults Selection选中如下几项

Kernel Version (linux-2.4.x)

Libc Version (uClibc)

Customize Kernel Settings

 

选中之后exit,然后会弹出另外一个窗口。

4. 选择general setup--> Default kernel command string,原始语句是

ttyS0,115200root=/dev/ram0 initrd=0x00800000,8Mmem=64M@0x00000000

将其修改成

ttyS1,115200root=/dev/ram0 initrd=0x00800000,8Mmem=64M@0x00000000

选中Force default kernel command string

4.     在Main Menu->Networking options选中QoS and/or fair queueing。

QoS and/or fair queueing菜单中, 选择[ ] QoS and/or fair queueing后,会出现很多选项,选择其中的一种queue,比如RED queue。所有的选好之后保存退出。

所有的选择完成之后,执行下面两天指令:

#make dep

#make

这样就编译好了。

 

配置编译IXP驱动

       IXP驱动的驱动分为两个部分,一个是Intel_IXP400_Access_Library,一个是driver。Intel_IXP400_Access_Library需要很多修改,所以借用snapgear的补丁。

编译Intel_IXP400_Access_Library

给Intel_IXP400_Access_Library打补丁

1.     解开snapgear补丁。按照“移植uClinux2.4到IX425DP”一章的做法,将snapgear-modules-20071004.sh解开,得到modules-csr2.4-20071004.patch。

2.     将BSD_ixp400AccessLibrary-2_4.zip,IPL_ixp400NpeLibrary-2_4.zip 和modules-csr2.4-20071004.patch复制到/home/linuxuser/ixp/ixp_lib24,执行如下命令:

#cd /home/linuxuser/ixp/ixp_lib24

#unzip BSD_ixp400AccessLibrary-2_4.zip

#unzip IPL_ixp400NpeLibrary-2_4.zip

#patch -p1 < modules-csr2.4-20071004.patch

修改OemMake.mk文件

打开\ixp_osal\platforms\ixp42X\os\linux\make\OemMake.mk,将

CFLAGS_ETC =-mapcs-32 -mshort-load-bytes

修改为

CFLAGS_ETC =-mapcs-32

修改makefile文件

 

打开/home/linuxuser/ixp/ixp_lib24/Makefile

1.在.EXPORT_ALL_VARIABLES:下加入

 

ARCH=arm

CROSS_COMPILE=arm-linux-

CC=arm-linux-gcc

LD=arm-linux-ld

KERNELDIR=/home/linuxuser/uClinux-dist/linux-2.4.x

CFLAGS =-D__KERNEL__ -I$(KERNELDIR)/include -Wall -Wstrict-prototypes -O -pipe-mapcs-32 -D__LINUX_ARM_ARCH__=5 -msoft-float -DMODULE -O2 -mbig-endian-DENABLE_IOMEM -DENABLE_BUFFERMGT

CFLAGS +=-DEXPORT_SYMTAB -DIX_OSAL_OEM_FAST_MUTEX

HOSTCC=gcc

2.     将-include $(ROOTDIR)/modules/.config改为

-include ./.config

 

3. 将

ifdef obj

ixobj := $(obj)

ixbase := $(obj)

else

ixobj :=$(ROOTDIR)/modules/ixp425/ixp400-2.4

ixbase := .

endif

 

修改为

ifdef obj

ixobj := $(obj)

ixbase := $(obj)

else

#ixobj :=$(ROOTDIR)/modules/ixp425/ixp400-2.4

ixobj := .

ixbase := .

endif

 

3.删除IXCFLAGS += -I$(ROOTDIR),在IXCFLAGS +=-I$(ixobj)/ixp_osal/platforms/$(IX_DEVICE)/os/linux/include

下面加入

IXCFLAGS += -I/home/linuxuser/uClinux-dist/include

IXCFLAGS += -I/home/linuxuser/uClinux-dist/linux-2.4.x/include

IXCFLAGS +=-I./ixp400_xscale_sw/src/featureCtrl/include

IXCFLAGS +=-I./ixp400_xscale_sw/src/npeDl/include

IXCFLAGS +=-I./ixp400_xscale_sw/src/npeMh/include

IXCFLAGS +=-I./ixp400_xscale_sw/src/ethAcc/include

IXCFLAGS +=-I./ixp400_xscale_sw/src/ethDB/include

IXCFLAGS +=-I./ixp400_xscale_sw/src/ethMii/include

IXCFLAGS +=-I./ixp400_xscale_sw/src/featureCtrl/include

IXCFLAGS +=-I./ixp400_xscale_sw/src/npeDl/include

IXCFLAGS +=-I./ixp400_xscale_sw/src/npeMh/include

IXCFLAGS +=-I./ixp400_xscale_sw/src/oslinux/include

IXCFLAGS +=-I./ixp400_xscale_sw/src/osServices/include

IXCFLAGS +=-I./ixp400_xscale_sw/src/ossl/include

IXCFLAGS +=-I./ixp400_xscale_sw/src/qmgr/include

 

CFLAGS+=$(IXCFLAGS)

 

4. 将

ixp400.o:$(ixp400-objs)

    $(LD) -r -o $@ $(ixp400-objs)

改为

ixp400.o:$(ixp400-objs)

    $(LD) -EB -r-o $@ $(ixp400-objs)

 

5. 注释cd $(DLDIR) ; $(CVBIN)

修改IxEthDBSymbols.c

打开ixp400_xscale_sw\src\ethDB\IxEthDBSymbols.c,将

#include<include/IxEthDB_p.h>

修改为

#include IxEthDB_p.h

 

加入autoconf.h

新建autoconf.h文件,将其复制到/home/linuxuser/ixp/ixp_lib24/ixp_osal/common/include/modules, 内容如下:

 

/*

 * Automatically generated by make menuconfig:don't edit

 */

#defineAUTOCONF_INCLUDED

#defineCONFIG_MODULES 1

 

/*

 * OCF Configuration

 */

#undef  CONFIG_OCF_OCF

#undef  CONFIG_OCF_FIPS

#undef  CONFIG_OCF_RANDOMHARVEST

#undef  CONFIG_OCF_CRYPTODEV

#undef  CONFIG_OCF_CRYPTOSOFT

#undef  CONFIG_OCF_SAFE

#undef  CONFIG_OCF_IXP4XX

#undef  CONFIG_OCF_IXP4XX_SHA1_MD5

#undef  CONFIG_OCF_HIFN

#undef  CONFIG_OCF_TALITOS

#undef  CONFIG_OCF_OCFNULL

#undef  CONFIG_OCF_BENCH

 

/*

 * XSCALE/IXP400 Modules

 */

#undef  CONFIG_IXP400_LIB

#defineCONFIG_IXP400_LIB_MODULE 1

#undef  CONFIG_IXP400_LIB_1_4

#undef  CONFIG_IXP400_LIB_2_1

#defineCONFIG_IXP400_LIB_2_4 1

#undef  CONFIG_IXP425_ATM

#undef  CONFIG_IXP400_ETH

#defineCONFIG_IXP400_ETH_MODULE 1

#undef  CONFIG_IXP425_IXP_AS_ETH

#defineCONFIG_IXP400_ETH_2_4 1

#undef  CONFIG_IXP400_NAPI

#defineCONFIG_IXP400_ETH_ALL 1

#undef  CONFIG_IXP400_ETH_NPEB_ONLY

#undef  CONFIG_IXP400_ETH_NPEC_ONLY

#undef  CONFIG_IXP400_ETH_SKB_RECYCLE

#undef  CONFIG_IXP400_ETH_QDISC_ENABLED

#undef  CONFIG_IXP425_COMPONENT_ADSL

#undef  CONFIG_IXP425_COMPONENT_ATMDACC

#undef  CONFIG_IXP425_COMPONENT_ATMM

#undef  CONFIG_IXP425_COMPONENT_ATMSCH

#defineCONFIG_IXP425_COMPONENT_QMGR 1

#defineCONFIG_IXP425_COMPONENT_NPEMH 1

#defineCONFIG_IXP425_COMPONENT_NPEDL 1

#undef  CONFIG_IXP425_COMPONENT_CODEC

#defineCONFIG_IXP425_COMPONENT_ETHACC 1

#defineCONFIG_IXP425_COMPONENT_ETHDB 1

#defineCONFIG_IXP425_COMPONENT_ETHMII 1

#undef  CONFIG_IXP425_COMPONENT_HSSACC

#defineCONFIG_IXP425_COMPONENT_TIMERCTRL 1

#undef  CONFIG_IXP425_COMPONENT_USB

#undef  CONFIG_IXP425_COMPONENT_UARTACC

#defineCONFIG_IXP425_COMPONENT_OSSL 1

#defineCONFIG_IXP425_COMPONENT_OSSERVICES 1

#defineCONFIG_IXP425_COMPONENT_FEATURECTRL 1

#undef  CONFIG_IXP425_COMPONENT_PERFPROFACC

#undef  CONFIG_IXP425_COMPONENT_CRYPTOACC

#undef  CONFIG_IXP425_COMPONENT_DMAACC

#undef  CONFIG_IXP425_CODELET_ETHAAL5APP

#undef  CONFIG_IXP425_CODELET_HSSACC

#undef  CONFIG_IXP425_CODELET_ETHACC

#undef  CONFIG_IXP425_CODELET_USB

#undef  CONFIG_IXP425_CODELET_TIMERS

#undef  CONFIG_IXP425_CODELET_PERFPROFACC

#undef  CONFIG_IXP425_CODELET_ATM

#undef  CONFIG_IXP425_CODELET_DSPENG

#undef  CONFIG_IXP425_CODELET_CRYPTOACC

#undef  CONFIG_IXP425_CODELET_DMAACC

加入.config

在/home/linuxuser/ixp/ixp_lib24/下新建.config文件,内容如下:

 

#

# Automaticallygenerated by make menuconfig: don't edit

#

CONFIG_MODULES=y

 

#

# OCFConfiguration

#

CONFIG_OCF_OCF=y

#CONFIG_OCF_FIPS is not set

#CONFIG_OCF_RANDOMHARVEST is not set

#CONFIG_OCF_CRYPTODEV is not set

#CONFIG_OCF_CRYPTOSOFT is not set

#CONFIG_OCF_SAFE is not set

CONFIG_OCF_IXP4XX=y

#CONFIG_OCF_IXP4XX_SHA1_MD5 is not set

#CONFIG_OCF_HIFN is not set

#CONFIG_OCF_TALITOS is not set

#CONFIG_OCF_OCFNULL is not set

#CONFIG_OCF_BENCH is not set

 

#

# XSCALE/IXP400Modules

#

CONFIG_IXP400_LIB=m

#CONFIG_IXP400_LIB_1_4 is not set

#CONFIG_IXP400_LIB_2_1 is not set

CONFIG_IXP400_LIB_2_4=y

#CONFIG_IXP425_ATM is not set

CONFIG_IXP400_ETH=y

#CONFIG_IXP425_IXP_AS_ETH is not set

CONFIG_IXP400_ETH_2_4=y

#CONFIG_IXP400_NAPI is not set

CONFIG_IXP400_ETH_ALL=y

#CONFIG_IXP400_ETH_NPEB_ONLY is not set

#CONFIG_IXP400_ETH_NPEC_ONLY is not set

#CONFIG_IXP400_ETH_SKB_RECYCLE is not set

#CONFIG_IXP400_ETH_QDISC_ENABLED is not set

#CONFIG_IXP425_COMPONENT_ADSL is not set

#CONFIG_IXP425_COMPONENT_ATMDACC is not set

#CONFIG_IXP425_COMPONENT_ATMM is not set

#CONFIG_IXP425_COMPONENT_ATMSCH is not set

CONFIG_IXP425_COMPONENT_QMGR=y

CONFIG_IXP425_COMPONENT_NPEMH=y

CONFIG_IXP425_COMPONENT_NPEDL=y

#CONFIG_IXP425_COMPONENT_CODEC is not set

CONFIG_IXP425_COMPONENT_ETHACC=y

CONFIG_IXP425_COMPONENT_ETHDB=y

CONFIG_IXP425_COMPONENT_ETHMII=y

#CONFIG_IXP425_COMPONENT_HSSACC is not set

CONFIG_IXP425_COMPONENT_TIMERCTRL=y

#CONFIG_IXP425_COMPONENT_USB is not set

#CONFIG_IXP425_COMPONENT_UARTACC is not set

CONFIG_IXP425_COMPONENT_OSSL=y

CONFIG_IXP425_COMPONENT_OSSERVICES=y

CONFIG_IXP425_COMPONENT_FEATURECTRL=y

#CONFIG_IXP425_COMPONENT_PERFPROFACC is not set

#CONFIG_IXP425_COMPONENT_CRYPTOACC is not set

#CONFIG_IXP425_COMPONENT_DMAACC is not set

#CONFIG_IXP425_CODELET_ETHAAL5APP is not set

#CONFIG_IXP425_CODELET_HSSACC is not set

#CONFIG_IXP425_CODELET_ETHACC is not set

#CONFIG_IXP425_CODELET_USB is not set

#CONFIG_IXP425_CODELET_TIMERS is not set

#CONFIG_IXP425_CODELET_PERFPROFACC is not set

#CONFIG_IXP425_CODELET_ATM is not set

#CONFIG_IXP425_CODELET_DSPENG is not set

#CONFIG_IXP425_CODELET_CRYPTOACC is not set

#CONFIG_IXP425_CODELET_DMAACC is not set

 

执行编译

执行make,最后会出现下面的错误信息。

gcc -o./ixp400_xscale_sw/src/npeDl/ixNpeDlImageConverter-I./ixp400_xscale_sw/src/include./ixp400_xscale_sw/src/npeDl/ixNpeDlImageConverter.c

#cd ./ixp400_xscale_sw/src/npeDl ;./ixp400_xscale_sw/src/npeDl/ixNpeDlImageConverter

cp./ixp400_xscale_sw/src/npeDl/IxNpeMicrocode.dat ./

cp: cannot stat`./ixp400_xscale_sw/src/npeDl/IxNpeMicrocode.dat': No such file or directory

make: *** [IxNpeMicrocode.dat] Error 1。

 

进入/home/linuxuser/ixp/ixp_lib24/ixp400_xscale_sw/src/npeDl,会发现ixNpeDlImageConverter可执行文件,双击执行,会生成一个IxNpeMicrocode.dat文件。

再次执行make。就会得到/home/linuxuser/ixp/ixp_lib24/ixp400.o文件。

 

编译IXP以太网驱动

       GPL_ixp400LinuxEthernetDriverPatch-1_7.zip里包含的驱动文件就一个,但是需要很多的修改。基本上手动修改的地方太多。所以将snapgear /modules/ixp425/net-2.4里的makefile和ixp400_eth.c都移植过来比较恰当。将ixp400_eth.c和makefile都复制到/home/linuxuser/ixp/ixp24drvier/GPL_ixp400LinuxEthernetDriverPatch-1_7/。

       修改makefile文件如下:

KERNELDIR=/home/linuxuser/uClinux-dist/linux-2.4.x

 

CFLAGS =-D__KERNEL__ -I$(KERNELDIR)/include -Wall -Wstrict-prototypes -O -pipe-mapcs-32 -D__LINUX_ARM_ARCH__=5 -msoft-float -DMODULE -O2 -mbig-endian

 

CC =arm-linux-gcc

 

.EXPORT_ALL_VARIABLES:

 

-include./.config

 

 

IXCFLAGS +=-D__linux

IXCFLAGS +=-DIX_UTOPIAMODE=0

IXCFLAGS +=-DIX_MPHYSINGLEPORT=0

IXCFLAGS +=-DIX_ACC_DRAM_PHYS_OFFSET=0

IXCFLAGS +=-DIX_OSAL_OEM_FAST_MUTEX

IXCFLAGS +=-DIX_OSAL_THREAD_EXIT_GRACEFULLY

IXCFLAGS +=-DIX_SDRAM_DC

IXCFLAGS +=-DENABLE_IOMEM

IXCFLAGS +=-DENABLE_BUFFERMGT

IXCFLAGS +=-DENABLE_DDK

 

ifeq($(CONFIG_IXP425_IXP_AS_ETH),y)

IXCFLAGS += -DCONFIG_IXP425_IXP_AS_ETH=1

endif

ifeq($(CONFIG_CPU_IXP46X),y)

IXCFLAGS +=-D__ixp46X

IXPLATFORM :=ixp46X

else

ifeq($(CONFIG_CPU_IXP43X),y)

IXCFLAGS +=-D__ixp43X

IXPLATFORM :=ixp43X

else

IXCFLAGS +=-D__ixp42X

IXPLATFORM :=ixp42X

endif

endif

IXPLATFORM=ixp42X

CSRDIR :=/home/linuxuser/ixp/ixp_lib24

IXCFLAGS +=-I/home/linuxuser/uClinux-dist/include

IXCFLAGS +=-I$(CSRDIR)/ixp400_xscale_sw/src/include

IXCFLAGS +=-I$(CSRDIR)/ixp_osal/common/include

IXCFLAGS +=-I$(CSRDIR)/ixp_osal/common/include/modules

IXCFLAGS +=-I$(CSRDIR)/ixp_osal/common/include/modules/ddk

IXCFLAGS +=-I$(CSRDIR)/ixp_osal/common/include/modules/bufferMgt

IXCFLAGS +=-I$(CSRDIR)/ixp_osal/common/include/modules/ioMem

IXCFLAGS +=-I$(CSRDIR)/ixp_osal/common/os/linux/include

IXCFLAGS += -I$(CSRDIR)/ixp_osal/common/os/linux/include/core

IXCFLAGS +=-I$(CSRDIR)/ixp_osal/common/os/linux/include/modules

IXCFLAGS +=-I$(CSRDIR)/ixp_osal/common/os/linux/include/modules/ddk

IXCFLAGS +=-I$(CSRDIR)/ixp_osal/common/os/linux/include/modules/bufferMgt

IXCFLAGS +=-I$(CSRDIR)/ixp_osal/common/os/linux/include/modules/ioMem

IXCFLAGS +=-I$(CSRDIR)/ixp_osal/platforms/$(IXPLATFORM)/include

IXCFLAGS +=-I$(CSRDIR)/ixp_osal/platforms/$(IXPLATFORM)/os/linux/include

 

CFLAGS +=$(IXCFLAGS)

EXTRA_CFLAGS +=$(IXCFLAGS)

 

obj-$(CONFIG_IXP400_ETH)+= ixp400_eth.o

 

obj-m  := $(obj-y) $(obj-m)

M_OBJS :=$(obj-m)

#obj-y  :=

 

all:ixp400_eth.o

 

ifdef TOPDIR

-include$(TOPDIR)/Rules.make

endif

 

.PHONY: cleanmrproper distclean

 

clean:

    rm -f .*o.cmd .*.o.flags *.mod.c *.ko *.o

 

mrproper: clean

    rm -f .depend

 

distclean:mrproper

 

将编译Intel_IXP400_Access_Library时制作的.config文件复制一份到/home/linuxuser/ixp/ixp24drvier/GPL_ixp400LinuxEthernetDriverPatch-1_7,用make执行编译,得到ixp400_eth.o。

 

集成IXP驱动到ramdisk

将ixp400_eth.o,ixp400.o和IxNpeMicrocode.dat复制到/home/linuxuser/ixp/ixp_test。在该目录下新建一个install_ixp.txt文件,内容如下:

umount tmp

rm -rframdisk.gz

rm -rf ramdisk

rm -rf tmp

mkdir tmp

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

gunzip ramdisk

mount -o loopramdisk tmp

 

mkdir./tmp/lib/modules/ixp425

cp -rf./ixp400.o ./tmp/lib/modules/ixp425

cp -rf./ixp400_eth.o ./tmp/lib/modules/ixp425

cp -rf./IxNpeMicrocode.dat ./tmp/etc/

 

umount tmp

gzip ramdisk

cp -rframdisk.gz /tftpboot/ramdisktest.gz

rm -rf tmp

这个时候,应该内核和ramdisk都编译好了,并且在/tftpboot下有一份。那么在/home/linuxuser/ixp/ixp_test下执行

#chmod +x install_ixp.txt

#./install_ixp.txt

新的ramdisktest.gz就做好了。

 

在IXP425上启动IXP网卡

       将zImage和ramdisktest.gz下载到板子上,板子启动后执行下面指令。

#cd /lib/modules/ixp425

#insmod ixp400.o

#cat/etc/IxNpeMicrocode.dat > /dev/ixNpe

#insmod ixp400_eth.o

#ifconfig ixp0up

#ifconfig ixp0192.168.1.220

这个时候应该就可以ping通192.168.1.0/255网段的地址了

 

配置,编译uClinux2.6(20080808)

       集成补丁的方法和前面的非常类似。内核配置也很相似,只不过位置换了一下。

1.     执行如下命令:

#cd /home/linuxuser/uClinux-dist

#make clean

#make menuconfig

 

因为是首次执行make menuconfig,可能会提示没有默认的config文件,那么按crtl-c退出。这时候会产生一个默认.config。第二次执行make menuconfig就能进入菜单。

 

2.     选择Vendor/Product Selection--> Vendor (Intel)/ Intel Products(IXDP425)

 

3.     在Kernel/Library/Defaults Selection选中如下几项

Kernel Version (linux-2.6.x)

Libc Version (uClibc)

Customize Kernel Settings

选中之后exit,然后会弹出另外一个窗口。

4.     选择boot options

修改consoleoption

这个是原始语句:

console=ttyS0,115200root=/dev/ram0 initrd=0x00800000,8Mmem=64M@0x00000000

修改ttyS0 ttyS1, 下面是修改完的语句

console=ttyS1,115200root=/dev/ram0 initrd=0x00800000,8Mmem=64M@0x00000000

注意console=ttyS1之间不能用空格。

另外选中Force defaultkernel command string

5.     选择Networking  ---> Networkingoptions  ---> QoS and/or fair queueing.选中一个queue的方法。

所有的选择完成之后,执行make,这样就编译好了。

配置编译IXP驱动

编译Intel_IXP400_Access_Library

       在uclinux2.4的修改Intel_IXP400_Access_Library的基础上,加入以下改变。

 

修改makefile

打开/home/linuxuser/ixp/ixp_lib24/Makefile,修改完的makefile内容如下:

 

.EXPORT_ALL_VARIABLES:

ARCH=arm

CROSS_COMPILE=arm-linux-

CC=arm-linux-gcc-mbig-endian

LD=arm-linux-ld-EB

#KERNEL_SOURCE_PATH=snapgear

KERNEL_SOURCE_PATH=uClinux-dist

KERNELDIR=/home/linuxuser/$(KERNEL_SOURCE_PATH)/linux-2.6.x

CFLAGS =-D__KERNEL__ -I$(KERNELDIR)/include -Wall -Wstrict-prototypes -O -pipe-mapcs-32 -D__LINUX_ARM_ARCH__=5 -msoft-float -DMODULE -O2 -mbig-endian-DENABLE_IOMEM -DENABLE_BUFFERMGT -fno-common

CFLAGS += -DEXPORT_SYMTAB-DIX_OSAL_OEM_FAST_MUTEX

 

EXTRA_CFLAGS +=-D__KERNEL__ -I$(KERNELDIR)/include -Wall -Wstrict-prototypes -O -pipe-mapcs-32 -D__LINUX_ARM_ARCH__=5 -msoft-float -DMODULE -O2  -DENABLE_IOMEM -DENABLE_BUFFERMGT -fno-common-DEXPORT_SYMTAB -DIX_OSAL_OEM_FAST_MUTEX -mbig-endian

CONFIG_CPU_BIG_ENDIAN=y

 

#-include$(ROOTDIR)/modules/.config

-include./.config

ifdef obj

ixobj := $(obj)

ixbase := $(obj)

else

#ixobj :=$(ROOTDIR)/modules/ixp425/ixp400-2.4

ixobj := .

ixbase := .

endif

HOSTCC=gcc

 

#

# Figure outwhich platform we are building for. We need to know this up

# front, sincewe traverse certain directories based on it, and set

# certaindefines for it. This name reflects the directory names used in

# the AccessLibrary code.

#

ifeq($(CONFIG_CPU_IXP46X),y)

PLATFORM :=ixp465

IX_DEVICE :=ixp46X

else

ifeq($(CONFIG_CPU_IXP43X),y)

PLATFORM :=ixp435

IX_DEVICE :=ixp43X

else

PLATFORM :=ixp425

IX_DEVICE :=ixp42X

endif

endif

 

#

# Construct thelist of components that we are going to build into

# the ixp400library module.

#

COMPONENTS-y +=oslinux

COMPONENTS-$(CONFIG_IXP425_COMPONENT_ATMDACC)+= atmdAcc

COMPONENTS-$(CONFIG_IXP425_COMPONENT_ATMM)+= atmm

COMPONENTS-$(CONFIG_IXP425_COMPONENT_ATMSCH)+= atmsch

COMPONENTS-$(CONFIG_IXP425_COMPONENT_QMGR)+= qmgr

COMPONENTS-$(CONFIG_IXP425_COMPONENT_NPEDL)+= npeDl

COMPONENTS-$(CONFIG_IXP425_COMPONENT_NPEMH)+= npeMh

COMPONENTS-$(CONFIG_IXP425_COMPONENT_CODEC)+= codec

COMPONENTS-$(CONFIG_IXP425_COMPONENT_ETHACC)+= ethAcc

COMPONENTS-$(CONFIG_IXP425_COMPONENT_ETHDB)+= ethDB

COMPONENTS-$(CONFIG_IXP425_COMPONENT_ETHMII)+= ethMii

COMPONENTS-$(CONFIG_IXP425_COMPONENT_HSSACC)+= hssAcc

COMPONENTS-$(CONFIG_IXP425_COMPONENT_USB)+= usb

COMPONENTS-$(CONFIG_IXP425_COMPONENT_UARTACC)+= uartAcc

COMPONENTS-$(CONFIG_IXP425_COMPONENT_OSSL)+= ossl

COMPONENTS-$(CONFIG_IXP425_COMPONENT_OSSERVICES)+= osServices

COMPONENTS-$(CONFIG_IXP425_COMPONENT_FEATURECTRL)+= featureCtrl

COMPONENTS-$(CONFIG_IXP425_COMPONENT_PERFPROFACC)+= perfProfAcc

COMPONENTS-$(CONFIG_IXP425_COMPONENT_CRYPTOACC)+= cryptoAcc

COMPONENTS-$(CONFIG_IXP425_COMPONENT_DMAACC)+= dmaAcc

COMPONENTS-$(CONFIG_IXP425_COMPONENT_TIMESYNCACC)+= timeSyncAcc

COMPONENTS-$(CONFIG_IXP425_COMPONENT_PARITYENACC)+= parityENAcc

COMPONENTS-$(CONFIG_IXP425_COMPONENT_I2C) += i2c

COMPONENTS-$(CONFIG_IXP425_COMPONENT_SSPACC)+= sspAcc

 

CODELETS_COMPONENTS-$(CONFIG_IXP425_CODELET_ETHAAL5APP)+= ethAal5App

CODELETS_COMPONENTS-$(CONFIG_IXP425_CODELET_HSSACC)+= hssAcc

CODELETS_COMPONENTS-$(CONFIG_IXP425_CODELET_ETHACC)+= ethAcc

CODELETS_COMPONENTS-$(CONFIG_IXP425_CODELET_USB)+= usb

CODELETS_COMPONENTS-$(CONFIG_IXP425_CODELET_TIMERS)+= timers

CODELETS_COMPONENTS-$(CONFIG_IXP425_CODELET_PERFPROFACC)+= perfProfAcc

CODELETS_COMPONENTS-$(CONFIG_IXP425_CODELET_ATM)+= atm

CODELETS_COMPONENTS-$(CONFIG_IXP425_CODELET_dspEng)+= dspEng

CODELETS_COMPONENTS-$(CONFIG_IXP425_CODELET_CRYPTOACC)+= cryptoAcc

CODELETS_COMPONENTS-$(CONFIG_IXP425_CODELET_DMAACC)+= dmaAcc

 

#

# Construct thelist of osal pieces of the ixp_osal lib code we need.

# The setup is alittle more convoluted through the ixp_osal code,

# we need toseparate out the os specific part for processing.

#

OSAL_CORE-y :=ixp_osal/common/src/core

OSAL_CORE-y +=ixp_osal/common/src/modules/ddk

OSAL_CORE-y +=ixp_osal/common/src/modules/ioMem

OSAL_CORE-y +=ixp_osal/common/src/modules/bufferMgt

 

OSAL_OS-y :=ixp_osal/common/os/linux/src/core

OSAL_OS-y +=ixp_osal/common/os/linux/src/modules/ddk

OSAL_OS-y +=ixp_osal/common/os/linux/src/modules/ioMem

OSAL_OS-y +=ixp_osal/common/os/linux/src/modules/bufferMgt

 

OSAL_PLATFORM-y:= ixp_osal/platforms/$(IX_DEVICE)/os/linux/src

 

OSAL_COMPONENTS-y:= $(OSAL_CORE-y) $(OSAL_OS-y) $(OSAL_PLATFORM-y)

 

#

# Local flagsrequired for building.

#

IXCFLAGS +=-DCPU=XSCALE -DXSCALE=33 -DSIMSPARCSOLARIS=34 -DSIMLINUX=35

IXCFLAGS +=-D__linux

IXCFLAGS +=-DIX_NPEDL_READ_MICROCODE_FROM_FILE

IXCFLAGS +=-DIX_UTOPIAMODE=0 -DIX_MPHYSINGLEPORT=0 -DIX_ACC_DRAM_PHYS_OFFSET=0

 

#IXCFLAGS +=-DIX_HW_COHERENT_MEMORY

 

ifeq($(PLATFORM),ixp465)

IXCFLAGS +=-D__ixp46X

else

ifeq($(PLATFORM),ixp435)

IXCFLAGS +=-D__ixp43X

else

IXCFLAGS +=-D__ixp42X

endif

endif

 

#IXCFLAGS +=-I$(ROOTDIR)

IXCFLAGS +=-I/home/linuxuser/$(KERNEL_SOURCE_PATH)/include

IXCFLAGS +=-I$(ixobj)/ixp400_xscale_sw/src/include

IXCFLAGS +=-I$(ixobj)/ixp_osal/common/include

IXCFLAGS +=-I$(ixobj)/ixp_osal/common/include/modules

IXCFLAGS +=-I$(ixobj)/ixp_osal/common/include/modules/ddk

IXCFLAGS +=-I$(ixobj)/ixp_osal/common/include/modules/bufferMgt

IXCFLAGS +=-I$(ixobj)/ixp_osal/common/include/modules/ioMem

IXCFLAGS +=-I$(ixobj)/ixp_osal/common/os/linux/include

IXCFLAGS +=-I$(ixobj)/ixp_osal/common/os/linux/include/core

IXCFLAGS +=-I$(ixobj)/ixp_osal/common/os/linux/include/modules

IXCFLAGS +=-I$(ixobj)/ixp_osal/common/os/linux/include/modules/ddk

IXCFLAGS +=-I$(ixobj)/ixp_osal/common/os/linux/include/modules/bufferMgt

IXCFLAGS +=-I$(ixobj)/ixp_osal/common/os/linux/include/modules/ioMem

IXCFLAGS +=-I$(ixobj)/ixp_osal/platforms/$(IX_DEVICE)/include

IXCFLAGS +=-I$(ixobj)/ixp_osal/platforms/$(IX_DEVICE)/os/linux/include

IXCFLAGS +=-I./ixp400_xscale_sw/src/featureCtrl/include

IXCFLAGS +=-I./ixp400_xscale_sw/src/npeDl/include

IXCFLAGS +=-I./ixp400_xscale_sw/src/npeMh/include

IXCFLAGS +=-I./ixp400_xscale_sw/src/ethAcc/include

 

IXCFLAGS +=-I./ixp400_xscale_sw/src/ethDB/include

 

IXCFLAGS +=-I./ixp400_xscale_sw/src/ethMii/include

IXCFLAGS +=-I./ixp400_xscale_sw/src/featureCtrl/include

IXCFLAGS +=-I./ixp400_xscale_sw/src/npeDl/include

IXCFLAGS +=-I./ixp400_xscale_sw/src/npeMh/include

IXCFLAGS += -I./ixp400_xscale_sw/src/oslinux/include

IXCFLAGS +=-I./ixp400_xscale_sw/src/osServices/include

IXCFLAGS +=-I./ixp400_xscale_sw/src/ossl/include

IXCFLAGS +=-I./ixp400_xscale_sw/src/qmgr/include

 

#CFLAGS+=$(IXCFLAGS)

 

#

# Include thesub component code makefiles. We use this to get at

# the objectlist for each component.

#

IX_TARGET_OS :=linux

include$(COMPONENTS-y:%=$(ixobj)/ixp400_xscale_sw/src/%/component.mk)

include$(OSAL_COMPONENTS-y:%=$(ixobj)/%/component.mk)

 

include$(ixobj)/ixp_osal/platforms/$(IX_DEVICE)/os/$(IX_TARGET_OS)/make/OsalConfig.mk

 

#

# Construct thelist of objects that need to be built. They need to be

# listed withthe relative path, so the top level rules can find the

# source code topass to the compiler.

#

ixp400-component-objs:= $(foreach c, $(COMPONENTS-y), $($(c)_OBJ:%=ixp400_xscale_sw/src/$(c)/%))

 

ixp400-osal-objs:= $(foreach c, $(OSAL_CORE-y), $($(notdir $(c))_OBJ:%=$(c)/%))

ixp400-osal-objs+= $(foreach c, $(OSAL_OS-y), $($(notdir $(c))_os_OBJ:%=$(c)/%))

ixp400-osal-objs+= $(foreach c, $(OSAL_PLATFORM-y), $(platform_OBJ:%=$(c)/%))

 

ixp400-objs :=$(ixp400-component-objs) $(ixp400-osal-objs) stub.dat

 

#

# Setup thespecific CFLAGS for each object. These are already defined in

# thecomponent.mk files of the Access Library, so we just need to convert

# them to theright kernel notation for use. This rule is a little tricky,

# you may needto read it a couple of times to understand what it is doing :-)

# Complicatingall this is that the setup is slightly different for 2.4 and

# 2.6 kernels,thus similar rules, generating slightly different define

# names tosatisfy both.

#

 

$(foreach c,$(ixp400-component-objs), $(eval CFLAGS_$(notdir $(c)) += $(subst -I./src,-I$(ixobj)/ixp400_xscale_sw/src/, $(subst -Isrc, -I$(ixobj)/ixp400_xscale_sw/src,$($(strip $(patsubst %/, %, $(dir $(c:ixp400_xscale_sw/src/%=%)))_CFLAGS))))-I$(ixobj)/$(dir $(c)) ))

 

$(foreach c,$(ixp400-component-objs), $(eval CFLAGS_$(c) += $(subst -I./src,-I$(ixobj)/ixp400_xscale_sw/src/, $(subst -Isrc, -I$(ixobj)/ixp400_xscale_sw/src,$($(strip $(patsubst %/, %, $(dir $(c:ixp400_xscale_sw/src/%=%)))_CFLAGS))))-I$(ixobj)/$(dir $(c)) ))

 

ifndef obj

export-objs +=$(foreach c, $(COMPONENTS-y), $($(c)_EXPORT_OBJ:%=ixp400_xscale_sw/src/$(c)/%))

export-objs +=$(ixp400-osal-objs)

list-multi +=ixp400.o

endif

 

EXTRA_CFLAGS +=$(IXCFLAGS) $(OSAL_CFLAGS)

 

#

# Finally tellthe kernel what objects need to be built for the ixp400

# module itself.

#

obj-m +=ixp400.o

M_OBJS :=$(obj-m)

obj-y :=

#obj-m =ixp400.o

 

default:

   

    echo "CFLAGS = $(CFLAGS)"

    echo "LDFLAGS = $(LDFLAGS)"

    echo "CONFIG_CPU_BIG_ENDIAN =$(CONFIG_CPU_BIG_ENDIAN)"

 

    $(MAKE) -C $(KERNELDIR) ARCH=armCROSS_COMPILE=arm-linux- M=$(PWD)

 

 

ixp400.o:$(ixp400-objs)

    $(LD) -EB -r -o $@ $(ixp400-objs)

 

#

# The CSR codehas some files that end in .s that really need to be

# C-preprocessedfirst (they should be .S files). This rule caters for

# that, on both2.4 and 2.6 kernels.

#

ASMOBJS +=$(ixbase)/ixp400_xscale_sw/src/qmgr/IxQMgrAsmRoutines.o

ASMOBJS +=$(ixbase)/ixp400_xscale_sw/src/cryptoAcc/IxCryptoAccXScaleWep.o

 

$(ASMOBJS): %.o: %.s

    echo "ln201 export-objs :$(export-objs)"

    $(CC) $(CPPFLAGS) $(CFLAGS) $(IXCFLAGS) -xassembler-with-cpp -o $@ -c $<

 

#

# Build theMicrocode downloader app. We "attach" it to building

# the npeDl code(trick is to not link it into the module on 2.6

# kernels).

#

DLDIR :=$(ixobj)/ixp400_xscale_sw/src/npeDl

CVBIN :=$(DLDIR)/ixNpeDlImageConverter

CVSRC :=$(CVBIN).c

 

$(ixbase)/stub.dat:$(ixbase)/stub.c $(ixobj)/IxNpeMicrocode.dat

    $(CC) $(CPPFLAGS) $(CFLAGS) -o$(ixbase)/stub.o -c $(ixbase)/stub.c

    cp $(ixbase)/stub.o $(ixbase)/stub.dat

 

$(ixobj)/IxNpeMicrocode.dat:

    echo "HOSTCC $(HOSTCC)"

    $(HOSTCC) -o $(CVBIN)-I$(ixobj)/ixp400_xscale_sw/src/include $(CVSRC)

    #cd $(DLDIR);$(CVBIN)

    cp $(DLDIR)/IxNpeMicrocode.dat $(ixobj)/

 

 

ifdef TOPDIR

-include$(TOPDIR)/Rules.make

endif

 

.PHONY: cleanmrproper distclean

 

clean:

    find -name "*.[od]" | grep -vdsr.o | xargs rm -f

    find -name ".*o.cmd" | xargs rm -f

    find -name ".*.o.flags" | xargs rm-f

    rm -f *.mod.c *.ko *.dat

    rm -f $(CVBIN) $(DLDIR)/IxNpeMicrocode.dat

 

mrproper: clean

    rm -f .depend

 

distclean:mrproper

 

 

修改IxOsal.h

打开/home/linuxuser/ixp/ixp_lib24/ixp_osal/common/include,在

#ifndef IxOsal_H

#define IxOsal_H

下一行加入

#include <linux/fs.h>

 

 

修改IxLinuxInit.c

打开/home/linuxuser/ixp/ixp_lib24/ixp400_xscale_sw/src/oslinux/IxLinuxInit.c

找到如下语句

    if (unregister_chrdev(DEV_IXNPE_MAJOR_NUMBER,"ixNpe"))

    {

    printk (KERN_ERR "Failed to unregisterdriver for /dev/ixNpe\n");

    }

 

将其修改为

unregister_chrdev(DEV_IXNPE_MAJOR_NUMBER,"ixNpe");

修改/IxOsalOs.h

打开/home/linuxuser/ixp/ixp_lib24/ixp_osal/common/os/linux/include/core/IxOsalOs.h

 

将下面这段:

#ifndefIX_HW_COHERENT_MEMORY

 

#ifKERNEL_VERSION(2,6,0) <= LINUX_VERSION_CODE

 

#defineIX_OSAL_OS_CACHE_INVALIDATE(addr, size) \

    (consistent_sync((void*)addr, (size_t)size, DMA_FROM_DEVICE))

 

#defineIX_OSAL_OS_CACHE_FLUSH(addr, size) \

    (consistent_sync((void*)addr, (size_t)size, DMA_TO_DEVICE))

 

#else /*!KERNEL_VERSION 2.6 */

 

#defineIX_OSAL_OS_CACHE_INVALIDATE(addr, size) \

    (invalidate_dcache_range((__u32)addr,(__u32)addr + size ))

 

#defineIX_OSAL_OS_CACHE_FLUSH(addr, size) \

    (clean_dcache_range((__u32)addr,(__u32)addr + size))

 

#endif /*KERNEL_VERSION */

 

#else /*IX_HW_COHERENT_MEMORY */

 

/*

 * The non-coherent memory region is exposed asuncacheable memory.

 * So there is no need for cache invalidation orcache flushing

 */

#defineIX_OSAL_OS_CACHE_INVALIDATE(addr, size) do {  } while(0);

 

#defineIX_OSAL_OS_CACHE_FLUSH(addr, size)      do {  }while(0);

 

#endif /*IX_HW_COHERENT_MEMORY  */                                           

 

修改为

#ifndefIX_HW_COHERENT_MEMORY

 

#if LINUX_VERSION_CODE<= KERNEL_VERSION(2,6,19)

 

    #define CONSISTENT_FUNC consistent_sync

#else

    #define CONSISTENT_FUNC dma_cache_maint

#endif

 

#ifKERNEL_VERSION(2,6,0) <= LINUX_VERSION_CODE

 

#defineIX_OSAL_OS_CACHE_INVALIDATE(addr, size) \

    (CONSISTENT_FUNC((void*)addr, (size_t)size, DMA_FROM_DEVICE))

 

#defineIX_OSAL_OS_CACHE_FLUSH(addr, size) \

    (CONSISTENT_FUNC((void*)addr, (size_t)size, DMA_TO_DEVICE))

 

#else /*!KERNEL_VERSION 2.6 */

 

#defineIX_OSAL_OS_CACHE_INVALIDATE(addr, size) \

    (invalidate_dcache_range((__u32)addr,(__u32)addr + size ))

 

#defineIX_OSAL_OS_CACHE_FLUSH(addr, size) \

    (clean_dcache_range((__u32)addr,(__u32)addr + size))

 

#endif /*KERNEL_VERSION */

 

#else /*IX_HW_COHERENT_MEMORY */

/*

 * The non-coherent memory region is exposed asuncacheable memory.

 * So there is no need for cache invalidationor cache flushing

 */

#defineIX_OSAL_OS_CACHE_INVALIDATE(addr, size) do {  } while(0);

 

#defineIX_OSAL_OS_CACHE_FLUSH(addr, size)      do {  }while(0);

 

#endif /*IX_HW_COHERENT_MEMORY  */   

执行编译

 

执行make,最后会出现下面的错误信息:

gcc -o./ixp400_xscale_sw/src/npeDl/ixNpeDlImageConverter-I./ixp400_xscale_sw/src/include./ixp400_xscale_sw/src/npeDl/ixNpeDlImageConverter.c

#cd ./ixp400_xscale_sw/src/npeDl ;./ixp400_xscale_sw/src/npeDl/ixNpeDlImageConverter

cp./ixp400_xscale_sw/src/npeDl/IxNpeMicrocode.dat ./

cp: cannot stat`./ixp400_xscale_sw/src/npeDl/IxNpeMicrocode.dat': No such file or directory

make: *** [IxNpeMicrocode.dat] Error 1。

 

进入/home/linuxuser/ixp/ixp_lib24/ixp400_xscale_sw/src/npeDl,会发现ixNpeDlImageConverter可执行文件,双击执行,会生成一个IxNpeMicrocode.dat文件。

再次执行make。就会得到/home/linuxuser/ixp/ixp_lib24/ixp400.ko文件。

 

编译IXP以太网驱动

       在2.4 kernel修改的基础上,需要修改makefile。修改完的makefile文件如下:

KERNELDIR=/home/linuxuser/uClinux-dist/linux-2.6.x

 

CFLAGS =-D__KERNEL__ -I$(KERNELDIR)/include -Wall -Wstrict-prototypes -O -pipe-mapcs-32 -D__LINUX_ARM_ARCH__=5 -msoft-float -DMODULE -O2 -mbig-endian-fno-common

 

CC =arm-linux-gcc

 

.EXPORT_ALL_VARIABLES:

 

-include./.config

 

 

IXCFLAGS +=-D__linux

IXCFLAGS +=-DIX_UTOPIAMODE=0

IXCFLAGS +=-DIX_MPHYSINGLEPORT=0

IXCFLAGS +=-DIX_ACC_DRAM_PHYS_OFFSET=0

IXCFLAGS +=-DIX_OSAL_OEM_FAST_MUTEX

IXCFLAGS +=-DIX_OSAL_THREAD_EXIT_GRACEFULLY

IXCFLAGS +=-DIX_SDRAM_DC

IXCFLAGS +=-DENABLE_IOMEM

IXCFLAGS +=-DENABLE_BUFFERMGT

IXCFLAGS +=-DENABLE_DDK

#IXCFLAGS +=-DIX_HW_COHERENT_MEMORY

 

ifeq($(CONFIG_IXP425_IXP_AS_ETH),y)

IXCFLAGS +=-DCONFIG_IXP425_IXP_AS_ETH=1

endif

ifeq($(CONFIG_CPU_IXP46X),y)

IXCFLAGS +=-D__ixp46X

IXPLATFORM :=ixp46X

else

ifeq($(CONFIG_CPU_IXP43X),y)

IXCFLAGS +=-D__ixp43X

IXPLATFORM :=ixp43X

else

IXCFLAGS +=-D__ixp42X

IXPLATFORM :=ixp42X

endif

endif

IXPLATFORM=ixp42X

CSRDIR := /home/linuxuser/ixp/ixp_lib24

IXCFLAGS +=-I/home/linuxuser/uClinux-dist/include

IXCFLAGS +=-I$(CSRDIR)/ixp400_xscale_sw/src/include

IXCFLAGS +=-I$(CSRDIR)/ixp_osal/common/include

IXCFLAGS +=-I$(CSRDIR)/ixp_osal/common/include/modules

IXCFLAGS +=-I$(CSRDIR)/ixp_osal/common/include/modules/ddk

IXCFLAGS +=-I$(CSRDIR)/ixp_osal/common/include/modules/bufferMgt

IXCFLAGS +=-I$(CSRDIR)/ixp_osal/common/include/modules/ioMem

IXCFLAGS +=-I$(CSRDIR)/ixp_osal/common/os/linux/include

IXCFLAGS +=-I$(CSRDIR)/ixp_osal/common/os/linux/include/core

IXCFLAGS +=-I$(CSRDIR)/ixp_osal/common/os/linux/include/modules

IXCFLAGS +=-I$(CSRDIR)/ixp_osal/common/os/linux/include/modules/ddk

IXCFLAGS +=-I$(CSRDIR)/ixp_osal/common/os/linux/include/modules/bufferMgt

IXCFLAGS +=-I$(CSRDIR)/ixp_osal/common/os/linux/include/modules/ioMem

IXCFLAGS +=-I$(CSRDIR)/ixp_osal/platforms/$(IXPLATFORM)/include

IXCFLAGS +=-I$(CSRDIR)/ixp_osal/platforms/$(IXPLATFORM)/os/linux/include

 

#CFLAGS +=$(IXCFLAGS)

EXTRA_CFLAGS +=$(IXCFLAGS)

EXTRA_CFLAGS +=$(CFLAGS)

#obj-$(CONFIG_IXP400_ETH)+= ixp400_eth.o

 

PWD:=$(shellpwd)

#obj-m  := $(obj-y) $(obj-m)

#M_OBJS :=$(obj-m)

#obj-y  :=

obj-m  :=ixp400_eth.o

 

default:

    $(MAKE) -C $(KERNELDIR) ARCH=armCROSS_COMPILE=arm-linux- M=$(PWD)

 

#all:ixp400_eth.o

 

ifdef TOPDIR

-include$(TOPDIR)/Rules.make

endif

 

.PHONY: cleanmrproper distclean

 

clean:

    rm -f .*o.cmd .*.o.flags *.mod.c *.ko *.o

 

mrproper: clean

    rm -f .depend

 

distclean:mrproper

 

       另外.config文件已经准备好了,执行make得到ixp400_eth.ko文件。

集成IXP驱动到ramdisk

       将ixp400_eth.o,ixp400.o和IxNpeMicrocode.dat复制到/home/linuxuser/ixp/ixp_test。在该目录下新建一个install_ixp.txt文件,内容如下:

umount tmp

rm -rframdisk.gz

rm -rf ramdisk

rm -rf tmp

mkdir tmp

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

gunzip ramdisk

mount -o loopramdisk tmp

 

mkdir./tmp/lib/modules/ixp425

cp -rf ./ixp400.ko./tmp/lib/modules/ixp425

cp -rf./ixp400_eth.ko ./tmp/lib/modules/ixp425

cp -rf./IxNpeMicrocode.dat ./tmp/etc/

 

umount tmp

gzip ramdisk

cp -rf ramdisk.gz/tftpboot/ramdisktest.gz

rm -rf tmp

这个时候,应该内核和ramdisk都编译好了,并且在/tftpboot下有一份。那么在/home/linuxuser/ixp/ixp_test下执行

#chmod +x install_ixp.txt

#./install_ixp.txt

新的ramdisktest.gz就做好了。

 

在IXP425上启动IXP网卡

       将zImage和ramdisktest.gz下载到板子上,板子启动后执行下面指令。

#cd /lib/modules/ixp425

#insmod ixp400.ko

#cat /etc/IxNpeMicrocode.dat> /dev/ixNpe

#insmod ixp400_eth.ko

#ifconfig ixp0up

#ifconfig ixp0192.168.1.220

#echo 0 >/proc/sys/kernel/hung_task_timeout_secs

这个时候应该就可以ping通192.168.1.0/255网段的地址了

 

移植IXP驱动的摸索

       因为snapgear上自带的软件实在是非常的陈旧,所以尝试移植IXP驱动到最新版的uClinux-dist-20080808。为了加入最新的特性,特意从www.uclinux.org上拿到了最新的uClinux-dist-20080808-20090302.patch.gz,并且将其集成到uClinux-dist-20080808,后来的实验证明绝对是个错误。

尝试编译2.4原版驱动

       首先在下载BSD_ixp400AccessLibrary-2_4.zip和IPL_ixp400NpeLibrary-2_4.zip,先解压BSD_ixp400AccessLibrary-2_4.zip得到ixp400_xscale_sw和ixp_osal,然后解压IPL_ixp400NpeLibrary-2_4.zip得到ixp400_xscale_sw。将IPL得到的ixp400_xscale_sw覆盖BSD得到的ixp400_xscale_sw。实际上是加入了IxNpeMicrocode.dat的支持。

 

在实际的尝试过程中,原版code编译出现很多错误,无法一一纠正。而且有的竟然是语法错误,比如在原版code当中出现:

thread_data.entryPoint= entryPoint;

thread_data.arg= arg;

而thread_data是结构体而不是一个结构体变量,参照snapgear下的代码,会发现被修改为:

    IxOsalOsThreadData.entryPoint = entryPoint;

    IxOsalOsThreadData.arg = arg;

而snapgear的就可以编译通过。

 

下面从头开始,先解压uClinux-dist-20080808,将uClinux-dist-20080808-20090302.patch.gz补丁打上,然后开始编译驱动。

使用source命令用脚本设定环境变量

       查看了ixp400_xscale_sw和ixp_osal下的makefile,需要设定很多的环境变量,在/home/linuxuser/ixp/ixp_lib24/ixp400_xscale_sw/buildUtils下有一些辅助配置脚本,其中environment.linux.sh可以使用。修改environment.linux.sh文件以后,路径,编译器都设定无误,内容如下:

# -- End ofCopyright Notice --

# Change thefollowing line to your linux kernel source tree

linuxbe_KERNEL_DIR=/home/linuxuser/uClinux-dist/linux-2.4.x

 

# Change thefollowing line to your toolchain bin directory

CROSSCOMPILER_DIR=/home/linuxuser/usr/local/bin

 

# Change thebelow to specify the prefix of your cross compiler

# E.g: ifarmv5b-linux-gcc is your C cross compiler, then the prefix is

# armv5b-linux-

IX_LINUX_CROSSCOMPILER=arm-linux-

 

# You may wantto edit the following to point to your ixp400_xscale_sw

# directory.Otherwise you must source this file from that directory.

IX_XSCALE_SW=/home/linuxuser/ixp/ixp_lib24/ixp400_xscale_sw

 

PATH=/usr/bin:$CROSSCOMPILER_DIR:$PATH

 

#NOTE: All flagdefinitions below are case sensitive

 

# For IXDP425platform, set IX_DEVICE to ixp42X

# For KIXRP435platform, set IX_DEVICE to ixp43X

# For IXDP465platform, set IX_DEVICE to ixp46X

IX_DEVICE=ixp42X

 

# For IXDP425platform, set IX_PLATFORM to ixdp42x

# For KIXRP435platform, set IX_PLATFORM to kixrp43x

# For IXDP465platform, set IX_PLATFORM to ixdp46x

IX_PLATFORM=ixdp42x

 

# For Bigendian, set IX_TARGET to linuxbe (this version only support big-endian)

IX_TARGET=linuxbe

 

exportlinuxbe_KERNEL_DIR HARDHAT_BASE IX_XSCALE_SW PATH IX_DEVICE IX_PLATFORMIX_TARGET

exportIX_LINUX_CROSSCOMPILER

exportIX_KBUILD_CROSSCOMPILE="ARCH=armCROSS_COMPILE=${IX_LINUX_CROSSCOMPILER}"

       如果直接执行environment.linux.sh,那么使用env命令之后会发现根本没有起作用。必须使用source ./environment.linux.sh才可以。用source 执行脚本和用sh 执行脚本区别是:source不是直接执行一个文件,而是从一个文本文件里面读命令行,然后执行这些命令。

 

编译ixp_osal的大量错误

按照要求,应该是先编译ixp_osal文件夹。直接make不行,于是查看osal/Makefile中说明部分如下:

 

osal/Makefileusage (for linux)

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

Requirements:

 - IX_TARGET       : [linuxle | linuxbe]

 - IX_LINUXVER     : 2.6

 - LINUX_SRC       : <Path of Linux kernel src>

 - IX_OSAL_OS_LEVEL: [kernel_space |user_space]

 - IX_TARGET       : linuxle

 - IX_OSAL_PLATFORM: platform_name

 - IX_HW_COHERENT_MEMORY: 1

 - IX_OSAL_INTEG_TEST: [1 | 0]

 - source the same environment.tcsh asixp400_xscale

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

osal/Makefileusage (for vxworks)

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

Requirements:

 - IX_TARGET: [vxle | vxbe]

 - Source env_scripts/env_vxworksXY_xscale.batin ixp_osal/

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

Build commands:

make lkm:      to build osal as a loadable module

make libosal:  to build osal library

make clean:    to remove library and dependency files.

 

进入/home/linuxuser/ixp/ixp24/BSD_ixp400AccessLibrary-2_4/ixp_osal,输入

#make libosal

出现如下错误

 

ucfront-gccarm-linux-gcc -M -mbig-endian -D__ixp42X -D__KERNEL__-I/home/linuxuser/snapgear/linux-2.4.x/include -Wall -Wno-trigraphs -fno-common-pipe -mapcs-32 -mshort-load-bytes -msoft-float-DMODULE -D__linux -DCPU=33 -DXSCALE=33 -D__LINUX_ARM_ARCH__=5 -mcpu=xscale-mtune=xscale  -DEXPORT_SYMTAB  -DIX_OSAL_OEM_FAST_MUTEX-DIX_OSAL_THREAD_EXIT_GRACEFULLY -DIX_SDRAM_DC -DENABLE_IOMEM-DENABLE_BUFFERMGT -DENABLE_DDK  -I/home/linuxuser/snapgear/linux-2.4.x/include/asm-arm/arch-ixp425/-Icommon/include -Icommon/include/. -Icommon/include/core-Icommon/include/modules/ddk -Icommon/include/modules/ioMem-Icommon/include/modules/bufferMgt -Icommon/os/linux/include/. -Icommon/os/linux/include/core-Icommon/os/linux/include/modules/ddk -Icommon/os/linux/include/modules/ioMem-Icommon/os/linux/include/modules/bufferMgt -Iplatforms/ixp42X/include-Iplatforms/ixp42X/os/linux/include -DIX_COMPONENT=1 -DENABLE_IOMEM-DENABLE_BUFFERMGT -DENABLE_DDK -DIX_OSAL_TARGET_OS_EXT=_linux-DIX_OSAL_PLATFORM_EXT=_ixp42X -DIX_COMPONENT_NAME=ix_osal  -DIX_GENERATING_DEPENDENCIESplatforms/ixp42X/os/linux/src/IxOsalOsOemSymbols.c > lib/ixp42X/linux/linuxbe/platforms/ixp42X/os/linux/src/IxOsalOsOemSymbols.d.tmp

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

 

short-load-bytes已经遇到过,原因是高版本的编译器不支持-mshort-load-bytes选项,改为-malignment-traps即可。这个情况在编译madwifi驱动一章已经提到过。根据short-load-bytes在编译选项中的位置查找。ixp_osal/makefile里根本没有short-load-bytes,说明是外面引入的。而ixp_osal/makefile为顶层的makefile,最开始执行的只有environment.linux.sh,并不包含任何short-load-bytes。另外因为是和kernel有关系的,所以有两种可能:

1.     /home/linuxuser/snapgear/linux-2.4.x/arch/arm/makefile

2.     顶层的makefile包含了其他的配置文件。

首先查找ixp_osal/makefile,找到CFLAGS += $(IX_OSAL_MK_CFLAGS),而CFLAGS通常是编译选项的来源。

在附近找到以下几句:

 

includeplatforms/$(IX_OSAL_MK_TGT_DEVICE)/os/$(IX_OSAL_MK_TARGET_OS)/make/OemMake.mk

includecommon/os/${IX_OSAL_MK_TARGET_OS}/make/macros.mk

 

# include anyadditional flags set by the user

CFLAGS +=$(IX_OSAL_MK_CFLAGS)

LDFLAGS +=$(IX_OSAL_MK_LDFLAGS)

查找ixp_osal/platforms/ixp42X/os/linux/make/OemMake.mk,果然找到

 

ifeq($(IX_LINUXVER), 2.6)

    LINUX_MACH_CFLAGS := -D__LINUX_ARM_ARCH__=5-march=armv5te -Wa,-mcpu=xscale -mtune=xscale

# Commented outto remove a warning  

#    CFLAGS_ETC = -mabi=apcs-gnu

else

    LINUX_MACH_CFLAGS := -D__LINUX_ARM_ARCH__=5-mcpu=xscale -mtune=xscale

    CFLAGS_ETC = -mapcs-32 -mshort-load-bytes

Endif

 

而目前编译的目标kernel是2.4,显然-mshort-load-bytes就是这么来的。删除掉重新编译。还是出错。

 

---Makefile:  Building object filelib/ixp42X/linux/linuxbe/platforms/ixp42X/os/linux/src/IxOsalOsOem.o from C

ucfront-gccarm-linux-gcc -mbig-endian -D__ixp42X -D__KERNEL__-I/home/linuxuser/snapgear/linux-2.4.x/include -Wall -Wno-trigraphs -fno-common-pipe -mapcs-32  -msoft-float -DMODULE-D__linux -DCPU=33 -DXSCALE=33 -D__LINUX_ARM_ARCH__=5 -mcpu=xscale-mtune=xscale  -DEXPORT_SYMTAB  -DIX_OSAL_OEM_FAST_MUTEX-DIX_OSAL_THREAD_EXIT_GRACEFULLY -DIX_SDRAM_DC -DENABLE_IOMEM -DENABLE_BUFFERMGT-DENABLE_DDK -I/home/linuxuser/snapgear/linux-2.4.x/include/asm-arm/arch-ixp425/-Icommon/include -Icommon/include/. -Icommon/include/core-Icommon/include/modules/ddk -Icommon/include/modules/ioMem-Icommon/include/modules/bufferMgt -Icommon/os/linux/include/.-Icommon/os/linux/include/core -Icommon/os/linux/include/modules/ddk -Icommon/os/linux/include/modules/ioMem-Icommon/os/linux/include/modules/bufferMgt -Iplatforms/ixp42X/include-Iplatforms/ixp42X/os/linux/include -DIX_COMPONENT=1 -DENABLE_IOMEM-DENABLE_BUFFERMGT -DENABLE_DDK -DIX_OSAL_TARGET_OS_EXT=_linux -DIX_OSAL_PLATFORM_EXT=_ixp42X-DIX_COMPONENT_NAME=ix_osal platforms/ixp42X/os/linux/src/IxOsalOsOem.c -c -olib/ixp42X/linux/linuxbe/platforms/ixp42X/os/linux/src/IxOsalOsOem.o

platforms/ixp42X/os/linux/src/IxOsalOsOem.c:In function `ixOsalMemMapInit':

platforms/ixp42X/os/linux/src/IxOsalOsOem.c:118:error: `IXP4XX_EXP_BUS_BASE_PHYS' undeclared (first use in this function)

platforms/ixp42X/os/linux/src/IxOsalOsOem.c:118:error: (Each undeclared identifier is reported only once

platforms/ixp42X/os/linux/src/IxOsalOsOem.c:118:error: for each function it appears in.)

platforms/ixp42X/os/linux/src/IxOsalOsOem.c:In function `ixOsalOemInit':

platforms/ixp42X/os/linux/src/IxOsalOsOem.c:165:error: `IXP4XX_TIMER_BASE_PHYS' undeclared (first use in this function)

make: *** [lib/ixp42X/linux/linuxbe/platforms/ixp42X/os/linux/src/IxOsalOsOem.o]Error 1

 

看样子是有几个关键的宏没有定义

IXP4XX_EXP_BUS_BASE_PHYS

IXP4XX_TIMER_BASE_PHYS

 

对比snapgear下的IXP库,发现了定义的不同.

/* compatabilitydefines for 2.4.x kernels */

#ifndefIXP4XX_PCI_CFG_BASE_PHYS

#define IXP4XX_PCI_CFG_BASE_PHYS   IXP425_PCI_CFG_BASE_PHYS

#define IXP4XX_PCI_CFG_BASE_VIRT   IXP425_PCI_CFG_BASE_VIRT

#define IXP4XX_PCI_CFG_REGION_SIZE IXP425_PCI_CFG_REGION_SIZE

#endif

#ifndefIXP4XX_EXP_CFG_BASE_PHYS

#define IXP4XX_EXP_CFG_BASE_PHYS   IXP425_EXP_CFG_BASE_PHYS

#define IXP4XX_EXP_CFG_BASE_VIRT   IXP425_EXP_CFG_BASE_VIRT

#define IXP4XX_EXP_CFG_REGION_SIZE IXP425_EXP_CFG_REGION_SIZE

#endif

#ifndefIXP4XX_EXP_BUS_BASE_PHYS

#define IXP4XX_EXP_BUS_BASE_PHYS   IXP425_EXP_BUS_BASE_PHYS

#define IXP4XX_EXP_BUS_BASE_VIRT   IXP425_EXP_BUS_BASE_VIRT

#define IXP4XX_EXP_BUS_REGION_SIZE IXP425_EXP_BUS_REGION_SIZE

#endif

#ifndefIXP4XX_QMGR_BASE_PHYS

#define IXP4XX_QMGR_BASE_PHYS      IXP425_QMGR_BASE_PHYS

#define IXP4XX_QMGR_BASE_VIRT      IXP425_QMGR_BASE_VIRT

#define IXP4XX_QMGR_REGION_SIZE    IXP425_QMGR_REGION_SIZE

#endif

#ifndef IXP4XX_PERIPHERAL_BASE_PHYS

#define IXP4XX_PERIPHERAL_BASE_PHYS IXP425_PERIPHERAL_BASE_PHYS

#define IXP4XX_PERIPHERAL_BASE_VIRT IXP425_PERIPHERAL_BASE_VIRT

#define IXP4XX_PERIPHERAL_REGION_SIZE  IXP425_PERIPHERAL_REGION_SIZE

#endif

#ifndef IXP4XX_TIMER_BASE_PHYS

#define IXP4XX_TIMER_BASE_PHYS     IXP425_TIMER_BASE_PHYS

#endif

#ifndefIXP4XX_EthA_BASE_PHYS

#define IXP4XX_EthA_BASE_PHYS      (IXP425_PERIPHERAL_BASE_PHYS + 0xC000)

#endif

#ifndefIXP4XX_EthB_BASE_PHYS

#define IXP4XX_EthB_BASE_PHYS      (IXP425_PERIPHERAL_BASE_PHYS + 0x9000)

#endif

#ifndefIXP4XX_EthC_BASE_PHYS

#define IXP4XX_EthC_BASE_PHYS      (IXP425_PERIPHERAL_BASE_PHYS + 0xA000)

#endif

 

#ifndefIRQ_IXP4XX_NPEA

#define IRQ_IXP4XX_NPEA    IRQ_IXP425_NPEA

#endif

#ifndefIRQ_IXP4XX_NPEB

#define IRQ_IXP4XX_NPEB    IRQ_IXP425_NPEB

#endif

#ifndefIRQ_IXP4XX_NPEC

#define IRQ_IXP4XX_NPEC    IRQ_IXP425_NPEC

#endif

#ifndefIRQ_IXP4XX_QM1

#define IRQ_IXP4XX_QM1     IRQ_IXP425_QM1

#endif

#ifndefIRQ_IXP4XX_QM2

#define IRQ_IXP4XX_QM2     IRQ_IXP425_QM2

#endif

#ifndefIRQ_IXP4XX_PCI_INT

#define IRQ_IXP4XX_PCI_INT IRQ_IXP425_PCI_INT

#endif

#ifndefIRQ_IXP4XX_SWCP_PE

#define IRQ_IXP4XX_SWCP_PE IRQ_IXP46X_SWCP

#endif

#ifndefIRQ_IXP4XX_QM_PE

#define IRQ_IXP4XX_QM_PE   IRQ_IXP46X_AQM

#endif

#ifndefIRQ_IXP4XX_MCU_ECC

#define IRQ_IXP4XX_MCU_ECC IRQ_IXP46X_MCU

#endif

#ifndefIRQ_IXP4XX_EXP_PE

#define IRQ_IXP4XX_EXP_PE  IRQ_IXP46X_EBC

#endif

#ifndefIRQ_IXP4XX_XSCALE_PMU

#define IRQ_IXP4XX_XSCALE_PMU  IRQ_IXP425_XSCALE_PMU

#endif

 

#defineIXP4XX_EXP_BUS_CSX_REGION_SIZE     (0x01000000)    /**< Expansionbus map size */

将snapgear的\ixp_osal\platforms\ixp42X\os\linux\include\IxOsalOsOem.h的内容全部复制过来。重新编译,出现如下错误。

 

/home/linuxuser/snapgear/tools/ucfront-gccarm-linux-gcc -mbig-endian -D__ixp42X -D__KERNEL__-I/home/linuxuser/snapgear/linux-2.4.x/include -Wall -Wno-trigraphs -fno-common-pipe -mapcs-32  -msoft-float -DMODULE-D__linux -DCPU=33 -DXSCALE=33 -D__LINUX_ARM_ARCH__=5 -mcpu=xscale-mtune=xscale  -DEXPORT_SYMTAB  -DIX_OSAL_OEM_FAST_MUTEX-DIX_OSAL_THREAD_EXIT_GRACEFULLY -DIX_SDRAM_DC -DENABLE_IOMEM-DENABLE_BUFFERMGT -DENABLE_DDK -I/home/linuxuser/snapgear/linux-2.4.x/include/asm-arm/arch-ixp425/-Icommon/include -Icommon/include/. -Icommon/include/core-Icommon/include/modules/ddk -Icommon/include/modules/ioMem -Icommon/include/modules/bufferMgt-Icommon/os/linux/include/. -Icommon/os/linux/include/core-Icommon/os/linux/include/modules/ddk -Icommon/os/linux/include/modules/ioMem-Icommon/os/linux/include/modules/bufferMgt -Iplatforms/ixp42X/include-Iplatforms/ixp42X/os/linux/include -DIX_COMPONENT=1 -DENABLE_IOMEM -DENABLE_BUFFERMGT-DENABLE_DDK -DIX_OSAL_TARGET_OS_EXT=_linux -DIX_OSAL_PLATFORM_EXT=_ixp42X-DIX_COMPONENT_NAME=ix_osal common/src/core/IxOsalTime.c -c -olib/ixp42X/linux/linuxbe/common/src/core/IxOsalTime.o

common/src/core/IxOsalTime.c:In function `timerInit':

common/src/core/IxOsalTime.c:370:error: `MAX_RT_PRIO' undeclared (first use in this function)

common/src/core/IxOsalTime.c:370:error: (Each undeclared identifier is reported only once

common/src/core/IxOsalTime.c:370:error: for each function it appears in.)

make: ***[lib/ixp42X/linux/linuxbe/common/src/core/IxOsalTime.o] Error 1

应该是MAX_RT_PRIO没有定义

MAX_RT_PRIO本来应该是/home/linuxuser/snapgear/linux-2.4.x/include/linux/sched.h里定义的,但是uc里面没有找到。

 

对比snapgear的ixp_osal\common\os\linux\include\core\IxOsalOsTypes.h,有如下定义:

#ifdefMAX_RT_PRIO

#defineIX_OSAL_OS_DEFAULT_THREAD_PRIORITY   (MAX_RT_PRIO)

#else

#defineIX_OSAL_OS_DEFAULT_THREAD_PRIORITY   (90)

#endif

       将其复制到2.4对应文件。继续编译有新的错误:

/home/linuxuser/snapgear/tools/ucfront-gccarm-linux-gcc -mbig-endian -D__ixp42X -D__KERNEL__-I/home/linuxuser/snapgear/linux-2.4.x/include -Wall -Wno-trigraphs -fno-common-pipe -mapcs-32  -msoft-float -DMODULE-D__linux -DCPU=33 -DXSCALE=33 -D__LINUX_ARM_ARCH__=5 -mcpu=xscale-mtune=xscale  -DEXPORT_SYMTAB  -DIX_OSAL_OEM_FAST_MUTEX-DIX_OSAL_THREAD_EXIT_GRACEFULLY -DIX_SDRAM_DC -DENABLE_IOMEM-DENABLE_BUFFERMGT -DENABLE_DDK -I/home/linuxuser/snapgear/linux-2.4.x/include/asm-arm/arch-ixp425/-Icommon/include -Icommon/include/. -Icommon/include/core-Icommon/include/modules/ddk -Icommon/include/modules/ioMem -Icommon/include/modules/bufferMgt-Icommon/os/linux/include/. -Icommon/os/linux/include/core-Icommon/os/linux/include/modules/ddk -Icommon/os/linux/include/modules/ioMem-Icommon/os/linux/include/modules/bufferMgt -Iplatforms/ixp42X/include-Iplatforms/ixp42X/os/linux/include -DIX_COMPONENT=1 -DENABLE_IOMEM -DENABLE_BUFFERMGT-DENABLE_DDK -DIX_OSAL_TARGET_OS_EXT=_linux -DIX_OSAL_PLATFORM_EXT=_ixp42X-DIX_COMPONENT_NAME=ix_osal common/os/linux/src/core/IxOsalOsThread.c -c -olib/ixp42X/linux/linuxbe/common/os/linux/src/core/IxOsalOsThread.o

common/os/linux/src/core/IxOsalOsThread.c:In function `ixOsalThreadCreate':

common/os/linux/src/core/IxOsalOsThread.c:354:error: `IxOsalOsThreadData' undeclared (first use in this function)

common/os/linux/src/core/IxOsalOsThread.c:354:error: (Each undeclared identifier is reported only once

common/os/linux/src/core/IxOsalOsThread.c:354:error: for each function it appears in.)

make: ***[lib/ixp42X/linux/linuxbe/common/os/linux/src/core/IxOsalOsThread.o] Error 1.

 

 

原来是code的bug,在snapgear中有修改

    thread_data.entryPoint = entryPoint;

    thread_data.arg = arg;

后面的错误估计非常的多。就不一一列举了,如果发现错误,就和snapgear对比。另外发现snapgear打了补丁以后确实有很多的不同,不管是makefile,h和c文件也有不同。

将snapgear清空,用make menuconfig去掉ixp网卡的支持,编译。然后makemenuconfig加上支持。再make,这样编译信息不是那么多,很容易看到make ixp网卡驱动的全过程。因为和snapgear能够编译的差别太大,而且经常出现语法错误,所以决定放弃。

 

编译打过补丁的2.4驱动

       检查snapgear,对比了snapgear的2.4和2.6内核下的编译代码,没有差别。另外担心是不是snapgear除了modules-csr2.4-20071004.patch还利用系统的补丁加入了新的内容。检查一下手动在独立文件夹下打完补丁的IXP驱动,果然和snapgear下的一模一样,说明snpagear的额外补丁并没有造成影响,关键还是modules-csr2.4-20071004.patch。补丁的方法前文已经说过了。

       打过补丁之后,多出来一个顶层的makefile和stub.c文件。

       尝试直接编译打完补丁的ixp24。尝试过修改environment.linux.sh,因为这是模块,即使在内核选项里选择使用uclibc,编译器还是使用arm-linux-gcc,不需要ucfront-gcc。还是先尝试编译ixp_osal,这次没有问题。

       再编译ixp400_xscale_sw,出现了后续太多错误,无法一一更正。有的需要在file里加入include有的。实际上对比patch后的code和原版的code,像atm这种根本就没有打补丁,也许就不能够编译成功。而且snapgear也并没有编译xip的atm功能。

       另外发生过IxEthDBSymbols.c找不到IxEthDB_p.h的错误,发现别的文件写的都是#include “IxEthDB_p.h”,但是这个文件写的是#include<include/IxEthDB_p.h>,修改就好了。还有就是IX_OSAL_OEM_FAST_MUTEX之类的宏没有定义的问题。

EXPORT_SYMTAB的问题

在尝试编译单独的文件的时候,出现如下错误:

ixp400_xscale_sw/src/qmgr/IxQMgrSymbols.c:59:error: parse error before"this_object_must_be_defined_as_export_objs_in_the_Makefile"

       有两个原因造成这个错误,一个是export-objs列表里少了这个模块,另外一个编译是没有定义EXPORT_SYMTAB。这个错误是EXPORT_SYMTAB造成的,在Makefile中加上CFLAGS += -DEXPORT_SYMTAB.问题解决。

 

      

 

 

利用snapgear的config文件

       单独编译的问题实在是太多,而snapgear是利用ixp_lib24/makefile进行编译的,不是分别编译ixp400_xscale_sw和ixp_osal。决定采用ixp_lib24/makefile,并且根据ixp_lib24/makefile找到系统的.config文件,编译的时候发现autoconf.h文件也是snapgear在make menuconfig生成的,一并复制过来,编译。到了最后,出现如下错误:

    # make

o./ixp400_xscale_sw/src/npeDl/ixNpeDlImageConverter-I./ixp400_xscale_sw/src/include./ixp400_xscale_sw/src/npeDl/ixNpeDlImageConverter.c

make: o: Commandnot found

make:[IxNpeMicrocode.dat] Error 127 (ignored)

cd ./ixp400_xscale_sw/src/npeDl; ./ixp400_xscale_sw/src/npeDl/ixNpeDlImageConverter

/bin/sh:./ixp400_xscale_sw/src/npeDl/ixNpeDlImageConverter: No such file or directory

make: ***[IxNpeMicrocode.dat] Error 127

 

对比在snapgear编译的时候,是gcc来编译这个的.估计是什么变量配置错误了,gcc都没了。手工输入

gcc -o./ixp400_xscale_sw/src/npeDl/ixNpeDlImageConverter-I./ixp400_xscale_sw/src/include./ixp400_xscale_sw/src/npeDl/ixNpeDlImageConverter.c

 

编译成功得到ixNpeDlImageConverter。

 

利用echo发现HOSTCC没有定义,在makefile前面加上定义,解决了这个问题。

 

继续编译出现错误

arm-linux-ld:ixp400_xscale_sw/src/oslinux/IxLinuxInit.o: compiled for a big endian systemand target is little endian

arm-linux-ld:failed to merge target specific data of file ixp400_xscale_sw/src/oslinux/IxLinuxInit.o

 

这个比较简单,是-EB没有加的原因。终于编译成功得到ixp400.o。

 

编译ixp400_eth

       刚才编译的都是驱动所需要的lib库,驱动文件是GPL_ixp400LinuxEthernetDriverPatch-1_7.zip,解压之后会得到ixp400_eth.c和ixp400LinuxEthernetDriver-1_7.patch。这个patch是为了特定的kernel版本定制,待了patch之后失败不说,而且会破坏现有的kernel导致kernel无法编译通过。而且根据编译lib的经验,对比snapgear补丁之后的ixp400_eth.c,差别很大。另外snapgear提供了makefile。GPL_ixp400LinuxEthernetDriverPatch-1_7.zip里并没有makefile,决定放弃GPL_ixp400LinuxEthernetDriverPatch-1_7.zip,采用snapgear里的makefile和ixp400_eth.c。

      

用snapgear修改完的文件编译。立刻成功。测试:

将ixp400.o, ixp400_eth.o, IxNpeMicrocode.dat提取出来,按照集成到ramdisk里,然后按照以前的方法启动网卡,结果成功。

      

为snapgear编译2.6下的驱动

       先将kernel的source path定义到snapgear,试试能不能编译过,修改makefile的里的path定义。很容易就能够编译通过。只不过insmod的时候提示:

 

# insmod ixp400.ko

ixp400: module license 'unspecified' taintskernel.

ixp400: please compile with -fno-common

ixp400: please compile with -fno-common.

       编译的CFLAGS时候加上-fno-common就解决了。

 

 

为打了09补丁的uClinux2008编译2.6下的驱动

       还是刚才在snapgear下独立编译过的code,修改makefile的path,编译出现如下错误:

# make

make -C/home/linuxuser/uClinux-dist/linux-2.6.x ARCH=arm CROSS_COMPILE=arm-linux-M=/home/linuxuser/driver/test/hello_mod_single26

make[1]:Entering directory `/home/linuxuser/uClinux-dist/linux-2.6.x'

scripts/Makefile.build:46:*** CFLAGS was changed in"/home/linuxuser/driver/test/hello_mod_single26/Makefile". Fix it touse EXTRA_CFLAGS.  Stop.

make[1]: ***[_module_/home/linuxuser/driver/test/hello_mod_single26] Error 2

make[1]: Leavingdirectory `/home/linuxuser/uClinux-dist/linux-2.6.x'

make: ***[default] Error 2

 

这个是因为系统指定编译使用EXTRA_CFLAGS而不是CFLAGS,在makefile里面修改一下就行。再编译出现如下错误:

make -C /home/linuxuser/uClinux-dist/linux-2.6.xARCH=arm CROSS_COMPILE=arm-linux- M=/home/linuxuser/ixp/ixplib24_uc26

make[1]: Entering directory`/home/linuxuser/uClinux-dist/linux-2.6.x'

  CC [M] /home/linuxuser/ixp/ixplib24_uc26/ixp400_xscale_sw/src/oslinux/IxLinuxInit.o

arm-linux-gcc: -mbig-endian and -mlittle-endian maynot be used together

make[2]: ***[/home/linuxuser/ixp/ixplib24_uc26/ixp400_xscale_sw/src/oslinux/IxLinuxInit.o]Error 1

make[1]: ***[_module_/home/linuxuser/ixp/ixplib24_uc26] Error 2

make[1]: Leaving directory`/home/linuxuser/uClinux-dist/linux-2.6.x'

make: *** [default] Error 2

 

检查了各个文件夹下的makefie,并没有-mlittle-endian的定义,再检查/home/linuxuser/uClinux-dist/linux-2.6.x/arch/arm/makefile,发现有如下定义:

ifeq ($(CONFIG_CPU_BIG_ENDIAN),y)

KBUILD_CPPFLAGS +=-mbig-endian

AS      += -EB

LD      += -EB

else

KBUILD_CPPFLAGS +=-mlittle-endian

AS      += -EL

LD      += -EL

endif

 

在/home/linuxuser/ixp/ixplib24_uc26/makefile里面加上CONFIG_CPU_BIG_ENDIAN = y就行了。

 

再编译出现如下错误

make -C/home/linuxuser/uClinux-dist/linux-2.6.x ARCH=arm CROSS_COMPILE=arm-linux-M=/home/linuxuser/ixp/ixplib24_uc26

make[1]:Entering directory `/home/linuxuser/uClinux-dist/linux-2.6.x'

  CC [M] /home/linuxuser/ixp/ixplib24_uc26/ixp400_xscale_sw/src/oslinux/IxLinuxInit.o

/home/linuxuser/ixp/ixplib24_uc26/ixp400_xscale_sw/src/oslinux/IxLinuxInit.c:91:error: variable `ixNpe_dev_fops' has initializer but incomplete type

/home/linuxuser/ixp/ixplib24_uc26/ixp400_xscale_sw/src/oslinux/IxLinuxInit.c:92:error: unknown field `owner' specified in initializer

/home/linuxuser/ixp/ixplib24_uc26/ixp400_xscale_sw/src/oslinux/IxLinuxInit.c:92:warning: excess elements in struct initializer

/home/linuxuser/ixp/ixplib24_uc26/ixp400_xscale_sw/src/oslinux/IxLinuxInit.c:92:warning: (near initialization for `ixNpe_dev_fops')

/home/linuxuser/ixp/ixplib24_uc26/ixp400_xscale_sw/src/oslinux/IxLinuxInit.c:94:error: unknown field `open' specified in initializer

/home/linuxuser/ixp/ixplib24_uc26/ixp400_xscale_sw/src/oslinux/IxLinuxInit.c:94:warning: excess elements in struct initializer

/home/linuxuser/ixp/ixplib24_uc26/ixp400_xscale_sw/src/oslinux/IxLinuxInit.c:94:warning: (near initialization for `ixNpe_dev_fops')

/home/linuxuser/ixp/ixplib24_uc26/ixp400_xscale_sw/src/oslinux/IxLinuxInit.c:95:error: unknown field `release' specified in initializer

/home/linuxuser/ixp/ixplib24_uc26/ixp400_xscale_sw/src/oslinux/IxLinuxInit.c:95:warning: excess elements in struct initializer

/home/linuxuser/ixp/ixplib24_uc26/ixp400_xscale_sw/src/oslinux/IxLinuxInit.c:95:warning: (near initialization for `ixNpe_dev_fops')

/home/linuxuser/ixp/ixplib24_uc26/ixp400_xscale_sw/src/oslinux/IxLinuxInit.c:97:error: unknown field `write' specified in initializer

/home/linuxuser/ixp/ixplib24_uc26/ixp400_xscale_sw/src/oslinux/IxLinuxInit.c:98:warning: excess elements in struct initializer

/home/linuxuser/ixp/ixplib24_uc26/ixp400_xscale_sw/src/oslinux/IxLinuxInit.c:98:warning: (near initialization for `ixNpe_dev_fops')

/home/linuxuser/ixp/ixplib24_uc26/ixp400_xscale_sw/src/oslinux/IxLinuxInit.c:In function `ixp400_sw_init_module':

/home/linuxuser/ixp/ixplib24_uc26/ixp400_xscale_sw/src/oslinux/IxLinuxInit.c:134:error: implicit declaration of function `register_chrdev'

/home/linuxuser/ixp/ixplib24_uc26/ixp400_xscale_sw/src/oslinux/IxLinuxInit.c:In function `ixp400_sw_cleanup_module':

/home/linuxuser/ixp/ixplib24_uc26/ixp400_xscale_sw/src/oslinux/IxLinuxInit.c:162:error: implicit declaration of function `unregister_chrdev'

/home/linuxuser/ixp/ixplib24_uc26/ixp400_xscale_sw/src/oslinux/IxLinuxInit.c:At top level:

/home/linuxuser/ixp/ixplib24_uc26/ixp400_xscale_sw/src/oslinux/IxLinuxInit.c:91:error: storage size of `ixNpe_dev_fops' isn't known

make[2]: ***[/home/linuxuser/ixp/ixplib24_uc26/ixp400_xscale_sw/src/oslinux/IxLinuxInit.o]Error 1

make[1]: ***[_module_/home/linuxuser/ixp/ixplib24_uc26] Error 2

make[1]: Leavingdirectory `/home/linuxuser/uClinux-dist/linux-2.6.x'

 

检查了一下这个是因为struct file_operations没有定义的原因,而定义在<linux/fs.h>里,在IxOsal.h里加入#include <linux/fs.h>就行了。再编译:

make -C/home/linuxuser/uClinux-dist/linux-2.6.x ARCH=arm CROSS_COMPILE=arm-linux-M=/home/linuxuser/ixp/ixplib24_uc26

make[1]:Entering directory `/home/linuxuser/uClinux-dist/linux-2.6.x'

  CC [M] /home/linuxuser/ixp/ixplib24_uc26/ixp400_xscale_sw/src/oslinux/IxLinuxInit.o

/home/linuxuser/ixp/ixplib24_uc26/ixp400_xscale_sw/src/oslinux/IxLinuxInit.c:In function `ixp400_sw_cleanup_module':

/home/linuxuser/ixp/ixplib24_uc26/ixp400_xscale_sw/src/oslinux/IxLinuxInit.c:154:error: void value not ignored as it ought to be

make[2]: ***[/home/linuxuser/ixp/ixplib24_uc26/ixp400_xscale_sw/src/oslinux/IxLinuxInit.o]Error 1

make[1]: ***[_module_/home/linuxuser/ixp/ixplib24_uc26] Error 2

make[1]: Leavingdirectory `/home/linuxuser/uClinux-dist/linux-2.6.x'

make: ***[default] Error 2

 

       找到IxLinuxInit.c:154,是unregister_chrdev的问题,语句如下:

    if(unregister_chrdev(DEV_IXNPE_MAJOR_NUMBER, "ixNpe"))

    {

    printk (KERN_ERR "Failed to unregisterdriver for /dev/ixNpe\n");

    }

 

对比了snapgear和uClinux2008的unregister_chrdev不同。Snapgear的unregister_chrdev有返回值,永远是0。而uClinux2008里干脆就没有返回值。

insnapgear

intunregister_chrdev(unsigned int major, const char *name)

{

    struct char_device_struct *cd;

    cd = __unregister_chrdev_region(major, 0,256);

    if (cd && cd->cdev)

        cdev_del(cd->cdev);

    kfree(cd);

    return 0;

}

 

in uClinux2008

 

voidunregister_chrdev(unsigned int major, const char *name)

{

    struct char_device_struct *cd;

    cd = __unregister_chrdev_region(major, 0,256);

    if (cd && cd->cdev)

        cdev_del(cd->cdev);

    kfree(cd);

}

 

 

所以修改上面的语句为:

unregister_chrdev(DEV_IXNPE_MAJOR_NUMBER,"ixNpe")

问题就解决了。

 

再编译,还是有错误:

/home/linuxuser/ixp/ixplib24_uc26/ixp400_xscale_sw/src/ethAcc/IxEthAccDataPlane.c:In function `ixEthAccMbufTxQPrepare':

/home/linuxuser/ixp/ixplib24_uc26/ixp400_xscale_sw/src/ethAcc/IxEthAccDataPlane.c:346:error: implicit declaration of function `consistent_sync'

 

consistent_sync的引用部分,在IxOsalOs.h,是IX_HW_COHERENT_MEMORY控制的。利用在文件里加入error的方法,判断snapgear没有加入IX_HW_COHERENT_MEMORY的定义,也就是说snapgear使用了consistent_sync。

再往后,发现了*value = atomic_read(&((*sid)->count));的错误,snapgear和打了09补丁的uClinux20080808的semaphore完全不一样。涉及到修改的部分非常多。那么这个打了09补丁的uClinux20080808的驱动移植是太复杂了。

为原始uClinux2008编译2.6下的驱动

       检查原始uClinux20080808,发现semaphore的定义一样。那么只剩下一个问题,就是consistent_sync的问题。如果定义了IX_HW_COHERENT_MEMORY,可以编译通过,但是不能够正常驱动网卡。而snapgear是没有定义的,差别就在这里。

搜索consistent_sync,来源于<asm/dma-mapping.h>,在snapgear的引用如下:

 

/home/linuxuser/snapgear/linux-2.6.x/include/asm/dma-mapping.h

 

/*

 * DMA-consistent mapping functions.  These allocate/free a region of

 * uncached, unwrite-buffered mapped memoryspace for use with DMA

 * devices. This is the "generic" version. The PCI specific version

 * is in pci.h

 *

 * Note: Drivers should NOT use this functiondirectly, as it will break

 * platforms with CONFIG_DMABOUNCE.

 * Use the driver DMA support - seedma-mapping.h (dma_sync_*)

 */

extern voidconsistent_sync(void *kaddr, size_t size, int rw);

 

在uClinux2008里asm/dma-mapping.h的没有发现consistent_sync,但是发现相同的位置有如下的引用:

/home/linuxuser/uClinux-dist/linux-2.6.x/include/asm/dma-mapping.h

/*

 * DMA-consistent mapping functions.  These allocate/free a region of

 * uncached, unwrite-buffered mapped memoryspace for use with DMA

 * devices. This is the "generic" version. The PCI specific version

 * is in pci.h

 *

 * Note: Drivers should NOT use this functiondirectly, as it will break

 * platforms with CONFIG_DMABOUNCE.

 * Use the driver DMA support - see dma-mapping.h(dma_sync_*)

 */

extern voiddma_cache_maint(const void *kaddr, size_t size, int rw);

 

虽然uClinux2008在另外的文件里有consistent_sync,但是观察到dma_cache_maint的定义说明,参数的形式和consistent_sync一模一样,也许这个就是用来替代consistent_sync。于是修改/home/linuxuser/ixp/ixp_lib24/ixp_osal/common/os/linux/include/core/IxOsalOs.h。将其中的

#defineIX_OSAL_OS_CACHE_INVALIDATE(addr, size) \

    (consistent_sync((void*)addr, (size_t) size,DMA_FROM_DEVICE))

 

#defineIX_OSAL_OS_CACHE_FLUSH(addr, size) \

    (consistent_sync((void*)addr, (size_t)size, DMA_TO_DEVICE))

修改成

#defineIX_OSAL_OS_CACHE_INVALIDATE(addr, size) \

    (dma_cache_maint ((void*)addr, (size_t)size, DMA_FROM_DEVICE))

 

#defineIX_OSAL_OS_CACHE_FLUSH(addr, size) \

    (dma_cache_maint ((void*)addr, (size_t)size, DMA_TO_DEVICE))

 

保存编译成功。再编译ixp400_eth,只需要修改makefile中的path就行了。下载到板子上运行成功。

 

IXP打印提示信息的问题

在2.6下运行一段时间会出现如下信息

INFO: task EthDBevent thr:33 blocked for more than 120 seconds.

"echo 0> /proc/sys/kernel/hung_task_timeout_secs" disables this message.

EthDB event t Dc01e9fa4     0    33     2

[<c01e9d60>](schedule+0x0/0x294) from [<c01e9ba4>] (__down+0xb4/0x110)

[<c01e9af0>](__down+0x0/0x110) from [<c01e9a8c>] (__down_failed+0xc/0x20)

 r8:60000013 r7:bf05b48c r6:c3247f64r5:bf05b488 r4:00000000

[<bf01ead8>](ixOsalSemaphoreWait+0x0/0x194 [ixp400]) from [<bf0133f0>] (ixEthDBEventProcessorLoop+0x58/0x27c [ixp400])

这个解决的办法就是在盒子的命令行下输入echo 0 > /proc/sys/kernel/hung_task_timeout_secs就行了

几个小问题

必须先编译内核

       没有先编译内核就先去编译模块,肯定是编译不过的。提示错误也很奇怪。

ucfront-gcc的path问题

不能将uc的path放到bash.rc里面,会导致不同版本的uc编译错误.

 

/dev/ixNpe的问题

执行cat/etc/IxNpeMicrocode.dat > /dev/ixNpe。

必须先insmod ixp400.o之后才有/dev/ixNpe,如果一开始执行这个命令,会提示没有/dev/ixNpe

Argument list too long

出现过如下错误:

make -C/home/linuxuser/snapgear/linux-2.6.x ARCH=arm CROSS_COMPILE=arm-linux-M=/home/linuxuser/ixp/ixp400-1_7_good

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

  LD     /home/linuxuser/ixp/ixp400-1_7_good/built-in.o

make[2]: execvp:/bin/sh: Argument list too long

       这个是因为编译选项太长造成的。适当的减少就行了。编译module的时候,系统也加上很多include和编译选项之类的东西,才会导致过长。

 

你可能感兴趣的:(移植IXP驱动到uClinux2008)