uboot 中nand write 与nand write.yaffs

nand write会计算ECC并将其烧录到oob中。

nand write.yaffs不计算ECC,因为yaffs image中自带了含ECC的OOB数据,直接将其烧录到oob区即可。

 

1. nand write.yaffs

(common/cmd_nand.c: int do_nand())
nand_write_skip_bad(nand, off, &rwsize,
                        (u_char *)addr,
                        WITH_YAFFS_OOB);
      
  ------------>
  (drivers/mtd/nand/nand_util.c: int nand_write_skip_bad())
  ops.mode = MTD_OOB_RAW;
  ops.datbuf = p_buffer;
  ops.oobbuf = ops.datbuf + pagesize;
  rval = nand->write_oob(nand, offset, &ops); (call nand_write_oob() )
  
        -------------->
      (drivers/mtd/nand/nand_base.c: static int nand_write_oob())
      ret = nand_do_write_ops(mtd, to, ops);
     ----------->
     (drivers/mtd/nand/nand_base.c: static int nand_do_write_ops())
      uint8_t *oob = ops->oobbuf;
      uint8_t *buf = ops->datbuf;
      uint8_t *wbuf = buf;
               if (unlikely(oob)) {
      size_t len = min(oobwritelen, oobmaxlen);
      oob = nand_fill_oob(chip, oob, len, ops);  //prepare chip->oob_poi
      oobwritelen -= len;
     }
     ret = chip->write_page(mtd, chip, wbuf, page, cached,
                       (ops->mode == MTD_OOB_RAW)); (call nand_write_page())
           ---------->
            (drivers/mtd/nand/nand_base.c: static int nand_write_page())
            if (unlikely(raw)){ //here raw=1 unlikely(raw) is true
            chip->ecc.write_page_raw(mtd, chip, buf); (call nand_write_page_raw())
         }
                ------------->
          (drivers/mtd/nand/nand_base.c: static void nand_write_page_raw())
          chip->write_buf(mtd, buf, mtd->writesize);
          chip->write_buf(mtd, chip->oob_poi, mtd->oobsize);

       

2. nand write
  
(common/cmd_nand.c: int do_nand())
ret = nand_write_skip_bad(nand, off, &rwsize,
                              (u_char *)addr, 0);
  ------------>
  (drivers/mtd/nand/nand_util.c: int nand_write_skip_bad())
  if (!need_skip && !(flags & WITH_YAFFS_OOB)) {
   rval = nand_write (nand, offset, length, buffer);
   if (rval == 0)
    return 0;

   *length = 0;
   printf ("NAND write to offset %llx failed %d\n",
    offset, rval);
   return rval;
  }
        -------------->
      (drivers/mtd/nand/nand_base.c: static int nand_write())
       chip->ops.len = len;
    chip->ops.datbuf = (uint8_t *)buf;
    chip->ops.oobbuf = NULL;

    ret = nand_do_write_ops(mtd, to, &chip->ops);

     -----------> 
     (drivers/mtd/nand/nand_base.c: static int nand_do_write_ops())
      uint8_t *oob = ops->oobbuf;
      uint8_t *buf = ops->datbuf;
      uint8_t *wbuf = buf;
               if (unlikely(oob)) {
      size_t len = min(oobwritelen, oobmaxlen);
      oob = nand_fill_oob(chip, oob, len, ops);
      oobwritelen -= len;
     }
     ret = chip->write_page(mtd, chip, wbuf, page, cached,
                       (ops->mode == MTD_OOB_RAW)); (call nand_write_page())
             ---------->  
          (drivers/mtd/nand/nand_base.c: static int nand_write_page())
       if (unlikely(raw)){ //here raw=0, unlikely(raw) is false
        chip->ecc.write_page_raw(mtd, chip, buf);
       }else{
        chip->ecc.write_page(mtd, chip, buf); (call nand_write_page_swecc())
       }
        ----------->
        (drivers/mtd/nand/nand_base.c: static void nand_write_page_swecc())
            /* Software ecc calculation */
        for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize)
        chip->ecc.calculate(mtd, p, &ecc_calc[i]);

        for (i = 0; i < chip->ecc.total; i++)
        chip->oob_poi[eccpos[i]] = ecc_calc[i];

        chip->ecc.write_page_raw(mtd, chip, buf);(call nand_write_page_raw())
                                     ---------->
         (drivers/mtd/nand/nand_base.c: static void nand_write_page_raw())
          chip->write_buf(mtd, buf, mtd->writesize);
          chip->write_buf(mtd, chip->oob_poi, mtd->oobsize);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值