This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Found and fixed bug in OMAPL138 Flashing utility's NAND driver

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;
}
}

  • Hi Kevin,

     

                Kindly let us know the version of serial flasher utility you are trying to use?

    As per the latest version of serial flasher utility, the function you have posted doesn’t have the && 0X00FF and its specified & 0X00FF.

     The latest version of serial flasher utility can be found on this wiki

    http://processors.wiki.ti.com/index.php/Serial_Boot_and_Flash_Loading_Utility_for_OMAP-L138#Obtaining_the_software.

     

    Regards

    Iyshwarya

     

    If this answers your question, please click the Verify Answer button below. If not, please reply back with more information.

     

  • Sorry I was typing quickly

    // 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;
    }
    }

    return E_PASS;
    }

    This function with the & is erasing bad blocks on a micron device. The UBL code that came with the board support package has

    // 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;
    }
    }

    return E_PASS;
    }

    The '& 0x00FF' is causing the bad blocks to get erased via the flashing utility for device_nand.c