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.

CCS/tms320c6457: tms320c6457 NDK not work

Part Number: TMS320C6457

Tool/software: Code Composer Studio

I use a board of our own design. The problem with the NDK. Board is initialized, but the data is not coming. TCP client on the computer is not connected. 

I think interrupts are not working.

Soft:

Code Composer Studio 7.3

bios_6_42_03_35

MCSDK 1.0.0.8 (CSL)

ndk_2_23_02_03

xdctools_3_32_02_25

Compiler 7.4.18

Log initialization

MAC Address read from EFUSE: 3c-2d-b7-d9-35-8e
EFUSED MAC Address = 3c-2d-b7-d9-35-8e
SGMII reset successful........
SGMII config successful........
SerDes should be up and running ...
EMAC has been started successfully
Registeration of the EMAC Successful
Network Added: If-1 192.168.2.133

Code HwPktOpen

uint HwPktOpen( PDINFO *pi )
{
	Uint32          i, j, stat;
    PBM_Handle      hPkt;
	EMAC_Config     ecfg;
	EMAC_AddrConfig *addrCfg;
	SGMII_Config    SgmiiCfg;
	unsigned short tmp;

	pPDI = pi;

    /* Initialize EMAC setup */
	mmZeroInit( &RxQueue, sizeof(PKT_QUEUE) );
    mmZeroInit( &TxQueue, sizeof(PKT_QUEUE) );
    mmZeroInit( &ecfg, sizeof(EMAC_Config) );

	ecfg.EMACCommonConfig.UseMdio            = 1;
    ecfg.EMACCommonConfig.CoreNum            = 0;
    ecfg.EMACCommonConfig.MdioPhyAddr = 0;
	ecfg.EMACCommonConfig.PktMTU             = 1514;
	ecfg.EMACCoreConfig.NumOfMacAddrs = 2;        /* We are using two channels, so lets configure two MAC addresses */
	ecfg.EMACCoreConfig.DescBase           = EMAC_DESC_BASE_L2; //EMAC_DESC_BASE_CPPI;

	PktMTU                  = ecfg.EMACCommonConfig.PktMTU;

	
    /* Queue up some initialized receive buffers */
	for( i=0; i<PKT_MAX; i++ )
	{
		hPkt = PBM_alloc(ecfg.EMACCommonConfig.PktMTU);
        /* Couldnt allocate memory, return error */
		if (hPkt == NULL)
			return 1;
		rcv_pkt[i].AppPrivate   = (Uint32)hPkt;
		rcv_pkt[i].pDataBuffer  = PBM_getDataBuffer(hPkt);
		rcv_pkt[i].BufferLen    = PBM_getBufferLen(hPkt);
        Queue_push( &RxQueue, &rcv_pkt[i] );
    }

    /* Queue up some transmit buffers */
	for( i=0; i<PKT_MAX; i++ )
	{
        Queue_push( &TxQueue, &send_pkt[i] );
    }

    /* Enable SGMII configuration, Gigabit and Full duplex operation on EMAC */
    ecfg.EMACCommonConfig.ModeFlags              = EMAC_CONFIG_MODEFLG_FULLDUPLEX |
                                  EMAC_CONFIG_MODEFLG_GIGABIT;

    /* Autonegotiation is supported by underlying PHY. Turn it on */
	ecfg.EMACCommonConfig.MdioModeFlags          = MDIO_MODEFLG_AUTONEG | MDIO_MODEFLG_SPECPHYADDR;

    ecfg.EMACCoreConfig.ChannelInfo.TxChanEnable = 0x9;  /* 00001001, Enable channel 0 for IP packets, channel 3 for Raw Packets Transmission */
	ecfg.EMACCoreConfig.ChannelInfo.RxChanEnable = 0x9;  /* 00001001, Enable channel 0 for IP packets, channel 3 for Raw Packets Reception */

    ecfg.EMACCoreConfig.RxMaxPktPool           = RXMAXPKTPOOL;
    ecfg.EMACCoreConfig.pfcbGetPacket          = &GetPacket;
    ecfg.EMACCoreConfig.pfcbFreePacket         = &FreePacket;
    ecfg.EMACCoreConfig.pfcbRxPacket           = &RxPacket;
    ecfg.EMACCoreConfig.pfcbStatus             = &StatusUpdate;
    ecfg.EMACCoreConfig.pfcbStatistics         = &StatisticsUpdate;

	ecfg.EMACCoreConfig.MacAddr = (EMAC_AddrConfig **)
     		       mmAlloc(ecfg.EMACCoreConfig.NumOfMacAddrs * sizeof(EMAC_AddrConfig *));

	for ( j=0; j<ecfg.EMACCoreConfig.NumOfMacAddrs; j++ )
    {
		ecfg.EMACCoreConfig.MacAddr[j] = (EMAC_AddrConfig *)mmAlloc(sizeof(EMAC_AddrConfig));
	}

    /* Generate a default MAC address to use */
    for( j=0; (Uint8)j<(ecfg.EMACCoreConfig.NumOfMacAddrs); j++ )
    {
		addrCfg = ecfg.EMACCoreConfig.MacAddr[j];
		addrCfg->ChannelNum = 0;
		if( j == 1 )
			addrCfg->ChannelNum = 1;
		if( j == 2  )
			addrCfg->ChannelNum = 2;
		if( j == 3  )
			addrCfg->ChannelNum = 3;
		if( j == 4  )
			addrCfg->ChannelNum = 4;
		if( j == 5  )
			addrCfg->ChannelNum = 5;
		if( j == 6  )
			addrCfg->ChannelNum = 6;
		if( j == 7  )
			addrCfg->ChannelNum = 7;
   		for( i=0; i<6; i++ )
        {
		 	addrCfg->Addr[i] = j * 0x10 + i ;
		}
	}

	addrCfg = ecfg.EMACCoreConfig.MacAddr[0];

    /*  Check if EMAC_getConfig had returned a valid MAC address to use. If not,
     *  use the default generated above.
     */
    for( i=0; (i<6) && (!(bMacAddr[i])); i++ );
    if( i==6 )
    {
		/* Copy the MAC Address into the PDI Structure */
        mmCopy( (void *)&pPDI->bMacAddr[0], (void *)&addrCfg->Addr[0], 6 );
        PutMes("Since EFUSE MAC address is Zero we use the MAC Address = %02x-%02x",
               pPDI->bMacAddr[0],pPDI->bMacAddr[1]);
        PutMes("Since EFUSE MAC address is Zero we use the MAC Address = %02x-%02x",
               pPDI->bMacAddr[2],pPDI->bMacAddr[3]);
        PutMes("Since EFUSE MAC address is Zero we use the MAC Address = %02x-%02x",
               pPDI->bMacAddr[4],pPDI->bMacAddr[5]);
    }
    else
    {
        mmCopy( (void *)&addrCfg->Addr[0], (void *)&bMacAddr[0], 6 );

		/* Copy the MAC Address into the PDI Structure */
		mmCopy ((void *)&pPDI->bMacAddr[0], (void *)&addrCfg->Addr[0], 6);

        PutMes("EFUSED MAC Address = %02x-%02x",
               pPDI->bMacAddr[0],pPDI->bMacAddr[1]);
        PutMes("EFUSED MAC Address = %02x-%02x",
               pPDI->bMacAddr[2],pPDI->bMacAddr[3]);
        PutMes("EFUSED MAC Address = %02x-%02x",
               pPDI->bMacAddr[4],pPDI->bMacAddr[5]);
    }


    hEMAC = (Handle)&EMACObj;
    memset(&EMACCore, 0, sizeof(EMAC_Core));
    memset(&EMACObj, 0, sizeof(EMAC_Device));

    i = EMAC_open(0, (Handle)0x12345678, &ecfg, hEMAC, &EMACCore);

    if( i )
	{
        PutMes("EMAC OPEN Returned error %d", i, 0);
		csl_errors++;
		return i;
	}

	Interrupt_init();

	((EMAC_Device *)hEMAC)->MdioDev.phyAddr = 0;
    ((EMAC_Device *)hEMAC)->MdioDev.regId = 0;
    ((EMAC_Device *)hEMAC)->MdioDev.ModeFlags = MDIO_MODEFLG_AUTONEG | MDIO_MODEFLG_SPECPHYADDR;

    hMDIO = (&((EMAC_Device *)hEMAC)->MdioDev);


    /* Wait for link to come up */
    pi->TxFree = 0;

    i = SGMII_reset();

    if ( i == 0 )
        PutMes("SGMII reset successful........", 0, 0);
    else
    {
        csl_errors++;
        PutMes("SGMII reset NOT successful........", 0, 0);
    }

    /* set sgmii lock mode */
    *(volatile Uint32 *)(CSL_ECTL_0_REGS + 0x88) = 1;

    SgmiiCfg.masterEn   = 0x1;          // Disable SGMII Master
    SgmiiCfg.loopbackEn = 0x0;          // Disable SGMII loopback
    SgmiiCfg.txConfig   = 0x00000a21;   // Enable tx
    SgmiiCfg.rxConfig   = 0x00081021;   // Enable rx


    // Setup for 125 MHz ref clock
    SgmiiCfg.auxConfig  = 0x0000000B;   // Enable PLL
    SgmiiCfg.modeOfOperation = SGMII_MODE_OF_OPERATION_WITH_AN;    //Auto Negotiation on

    i = SGMII_config(&SgmiiCfg);

    if( i == 0 )
        PutMes("SGMII config successful........", 0, 0);
    else
    {
        csl_errors++;
        PutMes("SGMII config NOT successful........", 0, 0);
        return i;
    }

    /* wait for the sgmii lock */
    do
    {
        stat = SGMII_REGS->STATUS;
        stat = stat & 0x10;
    } while( stat != 0x10 );    

    /* wait for the Link to Come Up */
    do
    {
        stat = SGMII_REGS->STATUS;
        stat = stat & 0x5;
    } while( stat != 0x5 );

    PutMes("SerDes should be up and running ...", 0, 0);


    /* Return success */
    return 0;
}