zoukankan      html  css  js  c++  java
  • 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?

    我觉得不应该是0xBF0000-0x400000,这两个值是不同的含义,不能相减。
    我对 “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.
    解决:只要够写就行,不一定全部写满的
  • 相关阅读:
    Qtranslate是Win10系统的一款非常小众的翻译神器,真的是办公人员利器
    大文件查找软件(WizTree) v3.37 ---非常快
    DirPrintOK --- 将文件以树的形式列出、可导出到excel、html文件,用于整理电脑的文件,非常好用
    Linux五大类常用命令
    Android pm list 命令查看手机安装的apk信息
    Android adb命令列出当前设备所有apk安装的路径和包名
    Win10 Python2.7.6 如何使用pip命令?如何离线安装第三方模块?PyCharm设置Python2.7.6,、wxPython安装
    证件照在线免费移除背景或更换背景
    Ubuntu wps办公软件快捷键
    根据书籍的ISBN号查询书籍信息
  • 原文地址:https://www.cnblogs.com/general001/p/2181773.html
Copyright © 2011-2022 走看看