[U-Boot] [U-boot]question: why write bbt and search bbt use different ops mode in nand_bbt.c in U-boot 2013.04?

TigerLiu at viatech.com.cn TigerLiu at viatech.com.cn
Tue Sep 24 04:13:52 CEST 2013


Hi , Scott:

First, My uboot version is 2013.04.

 

In the function scan_write_bbt(), U-boot uses MTD_OOB_PLACE to write BBT
data and BBT pattern. See ">>>" below

 

static int scan_write_bbt(struct mtd_info *mtd, loff_t offs, size_t len,

                              uint8_t *buf, uint8_t *oob)

{

         struct mtd_oob_ops ops;

 

>>>  ops.mode = MTD_OOB_PLACE;

         ops.ooboffs = 0;

         ops.ooblen = mtd->oobsize;

         ops.datbuf = buf;

         ops.oobbuf = oob;

         ops.len = len;

 

         return mtd->write_oob(mtd, offs, &ops);

}

 

while in funtion search_bbt() (actually in function
scan_read_raw_oob()), U-boot uses MTD_OOB_RAW to read BBT data and BBT
pattern. See ">>>" below.

 

static int scan_read_raw_oob(struct mtd_info *mtd, uint8_t *buf, loff_t
offs,

                            size_t len)

{

         struct mtd_oob_ops ops;

         int res;

 

>>>  ops.mode = MTD_OOB_RAW;

         ops.ooboffs = 0;

         ops.ooblen = mtd->oobsize;

 

 

         while (len > 0) {

                   if (len <= mtd->writesize) {

                            ops.oobbuf = buf + len;

                            ops.datbuf = buf;

                            ops.len = len;

                            return mtd->read_oob(mtd, offs, &ops);

                   } else {

                            ops.oobbuf = buf + mtd->writesize;

                            ops.datbuf = buf;

                            ops.len = mtd->writesize;

                            res = mtd->read_oob(mtd, offs, &ops);

 

                            if (res)

                                     return res;

                   }

 

                   buf += mtd->oobsize + mtd->writesize;

                   len -= mtd->writesize;

         }

         return 0;

}

 

It's confused that search BBT and write BBT uses different mtd ops mode.
And also data will not be valid if U-boot uses mtd ops MTD_OOB_RAW
during reading and no software ECC is implemented. 

I also noticed that in U-boot2013.07 both search BBT and write BBT uses
mtd ops MTD_OPS_PLACE_OOB.

 

Best wishes,



More information about the U-Boot mailing list