"Go" Linux kernel porting and NIC driver (ii)

Source: Internet
Author: User

Original URL: http://blog.chinaunix.net/uid-29589379-id-4708911.html

One, the kernel porting step:

1, modify the Makefile in the top-level directory

ARCH = $ (subarch)

Cross_compile = $ (config_cross_compile: "%" =%)

Modified to:

ARCH: =arm

Cross_compile: =/usr/local/arm/4.4.3/bin/arm-linux-

2, copy the configuration file

Here is the FS2410 Development Board, copy the corresponding board file to the top-level directory

CP Arch/arm/configs/s3c2410_defconfig./

Compile the configuration file to generate the . config file:

Make S3c2410_defconfig

The purpose of the kernel configuration:

The. config file records which parts are compiled into the kernel, which are compiled into kernel modules, and the kernel is looking for a. config file before compiling, as a guideline for his compilation. That is, the. config file is for makefile to read

3,1) Select the Board

In Arch/arm/mach-s3c2410/kconfig, modify the appropriate configuration

[Email protected]# vim Kconfig

[Email protected]# pwd

/change/linux-3.1.4/arch/arm/mach-s3c2410

Config arch_smdk2410

BOOL "smdk2410/a9m2410"

Select cpu_s3c2410

Select MACH_SMDK

Help

Say Y here if is using the SMDK2410 or the derived module a9m2410

Http://www.fsforth.de

Change to:

Config arch_smdk2410

BOOL "SMDK2410"

Select cpu_s3c2410

Select MACH_SMDK

Select S3c_dev_usb_host

Select S3c_dev_nand

Select S3c2410_setup_ts

Help

Say Y here if is using the SMDK2410 or the derived module a9m2410

Http://www.fsforth.de

2) optional resources, here is the fs2410 Development Board, can be /arch/arm/kconfig in the optional

If arch_s3c2410

#source "Arch/arm/mach-s3c2400/kconfig"

s3c2410 Target Board:

SOURCE "Arch/arm/mach-s3c2410/kconfig"

#A8 Target Board:

#source "Arch/arm/mach-s5pc100/kconfig"

#source "Arch/arm/mach-s3c2412/kconfig"

#source "Arch/arm/mach-s3c2416/kconfig"

#source "Arch/arm/mach-s3c2440/kconfig"

#source "Arch/arm/mach-s3c2443/kconfig"

endif

4, kernel configuration

1) General Setup--->

[*] Prompt for development and/or incomplete code/drivers (optional)

[*] Automatically append version information to the version string│

Kernel compression mode (GZIP)--->

2)[*] Enable loadable Module Support--->

[*] Forced module loading

[*] Module Unloading

[*] Forced module unloading

[*] Module Versioning Support

3)System Type---> (SELECT Board)

S3C2410 Machines--->

[*] smdk2410/a9m2410 (select only)

[] IPAQ H1940 (selected will be in 31008000)

4)Kernel Features--->

[*] Use the ARM EABI to compile the kernel

[*] Allow-old ABI binaries-to-run with this kernel (experimental

[*] Provide old-to-pass kernel parameters

5)userspace binary formats--->

[*] Kernel Support for ELF binaries

[*] Write ELF core dumps with partial segments

< > Kernel support for a.out and Ecoff binaries (this option will report some errors if selected)

6)Networking Support

Networking Options--->

[*] TCP/IP Networking

......

7)device Drivers---> (device driver, add modifications as needed, such as NIC,led,LCD,beep , etc.)

[*] Network Device Support---> (Network card devices supported)

Character Devices---> (character device support, such as:led,LCD)

<*> Multimedia Support---> (multimedia supported, such as:v4l2)

[*] USB Support---> (USB supported)

8)file Systems---> (filesystem, Support YAFFS2,Crmfs , etc.)

[*] Network File Systems---> (Web filesystem)

<*> NFS Client Support

[*] Root file system on NFS

5, kernel compiled and copied to tftpboot

Make Zimage

CP Arch/arm/boot/zimage/tftpboot

6. View the Memory mapping table:

[email protected]# VIM System.map

From the Memory map table, you can know

Description: The above configuration is for the Basic configuration of the arm platform. If you want to implement file sharing,led,LCD driver, etc., it can be modified and added on this basis.

Second,Nand flash driver add

Purpose:NAND flash is the default configuration, but his partition can be configured according to our actual situation

1. Modify the Partition information table

In the arch/arm/plat-s3c24xx/common-smdk.c , there is the NAND flash partition information, according to our actual production needs, to make some changes:

static struct Mtd_partition smdk_default_nand_part[] = {

[0] = {

. Name = "UBoot",

. Size = 0x40000,

. Offset = 0,

},

[1] = {

. Name = "Kernel",

. offset = 0x40000,

. Size = 0x400000,

},

[2] = {

. Name = "FS",

. offset = 0x440000,

. Size = 0x800000,

},

[3] = {

. Name = "extern FS",

. offset = 0xc40000,

. Size = 0x33c0000,

},

}

Name: Represents the partition name

Size: Represents the volume of the Flash partition (in bytes)

Offset: Represents the start address of the Flash partition (offset from 0x0)

2, configure the kernel on the previous basis:

Device Drivers--->

<*> Memory Technology Device (MTD) Support--->

<*> NAND Device Support--->

<*> NAND Flash support for Samsung s3c SoCs

3, compile well, after porting to the Development Board can see this printing information:

Creating 4 MTD partitions on "NAND":

0x000000000000-0x000000040000: "ub00t"

0x000000040000-0x000000440000: "Kernel"

0x000000440000-0x000000c40000: "FS"

0x000000c40000-0x000004000000: "extern FS"

Third, add the NIC driver:

Objective: To migrate the network card driver to the linux-3.1.4 kernel, so that it can mount the file system on the host environment by NFS, thus realizing the Linux system Start-up

The following modifications and configurations are made to the previous steps of the kernel migration:

1, the network card we use here is cs8900. Copy the downloaded NIC driver cs8900.c and cs8900.h Two files to the driver

[email protected]# CP ... /cs8900.* Drivers/net/arm

2. Modify the drivers/net/arm/kconfig add cs8900 configuration entry:

[email protected]# CD drivers/net/arm/

[Email protected]# vim Kconfig

Make the following configuration (add):

Config arm_cs8900

TriState "cs8900 Support"

Depends on ARM

Help

Support cs8900

3, modify drivers/net/arm/makefile Add kernel compile configuration:

[Email protected]# vim Makefile

Add a bit of content:

obj-$ (config_arm_cs8900) +=cs8900.o

4, add address mapping:

To add a macro definition in Arch/arm/plat-s3c24xx/include/plat/map.h:

[email protected]# VIM Arch/arm/mach-s3c2410/include/mach/map.h

#define S3C24XX_VA_CS8900 0xe0000000

#define S3C24XX_PA_CS8900 0x19000000

#define S3C24XX_SZ_CS8900 sz_1m

5. Add Platform Code

Add in arch/arm/mach-s3c2410/mach-smdk2410.c :

[email protected]# VIM ARCH/ARM/MACH-S3C2410/MACH-SMDK2410.C

static struct Map_desc smdk2410_iodesc[] __initdata = {

Iodesc_ent (CS8900)}

6, conversion of virtual address to physical address:

View Arch/arm/plat-samsang/include/plat/cpu.h

[email protected]# VIM Arch/arm/plat-samsung/include/plat/cpu.h

#define Iodesc_ent (x) {(unsigned long) s3c24xx_va_# #x,

__PHYS_TO_PFN (s3c24xx_pa_# #x), s3c24xx_sz_# #x, Mt_device}

7, note: In the linux-3.1.4 core network card driver added interrupt processing mechanism

Add to:

#include <linux/interrupt.h>

Will Set_irq_type (DEV->IRQ, (1<<1) | | (1<<0)); Modified to:

Irq_set_irq_type (DEV->IRQ, (1<<1) | | (1<<0));

8, kernel configuration, so that it supports cs8900 network card:

Device Drivers--->

[*] Network Device Support--->

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

<*> cs8900 Support

9, recompile the kernel

Make Zimage

Ten, the network card transplant good can again the board above see the following information:

Cirrus Logic cs8900a driver for Linux (Modified for SMDK2410)

eth0:cs8900a Rev E at 0xe0000300 irq=53, addr:00:0:3e:26:0a:0

Description: The previous article, directly pasted the picture, but basically can not see clearly, so this article directly write the ha.

"Go" Linux kernel porting and NIC driver (ii)

Related Article

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.