Chinaunix

标题: 对128M nand flash添加新的分区,不成功. [打印本页]

作者: pxebxp    时间: 2010-06-23 09:59
标题: 对128M nand flash添加新的分区,不成功.
环境说明:嵌入式linux 2.6.18
问题:对128M nand flash添加新的分区,不成功。我目前的做法是: 修改分区表,然后在启动脚本加mount /dev/mtdblock-x  /mnt/x, 其他的没改动,这样的做法对吗,见以下分析.


//老的nand flash 分区
static struct mtd_partition nand_partitions[] = {
        /* bootloader (UBL, U-Boot, BBT) in sectors: 0 - 14 */
        {
                .name = "bootloader",
                .offset = 0,
                .size = 32 * NAND_BLOCK_SIZE,
                .mask_flags = MTD_WRITEABLE,        /* force read-only */
        },
        /* bootloader params in the next sector 15 */
        {
                .name = "params",
                .offset = MTDPART_OFS_APPEND,
                .size = 96 * NAND_BLOCK_SIZE,
                .mask_flags = MTD_WRITEABLE,        /* force read-only */
        },
        /* kernel in sectors: 16 */
        {
                .name = "kernel",
                .offset = MTDPART_OFS_APPEND,
                .size = SZ_2M,
                .mask_flags = 0
        },
        {
                .name = "filesystem1",
                .offset = MTDPART_OFS_APPEND,
                .size = SZ_16M + SZ_8M,
                .mask_flags = 0
        },
        {
                .name = "filesystem2",
                .offset = MTDPART_OFS_APPEND,
                .size = MTDPART_SIZ_FULL,
                .mask_flags = 0
        }
};


//新的nand flash 分区
static struct mtd_partition nand_partitions[] = {
        /* 0 bootloader (UBL, U-Boot, BBT) in sectors: 0 - 14 */
        {
                .name = "bootloader",
                .offset = 0,
                .size = 32 * NAND_BLOCK_SIZE, //NAND_BLOCK_SIZE=(SZ_16K)
                .mask_flags = MTD_WRITEABLE,        /* force read-only */
        },
        /* 1 bootloader params in the next sector 15 */
        {
                .name = "params",
                .offset = MTDPART_OFS_APPEND,
                .size = 96 * NAND_BLOCK_SIZE, //96 * 16 = 1536K = 1.5M
                .mask_flags = MTD_WRITEABLE,        /* force read-only */
        },
        /* 2 kernel in sectors: 16 */
        {
                .name = "kernel",
                .offset = MTDPART_OFS_APPEND,
                .size = SZ_2M,
                .mask_flags = 0
        },
        /* 3 */
        {
                .name = "filesystem1",
                .offset = MTDPART_OFS_APPEND,
                .size = SZ_16M + SZ_8M,
                .mask_flags = 0
        },
        /* 4 add for jffs2 up. */
        {
                .name = "jffs2up",
                .offset = MTDPART_OFS_APPEND,
                .size = SZ_16M,
                .mask_flags = 0
        },
        /* 5 add for jffs2 param. */
        {
                .name = "jffs2parm",
                .offset = MTDPART_OFS_APPEND,
                .size = SZ_16M,
                .mask_flags = 0
        },
        /* 6 */
        {
                .name = "filesystem4",
                .offset = MTDPART_OFS_APPEND,
                .size = MTDPART_SIZ_FULL,
                .mask_flags = 0
        }
};


重新uImage
#make uImage

重新做文件系统,主要改动rcS:
原来只挂一个分区是:mount -t jffs2 /dev/mtdblock4 /mnt/nand,对应老的nand flash 分区(表)。
现在改成,对应新的分区(表):
mount -t jffs2 /dev/mtdblock4 /mnt/firmware
mount -t jffs2 /dev/mtdblock5 /mnt/nand
其他的未改动。

进入U-BOOT打印环境变量如下:
my board>printenv
bootdelay=4
baudrate=115200
bootfile="uImage"
setboot=setenv bootargs $(bootargs)
stdin=serial
stdout=serial
stderr=serial
ver=U-Boot 1.3.4
filesize=C32000
fileaddr=82000000
gatewayip=192.168.2.1
netmask=255.255.255.0
ipaddr=192.168.1.92
serverip=192.168.1.101
bootcmd=nand read 0x82000000 0x400000 0xBF0000;nboot 0x80700000 0 0x200000;bootm 0x80700000
ethaddr=00:0C:8D:AD:0D:6C
bootargs=mem=56M console=ttyS1,115200n8 root=/dev/ram0 rw initrd=0x82000000,13M ip=dhcp eth=$(ethaddr)

Environment size: 553/16380 bytes
my board>


系统启动过程就提示错误:
nand_boar nand_boar.0: Using 4-bit hardware ECC
NAND device: Manufacturer ID: 0xec, Chip ID: 0x75 (Samsung NAND 32MiB 3,3V 8-bit)
Creating 7 MTD partitions on "nand_boar.0":
0x00000000-0x00080000 : "bootloader"
0x00080000-0x00200000 : "params"
0x00200000-0x00400000 : "kernel"
0x00400000-0x01c00000 : "filesystem1"
0x01c00000-0x02c00000 : "jffs2up"
mtd: partition "jffs2up" extends beyond the end of device "nand_boar.0" -- size truncated to 0x400000
0x02c00000-0x03c00000 : "jffs2parm"
mtd: partition "jffs2parm" is out of reach -- disabled
0x03c00000-0x02000000 : "filesystem4"
mtd: partition "filesystem4" is out of reach -- disabled
nand_boar nand_boar.0: hardware revision: 2.3

而老的分区的正常启动过程如下:
NAND device: Manufacturer ID: 0xec, Chip ID: 0x75 (Samsung NAND 32MiB 3,3V 8-bit)
Creating 5 MTD partitions on "nand_davinci.0":
0x00000000-0x00080000 : "bootloader"
0x00080000-0x00200000 : "params"
0x00200000-0x00400000 : "kernel"
0x00400000-0x01c00000 : "filesystem1"
0x01c00000-0x02000000 : "filesystem2"
nand_boar nand_boar.0: hardware revision: 2.3


新分区系统起来后,一个新的分区都未挂上。
# mount
rootfs on / type rootfs (rw)
/dev/root on / type cramfs (ro)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
tmpfs on /tmp type tmpfs (rw,sync)
/dev/root on /dev/.static/dev type cramfs (ro)
tmpfs on /dev type tmpfs (rw)
devpts on /dev/pts type devpts (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /dev/shm type tmpfs (rw)
none on /var/run type tmpfs (rw)
none on /tmp type tmpfs (rw,sync)
/dev/sbulla on /mnt/ramdisk type vfat (rw,fmask=0022,dmask=0022,codepage=cp437,iocharset=iso8859-1)
# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00080000 00004000 "bootloader"
mtd1: 00180000 00004000 "params"
mtd2: 00200000 00004000 "kernel"
mtd3: 01800000 00004000 "filesystem1"
mtd4: 00400000 00004000 "jffs2up"
mtd5: 00000000 00004000 "jffs2parm"
mtd6: 00000000 00004000 "filesystem4"
# cat /proc/partitions
major minor  #blocks  name

  31     0        512 mtdblock0
  31     1       1536 mtdblock1
  31     2       2048 mtdblock2
  31     3      24576 mtdblock3
  31     4       4096 mtdblock4
254     0        512 sbulla
#
作者: myforever    时间: 2010-06-24 20:24
分区之间不能有重叠




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2