Linux 2.6.30 kernel porting to S3C2440--CS8900 Nic porting

Source: Internet
Author: User

Author: reille

This blog: http://blog.csdn.net/reille/

Development Environment: Host: Window XP SP2; Linux: vmware7.01 + ubuntu9.10; Target Board: yangchuang utu2440-F Development Board

Cross Compiler: arm-linux-3.4.1

More please note: http://velep.com/

I. Description:

The CS8900 NIC Driver is transplanted based on the previous kernel version. In fact, it is transplanted from the CS8900 source file copied from the attached CD of the yangchuang Development Board.

The transplanted CS8900 NIC driver has been verified on the startup ubu2440-F Development Board, can be downloaded from the web site to: http://download.csdn.net/source/3342114

Ii. Point of transplantation:

The CS8900 NIC Driver is transplanted to S3C2440 based on the Linux kernel 2.6.30, mainly focusing on the following points:

1. Based on the old CS8900 NIC driver;

2. Structure of BSP Information Driven by CS8900 Nic;

2. Changes in header files;

3. the struct net_device of linux2.6.30 has changed, mainly because priv is not a member variable;

3. Migration steps:

1. Add the cs8900.c and cs8900.h files under the drivers/NET/ARM/directory.

If you try again on your own, these files can be searched online or downloaded from my blog resources: http://download.csdn.net/source/3342941.pdf if you use a self-transplanted Driver (some steps can be omitted) on my blog resources download: http://download.csdn.net/source/3342114

2. Modify the kconfig file in the drivers/NET/ARM/directory and add the following content at the end:

Config arm_cs8900 <br/> tristate "CS8900 support" <br/> depends on arm | Blackfin | MIPS <br/> help <br/> support for CS8900 chipset based Ethernet cards, if you have a network card of this type 

3. Modify the drivers/NET/ARM/MAKEFILE file and add:
OBJ-$ (config_arm_cs8900) + = cs8900.o

4. Compile and configure the kernel. Go to the configuration menu and add the CS8900 driver to the kernel:
# Make menuconfig

Device Drivers --->

[*] Network device support --->

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

<*> CS8900 support

5. Add BSP driver information about CS8900 NIC:

If it is ported to 2410, open the ARCH/ARM/mach-s3c2410/mach-smdk2410.c file; if it is ported to 2440, open the ARCH/ARM/mach-s3c2440/mach-smdk2440.c. I am using my own BSP file, namely ARCH/ARM/mach-s3c2440/mach-reille2440.c, in static struct map_desc smdk2410_iodesc [] _ initdata (for 2410) or static struct map_desc smdk2440_iodesc []
_ Initdata (for 2440) is last added:

, {<Br/> // support CS8900 | added by guoyirong 2011.06.04 <br/>. virtual = vsmdk2410_eth_io, // specify Ural ADDR that will be remapped <br/>. PFN = _ phys_to_pfn (s3c2410_cs3 + (1 <24), <br/>. length = sz_1m, <br/>. type = mt_device, <br/>} 

6. Modify the ARCH/ARM/mach-s3c2410/include/Mach/map. h file and add at the end:

/* CS8900 */<br/> # define psmdk2410_eth_io _ phys_to_pfn (0x19000000) <br/> # define vsmdk2410_eth_io 0xe0000000 <br/> # define irq_eint9 

7. Compile the kernel:

If the CS8900 driver I have ported is used, it will not be a problem. If it is an un-ported c8900 driver downloaded from the internet or from my blog resources, many errors will occur during compilation, including header files, macro definitions, and priv members, as shown below:

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

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

Handle the preceding errors as follows:

1) Remove # include <ASM/hardware. h>, # include "ASM/ARCH/bit-map.h" and # include <ASM/ARCH/regs-mem.h>, and add the following header files:

# Include <Mach/hardware. h> <br/> # include <Mach/regs-mem.h> <br/> # include <Mach/regs-irq.h> 

2) In netdevice. H, the struct net_device struct is added: void * priv;

3) include the # include <Linux/IRQ. h> file and define the following macros in the cs8900.c file:

# Define irqt_rising irq_type_edge_rising 

Block the 823 rows.

4) for errors: Drivers/NET/ARM/cs8900.c: 96: Error: Unknown field 'init 'specified in initializer

I don't know how to solve this error. I blocked the line and changed it to initialization in the cs8900_init () function.

After the above processing, an error occurs during startup: a null pointer is operated, because cs8900_dev is defined statically in cs8900.c but no private member space is allocated.

Therefore, use the alloc_etherdev () function to allocate cs8900_dev.

You can compare the source code of cs8900.c before and after transplantation.

Iv. References:

Http://blog.csdn.net/guolele2010/archive/2011/04/08/6309589.aspx

Http://blog.163.com/kmustchenb@126/blog/static/110905765200988765547/

Http://blog.163.com/kmustchenb@126/blog/static/1109057652009887734131/

Http://blog.ednchina.com/xiong_gang_whut/240010/message.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.