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.

Using TMS320DM6437 NANDWriter utility for writing multiple images to NAND Flash

Other Parts Discussed in Thread: TMS320DM6437

We are trying to modify the TMS320DM6437 NANDWriter utility provided with the bootloader example here:

We would like to use this code to write multipe blocks of data to the NAND Flash, but we have observed that subsequent writes disturb the information written in a different page during a previous write. For example, we write a block of data at gNandInfo.flashBase = 0x42000000 in Step 1 and then use NAND_WritePage() or NAND_EraseBlocks() in Step 2 to modify address gNandInfo.flashBase = 0x42100440. We observe that the data we read back from gNandInfo.flashBase = 0x42000000 is no longer correct after we execute Step 2.
Can anyone on this forum give us some pointers on what we're doing wrong? Any other NAND programming code that would make a better starting point for general purpose read/write of external NAND on DM6437?
We have isolated the when the problem occurs during Step 2 at the line indicated in either of the following two functions:
 
// ********************
// NAND Write Functions
// ********************
 
// Generic routine to write a page of data to NAND
Uint32 NAND_WritePage(Uint32 block, Uint32 page, Uint8 *src) {
            Uint32 eccValue[MAX_NUM_ECCS];
            Uint32 spareValue[MAX_NUM_ECCS];
            Uint8 i;
             
    // Make sure the NAND page pointer is at start of page
    flash_write_cmd((PNAND_INFO)&gNandInfo,NAND_LO_PAGE);
 
            // Write program command
            flash_write_cmd((PNAND_INFO)&gNandInfo, NAND_PGRM_START);
           
            // Write address                                          
            flash_write_addr_cycles((PNAND_INFO)&gNandInfo,block,page); //PROBLEM OCCURS HERE
           
            // Starting the ECC in the NANDFCR register for CS2(bit no.8)
            NAND_ECCReadAndRestart((PNAND_INFO)&gNandInfo);
.
.
.
// *******************************
// NAND Flash erase block function
// *******************************
Uint32 NAND_EraseBlocks(Uint32 startBlkNum, Uint32 blkCnt)
{          
            Uint32 i;
                       
            // Do bounds checking
            if ( (startBlkNum + blkCnt - 1) >= gNandInfo.numBlocks )
                        return E_FAIL;
           
            // Output info about what we are doing
            if(McBSPTest!=2) printf("Erasing blocks 0x%8.8X through 0x%8.8X.\r\n", startBlkNum, (startBlkNum + blkCnt - 1) );
 
            for (i = 0; i < blkCnt; i++)
            {
                        // Start erase command
                        flash_write_cmd((PNAND_INFO)&gNandInfo, NAND_BERASEC1);
 
                        // Write the row addr bytes only     
                        flash_write_row_addr_bytes((PNAND_INFO)&gNandInfo, (startBlkNum+i), 0); //PROBLEM OCCURS HERE
                       
                        // Confirm erase command
                        flash_write_cmd((PNAND_INFO)&gNandInfo, NAND_BERASEC2);
 
                        // Wait for the device to be ready
                        if (NAND_WaitForRdy(NAND_TIMEOUT) != E_PASS)
                                    return E_FAIL;
 
                        // verify the op succeeded by reading status from flash
                         if (NAND_WaitForStatus(NAND_TIMEOUT) != E_PASS)
                                    return E_FAIL;
            }
 
            return E_PASS;
}

 

 

  • Hi Ruben,

    I am not aware of PAGE_SIZE and BLOCK_SIZE of NAND chip present on DM6437 but on NAND the write happens on Page basis and Erase happens on Block basis. Just check when you are writing in step 2, it is not erasing the entire block starting at 42000000.

    Regards, Sudhakar