主题 : 2440下使用Initramfs或yaffs2作为根文件系统启动成功,但是Ramdisk作为根文件系统有问题 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 17006
精华: 0
发帖: 24
金钱: 120 两
威望: 24 点
综合积分: 48 分
注册时间: 2010-03-24
最后登录: 2018-07-15
楼主  发表于: 2011-01-29 13:09

 2440下使用Initramfs或yaffs2作为根文件系统启动成功,但是Ramdisk作为根文件系统有问题

使用Initramfs或yaffs2作为根文件系统启动成功,但是Ramdisk作为根文件系统有问题


最近在调一个很郁闷的系统问题:
使用Ramdisk作为根文件系统时,分区结构如图

static struct mtd_partition smdk_default_nand_part[] = {
    [0] = {
        .name    = "U-Boot",
        .size    = 0x60000,
        .offset    = 0,
    },
    [1] = {
        .name    = "Linux Kernel",
        .offset = 0x80000,
        .size    = 0x300000,
    },
    [2] = {
        .name    = "RAMDisk",
        .offset = 0x380000,
        .size    = 0x1000000,
    },
    [3] = {
        .name    = "Yaffs",
        .offset = 0x1380000,
        .size    = 0x08000000-0x1380000, //0x6C80000
    }
};

uboot启动参数:
#define CONFIG_BOOTARGS    "initrd=0x31000000,0x1000000 root=/dev/ram rw init=/linuxrc console=ttySAC0 mem=64M"  //ramdisk
#define CONFIG_BOOTCOMMAND    "nboot 30008000 0 80000;bootm 30008000"

使用
mkimage -n 'Kernel' -A arm -O linux -T kernel -C none -a 0x30008000 -e 0x30008040 -d linux-2.6.33.3/arch/arm/boot/zImage /var/lib/tftpboot/uImage
mkimage -n 'Ramdisk' -A arm -O linux -T ramdisk -C gzip -a 0x31000000 -e 0x31000040 -d initrd.gz ramdisk2.gz
做的image

结果只有第一次执行
tftp 0x31000000 initrd.gz
nand erase 0x380000 0x1000000
nand write 0x31000000 0x380000 0x520000
后可以正常启动,重启后就提示找不到Ramdisk了。
若把boot command设成
setenv bootcmd "nboot 30008000 0 80000; nand read 0x31000000 0x380000 0x520000; bootm 30008000 0x31000000"
则一次也不能启动成功。
刚开始怀疑是yaffs2的问题,把yaffs2给取消了,也不mount了,问题依旧。

但是若把rootfs放在yaffs2里,参数设为
setenv bootargs noinitrd root=/dev/mtdblock3 rootfstype=yaffs2 rw console=ttySAC0,115200 init=/linuxrc mem=64M
setenv bootcmd "nboot 30008000 0 80000;bootm 30008000"
则一切正常,但是因为会留下Flash写操作频繁的隐患。


开动FF上网,没有找到问题的解决方法,倒是找到了initramfs的制作方法。既然initramfs比ramdisk更潮,何不试试?
于是把uboot的参数设为
setenv bootargs root=/dev/ram rw init=/init console=ttySAC0 mem=64M
setenv bootcmd "nboot 30008000 0 80000;bootm 30008000"

分区表改为
static struct mtd_partition smdk_default_nand_part[] = {
    [0] = {
        .name    = "U-Boot",
        .size    = 0x60000,
        .offset    = 0,
    },
    [1] = {
        .name    = "Linux Kernel",
        .offset = 0x80000,
        .size    = 0x1300000,
    },
    [2] = {
        .name    = "Yaffs",
        .offset = 0x1380000,
        .size    = 0x08000000-0x1380000, //0x6C80000
    }
};
重新做了个将近11M的内核,
tftp 0x30008000 uImage
nand erase 0x80000 0xC00000
nand write 0x30008000 0x80000 0xB20000

重启一切正常。看来tmpfs还是很有优势的,至少问题没有Ramdisk那么多,那么繁琐,制作系统也灰常简单。



问题是:Ramdisk作为rootfs时,为什么重启后内核找不到rootfs呢? 还是没搞懂。
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
1楼  发表于: 2011-02-07 17:15
结果只有第一次执行
tftp 0x31000000 initrd.gz
nand erase 0x380000 0x1000000
nand write 0x31000000 0x380000 0x520000
后可以正常启动,重启后就提示找不到Ramdisk了。

重启之后没有通过tftp重新加载initrd.gz? ramdisk是放在ram里的,重启之后ram中的数据被覆盖了当然就找不到.

若把boot command设成
setenv bootcmd "nboot 30008000 0 80000; nand read 0x31000000 0x380000 0x520000; bootm 30008000 0x31000000"
则一次也不能启动成功。

命令看起来是正确的,但ramdisk加载成功取决于“nand read 0x31000000 0x380000 0x520000”将之前写入NAND Flash中的initrd.gz镜像成功地读取到ram地址0x31000000上。
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 新手上路
UID: 17006
精华: 0
发帖: 24
金钱: 120 两
威望: 24 点
综合积分: 48 分
注册时间: 2010-03-24
最后登录: 2018-07-15
2楼  发表于: 2011-02-15 14:13

 回 1楼(kasim) 的帖子

版主的意思是uboot在加载ramdisk时,nand read 0x31000000 0x380000 0x520000  这一条没有成功的从NAND Flash中把initrd.gz镜像成功地读取到ram地址0x31000000?
级别: 新手上路
UID: 34935
精华: 0
发帖: 38
金钱: 195 两
威望: 39 点
综合积分: 76 分
注册时间: 2010-12-23
最后登录: 2012-04-07
3楼  发表于: 2011-09-02 09:37

 回 楼主(skykingf) 的帖子

你有这个yaffs2或者是光盘带的这个文件吗,有的话给我 发一个,我的找不到啊,网上面也不好下载。
谢谢!
359078322@qq.com
好好学习,天天向上!