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.

DM6437 Nand interfacing problem

Other Parts Discussed in Thread: TMS320DM6437

HI,

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

i am able to read the electronic signature by issuing commands.

but when issue erase, program, read command its not responding.

the initial content of flash its displaying as 0x0000(in CCS memory window) i feel it should be 0xFFFF.

can anyone suggest me any solution for this problem?

  • How are you checking the memory window for NAND contents?

  • hi Renjith,

    sorry for late reply...

     i am checking memory window of flash.....

    view -> memory window....(while debugging)

    is it the right way to check flash contents???

    i am not able to erase or program the flash...

  • Vijay,

    This is not the right way to check. You've to follow the protocol and see the function that reads the NAND page. You can check the buffer passed to the function for debugging. 

  • Renjith,

    as per the datasheet i gave the command, address and data, and when i check for status it gives operation successful.

    but when i read it back... it gives 0x00.

    and you mentioned about buffer... what is that can you elaborate?

    as per the protocol i am following the right one...

  • From where are you reading the data? Where you storing the read data? By buffer I meant the place where the data is stored. 

    May I know what exactly is your problem?

  • Renjith,

    i am interfacing TMS320DM6437 with flash HY27UA081G1M series.

    flash is connected to CS2 of the processor which is at the address 0x42000000.

    in order to give command, address and data, we should add 0x10, 0x0B,0x00 to the base address(0x42000000)

    respectively.

    when i issue read flash id command (i.e 0x90) 0n address 0x42000010.

    device id and manufacture's id are coming properly. but when issue block erase command

    i.e

    0x42000010 = 60h

    address for next 3 cycles,

    0x4200000B = 0x00;

    0x4200000B = 0x00;

    0x4200000B = 0x00;

    and then confirm code

    0x42000010 = D0h

    i will wait for ready busy pin to go low.

    and then i will give read command as mentioned above i read the data in an array which i store in internal RAM(0x01081000).

    when i check that array(buffer) it reads as 0x00. which has to be 0xFF rite?

    i am reading from address: 0x42000000;

    which external memory address.

    even when i gave write command it is same as above.

    this is the problem that i am facing.

    .

  • Post the code for erase and read function. Have you written the code yourself? or Have you used some other reference? If not, then try to usu UBL driver as reference, which will make your life easy.

  • hey Renjith,

    this is my code,

    uint8_t Flash()
    {

        uint8_t dat[512]={1,2,3,4},* data = 0,data1=0;
        uint8_t dat2[512]={0,0,0,0};
        uint32_t start = 0x00000000;
        int32_t j=0,i,ecc;
        uint8_t *src8 = (uint8_t*)0x42000000;
        uint16_t invalid_bank[80]={0};
        volatile uint8_t *src = (uint8_t*)start;
        volatile uint8_t *src2 = (uint8_t*)0x42000050;
    //    uint16_t cnt = TIME_OUT,status=0,cnt2 = TIME_OUT;
        volatile uint8_t device_id=0, manufacture_id=0;
        uint32_t FLASH_BASE_CMD = 0x42000010;
        uint32_t FLASH_BASE_ADR = 0x4200000B;
        uint32_t FLASH_BASE_DATA = 0x42000000;
        uint32_t FLASH_BASE_ADDR= 0x42040000;
        volatile uint8_t *ADR = (uint8_t*)FLASH_BASE_ADR;
        volatile uint8_t *DAT = (uint8_t*)FLASH_BASE_DATA;
        volatile uint8_t *CMD = (uint8_t*)FLASH_BASE_CMD;



        //Reading Device ID

        *CMD = 0x90;
        manufacture_id  = *DAT;
        device_id = *DAT;
        start = 0x00000000;
        //erase block
        *CMD = 0x60;
        *ADR = (start >> 9);
        *ADR = (start >> 17);
        *ADR = (start >> 25);
        *CMD = 0xD0;
        while(!((NAND_READ_RB & NAND_NANDFSR_READY)&&( nand_timeout-- > 0)));
        *CMD = 0x70;
        data = (uint8_t*)DAT;



        //write
        *CMD = 0x00;
        for(i=0;i<256;i++)
        {
        *CMD = 0x80;
        *ADR = start;
        *ADR = (start >> 9);
        *ADR = (start >> 17);
        *ADR = (start >> 25);
        *DAT = 0xAA;
        start = start+8;
        *CMD = 0x10;
        }


        while(!((NAND_READ_RB & NAND_NANDFSR_READY)&&( nand_timeout-- > 0)));
        *CMD = 0x70;
        data = (uint8_t*)DAT;

        //read
            *CMD = 0x00;
            *ADR = start;
            *ADR = (start >> 9);
            *ADR = (start >> 17);
            *ADR = (start >> 25);
            while(!((NAND_READ_RB & NAND_NANDFSR_READY)&&( nand_timeout-- > 0)));
            for(i=0;i<512;i++)
            {
                dat[i] = *src8++;
            }


            //for erasing full flash
                for(j=0;j<1892;j++)
                {
                    *CMD = 0x00;
                    *CMD = 0x60;
                    *ADR = (start>>9);
                    *ADR = (start>>17);
                    *ADR = (start>>25);
                    *CMD = 0xD0;
                    while(!((NAND_READ_RB & NAND_NANDFSR_READY)&&(nand_timeout-- > 0)));
                    NAND_CMD( CMD_STATUS );
                    data1 = *DAT;
                    if(*DAT & 0x01)
                    {
                        printf("error in block erase %d",j);
                    }
                    start = start + 0x4000;

                }
                // for checking bad blocks..
                for(j=0;j<1892;j++)
                {
                *CMD = 0x00;
                for(i=0;i<512;i++)
                {
                    dat[i] = *src++;
                }
                if(dat[0] == 0xFF)
                {
                    printf("good block %d",j);
                }
                start = start +0x4000;

                }

        return(0);
    }

    this is my code which i modified it for my testing purpose.

    when i try utility provided by TI, it gives some error while flashing the code.

  • Vijay,

    I didn't go in detail. From a high level,  the write routine is completely wrong. You should send the command only once and send the data continuously to the data port. 

    Vijay Hiremath said:
    //write
        *CMD = 0x00;
        for(i=0;i<256;i++)
        {
        *CMD = 0x80;
        *ADR = start;
        *ADR = (start >> 9);
        *ADR = (start >> 17);
        *ADR = (start >> 25);
        *DAT = 0xAA;
        start = start+8;
        *CMD = 0x10;
        }

    Also you shouldn't be incrementing src8 address as you are reading from the port not a buffer. 

    Vijay Hiremath said:
    for(i=0;i<512;i++)
            {
                dat[i] = *src8++;
            }

    What I will recommend you to check it to see UBL or X-loader code where NAND driver is implemented properly.

  • hi Renjith,

    sorry for late reply...

    now i have modified the code according to your suggestion,

    uint8_t Flash()
    {

        uint8_t dat[512]={1,2,3,4},* data = 0,data1=0;
        uint32_t start = 0x00000000;
        int32_t j=0,i;
        uint8_t *src8 = (uint8_t*)0x42000000;
    //    volatile uint8_t *src = (uint8_t*)start;
    //    volatile uint8_t *src2 = (uint8_t*)0x42000050;
    //    uint16_t cnt = TIME_OUT,status=0,cnt2 = TIME_OUT;
        volatile uint8_t device_id=0, manufacture_id=0;
        uint32_t FLASH_BASE_CMD = 0x42000010;
        uint32_t FLASH_BASE_ADR = 0x4200000B;
        uint32_t FLASH_BASE_DATA = 0x42000000;
        volatile uint8_t *ADR = (uint8_t*)FLASH_BASE_ADR;
        volatile uint8_t *DAT = (uint8_t*)FLASH_BASE_DATA;
        volatile uint8_t *CMD = (uint8_t*)FLASH_BASE_CMD;

        //Reading Device ID
        *CMD = 0x90;
        manufacture_id  = *DAT;
        device_id = *DAT;
        *CMD = 0xFF;                            //reset command

        //erase block
        *CMD = 0x60;
        *ADR = (start >> 9);
        *ADR = (start >> 17);
        *ADR = (start >> 25);
        *CMD = 0xD0;
        waitloop(1000);
        while(!((NAND_READ_RB & NAND_NANDFSR_READY)&&( nand_timeout-- > 0)));
        *CMD = 0x70;
        data = (uint8_t*)DAT;
        if(*data == 0x01)
        {
            printf("Operation Failed");
        }
        *CMD = 0xFF;                            //reset command

        //read
        *CMD = 0x00;
        *ADR = start;
        *ADR = (start >> 9);
        *ADR = (start >> 17);
        *ADR = (start >> 25);
        waitloop(1000);
        while(!((NAND_READ_RB & NAND_NANDFSR_READY)&&( nand_timeout-- > 0)));
        for(i=0;i<512;i++)
        {
            dat[i] = *src8;
        }
        *CMD = 0xFF;                            //reset command


        //write
        *CMD = 0x00;
        *CMD = 0x80;
        *ADR = start;
        *ADR = (start >> 9);
        *ADR = (start >> 17);
        *ADR = (start >> 25);
        for(i=0;i<528;i++)
        {
        *DAT = 0xAA;
        }
        *CMD = 0x10;
        do
        {
            data1 = *DAT;
        }while(!(data1 & 40));
        waitloop(1000);
        while(!((NAND_READ_RB & NAND_NANDFSR_READY)&&( nand_timeout-- > 0)));

        *CMD = 0x70;
        data1 = *DAT;
        if(data1 == 0x01)
        {
            printf("Operation Failed");
        }

        *CMD = 0xFF;                            //reset command

            //read
            *CMD = 0x00;
            *ADR = start;
            *ADR = (start >> 9);
            *ADR = (start >> 17);
            *ADR = (start >> 25);
            waitloop(1000);
            while(!((NAND_READ_RB & NAND_NANDFSR_READY)&&( nand_timeout-- > 0)));
            for(i=0;i<528;i++)
            {
                dat[i] = *src8;
            }
            *CMD = 0xFF;                            //reset command

        return(0);
    }

    i have used spraag0e utility but still i am not able interface with Flash.

    can you please guide me on this??

    Thanks and regards,

    Vijay Hiremath

  • Vijay,

    Check the UBL or u-boot code for better understanding of NAND driver working.