zoukankan      html  css  js  c++  java
  • (转)nand flash的nand_ecclayout介绍

    内核的nand flash驱动真可谓用“日新月异”来形容,今儿个刚写完的驱动,等到明天下个新内核放进去,又不好使了。

    这里讨论下struct nand_ecclayout,即nand 的ecc布局问题,基于2.6.32-rc2.

    该结构体定义如下:

    struct nand_ecclayout {

    uint32_t eccbytes;    //表示使用几个ecc字节

    uint32_t eccpos[128]; //表示ecc占用的位置,因为现在大页面4kbyte也就128个,所以这里写了128,

                                       //以后有更大页面的,这里也要改了。

    uint32_t oobavail;       //有几个oob可用,这个跟下面的成员有点像,一般用下面的

    struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES];  //定义oob有效个数,从哪开始等

    };

    给个例子:

    static struct nand_ecclayout mylayout = {

    #ifdef CONFIG_SYS_NAND_PAGE_2K

    .eccbytes = 40,

    .eccpos = { 

    24, 25, 26, 27, 28,

    29, 30, 31, 32, 33, 34, 35, 36, 37, 38,

    39, 40, 41, 42, 43, 44, 45, 46, 47, 48,

    49, 50, 51, 52, 53, 54, 55, 56, 57, 58,

    59, 60, 61, 62, 63, 

    },

    .oobfree = {

    {.offset = 2, .length = 22, },

    },

    #endif

    }
     其中,.eccbytes = 40,跟初始化有关系,我们一般这样初始化:

    nand->ecc.size = 512; 

    nand->ecc.bytes = 10;

    恩,这下明朗了,我们需要每512个字节产生10个ecc字节,因此对2kbyte页面的flash来说,一页就是4个512,因此需要4*10=40个ecc字节。

    .eccpos就是告诉驱动,这些ecc字节放在哪里,一般是按顺序存放,不要覆盖芯片默认的坏块标记位,对2kbyte的flash来说,厂家说是前两个即第0、1个字节是坏块标志。

    所以分配为eccbytes和eccpos后,后面有个oobfree,这样看来也很明白了:

    offset=2表示从第2个字节开始(因为前面2个是坏块标志啊~~),length=22表示(从offset开始)共22个ecc字节可以用户随便用。

  • 相关阅读:
    nginx启动时指定配置文件
    idea修改忽视文件产生得bug
    SpringBoot整合RabbitMQ出现org.springframework.amqp.AmqpException: No method found for class
    解决git速度太慢的问题,亲测有效
    HttpRequestException encountered解决方法
    mybatis大于等于小于等于的写法
    Could not initialize class sun.awt.X11GraphicsEnvironment异常处理
    CF377C Captains Mode
    AT1251 たのしいたのしい家庭菜園
    CF1057C Tanya and Colored Candies
  • 原文地址:https://www.cnblogs.com/lihaiping/p/nandfalsh.html
Copyright © 2011-2022 走看看