2.6.18内核移植成功

时间:2021-01-10 12:01:57

Vivi编译器为:2.95.3

内核版本:2.6.18

内核编译器为:4.3.2


一、修改bootloader

由于2.6内核编译后的压缩镜像,经常超过1m,需将NANDflash改为:

需要修改arch/s3c2410/smdk.c文件中的default_mtd_partitions[]。修改后的内容为:

mtd_partition_tdefault_mtd_partitions[] = {

{

name:"vivi",

offset:0,

size:0x00020000,

//vivisize 128k modifyed by Eric

flag:0

},{

name:"param",

offset:0x00020000,

size:0x00010000,

//paramsize 64k

flag:0

},{

name:"kernel",

offset:0x00030000,

size:0x002d0000,

//kernelsize 2m+832k

flag:0

},{

name:"root",

offset:0x00300000,

size:0x00300000,

//rootsize 3m

flag:MF_BONFS

},{

name:"user",

offset:0x00600000,

size:0x03000000,

//usersize 48m

flag:MF_JFFS2

}

};

由于在2.4内核中串口ttyS0,2.6内核中改为ttySAC0,需要将此文件中的linux_cmd[]改为:

charlinux_cmd[] = "noinitrd root=/dev/bon/3 init=/linuxrcconsole=ttySAC0 console=tty0";

其中:

noinitrd:不使用initrd文件

root=/dev/bon/3:代表nandflash的第4个分区,作为rootfs

init=/linuxrc:启动初始化文件位置

console=ttySAC0:控制台使用串口1

console=tty0:控制台使用终端1

修改好此文件后,配置编译vivi

配置编译vivi

直接使用make命令编译就行

烧写vivi

由于板子上已经有vivi,所以直接使用vivi来烧写

loadflash vivi x

在出现writting....时按ctrl+a,然后按下s选择所要下载的文件,这步一定要迅速,否则可能无法成功


Linux2.6内核移植

修改Makefile文件

修改内核根目录下的Makefile文件,指明交叉编译器

找到ARCHCROSS_COMPILE,修改为:

ARCH?=arm

CROSS_COMPILE?=arm-linux-

设置flash分区

    1.修改arch/arm/plat-s3c24xx/devs.c文件

添加如下内容:


/*--------------forNAND Flash---------------*/

#include<linux/mtd/partitions.h>

#include<linux/mtd/nand.h>

#include<asm/arch/nand.h>

/*-------------------------------------------*/

……………………………

/*NANDController*/

/*建立flash分区表*/

/*--------------------------forpartitions---------*/


staticstruct mtd_partition partition_info[]={

{/*128k*/

name:"vivi",

size:0x00020000,

offset:0x00000000

},{/*64k*/

name:"param",

size:0x00010000,

offset:0x00020000

},{/*2m+832k*/

name:"kernel",

size:0x002d0000,

offset:0x00030000

},{/*3m*/

name:"root",

size:0x0030000,

offset:0x00300000

},{/*48*/

name:"user",

size:0x03000000,

offset:0x00600000

}

};

/*加入NANDFLASH分区*/

staticstruct s3c2410_nand_set nandset = {

nr_partitions:5,/*the number of partition*/

partitions:partition_info,

};

/*建立芯片支持*/

staticstruct s3c2410_platform_nand superlpplatform = {

tacls:0,

twrph0:30,

twrph1:0,

sets:&nandset,

nr_sets:1,

};

staticstruct resource s3c_nand_resource[] = {

[0]= {

.start= S3C2410_PA_NAND,

.end= S3C2410_PA_NAND + S3C24XX_SZ_NAND - 1,

.flags= IORESOURCE_MEM,

}

};

/*-----加入芯片支持到nandflash驱动----------*/

structplatform_device s3c_device_nand = {

.name= "s3c2410-nand",

.id= -1,

.num_resources= ARRAY_SIZE(s3c_nand_resource),

.resource= s3c_nand_resource,

/*------------------------forMTD partitions------------------*/

.dev= {

.platform_data= &superlpplatform

}

/*------------------------------------------------------------*/

};

    2.修改arch/arm/mach-s3c2410/mach-smdk2410.c

指定启动时初始化分区,使上面的修改生效。找到*smdk2410_devices[]__initdata

Staticstruct platform_device *smdk2410_devices[]__initdata ={

&s3c_device_iis,

/*添加如下语句*/

&s3c_device_nand,

}

    3.修改drivers/mtd/nand/s3c2410.c禁止flashECC校验

找到s3c2410_nand_init_chip()函数,在该函数体最后加上:

chip->ecc.mode= NAND_ECC_NONE;

4.如果有plat-s3c,那么就注释掉arch/arm/plat-s3c/dev-nand.c中的structplatform_device s3c_device_nand = {

.name = "s3c2410-nand",

.id = -1,

.num_resources = ARRAY_SIZE(s3c_nand_resource),

.resource = s3c_nand_resource,

}

否则会出现多次声明错误

5.修改scripts/mod/sumversion.c

添加#include<linux/limits.h>


配置内核

    1.修改fs/Kconfig,支持启动时挂载devfs

$vimfs/ Kconfig

找到menu“Pseudo filesystem”

在其中添加:

configDEVFS_FS

bool"/dev file system support (OBSOLETE)"

defaulty

configDEVFS_MOUNT

bool"Automatically mount at boot"

defaulty

dependson DEVFS_FS


2.配置内核产生.config文件

为简化配置内核文件的复杂度,先复制到arch/arm/configs/smdk2410_defconfig到内核根目录下。

$makemenuconfig

增删的内核配置选项如下:

Loadablemodule suport--->

[*]Enableloadable module suport

[*]Automatickernel module loading

SystemType--->[*]S3C2410 DMA suport

Bootoptions --->Default kernel command string:

noinitrdroot=/dev/mtdblock3 init=/linuxrc consolettySAC0,115200

mtdblock3代表第四个flash分区,为root分区

Floatingpoint emulation---->

[*]NWFPEmath emulation

#MTD子系统的配置

DeviceDrivers--->

MemoryTechnology Devices(MTD)--->

............................................

[*]MTDpartitioning support

[*]Commandline partition table parsing

............................................

[*]RAM/ROM/Flashchip drivers-->

<*>Detectflash chip by Common Flash Interface(CFI) prob

<*>Detectnon-CFI AMD/JEDEC-compatible flash chip

<*>Supportfor Intel/Sharp flash chip

<*>Supportfor AMD/Fujitsu flash chip

<*>Supportfor ROM chip in bus mapping

NAND FlashDevice Drivers--->

................................

<*>NANDDevice Support

<*>NANDFlash support foe S3C2410/S3C2440 Soc

Characterdevices--->

.............................

[*]Non-standardserial port support

[*]S3C2410RTC Driver

Filesystems--->

<>Secondextended fs support #去除ext2支持

Pseudofilesystems--->

[*]Virtualmemory file system support(former shm fs)

[*]/devfile system support(OBSOLETE)

[*]Automaticallymount at boot(NEW)

Miscellaneousfilesystems--->

............................

<*>JFFS2

<*>cramfs

.............................

NetworkFile Systems---->

<*>NFSfile system support

保存退出

编译内核

$make zImage

烧写flash

load flash kernel x

在出现writting....时按ctrl+a,然后按下s选择所要下载的文件,这步一定要迅速,否则可能无法成功


参照网上资料和自己的实际移植过程完成该文档...