Chinaunix首页 | 论坛 | 博客
  • 博客访问: 122600
  • 博文数量: 15
  • 博客积分: 1515
  • 博客等级: 上尉
  • 技术积分: 280
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-28 14:51
文章分类

全部博文(15)

文章存档

2010年(5)

2009年(5)

2008年(5)

我的朋友

分类: LINUX

2009-12-28 17:44:38

1.  准备工作

先在VIVI里面修改一下内核启动参数的设置:

系统加电启动之后,按空格键进入VIVI命令状态,然后修改如下

[root@123]# param set linux_cmd_line "noinitrd root=/dev/mtdblock/2 init=/linuxrc console=ttySAC0"

[root@123]# param save

2. 下载linux-2.6.14内核和yaffs文件系统

从 处下载内核,或者搜一个(呵呵,看着办吧)

从 处下载yaffs文件系统

3.修改makefile和添加yaffs2文件夹及相应的文件

1)进入内核目录下修改 Makefile

主要是以下两项: 

1 ) ARCH = arm

2) CROSS_COMPILE = /usr/local/arm/3.4.1/bin/arm-linux-

注 :在我的宿主机上有不少的交叉编译工具,而我又不习惯每次都传递参数,所以我选择写进 Makefile ,如果你的交叉编译工具存放在不同的目录或者使用不同的交叉编译工具,那你改变一下 CROSS_COMPILE 的值就行了。

补:开始时,我使用的是3.3.2的编译器,出现如下错误信息

GEN     .version

  CHK     include/linux/compile.h

dnsdomainname: 没有与名字关联的地址

  UPD     include/linux/compile.h

  CC      init/version.o

  LD      init/built-in.o

  LD      .tmp_vmlinux1

arm-linux-ld:arch/arm/kernel/vmlinux.lds:845: parse error

make: *** [.tmp_vmlinux1] Error 1

You have new mail in /var/spool/mail/root

[root@190 linux-2.6.14]#

使用3.4.1编译器之后,编译通过。

2)在fs目录下建立建立一个yaffs2文件夹,并把下载了的yaffs2文件解压,并拷贝相应的文件,下面是具体操作

# cd fs

# mkdir yaffs2

# cd yaffs2

# cp /abc/yaffs2/*.h .      //abc为你的yaffs2文件解压的所在的目录

# cp /abc/yaffs2/*.c .

# cp / abc /yaffs2/Makefile-kernel Makefile

# cp / abc /yaffs2/Kconfig .

4. 使内核支持yaffs2文件系统

1)在/arch/arm/mach-s3c2410/devs.c文件中添加如下内容:

/*Head use for NAND_FALSH*/

#include

#include

#include

#include

#include

2)建立nandflash分区表

/*NAND Flash Partitions*/

static int chip0_map[] = { 0 };

struct mtd_partition s3c_nand_part[] = {

[0] = {

.name = "bootloader",

.offset = 0x00000000,

.size = 0x00030000,

},

[1] = {

.name = "kernel",

.offset = 0x00030000,

.size = 0x00200000,

},

[2] = {

.name = "root",

.offset = 0x00230000,

.size = 0x03dcc000,

}

}; 

3)加入nandflash分区

static struct s3c2410_nand_set s3c_nand_sets[] = {

[0] = {

.name = "chip0",

.nr_chips = 1,

.nr_map = chip0_map,

.nr_partitions = ARRAY_SIZE(s3c_nand_part),

.partitions = s3c_nand_part

}

};

4)建立nandflash芯片支持

tatic struct s3c2410_platform_nand s3c_nand_info = {

.tacls = 0,

.twrph0 = 30,

.twrph1 = 0,

.nr_sets = ARRAY_SIZE(s3c_nand_sets),

.sets = s3c_nand_sets,

};

5)加入nandflash芯片支持到nandflash驱动(加粗内容为所加)

struct platform_device s3c_device_nand = {

    .name         = "s3c2410-nand",

    .id       = -1,

    .num_resources    = ARRAY_SIZE(s3c_nand_resource),

    .resource     = s3c_nand_resource,

    .dev = {

    .platform_data = &s3c_nand_info

}

};

5.指定启动时初始化

找到/arch/arm/mach-s3c2410/mach-smdk2410.c文件,修改smdk2410_devices[] ,添加如下信息

static struct platform_device *smdk2410_devices[] __initdata = {

    &s3c_device_usb,

    &s3c_device_lcd,

    &s3c_device_wdt,

    &s3c_device_i2c,

    &s3c_device_iis,

    &s3c_device_nand,    //所加

};

6.禁止flash  ECC校验

找到/drivers/mtd/nand/s3c210.c 文件,进行修改

/* s3c2410_nand_init_chip

 *

 * init a single instance of an chip

*/

static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info,

                   struct s3c2410_nand_mtd *nmtd,

                   struct s3c2410_nand_set *set)

{

    struct nand_chip *chip = &nmtd->chip;

 

    chip->IO_ADDR_R    = (char *)info->regs + S3C2410_NFDATA;

    chip->IO_ADDR_W    = (char *)info->regs + S3C2410_NFDATA;

    chip->hwcontrol    = s3c2410_nand_hwcontrol;

    chip->dev_ready    = s3c2410_nand_devready;

    chip->cmdfunc      = s3c2410_nand_command;

    chip->write_buf    = s3c2410_nand_write_buf;

    chip->read_buf     = s3c2410_nand_read_buf;

    chip->select_chip  = s3c2410_nand_select_chip;

    chip->chip_delay   = 50;

    chip->priv     = nmtd;

    chip->options      = 0;

    chip->controller   = &info->controller;

 

    nmtd->info     = info;

    nmtd->mtd.priv     = chip;

    nmtd->set      = set;

 

    if (hardware_ecc) {

        chip->correct_data  = s3c2410_nand_correct_data;

        chip->enable_hwecc  = s3c2410_nand_enable_hwecc;

        chip->calculate_ecc = s3c2410_nand_calculate_ecc;

        chip->eccmode       = NAND_ECC_HW3_512;

        chip->autooob       = &nand_hw_eccoob;

    } else {

//      chip->eccmode       = NAND_ECC_SOFT;    

        chip->eccmode     = NAND_ECC_NONE;  //所加

    }

}

7.修改fs/Kconfig文件,使配置项出现yaffs2文件系统和devfs文件系统选项

1)找到menu "Pseudo filesystems"增加

config DEVFS_FS

    bool "/dev file system support (OBSOLETE)"

    depends on EXPERIMENTAL

    help

      This is support for devfs, a virtual file system (like /proc) which

      provides the file system interface to device drivers, normally found

      in /dev. Devfs does not depend on major and minor number

      allocations. Device drivers register entries in /dev which then

      appear automatically, which means that the system administrator does

      not have to create character and block special device files in the

      /dev directory using the mknod command (or MAKEDEV script) anymore.

 

      This is work in progress. If you want to use this, you *must* read

      the material in , especially

      the file README there.

 

      Note that devfs no longer manages /dev/pts!  If you are using UNIX98

      ptys, you will also need to mount the /dev/pts filesystem (devpts).

 

      Note that devfs has been obsoleted by udev,

      .

      It has been stripped down to a bare minimum and is only provided for

      legacy installations that use its naming scheme which is

      unfortunately different from the names normal Linux installations

      use.

 

      If unsure, say N.

 

config DEVFS_MOUNT

    bool "Automatically mount at boot"

    depends on DEVFS_FS

    help

      This option appears if you have CONFIG_DEVFS_FS enabled. Setting

      this to 'Y' will make the kernel automatically mount devfs onto /dev

      when the system is booted, before the init thread is started.

      You can override this with the "devfs=nomount" boot option.

 

      If unsure, say N.

 

config DEVFS_DEBUG

    bool "Debug devfs"

    depends on DEVFS_FS

    help

      If you say Y here, then the /dev file system code will generate

      debugging messages. See the file

      for more

      details.

 

      If unsure, say N.

 

config DEVPTS_FS_XATTR

    bool "/dev/pts Extended Attributes"

    depends on UNIX98_PTYS

    help

      Extended attributes are name:value pairs associated with inodes by

      the kernel or by users (see the attr(5) manual page, or visit

      for details).

 

      If unsure, say N.

 

config DEVPTS_FS_SECURITY

    bool "/dev/pts Security Labels"

    depends on DEVPTS_FS_XATTR

    help

      Security labels support alternative access control models

      implemented by security modules like SELinux.  This option

      enables an extended attribute handler for file security

      labels in the /dev/pts filesystem.

 

      If you are not using a security module that requires using

      extended attributes for file security labels, say N.

 

config TMPFS

    bool "Virtual memory file system support (former shm fs)"

    help

      Tmpfs is a file system which keeps all files in virtual memory.

 

      Everything in tmpfs is temporary in the sense that no files will be

      created on your hard drive. The files live in memory and swap

      space. If you unmount a tmpfs instance, everything stored therein is

      lost.

 

      See for details.

 

2)找到menu "Miscellaneous filesystems"增加

#

# YAFFS file system configurations

#

source "fs/yaffs2/Kconfig”

8.修改fs/Makefile文件,添加如下内容:

obj-$(CONFIG_YAFFS_FS) += yaffs2/  

 

至此,所有的修改工作已经完成,下面该配置内核的时候了。

9.配置内核

cp arch/arm/configs/smdk2410_defconfig  .config

make menuconfig

选择对devfs文件系统的支持,如下图所示

选择对yaffs2文件系统的支持,

其他选项配置略(具体视自己的开发板一致)。修改内核启动参数,与开始修改VIVI参数一致。完成之后设置启动参数,如下图所示

配置完之后,保存退出。

10.编译内核

make   zImage

11.下载内核,并运行,其结果如图所示

内核已经跑起来了

根文件系统已经挂载成功

进入根文件系统的shell用户交互界面

 

注:整个运行yaffs2文件系统的时候,出现大量的

Witing data without ECC to NAND-FLASH is not recommended 信息,很是疑惑;其次,如图所示,运行的根文件系统不是自己做的,出现很多模块加载不成功,那是很自然的现象,呵呵,下一步该是制作根文件系统的时候了。

移植linux-2.6.18内核的时候,出现如下信息

移植yaffs或yaffs2都不成功。

阅读(962) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~