Chinaunix首页 | 论坛 | 博客
  • 博客访问: 44752
  • 博文数量: 14
  • 博客积分: 1551
  • 博客等级: 上尉
  • 技术积分: 215
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-20 22:02
文章分类
文章存档

2011年(6)

2010年(2)

2009年(1)

2008年(5)

我的朋友

分类: LINUX

2011-06-15 16:38:35

cd /new_disk/weiyan/linux-2.6.25

vi arch/arm/mach-s3c2440/mach-smdk2440.c

修改板级配置文件,为统一驱动的配置,设备的配置信息一般在此文件中添加。

 

1)    添加头文件

#include

#include

#include

#include

#include

 

2)    添加nand划分信息

static struct mtd_partition wy_nand_part[] = {

        [0] = {    //u-boot及内存存放的分区

                .name   = "BOOT",

                .size   = SZ_2M,

                .offset = 0,

        },

        [1] = {    //文件系统存放的分区

                .name   = "ROOTFS",

                .offset = SZ_2M,

                .size   = SZ_32M,

        },

        [2] = {    //剩余空间

                .name   = "BACKUP",

                .offset = SZ_32M + SZ_2M,

                .size   = SZ_32M - SZ_2M,

        },

};

 

static struct s3c2410_nand_set wy_nand_sets[] = {

        [0] = {

                .name        = "NAND",

                .nr_chips     = 1,

                .nr_partitions  = ARRAY_SIZE(wy_nand_part),

                .partitions     = wy_nand_part,

        },

};

 

3)    添加nand flash的读写匹配时间,各时间定义如图

static struct s3c2410_platform_nand wy_nand_info = {

        .tacls          = 10,

        .twrph0         = 25,

        .twrph1         = 10,

        .nr_sets        = ARRAY_SIZE(wy_nand_sets),

        .sets           = wy_nand_sets,

};

4)    添加nand设备到初始化表

static struct platform_device *smdk2440_devices[] __initdata = {

              ……(此处省略其他设备,添加时请注意。)

        &s3c_device_iis,

        &s3c_device_nand,

};

 

5)    添加nand初始化信息与nand设备的关联

static void __init smdk2440_machine_init(void)

{    

       s3c24xx_fb_set_platdata(&smdk2440_fb_info);

       s3c_device_nand.dev.platform_data = &wy_nand_info;

       //添加Nand初始化数据

       platform_add_devices(smdk2440_devices, ARRAY_SIZE(smdk2440_devices));

//     smdk_machine_init();

       s3c2410_pm_init();              //注释不需要的led初始化,增加电源管理初始化

}

 

6)    添加硬件校验

make menuconfig

Device Drivers  --->

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

<*>   NAND Device Support  --->

[*]     S3C2410 NAND Hardware ECC

make uImage && cp arch/arm/boot/uImage /new_disk/tftp

 

7)    重新生成jffs2文件系统

./mkfs.jffs2 -d rootfs -p -s 0x200 -e 0x4000 -n -l -U -o rootfs.jffs2

-d指定目录rootfs-s指定页大小为0x200字节,-e指定块大小为0x4000字节,-p指定用0xff填充最后块的空闲空间,-n指定不添加清空标志,-l指定小端格式,-U指定所有文件的属主为root-o指定输出的镜像文件名。

cp rootfs.jffs2 /new_disk/tftp

8)    修改u-boot传给内核的参数

WEIYAN # set bootargs root=/dev/mtdblock1 rootfstype=jffs2 console=ttySAC0

指定分区1"ROOTFS")为存放根文件系统的分区,类型为jffs2

 

9)    烧写jffs2文件系统及Linux内核

WEIYAN # nand erase 0x50000

//擦除从0x50000320K)开始的全部空间,从0~320K为保留的U-boot空间。

 

WEIYAN # tftp 0x31000000 rootfs.jffs2

//jffs2根文件系统下载到0x31000000的内存段

WEIYAN # nand write.jffs2 0x31000000 0x200000 $(filesize)

//将根文件系统写入到0x200000开始的空间,写入大小为下载的大小$(filesize)

 

WEIYAN # tftp 0x31000000 uImage

WEIYAN # nand write.jffs2 0x31000000 0x50000 $(filesize)

//将内核写入到0x50000开始的Nand flash,写入大小为$(filesize)

 

WEIYAN # set  bootread  nand  read.jffs2  0x31000000  0x50000  $(filesize)

WEIYAN # set  bootcmd  $(bootread)  \;bootm  0x31000000

//设置启动脚本为将Nand flash上的内核读到sdram里,并自动启动内核。

WEIYAN # save;reset                  //保存参数并重新启动

 

10)              系统正常启动显示如下

VFS: Mounted root (jffs2 filesystem).

Freeing init memory: 132K

init started: BusyBox v1.10.1 (2008-03-02 02:33:43 CST)

starting pid 771, tty '': '/etc/init.d/rcS'

 

Please press Enter to activate this console.

阅读(614) | 评论(0) | 转发(0) |
0

上一篇:基于busybox-1.10.1的简易根文件系统制作

下一篇:没有了

给主人留下些什么吧!~~