TMS320C6678 DSP单双网口切换 + 千兆/百兆网速切换

关于网络模块的配置在ti论坛有很多讨论,但是问题很多很杂,很难从里面获取有效信息,我根据调板经验将关于本文主题的内容整理出来,供大家讨论参考,希望我在这上面浪费的时间能为大家节省时间。

如何使helloworld_evmc6678l工程支持双网口(或支持port 0)

由于pdk6678_1_1_2_x中默认的网络驱动是关于port1的配置,要使程序同时支持两个网口(或支持port0),可以按下面的步骤修改:

步骤1.

导入NIMU工程(C:\ti\pdk_C6678_1_1_2_6\packages\ti\transport\ndk\nimu),修改nimu_eth.c文件。修改方法:

	EmacSend()函数中,移除下面这行代码:

Cppi_setPSFlags (Cppi_DescType_HOST, (Cppi_Desc *)pCppiDesc, (1<<gTxPort));

	EMACInit_Core()函数中,用下面的代码替换"#ifndef SIMULATOR_SUPPORT""#else" 之间的代码:

platform_get_emac_info(0, &emac_info);
memcpy(ptr_pvt_data->pdi.bMacAddr, emac_info.mac_address, 6);

	Init_Switch()函数中,把下面的代码放到Init_Switch()函数的最后:
   
// Configure "Learning"/"Forward" state for all 3 ports
int portNum;
for (portNum=0; portNum<3; portNum++)
{
    CSL_CPSW_3GF_ALE_PORTCONTROL alePortControlCfg;
    alePortControlCfg.portState             =   ALE_PORTSTATE_FORWARD;
    alePortControlCfg.dropUntaggedEnable    =   0;
    alePortControlCfg.vidIngressCheckEnable =   0;
    alePortControlCfg.noLearnModeEnable     =   0;
    alePortControlCfg.mcastLimit            =   0;
    alePortControlCfg.bcastLimit            =   0;
    CSL_CPSW_3GF_setAlePortControlReg (portNum, &alePortControlCfg);
}

	用下面的函数替代整个Init_Cpsw()函数:

int32_t Init_Cpsw (uint32_t mtu, uint8_t* myMACAddress)
{                      
    uint8_t portMac[6] = {0x1, 0x1, 0x1, 0x1, 0x1, 0x1};
    Init_MAC(0, portMac, mtu);

    portMac[0] = 2;
    Init_MAC(1, portMac, mtu);

    /* Setup the Phys by initializing the MDIO - not needed for Simulator*/
    Init_MDIO();

    /* Setup the Ethernet switch finally. */
    Init_Switch(mtu);

    /* CPSW subsystem setup done. Return success */
    return 0;
}

步骤2.

导入Platform_lib工程(C:\ti\pdk_C6678_1_1_2_6\packages\ti\platform\evmc6678l\platform_lib),修改platform.c,如果要支持双网口,把Init_SGMII(0);的注释去掉;如果要修改使之只支持port0,去掉Init_SGMII(0)的注释,并注释Init_SGMII(1)。

步骤3.

  • rebuild “Platform_lib工程”
  • rebuild “NIMU工程”
  • 向"helloworld_evmc6678l工程"的工程属性(properties)的predefined symbols中加入_INCLUDE_NIMU_CODE和C66_PLATFORMS。如下图所示:
    TMS320C6678 DSP单双网口切换 + 千兆/百兆网速切换_第1张图片
  • rebuild "helloworld_evmc6678l工程“

如何修改ti文件以配置连接为千兆网/百兆网

打开C:\ti\pdk_C6678_1_1_2_6\packages\ti\platform\evmc6678l\platform_lib\src中的
evmc6678_phy.c,找到void Init_SGMII (uint32_t macPortNum)函数,如何修改见函数体内:

void Init_SGMII (uint32_t macPortNum)
{
    CSL_SGMII_ADVABILITY    sgmiiCfg;
    CSL_SGMII_STATUS        sgmiiStatus;

/* Reset the port before configuring it */
CSL_SGMII_doSoftReset (macPortNum);
while (CSL_SGMII_getSoftResetStatus (macPortNum) != 0);

/* 这段是关于port1的配置,如果板子为单网口,一般走的是port0 */
 if (macPortNum == 1) {
    /* Hold the port in soft reset and set up
     * the SGMII control register:
     *      (1) Disable Master Mode
     *      (2) Enable Auto-negotiation
     */
    CSL_SGMII_startRxTxSoftReset (macPortNum);
    CSL_SGMII_disableMasterMode (macPortNum);
    CSL_SGMII_enableAutoNegotiation (macPortNum);
    CSL_SGMII_endRxTxSoftReset (macPortNum);

    /* Setup the Advertised Ability register for this port:
     *      (1) Enable Full duplex mode
     *      (2) Enable Auto Negotiation
     *      (3) Enable the Link
     */
     /* 这里配置连接网络为千兆网/百兆网 */
//        sgmiiCfg.linkSpeed      =   CSL_SGMII_1000_MBPS;
        sgmiiCfg.linkSpeed      =   CSL_SGMII_100_MBPS;
        sgmiiCfg.duplexMode     =   CSL_SGMII_FULL_DUPLEX;
        CSL_SGMII_setAdvAbility (macPortNum, &sgmiiCfg);

    do
    {
        CSL_SGMII_getStatus(macPortNum, &sgmiiStatus);
    } while (sgmiiStatus.bIsLinkUp != 1);

    /* Wait for SGMII Autonegotiation to complete without error */
    do
    {
        CSL_SGMII_getStatus(macPortNum, &sgmiiStatus);
        if (sgmiiStatus.bIsAutoNegError != 0)
            return; /* This is an error condition */
    } while (sgmiiStatus.bIsAutoNegComplete != 1);
}
/* 这段是关于port0的配置 */
if (macPortNum == 0) {
    /* Hold the port in soft reset and set up
     * the SGMII control register:
     *      (1) Disable Master Mode
     *      (2) Enable Auto-negotiation
     */
    CSL_SGMII_startRxTxSoftReset (macPortNum);
    CSL_SGMII_disableMasterMode (macPortNum);
    CSL_SGMII_enableAutoNegotiation (macPortNum);
    CSL_SGMII_endRxTxSoftReset (macPortNum);

    /* Setup the Advertised Ability register for this port:
     *      (1) Enable Full duplex mode
     *      (2) Enable Auto Negotiation
     *      (3) Enable the Link
     */
     /* 这里配置连接网络为千兆网/百兆网 */
//        	sgmiiCfg.linkSpeed      =   CSL_SGMII_1000_MBPS;
        sgmiiCfg.linkSpeed      =   CSL_SGMII_100_MBPS;
        sgmiiCfg.duplexMode     =   CSL_SGMII_FULL_DUPLEX;
        sgmiiCfg.bLinkUp        =   1;
        CSL_SGMII_setAdvAbility (macPortNum, &sgmiiCfg);

    do
    {
        CSL_SGMII_getStatus(macPortNum, &sgmiiStatus);
    } while (sgmiiStatus.bIsLinkUp != 1);
 }

/* All done with configuration. Return Now. */
return;
}

你可能感兴趣的:(SRIO学习,DSP6678,SRIO调试教程)