Linux 2.6.30内核移植到S3C2440——CS8900网卡移植

本网站用的阿里云ECS,推荐大家用。自己搞个学习研究也不错

<

div id=”content”>开发环境:主机:Window XP SP2;linux:VMware7.01+Ubuntu9.10;目标板:扬创utu2440-F开发板

交叉编译器:arm-linux-3.4.1

一、说明:

本CS8900网卡驱动移植是基于之前内核版本的,实际上是从扬创开发板附送光盘上拷贝下来的CS8900源文件移植而来。

移植好的CS8900网卡驱动在扬创ubu2440-F开发板上已验证通过。

二、移植要点:

CS8900网卡驱动移植到基于linux2.6.30内核版本的S3C2440中,主要关注其中几点:

  1. 基于旧的CS8900网卡驱动;

  2. CS8900网卡驱动的BSP信息构造;

  3. 头文件的变化;

  4. linux2.6.30的struct net_device有变化,主要是没有了priv这个成员变量;

本文要用到的相关文件在Linux公社的1号FTP服务器里,下载地址:

FTP地址:ftp://www.linuxidc.com

用户名:www.linuxidc.com

密码:www.muu.cc

在 2011年LinuxIDC.com\6月\Linux 2.6.30内核移植到S3C2440——CS8900网卡移植

下载方法见 http://www.linuxidc.net/thread-1187-1-1.html

三、移植步骤:

1. 在drivers/net/arm/ 目录下添加 cs8900.c,cs8900.h两个文件。

如果是你自己重新移植的话,这两文件可从Linux公社FTP上下载;如果使用本人移植好的驱动(可以省略一些步骤)。

2. 修改drivers/net/arm/目录下的Kconfig文件,在最后添加如下内容:

  1. config ARM_CS8900    
  2.     tristate “CS8900 support”    
  3.     depends on ARM || BLACKFIN || MIPS    
  4.     help    
  5.       support for cs8900 chipset based Ethernet cards , if you  have a network card of this type  

3. 修改drivers/net/arm/Makefile文件,添加:
obj-$(CONFIG_ARM_CS8900) += cs8900.o

4. 编译配置内核,进入配置菜单,添加CS8900驱动到内核:
# make menuconfig

Device Drivers  —>

       [*] Network device support  —>

              [*]   Ethernet (10 or 100Mbit)  —>

                        CS8900 support

5.  添加BSP关于CS8900网卡驱动信息:

如果是移植到2410,则打开arch/arm/mach-s3c2410/mach-smdk2410.c文件;如果是移植到2440,则打开arch/arm/mach-s3c2440/mach-smdk2440.c。本人使用自己创建的BSP文件,即arch/arm/mach-s3c2440/mach-reille2440.c,在static struct map_desc smdk2410_iodesc[] __initdata (对2410而言)或static struct map_desc smdk2440_iodesc[] __initdata(对2440而言)最后添加:

  1. ,{    
  2.         // support cs8900|added by guoyirong 2011.06.04    
  3.           .virtual     = vSMDK2410_ETH_IO,        // virtural addr that will be remapped    
  4.           .pfn          = __phys_to_pfn(S3C2410_CS3 + (1<<24)),    
  5.           .length      = SZ_1M,    
  6.           .type          = MT_DEVICE,    
  7.  }  

6. 修改arch/arm/mach-s3c2410/include/mach/map.h文件,在最后添加:

  1. /* CS8900 */   
  2. #define pSMDK2410_ETH_IO     __phys_to_pfn(0x19000000)   
  3. #define vSMDK2410_ETH_IO     0xE0000000   
  4. #define SMDK2410_ETH_IRQ     IRQ_EINT9  

7. 编译内核:

如果是使用我移植好的CS8900驱动,则不会有问题,如果是使用从网上下载或从我博客资源上下载的未移植好的C8900驱动,则编译时会出现很多错误,包括头文件、宏定义、priv成员等错误,如下所示:

drivers/net/arm/cs8900.c:56:26: asm/hardware.h: No such file or directory

drivers/net/arm/cs8900.c:71:30: asm/arch/bit-map.h: No such file or directory

drivers/net/arm/cs8900.c:72:31: asm/arch/regs-mem.h: No such file or directory

drivers/net/arm/cs8900.c:96: error: unknown field `init’ specified in initializer

drivers/net/arm/cs8900.c:97: warning: missing braces around initializer

drivers/net/arm/cs8900.c:97: warning: (near initialization for `cs8900_dev.name’)

drivers/net/arm/cs8900.c:97: warning: initialization makes integer from pointer without a cast

drivers/net/arm/cs8900.c:97: error: initializer element is not computable at load time

drivers/net/arm/cs8900.c:97: error: (near initialization for `cs8900_dev.name[0]’)

drivers/net/arm/cs8900.c:97: error: initializer element is not constant

drivers/net/arm/cs8900.c:97: error: (near initialization for `cs8900_dev.name’)

drivers/net/arm/cs8900.c:117: error: variable `cs8900_eeprom_fops’ has initializer but incomplete type

drivers/net/arm/cs8900.c:118: error: unknown field `owner’ specified in initializer

drivers/net/arm/cs8900.c:118: warning: excess elements in struct initializer

drivers/net/arm/cs8900.c:118: warning: (near initialization for `cs8900_eeprom_fops’)

drivers/net/arm/cs8900.c:119: error: unknown field `open’ specified in initializer

drivers/net/arm/cs8900.c:119: warning: excess elements in struct initializer

drivers/net/arm/cs8900.c:119: warning: (near initialization for `cs8900_eeprom_fops’)

drivers/net/arm/cs8900.c:120: error: unknown field `release’ specified in initializer

drivers/net/arm/cs8900.c:120: warning: excess elements in struct initializer

drivers/net/arm/cs8900.c:120: warning: (near initialization for `cs8900_eeprom_fops’)

drivers/net/arm/cs8900.c:121: error: unknown field `llseek’ specified in initializer

drivers/net/arm/cs8900.c:121: warning: excess elements in struct initializer

drivers/net/arm/cs8900.c:121: warning: (near initialization for `cs8900_eeprom_fops’)

drivers/net/arm/cs8900.c:122: error: unknown field `read’ specified in initializer

drivers/net/arm/cs8900.c:122: warning: excess elements in struct initializer

drivers/net/arm/cs8900.c:122: warning: (near initialization for `cs8900_eeprom_fops’)

drivers/net/arm/cs8900.c:123: error: unknown field `write’ specified in initializer

drivers/net/arm/cs8900.c:123: warning: excess elements in struct initializer

drivers/net/arm/cs8900.c:123: warning: (near initialization for `cs8900_eeprom_fops’)

drivers/net/arm/cs8900.c: In function `cs8900_receive’:

drivers/net/arm/cs8900.c:343: error: structure has no member named `priv’

drivers/net/arm/cs8900.c: In function `cs8900_send_start’:

drivers/net/arm/cs8900.c:382: error: structure has no member named `priv’

drivers/net/arm/cs8900.c: In function `cs8900_interrupt’:

drivers/net/arm/cs8900.c:434: error: structure has no member named `priv’

drivers/net/arm/cs8900.c:439: error: structure has no member named `priv’

drivers/net/arm/cs8900.c: In function `cs8900_transmit_timeout’:

drivers/net/arm/cs8900.c:496: error: structure has no member named `priv’

drivers/net/arm/cs8900.c: In function `cs8900_start’:

drivers/net/arm/cs8900.c:508: error: implicit declaration of function `set_irq_type’

drivers/net/arm/cs8900.c:508: error: `IRQT_RISING’ undeclared (first use in this function)

drivers/net/arm/cs8900.c:508: error: (Each undeclared identifier is reported only once

drivers/net/arm/cs8900.c:508: error: for each function it appears in.)

drivers/net/arm/cs8900.c:523: warning: passing arg 2 of `request_irq’ from incompatible pointer type

drivers/net/arm/cs8900.c: In function `cs8900_get_stats’:

drivers/net/arm/cs8900.c:580: error: structure has no member named `priv’

drivers/net/arm/cs8900.c: In function `cs8900_eeprom’:

drivers/net/arm/cs8900.c:599: error: structure has no member named `priv’

drivers/net/arm/cs8900.c:618: error: implicit declaration of function `register_chrdev’

drivers/net/arm/cs8900.c: In function `cs8900_eeprom_fllseek’:

drivers/net/arm/cs8900.c:674: error: dereferencing pointer to incomplete type

drivers/net/arm/cs8900.c:686: error: dereferencing pointer to incomplete type

drivers/net/arm/cs8900.c: In function `cs8900_probe’:

drivers/net/arm/cs8900.c:778: error: `S3C2410_BWSCON’ undeclared (first use in this function)

drivers/net/arm/cs8900.c:779: error: `S3C2410_BANKCON3′ undeclared (first use in this function)

drivers/net/arm/cs8900.c:807: error: structure has no member named `priv’

drivers/net/arm/cs8900.c:811: error: implicit declaration of function `SET_MODULE_OWNER’

drivers/net/arm/cs8900.c: In function `cs8900_cleanup’:

drivers/net/arm/cs8900.c:916: error: structure has no member named `priv’

drivers/net/arm/cs8900.c:919: error: implicit declaration of function `unregister_chrdev’

drivers/net/arm/cs8900.c: In function `cs8900_probe’:

drivers/net/arm/cs8900.c:778: warning: statement with no effect

drivers/net/arm/cs8900.c:779: warning: statement with no effect

drivers/net/arm/cs8900.c: At top level:

drivers/net/arm/cs8900.c:117: error: storage size of `cs8900_eeprom_fops’ isn’t known

make[3]: *** [drivers/net/arm/cs8900.o] Error 1

make[2]: *** [drivers/net/arm] Error 2

make[1]: *** [drivers/net] Error 2

make: *** [drivers] Error 2

————————————————————————

上述错误如下处理:

1) 把#include 、#include “asm/arch/bit-map.h”和#include 屏蔽掉,同时增加如下头文件:

  1. #include   
  2. #include   
  3. #include   

2) netdevice.h 中struct net_device结构体又添上了:void *priv;

3) 把#include 文件包含,同时在CS8900.c文件中定义如下宏:

  1. #define IRQT_RISING IRQ_TYPE_EDGE_RISING  

把823行屏蔽掉。

4)对于错误:drivers/net/arm/cs8900.c:96: error: unknown field `init’ specified in initializer

这个错误不知道怎么解决,我是把那行屏蔽掉了,同时把它改为在cs8900_init()函数中进行初始化。

按上述处理后,启动时会出现错误:操作了空指针,这是由于cs8900.c中静态定义了cs8900_dev但没有分配私有成员空间的缘漯div>

未经允许不得转载:演道网 » Linux 2.6.30内核移植到S3C2440——CS8900网卡移植

赞 (0)
分享到:更多 ()

评论 0

评论前必须登录!

登陆 注册