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.

Chip select problem

Other Parts Discussed in Thread: TMS320DM6437

hi,

     i am using TMS320DM6437 processor and trying to interface with NAND flash(HY27UA081G1M).

the flash is connected to CS2 of processor and it requires it to be low till the operation completes.

but in my case CS2 is pulsing.

so i want to make it as GPIO pin...

but i am not getting how to configure it as GPIO??

its in block selection can any one tell me the remedy for this??

  • Vijay,

    Are you facing any issues because of this behavior? See the PINMUX settings to configure this pin as GPIO if it is multiplexed with CS2.

  • hi Renjith,

    there is no pin muxing for CS2... it is dedicated.... but now i am facing flash utility problem....

    i am using Sample NAND Secondary Boot i downloaded it from spraa0e.

    in that i am using nand writer project write in the nand flash...

    but it is not able to write in it... giving errors...

    thanks and regards,

    vijay hiremath

  • Vijay,

    What is the error that you are getting when using nandwriter? 

  • HI Renjith,

     i am getting Data mismatch error.  while verifying... i feel its due to ECC problem... but i am not sure that its because of that...

    is it necessary to write spare area??? while writing to flash.. i have commented out both ECC and spare area writing..

    then it displays the message of "Program written successfully". but it won't write it.....

    Regards,

    Vijay Hiremath

  • Vijay,

    If you are trying to boot from NAND, then it is necessary to write the spare area. Otherwise BOOTROM will fail. If you are trying to read/write from the NAND otherwise, then you can skip ECC, but this is not recommended as NAND is prone to bit-flips or errors. 

    If you can share more screenshots or logs for the issue, it will be helpful. Its difficult to comment about the issue.

  • Hi Renjith,

    i have written an application program(.out) and converted it to AIS format using genAIS.pl.....(vij.bin)

    i am trying to load that .bin file to my NAnd flash and run the program from there...

    for writing into Nand flash i am using NandWriter utility provided by TI, (spraag0e)

    following errors will come while i am trying to write to NAND.

    [C64XP_0] Starting test of NAND Flash...
    [C64XP_0] Starting NANDWriter.
    [C64XP_0] Initializing NAND flash...
    [C64XP_0] Manufacturer ID  = 0x000000AD
    [C64XP_0] Device ID        = 0x00000079
    [C64XP_0] Pages Per Block  = 0x32
    [C64XP_0] Number of Blocks = 0x8192
    [C64XP_0] Bytes Per Page   = 0x512
    [C64XP_0]      Total blocks: 8192
    [C64XP_0]      Total pages:  262144
    [C64XP_0]      Total bytes:  134217728
    [C64XP_0] Enter the File Name
    vij.bin
    [C64XP_0] Number of blocks needed for writing: 0x00000001
    [C64XP_0] Attempting to start in block number 0x00000001
    [C64XP_0] Erasing blocks 0x00000001 through 0x00000001.
    [C64XP_0] Writing 512 bytes of data:
    [C64XP_0] eccValue = 0x0C750C75
    [C64XP_0] spareValue[gNandInfo.ECCOffset] = 0xFFFFFFFF
    [C64XP_0] NAND ECC failure!
    [C64XP_0] NAND_VerifyPage() failed.
    [C64XP_0] Skipping bad block at block number :1:
    [C64XP_0] Attempting to start in block number 0x00000002
    [C64XP_0] Erasing blocks 0x00000002 through 0x00000002.
    [C64XP_0] Writing 512 bytes of data:
    [C64XP_0] eccValue = 0x0C640C64
    [C64XP_0] spareValue[gNandInfo.ECCOffset] = 0xFFFFFFFF
    [C64XP_0] NAND ECC failure!
    [C64XP_0] NAND_VerifyPage() failed.
    [C64XP_0] Skipping bad block at block number :2:
    [C64XP_0] Attempting to start in block number 0x00000003
    [C64XP_0] Erasing blocks 0x00000003 through 0x00000003.
    [C64XP_0] Writing 512 bytes of data:
    [C64XP_0] eccValue = 0x0C5403AB
    [C64XP_0] spareValue[gNandInfo.ECCOffset] = 0xFFFFFFFF
    [C64XP_0] NAND ECC failure!
    [C64XP_0] NAND_VerifyPage() failed.
    [C64XP_0] Skipping bad block at block number :3:
    [C64XP_0] Attempting to start in block number 0x00000004
    [C64XP_0] Erasing blocks 0x00000004 through 0x00000004.
    [C64XP_0] Writing 512 bytes of data:
    [C64XP_0] eccValue = 0x0C670C67
    [C64XP_0] spareValue[gNandInfo.ECCOffset] = 0xFFFFFFFF
    [C64XP_0] NAND ECC failure!
    [C64XP_0] NAND_VerifyPage() failed.
    [C64XP_0] Skipping bad block at block number :4:
    [C64XP_0] Attempting to start in block number 0x00000005
    [C64XP_0] Erasing blocks 0x00000005 through 0x00000005.
    [C64XP_0] Writing 512 bytes of data:
    [C64XP_0] eccValue = 0x0C5703A8
    [C64XP_0] spareValue[gNandInfo.ECCOffset] = 0xFFFFFFFF
    [C64XP_0] NAND ECC failure!
    [C64XP_0] NAND_VerifyPage() failed.
    [C64XP_0] Skipping bad block at block number :5:
    [C64XP_0] Warning! Write Failed
    [C64XP_0]     : Writing data failed!! Error code = 276944744.

    Can you specify why is that Verification fails???

  • Vijay,

    Can you just post the code of NAND writer file where NAND write operation is implemented or give a link to the file? What I understand is he's getting "spareValue[gNandInfo.ECCOffset] = 0xFFFFFFFF"?

    Also can you dump the data inside the verify function and see whether its also 0xFF? If not, can you compare with the data that you've originally wrritten.

  • Hey Renjith,

                          here is the code for Nand page write,

    // 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 bytes
        flash_write_addr_cycles((PNAND_INFO)&gNandInfo,block,page);
        
        // Starting the ECC in the NANDFCR register for CS2(bit no.8)
        NAND_ECCReadAndRestart((PNAND_INFO)&gNandInfo);
        
        // Write data
        for (i=0; i<gNandInfo.numOpsPerPage; i++)
        {
            flash_write_bytes((PNAND_INFO)&gNandInfo, (void*) src, gNandInfo.bytesPerOp);    
                            
            // Read the ECC value
            eccValue[i] = NAND_ECCReadAndRestart((PNAND_INFO)&gNandInfo);
            //printf("\tWrite eccValue[i] = 0x%8.8X\r\n",eccValue[i]);    

            // Increment the pointer
            src += gNandInfo.bytesPerOp;
        }
        
        //  THE FOLLOWING IS COMMENTED SINCE NAND WRITE ECCs DON't APPEAR TO WORK
        // Write spare bytes
        for (i=0; i<MAX_NUM_ECCS; i++) {
           spareValue[i] = 0xFFFFFFFF;
        }

        for (i=0; i<gNandInfo.numOpsPerPage; i++)
        {
            // Swap the bytes for how the ROM needs them
            flash_swap_data((PNAND_INFO)&gNandInfo, &(eccValue[i]));
            // Place the ECC values where the ROM read routine expects them    
            spareValue[gNandInfo.ECCOffset] = eccValue[i];
            // Actually write the Spare Bytes               
            flash_write_bytes((PNAND_INFO)&gNandInfo, (void*)(spareValue), gNandInfo.spareBytesPerOp);
        }
                    
        // Write program end command
        flash_write_cmd((PNAND_INFO)&gNandInfo, NAND_PGRM_END);
        
        // Wait for the device to be ready
        if (NAND_WaitForRdy(NAND_TIMEOUT) != E_PASS)
            return E_FAIL;

        // Return status check result    
        return NAND_WaitForStatus(NAND_TIMEOUT);
    }

    Please can you brief what is that Ecc error?

  • Vijay,

    From this code nothing seems to be wrong from a first look. If you can put a print or break point to see the content of spareValue[] buffer it will be helpful.

    Vijay Hiremath said:
        // Write program end command
        flash_write_cmd((PNAND_INFO)&gNandInfo, NAND_PGRM_END);

    Also please attach the code for verify as well. If you can attach the complete file it will be helpful.

  • Renjith,

    www.ti.com/general/docs/lit/getliterature.tsp?...spraag0&track=no

    i am attaching the source code link.. 

    please see the full program and tell me if any corrections are there...

    Regards,

    Vijay Hiremath

    spraag0e.zip
  • Vijay,

    Again, there is nothing seems to be wrong from a high-level analysis. However can you enable couple of prints in your code and see?

    1. Can you print the contents of spareValue[] after executing this statement in write_page function?

    // Place the ECC values where the ROM read routine expects them
    spareValue[gNandInfo.ECCOffset] = eccValue[i];

    2. Can you print what is the value of the variable "gNandInfo.busWidth"? If its 16-bit, force it to 8-bit and try?

  • Renjith,

    TMS320DM6437(processor) doesn't support NAND flash which requires CS to be low for Tr(read time) ,

    and our NAND flash(HY27UA081G1m) requires CS to be low for Tr time. hence We have made CS of flash low by connecting it to ground.

    is that creating any issue????

    Regards,

    Vijay Hiremath

  • Vijay,

    If DM6437 doesn't support the low timing, then it will be applicable to data lines timing as well. This can be one reason for the failure. But can you dump the data as I requested earlier? It will give better idea on the problem.

  • Renjith,

    both of your valuable suggestions i implemented in code and saw that,

    bus width is 8-bit(as required), but spare value will be swapped and written it to the ROM.

    and also while reading it back it reads different value.

    ex:

    [C64XP_0]     Write eccValue[i] = 0x0A840A84
    [C64XP_0]    swapped eccValue[i] = 0x840A840A
    [C64XP_0]     Read eccValue[i] = 0x0F0D0F0D

    i am not understanding why is it spare value swapped and written to ROM?

    and why is it reads different value at the same address?

    Regards,

    Vijay Hiremath

  • Vijay,

    Basically whatever you are seeing is junk. There is something fundamentally wrong with the whole thing. Can you tell me what is the value set in the EMIF controller registers, AWCCR, A1CR, A2CR? 

  • Renjith,

    we didn't configure AWCCR register but its value after reset(default) is 0xF0000080.

    A1CR = 0x3FFFFFFC;

    A2CR = 0x3FFFFFFC;

    and one more thing i have written a code for interfacing NAND flash.

    which works perfectly fine with our board. i am able to read, write and erase flash contents.

    the problem occurs only when i use NANDWriter project to burn the flash....

    Regards,

    Vijay Hiremath

  • Vijay,

    Can you try AWCCR with the values 0x100000FF and 0x000000FF?

  • Renjith,

     i tried both the configuration but didn't work... error remains the same....

    #define MAX_PAGE_SIZE            (4224)          /* Including Spare Area */
    #define MAX_BYTES_PER_OP        (512)           /* Bytes per operation (device constrained by ECC calculations) */
    #define MAX_BYTES_PER_OP_SHIFT  (9)             /* Num of right shifts to enable division by MAX_BYTES_PER_OP */
    #define SPAREBYTES_PER_OP_SHIFT (5)             /* Num of right shifts to get spare_bytes per op from bytes per op */
    #define MAX_NUM_ECCS            (MAX_PAGE_SIZE / MAX_BYTES_PER_OP) /* Maximum Number of ECCs to calculate */
    #define SPARE_REGION_SIZE       (MAX_NUM_ECCS *  (MAX_BYTES_PER_OP >> SPAREBYTES_PER_OP_SHIFT))/* Maxium Size of Spare Region */
    #define MAX_SPARE_BYTES_PER_OP  (MAX_BYTES_PER_OP >> SPAREBYTES_PER_OP_SHIFT)
    #define BAD_BLOCK_FLAG_OFFSET   (1)             // Byte offset into spare area to where BAD BLOCK FLAG is written
    #define BAD_BLOCK_FLAG          (0xBADDBADD)    // Bad Block Indicator

    my page size is 512+16(spare)

    but in the NANDWriter it is specified as 4224.

    is that correct???

    Regars,

     Vijay Hiremath

  • Vijay,

    Vijay Hiremath said:

    [C64XP_0] Manufacturer ID  = 0x000000AD
    [C64XP_0] Device ID        = 0x00000079
    [C64XP_0] Pages Per Block  = 0x32
    [C64XP_0] Number of Blocks = 0x8192
    [C64XP_0] Bytes Per Page   = 0x512
    [C64XP_0]      Total blocks: 8192
    [C64XP_0]      Total pages:  262144
    [C64XP_0]      Total bytes:  134217728

    I think it detects your NAND properly. It shows 512 bytes. But I think some thing basic is missing in the configuration. Will you be able to send one board to me. I can fix it and send back.

  • Renjith,

    Thank you very much for your concern but i am working parallel in application as well as booting and i have only one board.

    so i will not be able to send the board. you have already given me lots of valuable suggestions...

    so i will request you to please answer to my queries. i hope i will be able to solve the problem.

    once again thank you very much for your valuable suggestion....

    Thanks and Regards,

    Vijay Hiremath

  • Vijay,

    I can help you through the forum. But this eats out a lot of my bandwidth. It will be easier to debug or imagine about the situation when one has basic things like schematics, boards, logs etc in place. 

  • Hi Renjith,

    I got the problem, whenever we write the data into flash, it starts writing from 3rd byte of Flash.

    hence i was getting that verification error, can you suggest me anything with this issue?

    why it starts from 3rd byte of Flash?

  • Vijay,

    Check for any writes (by mistake) to the data port? What is the value that's written to the first two bytes? Is if 0xFF or something else? If so, is it consistently same across all pages? 

  • Hi Vijay

    I have the problem that you asked in the forum.

    Do you solve the problem?

    Thanks and regards

    Songxia