2009-12-18 00:14:38     Problem about Nand ECC 512size Page code in 2009R1-RC6

Document created by Aaronwu Employee on Aug 20, 2013
Version 1Show Document
  • View in full screen mode

2009-12-18 00:14:38     Problem about Nand ECC 512size Page code in 2009R1-RC6

Xin Xin (CHINA)

Message: 83659   

 

static int bf5xx_nand_calculate_ecc(

struct mtd_info *mtd,

               const u_char *dat, u_char *ecc_code)

{

       struct bf5xx_nand_info *info = mtd_to_nand_info(mtd);

       struct bf5xx_nand_platform *plat = info->platform;

       u16 page_size = (plat->page_size ? 512 : 256);

       u16 ecc0, ecc1;

       u32 code[2];

       u8 *p;

 

       /* first 4 bytes ECC code for 256 page size */

       ecc0 = bfin_read_NFC_ECC0();

       ecc1 = bfin_read_NFC_ECC1();

 

       code[0] = (ecc0 & 0x7ff) | ((ecc1 & 0x7ff) << 11);

 

       dev_dbg(info->device, "returning ecc 0x%08x\n", code[0]);

 

       /* first 3 bytes in ecc_code for 256 page size */

       p = (u8 *) code;

       memcpy(ecc_code, p, 3);

 

       /* second 4 bytes ECC code for 512 page size */

       if (page_size == 512) {

               ecc0 = bfin_read_NFC_ECC2();

               ecc1 = bfin_read_NFC_ECC3();

               code[1] = (ecc0 & 0x7ff) | ((ecc1 & 0x7ff) << 11);

 

               /* second 3 bytes in ecc_code for second 256

                * bytes of 512 page size

                */

               p = (u8 *) (code + 1);

               memcpy((ecc_code + 3), p, 3);

               dev_dbg(info->device, "returning ecc 0x%08x\n", code[1]);

       }

 

       return 0;

}

 

static int bf5xx_nand_correct_data(struct mtd_info *mtd, u_char *dat,

                                       u_char *read_ecc, u_char *calc_ecc)

{

       struct bf5xx_nand_info *info = mtd_to_nand_info(mtd);

       struct bf5xx_nand_platform *plat = info->platform;

       unsigned short page_size = (plat->page_size ? 512 : 256);

       int ret;

 

       ret = bf5xx_nand_correct_data_256(mtd, dat, read_ecc, calc_ecc);

 

       /* If page size is 512, correct second 256 bytes */

       if (page_size == 512) {

               dat += 256;

               read_ecc += 8;

               calc_ecc += 8;

               ret |= bf5xx_nand_correct_data_256(mtd, dat, read_ecc, calc_ecc);

       }

 

       return ret;

}

 

Why need this "read_ecc += 8;calc_ecc += 8;"?

According to "bf5xx_nand_calculate_ecc", as following

memcpy(ecc_code, p, 3); memcpy((ecc_code + 3), p, 3);

 

Is "read_ecc += 3;calc_ecc += 3;" right?

QuoteReplyEditDelete

 

 

2009-12-18 00:17:24     Re: Problem about Nand ECC 512size Page code in 2009R1-RC6

Xin Xin (CHINA)

Message: 83660   

 

Hi,

 

    I rewrite the problem:

 

/// Why need this "read_ecc += 8;calc_ecc += 8;"? According to "bf5xx_nand_calculate_ecc", as following memcpy(ecc_code, p, 3); memcpy((ecc_code + 3), p, 3); Is "read_ecc += 3;calc_ecc += 3;" right?

 

Best Regards

 

Xin

QuoteReplyEditDelete

 

 

2009-12-18 07:45:51     Re: Problem about Nand ECC 512size Page code in 2009R1-RC6

Mike Frysinger (UNITED STATES)

Message: 83695   

 

do you have a problem with some NAND device, or are you simply reading code ?

 

QuoteReplyEditDelete

 

 

2009-12-21 02:52:44     Re: Problem about Nand ECC 512size Page code in 2009R1-RC6

Xin Xin (CHINA)

Message: 83772   

 

I met the ECC check erro at kernel 2.6.28.3, but the same code, and modified "+8" to "+3", and it works. Recently I update to the latest release, it works, but it's strange the code "+8" also works well.

Attachments

    Outcomes