Chinaunix首页 | 论坛 | 博客
  • 博客访问: 53883
  • 博文数量: 24
  • 博客积分: 1480
  • 博客等级: 上尉
  • 技术积分: 250
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-12 16:20
文章分类

全部博文(24)

文章存档

2010年(24)

我的朋友

分类: 嵌入式

2010-06-21 02:06:19

内核编译基本命令:

make mrproper --- 清理全部文件,包括.config和一些备份文件
make clean --- 清理生成文件,但会保留.config和一些模块文件。

make defconfig --- 生成包含全部默认选项的.config文件。这里用make s3c2410_defconfig替代
make oldconfig --- 在旧的.config基础上生成新的.config。如果只想在原来内核配置的基础上修改一些小地方,会省去不少麻烦

make config --- 基于文本的最为传统的配置界面,不推荐使用
make menuconfig --- 基于文本选单的配置界面,字符终端下推荐使用
make xconfig --- 基于图形窗口模式的配置界面,Xwindow下推荐使用

1. 解压源代码
$ tar jxvf linux-2.6.26.tar.bz2
$ cd linux-2.6.26


2. 更改Makefile
#ARCH        ?= $(SUBARCH)
#CROSS_COMPILE    ?=
ARCH        ?= arm
CROSS_COMPILE    ?= $HOME/toolchain/crosstool/gcc-4.1.0-glibc-2.3.2/arm-linux-gnu/bin/arm-linux-gnu-


3. 生成默认配置
$ make s3c2410_defconfig

4. 增加devfs文件系统支持
linux2.6.26已经去掉devfs,为了内核支持devfs以及在启动时并在/sbin/init运行 之前能自动挂载/dev为devfs文件系统,修改fs的Kconfig文件。
linux-2.6.26/fs/Kconfig

修 改的内容:
找到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.
这个步骤貌似对2.6.26来说貌似没有用,因为在fs下面的Makefile里面没有相应的文件,devfs文件夹也没有

5. 修改晶振( 可解决打印信息乱码问题 )
文件:arch/arm/mach-s3c2440/mach-smdk2440.c
    /*s3c24xx_init_clocks(16934400);*/
    s3c24xx_init_clocks(12000000);


6. 修改MTD分区
文件: arch/arm/plat-s3c24xx/common-smdk.c

/* fix mtd partition to be same with bootloader */
/* a flash all in 64M bit size have been devided into 4 partition: */
/*   1. boot : offset is 0 and size is 192k */
/*   2. kernel : offset is 0x30000 and size is 1856k */
/*   3. rootfs : offset is 0x200000 and size is 30M */
/*   4. ext-fs1 : offset is 0x2000000 and size is 32M */
static struct mtd_partition smdk_default_nand_part[] = {
    [0] = {
        .name    = "boot", /* default is "Boot Agent", by qspy */
        .size    = SZ_64K*3,  /* default is SZ_16K, qspy fix it to 192K*/
        .offset    = 0,
    },
    [1] = {
        .name    = "kernel", /* default is "S3C2410 flash partition 1", by qspy */
        .offset = SZ_64K*3,/* default is 0, by qspy */
        .size    = SZ_64K*29,/* default is SZ_2M, qspy fix it to 1856K*/
    },
    [2] = {
        .name    = "rootfs",/* default is "S3C2410 flash partition 2", by qspy */
        .offset = SZ_2M,/* default is SZ_4M, by qspy */
        .size    = SZ_1M*30,/* default is SZ_4M, qspy fix it to 30M*/
    },
    [3] = {
        .name    = "ext-fs1",/* default is "S3C2410 flash partition 2", by qspy */
        .offset    = SZ_32M,/* default is SZ_8M, by qspy */
        .size    = SZ_32M,/* default is SZ_2M, qspy fix it to 30M*/
    } /*,
    [4] = {
        .name    = "S3C2410 flash partition 4",
        .offset = SZ_1M * 10,
        .size    = SZ_4M,
    },
    [5] = {
        .name    = "S3C2410 flash partition 5",
        .offset    = SZ_1M * 14,
        .size    = SZ_1M * 10,
    },
    [6] = {
        .name    = "S3C2410 flash partition 6",
        .offset    = SZ_1M * 24,
        .size    = SZ_1M * 24,
    },
    [7] = {
        .name    = "S3C2410 flash partition 7",
        .offset = SZ_1M * 48,
        .size    = SZ_16M,
    } */
};


7. 关闭ECC校验
文件:drivers/mtd/nand/s3c2410.c
函 数:s3c2410_nand_init_chip
        /*chip->ecc.mode        = NAND_ECC_SOFT; */
        chip->ecc.mode    = NAND_ECC_NONE;



8. 配置内核
$ make xconfig

其中有几项一定要修改 的,分别是:


a. 启动
|---Boot options
|    |---Default kernel command string: [root=/dev/mtdblock2 rootfstype=cramfs init=/linuxrc console=ttySAC1,115200 devfs=mount mem=64]

分析:
/dev/mtdblock2 : 表示MTD分区的第2个分区存储根文件系统
rootfstype=cramfs : 分区是cramfs类型,这项不加应该关系不大
init=/linuxrc : 启动的首个脚本即根目录下的linuxrc
console=ttySAC1,115200 : 使用串口1作为串口调试,波特率设置为115200; 现在已经摒弃了以前使用ttyS0的写法
devfs=mount : 在/sbin/init运行之前能自动挂载/dev为devfs文件系统(这步貌似不起作用)
mem=64 : 存储器大小为64M

以上要是内核的cmdline起作用的话,需要在arch/arm/kernel/setup.c文件中 的parse_tag_cmdline()函数中的内容注释掉, 并且配置正确的CONFIG_CMDLINE参数,即可运行。以后每当改变内核参数只要改变CONFIG_CMDLINE就 可以了。(CONFIG_CMDLINE这个值可以在make menuconfig中配置,2.6.11版本和2.6.14版本配置位置有所不同,请注意)。

b. 增加devfs文件系统支持
|---File systems
|    |---Pseudo filesystems
|    |      |---/dev file system support
|    |      |      |---Automatically mount at boot
|    |      |      |---Debug devfs

这 几项都是必选的(这步貌似没有什么用,对2.6.26的内核来说

c.

在device drivers -> Memory Technology Device (MTD) support --->

选择

Caching block device access to MTD devices

详细请参见

http://hi.baidu.com/serial_story/blog/item/f7feb801b3fd0edd267fb500.html


9.make zImage


常见错误请参见

http://dev.firnow.com/course/6_system/linux/Linuxjs/200896/139613.html

文中的添加

static struct platform_device * smdk2410_device[] _initdata=

{

&s3c_device_usb,

&s3c_device_lcd,

&s3c_device_wdt,

&s3c_device_i2c,

&s3c_device_iis,

&s3c_device_nand,

};

这不没有选,也可以加载,具体的有待分析。

nand分析

http://xgc94418297.blog.163.com/blog/static/1129660402009675552824/


文件系统中要sudo mknod mtdblock2 b 31 2?没有验证。


这里还有一个方面要注意的,就是ECC问题,如果不把
    Device Drivers  --->
     Memory Technology Devices (MTD)  --->
        NAND Flash Device Drivers  --->
            [*]   S3C2410 NAND Hardware ECC
    去掉会出现如下的问题:
end_request: I/O error, dev mtdblock3, sector 2
EXT3-fs: unable to read superblock
end_request: I/O error, dev mtdblock3, sector 0


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