Nand分区及nand erase简解
我的nand flash 32M,kernel 2.6.18, rootfs is emb linux, cramfs.
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, //32x16 = 512k
.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, //96x16 = 1536k = 1.5M
.mask_flags = MTD_WRITEABLE, /* force read-only */
},
/* kernel in sectors: 16 */
{
.name = "kernel",
.offset = MTDPART_OFS_APPEND,
.size = SZ_2M, //2M
.mask_flags = 0
},
/* rootfs */
{
.name = "filesystem1",
.offset = MTDPART_OFS_APPEND,
.size = SZ_16M + SZ_8M, //24M
.mask_flags = 0
},
/*parameter*/
{
.name = "filesystem2",
.offset = MTDPART_OFS_APPEND,
.size = MTDPART_SIZ_FULL, //4M, /mnt/nand, save log,sysenv,
.mask_flags = 0
}
};
//系统启动后
# 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
#
# 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 "filesystem2"
#
我的问题是:
在U-boot烧写时,用以下命令:
tftpboot 0x80700000 uImage_ipnc_dm365 //可以理解
tftpboot 0x82000000 cramfsImage_ipnc_dm365.v1.2.4-debug-param //可以理解
nand erase 0x200000 0xDF0000 //不理解,本句的意思是把kernel分区和rootfs分区擦除,0xDF0000 = 13.9375M, 而内核和文件系统共2M+24M=26M,为什么不是#nand erase 0x200000 0x1A00000 (26M).
nand write 0x80700000 0x200000 0x200000 //可以理解,写内核到NAND FLASH, 从内存地址 0x80700000 读取大小为 0x200000(2M)的数据,写入nand flash,写入的起始地址为0x200000。
nand write 0x82000000 0x400000 0xBF0000 //不理解,写文件系统到NAND FLASH, 意思是从内存地址 0x82000000 读取大小为 0xBF0000(11.9375M)的数据,写入nand flash,写入的起始地址为0x400000。为什么只写0xBF0000(11.9375M)的数据,我的文件系统分区24M啊,实际的文件系统也22M左右,why?
我对 “nand write 0x82000000 0x400000 0xBF0000”这条命令的理解是这样的: 写文件系统到NAND FLASH, 从内存地址 0x82000000 读取大小为 0xBF0000(11.9375M)的数据,写入nand flash,写入的起始地址为0x400000。0xBF0000(11.9375M) 是写入的大小,0x400000是开始地址。
0xBF0000 = 11.9375M, 我是这样算的,0xBF0000 = 12517376(十进制),12517376(字节)/1024 = 12224k, 12224k/1024 = 11.9375M.