/* Calculate and write the ECC if we have enough data */
if ((col < nand->eccsize) && (last >= nand->eccsize))
{
nand_calculate_ecc (&nand->data_buf[0], &(ecc_code[0]));
for (i = 0; i < 3; i++)
{
nand->data_buf[(nand->oobblock + oob_config.ecc_pos)] = ecc_code;
}
if (oob_config.eccvalid_pos != -1)
{
nand->data_buf[nand->oobblock + oob_config.eccvalid_pos] = 0xf0;
}
}
/* Calculate and write the second ECC if we have enough data */
if ((nand->oobblock == 512) && (last == nand->oobblock))
{
nand_calculate_ecc (&nand->data_buf[256], &(ecc_code[3]));
for (i = 3; i < 6; i++)
{
nand->data_buf[(nand->oobblock + oob_config.ecc_pos)] = ecc_code;
}
if (oob_config.eccvalid_pos != -1)
{
nand->data_buf[nand->oobblock + oob_config.eccvalid_pos] &= 0x0f;
}
}
在这里进行了两次ecc,而且ecc_code也写进了data_buf,512-527中
再后面
for (i = 0; i < col; i++)
nand->data_buf = 0xff;
/* Postpad for partial page programming !!! oob is already padded */
for (i = last; i < nand->oobblock; i++)
nand->data_buf = 0xff;