I found an issue with the nand driver never detecting bad blocks properly. The check in the spare region always returns a positive saying it isn't a bad block. Or the code that uses it is backwards. It's a bit ambiguous if it's supposed to be returning a E_FAIL or E_PASS.
Here's the original code
// Function to determine if the spare bytes indicate a bad block
static Uint32 DEVICE_NAND_BB_checkSpareBytes(NAND_InfoHandle hNandInfo, Uint8 *spareBytes)
{
Uint32 i,j;
// Check all the free bytes (non-ECC bytes) for 0xFF
for (j = 0; j< hNandInfo->numOpsPerPage; j++)
{
for (i=0; i<DEVICE_NAND_ECC_START_OFFSET; i++)
{
if (spareBytes[i+hNandInfo->spareBytesPerOp*j] && 0x00FF != 0xFF)
return E_FAIL;
}
}
I fixed it by removing the && 0x00FF
// Function to determine if the spare bytes indicate a bad block
static Uint32 DEVICE_NAND_BB_checkSpareBytes(NAND_InfoHandle hNandInfo, Uint8 *spareBytes)
{
Uint32 i,j;
// Check all the free bytes (non-ECC bytes) for 0xFF
for (j = 0; j< hNandInfo->numOpsPerPage; j++)
{
for (i=0; i<DEVICE_NAND_ECC_START_OFFSET; i++)
{
if (spareBytes[i+hNandInfo->spareBytesPerOp*j] != 0xFF)
return E_FAIL;
}
}