Hi All,

 

I found a bug in serial flasher utility of DM6467.

 

Please find below bug description and fix:  

We found this issue in DM646x_FlashAndBootUtils_1_50.tar.gz
<http://sourceforge.net/projects/dvflashutils/files/DM646x/v1.50/DM646x_Flas
hAndBootUtils_1_50.tar.gz/download> .

 

Bug: DM6467 can't boot from reserved copy of UBL/U-Boot if there is ECC
error or descriptor table corruption error while loading UBL/ U-Boot from
first copy.

 

Introduction:

The serial flasher utility is used to write UBL and U-Boot of DM6467 on NAND
flash. The serial flasher utility writes multiple copies (based on size of
UBL/U-Boot) of UBL and U-Boot on NAND to handle ECC and descriptor table
corruption errors. The RBL and UBL of DM6467 are designed such that if
RBL/UBL founds ECC or descriptor table corruption error during UBL or U-Boot
loading, then RBL/UBL will go to next block and boot from next copy of
UBL/U-Boot.  

 

Bug Description:

The serial flasher utility should write same copy of UBL/U-Boot in to
multiple blocks. I found that serial flasher utility is writing correct data
only in first copy of UBL/U-Boot, other copies are written with junk data
from DDR.

 

In DM646x_FlashAndBootUtils_1_50/Common/sft/src/uartboot.c file,
LOCAL_NANDWriteHeaderAndData () function gets srcBuf pointer which has image
data to be written in to NAND. This function writes multiple copies of
UBL/U-Boot. There are 2 do - while loops. One of them is responsible for
writing multiple copies of image in to NAND and the other is responsible for
writing multiple pages to flash one image on NAND. Now srcBuf pointer is
incremented by number of data bytes per page after each write operation
inside inner do - while loop. After writing one copy srcBuf must be
reinitialised to original value to write same image data in to next copy. In
current implementation srcBuf is not initialised to original value so it
keeps on incrementing and writes junk data from the DDR. 

 

Please refer below partial code snap of LOCAL_NANDWriteHeaderAndData ()
function from file DM646x_FlashAndBootUtils_1_50/Common/sft/src/uartboot.c,
:

 

static Uint32 LOCAL_NANDWriteHeaderAndData

(NAND_InfoHandle hNandInfo, NANDBOOT_HeaderHandle hNandBoot, Uint8 *srcBuf)

{

        

        // Unprotect all needed blocks of the flash

 

        // Check if device is write protected

 

        // Get total number of blocks needed for each copy

 

        // Go to first good block

 

        // Keep going while we have room to place another copy

        do

        {

                // Erase the block where the header goes and the data starts

                // Clear write buffer

   // Setup header to be written

                // Write the header to page 0 of the current blockNum

  // Verify the page just written                

 

                do

                {

                        // Write the UBL or APP data on a per page basis

                        if (NAND_writePage(hNandInfo, currBlockNum,
currPageNum, srcBuf) != E_PASS)

                        {

                                // Attempt to mark block bad

                                NAND_badBlockMark(hNandInfo, currBlockNum);

                                currBlockNum++;

                                DEBUG_printString("Write failed, skipping
block!\r\n");

                                if ( (numBlksRemaining == numBlks) ||
(hNandBoot->forceContigImage) )

                                        break;    

                                else

                                {

                                        srcBuf -=
(hNandInfo->dataBytesPerPage * currPageNum);

                                        pageCnt -= currPageNum;

                                        currPageNum = 0;

                                        continue;

                                }

                        }

 

                        // Verify the page just written

                        

                        // Increment source buffer, and page number 

                        srcBuf += hNandInfo->dataBytesPerPage;

                        pageCnt++;

                        currPageNum++;

                }

                while ( One copy of UBL/U-Boot image is written to NAND  );

        }

        while( (There is enough space to accommodate new copy of
UBL/U-Boot);

 

        // Protect all blocks

 

        // We succeeded in writing all copies that would fit

        return E_PASS;

}

 

 

Bug Fix:

Please find below patch to fix above issue:

 

diff -Naur DM646x_FlashAndBootUtils_1_50/Common/sft/src/uartboot.c
DM646x_FlashAndBootUtils_1_50_updated/Common/sft/src/uartboot.c

--- DM646x_FlashAndBootUtils_1_50/Common/sft/src/uartboot.c     2009-04-08
23:03:12.000000000 +0530

+++ DM646x_FlashAndBootUtils_1_50_updated/Common/sft/src/uartboot.c
2012-07-17 21:22:27.000000000 +0530

@@ -542,6 +542,7 @@

   Uint32    *ptr;^M

   Uint32    currBlockNum,currPageNum,pageCnt,i;^M

   Uint32    numBlks, numBlksRemaining;^M

+  Uint8     *dataBuf = srcBuf;

   ^M

   // Unprotect all needed blocks of the flash ^M

   if
(NAND_unProtectBlocks(hNandInfo,hNandBoot->startBlock,hNandBoot->endBlock-hN
andBoot->startBlock+1) != E_PASS)^M

@@ -593,6 +594,7 @@

   do^M

   {^M

     numBlksRemaining = numBlks;^M

+    srcBuf = dataBuf;

    ^M

     // Erase the block where the header goes and the data starts^M

     if (NAND_eraseBlocks(hNandInfo,currBlockNum,numBlks) != E_PASS)^M

 

Please find attached patch file with  this mail.

 

Thanks,

Kiran Sutariya

Attachment: dm6467_serial_flasher_multi_copy_fix.patch
Description: Binary data

_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to