|  | 
| 关于u-boot中硬件ECC校验失败的原因,花了几天的世间我将问题定位到了nand_read_page 这个函数里面 ,然后通过串口调试,发现 pmc_cfg->bch_result_0_3[0].bch_result3,pmc_cfg->bch_result_0_3[0].bch_result2,pmc_cfg->bch_result_0_3[0].bch_result1中的数据都是正常的,pmc_cfg->bch_result_0_3[0].bch_result1中的数据都是错误的,只要是pmc_cfg->bch_result_0_3[0].bch_result1中的数据都是错误的,于是我就去查看手册中的 Nand Flash 控制器,看到这段话
 The ECC accumulator must be reset before any ECC computation accumulation process. The
 GPMC_ECC_CONTROL[8] ECCCLEAR bit must be set to 1 (nonpersistent bit) to clear the accumulator
 and all ECC result registers.
 于是就猜想和尝试以下修改
 drivers/mtd/nand/am335x_spl_bch.c 中的 nand_read_page 做了以下修改
 for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {
 this->ecc.hwctl(&mtd, NAND_ECC_READ);
 for(j=1000;j>0;j--);    //pyh add
 nand_command(block, page, data_pos, NAND_CMD_RNDOUT);
 
 this->read_buf(&mtd, p, eccsize);
 
 this->ecc.hwctl(&mtd, NAND_ECC_READ);  //pyh  add
 nand_command(block, page, oob_pos, NAND_CMD_RNDOUT);
 
 this->ecc.hwctl(&mtd, NAND_ECC_READ);
 this->read_buf(&mtd, oob, eccbytes);
 this->ecc.calculate(&mtd, p, &ecc_calc[i]);
 
 data_pos += eccsize;
 oob_pos += eccbytes;
 oob += eccbytes;
 }
 结果问题解决了,/pyh add 是我添加的代码
 
 
 | 
 |