linux 2.6 kernel porting

Kernel porting process

 

  Download linux kernel

From http://www.kernel.org/pub/linux/kernel/v2.6/linux2.6.14.1.tar.bz2 

Linux2.6.14.1 download kernel to home / arm / dev_home / kernel. [Root @ localhost ~] #su arm

[arm@localhost ~]#cd $KERNEL

[arm@localhost kernel]#tar ­xzvf linux­2.6.14.1.tar.gz [arm@localhost kernel]# pwd

/home/arm/dev_home/kernel [arm@localhost kernel]# cd linux­2.6.14

Directory after decompression into the core, after the example, as long as the relative path with respect to all

/home/arm/dev_home/kernel/linux2.6.14/ this directory

 

   Modify Makefile

Modify the kernel Makefile under the root directory, indicating cross-compiler [arm @ localhost linux2.6.14] # vi Makefile ARCH find and CROSS_COMPILE, modify

ARCH             ?= arm CROSS_COMPILE   ?= arm­linux­

 

Then set your PATH environment variable to find your cross-compiler tool chain [arm @ localhost linux2.6.14] # echo $ PATH

 

/usr/local/arm/3.4.4/bin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/ly/bin

If /usr/local/arm/3.4.4/bin search path, the following statement is added in ~ / .bashrc

[arm@localhost linux­2.6.14]# vi ~/.bashrc export PATH=/usr/local/arm/3.4.4/bin:$PATH

 

Re-landing.

[arm@localhost linux­2.6.14]#su arm

 

   Set flash partition

Here To modify a total of three documents, namely:

 

Specified partition information

In arch / arm / machs3c2410 / devs.c file:

[arm@localhost linux­2.6.14]$ vi arch/arm/mach­s3c2410/devs.c

Add the following:

#include <linux/mtd/partitions.h>

#include <linux/mtd/nand.h>

#include <asm/arch/nand.h>

...

/* NAND Controller */

 

1. The establishment of Nand Flash partition table

/ * A total Nand Flash 64MB, partition * / static struct mtd_partition partition_info follows size [] = {

{ /* 1MB */

name: "bootloader", size: 0x00100000, offset: 0x0,

}, {/ * 3MB * /

name: "kernel", size:    0x00300000, offset: 0x00100000,

}, { /* 40MB */

name: "root",

size:     0x02800000, offset: 0x00400000,

}, { /* 20MB */

name: "user", size: 0x00f00000,

offset: 0x02d00000,

}

};

 

name: the name of the representative partition

size: Representative flash partition size (unit: bytes)

offset: Representative flash partition start address (offset relative to 0x0)

 

Target board plan is divided into 4 zones, were stored bootloader, kernel, rootfs and to expand later use user file system space. . Each partition size Nand flash partition start address recorded as follows:

 

bootloader:

start: 0x00000000 len: 0x00100000 1MB

 

kernel:

 

 

 

 

rootfs:

 

 

 

 

User:


 

start: 0x00100000 len: 0x00300000 3MB

 

start: 0x00400000 len: 0x02800000 40MB

 

start: 0x02c00000 len: 0x01400000 20MB

 

 

  1. Join Nand Flash partition

struct s3c2410_nand_set nandset ={

nr_partitions: 4,                 /* the number of partitions */ partitions: partition_info, /* partition table                                     */

};

nr_partitions: partition_info specified number of partitions defined partitions: partition table

 

  1. The establishment of Nand Flash chips support

struct s3c2410_platform_nand superlpplatform={ tacls:0,

twrph0: 30, twrph1: 0,

sets: &nandset, nr_sets: 1,

};

tacls, twrph0, twrph1 mean see 63 S3C2410 manual, which will last three values ​​are set to NFCONF, and behold S3C2410 manual 66. sets: support zone set

Set the number of partitions: nr_set

 

  1. Join Nand Flash chips support to Nand Flash drive Also, modify s3c_device_nand structure variables in this file, add the assignment struct platform_device s3c_device_nand members of the dev = {

.name              = "s3c2410­nand",     /* Device name */

.id                     = ­1,                              /* Device ID      */

.num_resources    = ARRAY_SIZE(s3c_nand_resource),

.resource          = s3c_nand_resource, /* Nand Flash Controller Registers */

 

/* Add the Nand Flash device */

.dev = {

.platform_data = &superlpplatform

}

};

 

name: The device name

id: valid device ID, if there is only one device 1, a plurality of devices starts counting from 0 num_resource:. There are several registers region

resource: an array of first address register area

dev: Nand Flash supported devices

 

Specify initialization startup

According to our initial set of partition configuration changes arch / arm / machs3c2410 / machsmdk2410.c file kernel boot

[Arm @ localhost linux2.6.14] $ vi arch / arm / machs3c2410 / machsmdk2410.c modified smdk2410_devices []. Partition information includes a static struct platform_device flash we previously set at the time specified in the initialization * smdk2410_devices [] initdata = {

&s3c_device_usb, &s3c_device_lcd, &s3c_device_wdt, &s3c_device_i2c, &s3c_device_iis,

 

/ * Add the following statement to * / & s3c_device_nand,

};

Save and exit.

 

Prohibition F. L AS H E C C check

Our kernel is written by UBOOT Nand Flash, the software ECC algorithm UBOOT by generating ECC check code, which is not the same with the kernel checksum ECC code, the kernel code is generated by the ECC in S3C2410 Nand Flash Controller in. so, here we choose to disable kernel ECC check.

Modify drivers / mtd / nand / s3c2410.c file:

[Arm @ localhost linux2.6.14] $ vi drivers / mtd / nand / s3c2410.c found s3c2410_nand_init_chip () function, the function body plus a final statement: chip> eccmode = NAND_ECC_NONE;

Save and exit.

 

OK. We set up partitions on flash completed.

 

 

Configuring the kernel

 

When starting to mount support devfs

In order to support our core and can automatically mount devfs and before the / sbin / init to run at startup / dev is devfs file system, modifying fs / Kconfig file

[Arm @ localhost linux2.6.14] $ vi fs / Kconfig find the menu "Pseudo filesystems" add the following statement:

config DEVFS_FS

bool "/dev file system support (OBSOLETE)" default y

 

config DEVFS_MOUNT

 

bool "Automatically mount at boot" default y

depends on DEVFS_FS

 

Configure the kernel to generate .config file

[arm@localhost linux­2.6.14]$ cp arch/arm/configs/smdk2410_defconfig .config [arm@localhost linux­2.6.14]$ make menuconfig

In smdk2410_defconfig basis, I add or delete kernel configuration items as follows: Loadable module support>

[*] Enable loadable module support

[*] Automatic kernel module loading System Type  ­­­> [*] S3C2410 DMA support

Boot options  ­­­> Default kernel command string:

noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0,115200

 

# Description: mtdblock2 represents my third flash partition, it is my rootfs

# Console = ttySAC0,115200 kernel during startup so all information output to the serial port 0.

# 2.6 kernel for serial named changed to ttySAC0, without prejudice to serial programming user space.

# Serial programming for the user space is still / dev / ttyS0, etc.

 

Floating point emulation ­­­>

[*] NWFPE math emulation

This is necessary to run most binaries!!!

 

# The next step is to set the kernel Device Drivers MTD subsystem>

Memory Technology Devices (MTD) ­­­>

[*] MTD partitioning support

# Support MTD partition, so we set up in front of the partition makes sense [*] Command line partition table parsing

# Set flash partition information from the command line support, flexible

RAM/ROM/Flash chip drivers ­­­>

<*> Detect flash chips by Common Flash Interface (CFI) probe

<*> Detect non­CFI AMD/JEDEC­compatible flash chips

<*> Support for Intel/Sharp flash chips

<*> Support for AMD/Fujitsu flash chips

<*> Support for ROM chips in bus mapping NAND Flash Device Drivers ­­­>

<*> NAND Device Support

<*> NAND Flash support for S3C2410/S3C2440 SoC

 

Character devices  ­­­>

[*] Non­standard serial port support [*] S3C2410 RTC Driver

 

# Do next is set for the file system, the file system when I want to experiment on the target board is cramfs, so do the following configuration

 

File systems ­­­>


 

<> Second extended fs support # Pseudo filesystems support for ext2 removal of>

[*] /proc file system support

[*] Virtual memory file system support (former shm fs) [*] /dev file system support (OBSOLETE)

[*] Automatically mount at boot (NEW)

# Here to see the first change fs / Kconfig of us before the results, devfs has been supported on the Miscellaneous filesystems>

<*> Compressed ROM file system support (cramfs)

# Support cramfs Network File Systems>

<*> NFS file system support

 

 

Save and exit, generating .config file.

.Config file from the kernel package provided by 2.4.14.1 found in the file name config.back.

 

Compile the kernel

[arm@localhost linux­2.6.14]$ make zImage

Note: If the situation is as follows compile a kernel

LD       .tmp_vmlinux1 arm­linux­ld:arch/arm/kernel/vmlinux.lds:1439: parse error make: *** [.tmp_vmlinux1] Error 1

 

Solution: Modification of arch / arm / kernel / vmlinux.lds [arm @ localhost linux2.6.14] $ vi arch / arm / kernel / vmlinux.lds the end of the file 2 is commented ASSERT (line 1439)

/* ASSERT((    proc_info_end ­     proc_info_begin), "missing CPU support") */

/* ASSERT((    arch_info_end ­     arch_info_begin), "no machine record defined") */

 

Then again you can make zImage

 

 

Download zImage to development board

CRANE2410 # tftp 0x30008000 zImage

TFTP from server 192.168.1.6; our IP address is 192.168.1.5 Filename 'zImage'.

Load address: 0x30008000

Loading: #################################################################

#################################################################

#################################################################

#############################

done

Bytes transferred = 1142856 (117048 hex) CRANE2410 # bootm 0x30008000

 

Start information follows the target board

IRQ Stack: 33fc149c FIQ Stack: 33fc249c 1

 

1

DRAM Configuration: Bank #0: 30000000 64 MB

1

NAND:64 MB

In:    serial Out: serial Err:   serial

Hit any key to stop autoboot: 0 zImage magic = 0x016f2818 NOW, Booting Linux......

Uncompressing Linux............................................................................ don.Linux version 2.6.14.1 (arm@dozec) (gcc version 3.3.2) #15 Thu Jul 6 14:26:29 CST 2006

CPU: ARM920Tid(wb) [41129200] revision 0 (ARMv4T)

Machine: SMDK2410

Warning: bad configuration page, trying to continue Memory policy: ECC disabled, Data cache writeback CPU S3C2410A (id 0x32410002)

S3C2410: core 202.800 MHz, memory 101.400 MHz, peripheral 50.700 MHz S3C2410 Clocks, (c) 2004 Simtec Electronics

CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on CPU0: D VIVT write­back cache

CPU0: I cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets

CPU0: D cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets

Built 1 zonelists

Kernel command line: noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0,115200 irq: clearing subpending status 00000002

PID hash table entries: 128 (order: 7, 2048 bytes)

timer tcon=00500000, tcnt a509, tcfg 00000200,00000000, usec 00001e4c Console: colour dummy device 80x30

Dentry cache hash table entries: 4096 (order: 2, 16384 bytes) Inode­cache hash table entries: 2048 (order: 1, 8192 bytes) Memory: 16MB = 16MB total

Memory: 13712KB available (1927K code, 422K data, 104K init) Mount­cache hash table entries: 512

CPU: Testing write buffer coherency: ok softlockup thread 0 started up.

NET: Registered protocol family 16 S3C2410: Initialising architecture SCSI subsystem initialized

usbcore: registered new driver usbfs usbcore: registered new driver hub

S3C2410 DMA Driver, (c) 2003­2004 Simtec Electronics DMA channel 0 at c1800000, irq 33

DMA channel 1 at c1800040, irq 34 DMA channel 2 at c1800080, irq 35 DMA channel 3 at c18000c0, irq 36

NetWinder Floating Point Emulator V0.97 (double precision) devfs: 2004­01­31 Richard Gooch ([email protected]) devfs: boot_options: 0x1

Console: switching to colour frame buffer device 80x25

fb0: Virtual frame buffer device, using 1024K of video memory

 

S3C2410 RTC, (c) 2004 Simtec Electronics

s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2410 s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2410 s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2410 io scheduler noop registered

io scheduler anticipatory registered io scheduler deadline registered

io scheduler cfq registered

RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize Cirrus Logic CS8900A driver for Linux (Modified for SMDK2410)

eth0: CS8900A rev E at 0xe0000300 irq=53, no eeprom , addr: 08: 0:3E:26:0A:5B S3C24XX NAND Driver, (c) 2004 Simtec Electronics

s3c2410­nand: mapped registers at c1980000

s3c2410­nand: timing: Tacls 10ns, Twrph0 30ns, Twrph1 10ns

NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8­bit) NAND_ECC_NONE selected by board driver. This is not recommended !!

Scanning device for bad blocks

Creating 4 MTD partitions on "NAND 64MiB 3,3V 8­bit": 0x00000000­0x00100000 : "bootloader" 0x00100000­0x00500000 : "kernel"

0x00500000­0x02d00000 : "root"

0x02d00000­0x03c00000 : "User"

usbmon: debugfs is not available

116x: driver isp116x­hcd, 05 Aug 2005 s3c2410­ohci s3c2410­ohci: S3C24XX OHCI

s3c2410­ohci s3c2410­ohci: new USB bus registered, assigned bus number 1 s3c2410­ohci s3c2410­ohci: irq 42, io mem 0x49000000

usb usb1: Product: S3C24XX OHCI

usb usb1: Manufacturer: Linux 2.6.14.1 ohci_hcd usb usb1: SerialNumber: s3c24xx

hub 1­0:1.0: USB hub found hub 1­0:1.0: 2 ports detected

sl811: driver sl811­hcd, 19 May 2005 usbcore: registered new driver cdc_acm

drivers/usb/class/cdc­acm.c: v0.23:USB Abstract Control Model driver for USB modems and ISDN adaptesdrivers/usb/class/bluetty.c: USB Bluetooth support registered

usbcore: registered new driver bluetty drivers/usb/class/bluetty.c: USB Bluetooth tty driver v0.13 usbcore: registered new driver usblp

drivers/usb/class/usblp.c: v0.13: USB Printer Device Class driver Initializing USB Mass Storage driver...

usbcore: registered new driver usb­storage USB Mass Storage support registered.

mice: PS/2 mouse device common for all mice NET: Registered protocol family 2

IP route cache hash table entries: 256 (order: ­2, 1024 bytes) TCP established hash table entries: 1024 (order: 0, 4096 bytes) TCP bind hash table entries: 1024 (order: 0, 4096 bytes)

TCP: Hash tables configured (established 1024 bind 1024) TCP reno registered

TCP bic registered

NET: Registered protocol family 1

 

NET: Registered protocol family 17

Reading data from NAND FLASH without ECC is not recommended VFS: Mounted root (cramfs filesystem) readonly.

Mounted devfs on /dev Freeing init memory: 104K

Reading data from NAND FLASH without ECC is not recommended mount /etc as ramfs

re­create the /etc/mtab entries

­­­­­­­­­­­­mount /dev/shm as tmpfs

­­­­­­­­­­­­mount /proc as proc

­­­­­­­­­­­­mount /sys as sysfs

init started: BusyBox v1.1.3 (2006.07.03­03:43+0000) multi­call binary Starting pid 28, console /dev/tts/0: '/etc/init.d/rcS'

in /etc/init.d/rcS

­­­­­­­­­­­­­/sbin/ifconfig eth0 192.168.1.5

 

Please press Enter to activate this console.

Guess you like

Origin www.cnblogs.com/fanweisheng/p/11105652.html