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.

6678网口ping不通,请求指教!

Other Parts Discussed in Thread: SYSBIOS

各位好!

问题RT:

硬件:自己的板卡

软件:基于Helloworld例程修改,替换了GEL等初始化

运行程序后,输出如下:

TCP/IP Stack 'Hello World!' Application

PASS successfully initialized
Ethernet subsystem successfully initialized
Ethernet eventId : 48 and vectId (Interrupt) : 7
Registration of the EMAC Successful, waiting for link up ..
Network Added: If-1:192.168.2.100

从上面看,好像是已经初始化成功了,可是通过ping 192.168.2.100,会出现超时,或请求失败!请大神帮忙分析原因!谢谢!

PC IP是192.168.2.114

  • 补充:网口水晶头的指示灯已经亮了

  • 补充代码:请大神指教

    /*
    * helloWorld_bios6.c
    *
    * TCP/IP Stack 'Hello World!' Example ported to use BIOS6 OS.
    *
    * Copyright (C) 2007, 2011 Texas Instruments Incorporated - http://www.ti.com/
    *
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    *
    * Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    *
    * Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the
    * distribution.
    *
    * Neither the name of Texas Instruments Incorporated nor the names of
    * its contributors may be used to endorse or promote products derived
    * from this software without specific prior written permission.
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    *
    */

    //--------------------------------------------------------------------------
    // IP Stack 'Hello World!' Example
    //
    // This is a skeleton application, intended to provide application
    // programmers with a basic Stack setup, to which they can start
    // adding their code.
    //
    // To test it as is, use with helloWorld.exe from \winapps directory
    //

    #include "Init.h"

    #include <stdio.h>
    #include <ti/ndk/inc/netmain.h>

    /* BIOS6 include */
    #include <ti/sysbios/BIOS.h>

    /* Platform utilities include */
    #include "ti/platform/platform.h"
    #include "ti/platform/resource_mgr.h"

    #include <string.h>

    /* XDC types include */
    #include <xdc/std.h>

    /* Chip Level definitions include */
    #include <ti/csl/csl_chip.h>
    #include <ti/csl/csl_bootcfgAux.h>

    /* CSL EMAC include */
    #include <ti/csl/csl_cpsw.h>
    #include <ti/csl/csl_cpsgmii.h>
    #include <ti/csl/csl_cpsgmiiAux.h>
    #include <ti/csl/cslr_cpsgmii.h>
    #include <ti/csl/csl_mdio.h>
    #include <ti/csl/csl_mdioAux.h>

    /* BootCfg module include */
    #include <ti/csl/csl_bootcfg.h>
    #include <ti/csl/csl_bootcfgAux.h>

    #include <cpsw_singlecore.h>


    /* Platform Information - we will read it form the Platform Library */
    platform_info gPlatformInfo;


    //---------------------------------------------------------------------------
    // Title String
    //
    char *VerStr = "\nTCP/IP Stack 'Hello World!' Application\n\n";
    int *sendbuf = (int*)0x00820000;//LQ_add

    // Our NETCTRL callback functions
    static void NetworkOpen();
    static void NetworkClose();
    static void NetworkIPAddr( IPN IPAddr, uint IfIdx, uint fAdd );

    // Fun reporting function
    static void ServiceReport( uint Item, uint Status, uint Report, HANDLE hCfgEntry );

    // External references
    extern int dtask_tcp_echo();

    //---------------------------------------------------------------------------
    // Configuration
    //
    char *HostName = "tidsp";
    char *LocalIPAddr = "192.168.2.100";
    char *LocalIPMask = "255.255.255.0"; // Not used when using DHCP
    char *GatewayIP = "192.168.2.1"; // Not used when using DHCP
    char *DomainName = "demo.net"; // Not used when using DHCP
    char *DNSServer = "0.0.0.0"; // Used when set to anything but zero

    /*************************************************************************
    * @b EVM_init()
    *
    * @n
    *
    * Initializes the platform hardware. This routine is configured to start in
    * the evm.cfg configuration file. It is the first routine that BIOS
    * calls and is executed before Main is called. If you are debugging within
    * CCS the default option in your target configuration file may be to execute
    * all code up until Main as the image loads. To debug this you should disable
    * that option.
    *
    * @param[in] None
    *
    * @retval
    * None
    ************************************************************************/
    //void EVM_init()
    //{
    // platform_init_flags sFlags;
    // platform_init_config sConfig;
    // /* Status of the call to initialize the platform */
    // int32_t pform_status;
    //
    // Init_SGMII_SERDES();
    // //((int)* 0x02620340)=0x00000081;
    //
    // /*
    // * You can choose what to initialize on the platform by setting the following
    // * flags. Things like the DDR, PLL, etc should have been set by the boot loader.
    // */
    // memset( (void *) &sFlags, 0, sizeof(platform_init_flags));
    // memset( (void *) &sConfig, 0, sizeof(platform_init_config));
    //
    // sFlags.pll = 0; /* PLLs for clocking */
    // sFlags.ddr = 0; /* External memory */
    // sFlags.tcsl = 1; /* Time stamp counter */
    //#ifdef _SCBP6618X_
    // sFlags.phy = 0; /* Ethernet */
    //#else
    // sFlags.phy = 1; /* Ethernet */
    //#endif
    // sFlags.ecc = 0; /* Memory ECC */
    //
    // sConfig.pllm = 0;//0 /* Use libraries default clock divisor */
    //
    // pform_status = platform_init(&sFlags, &sConfig);
    //
    // /* If we initialized the platform okay */
    // if (pform_status != Platform_EOK) {
    // /* Initialization of the platform failed... die */
    // while (1) {
    // (void) platform_led(1, PLATFORM_LED_ON, PLATFORM_USER_LED_CLASS);
    // (void) platform_delay(50000);
    // (void) platform_led(1, PLATFORM_LED_OFF, PLATFORM_USER_LED_CLASS);
    // (void) platform_delay(50000);
    // }
    // }
    //
    //}
    //Int32 Init_SGMII_SERDES(Void);
    //---------------------------------------------------------------------
    // Main Entry Point
    //---------------------------------------------------------------------
    int main()
    {


    C6678_Board_Init();//自己的板卡初始化,主要是pll ddr等


    *sendbuf = 0x87654321;

    /* Start the BIOS 6 Scheduler */
    BIOS_start ();
    }

    //
    // Main Thread
    //
    //
    //Int32 Init_SGMII_SERDES(Void)
    //{
    //
    //
    // // if (cpswSimTest)//这一部分最好初始化一下,在线调试的时候GEL文件中也会有初始化。
    // // {
    //
    // /* Unlock the chip configuration registers to allow SGMII SERDES registers to
    // * be written */
    // CSL_BootCfgUnlockKicker();
    //
    // CSL_BootCfgSetSGMIIConfigPLL (0x00000081);
    // CSL_BootCfgSetSGMIIRxConfig (0, 0x00700621);
    // CSL_BootCfgSetSGMIITxConfig (0, 0x000108A1);
    // CSL_BootCfgSetSGMIIRxConfig (1, 0x00700621);
    // CSL_BootCfgSetSGMIITxConfig (1, 0x000108A1);
    //
    // /* Re-lock the chip configuration registers to prevent unintentional writes */
    // CSL_BootCfgLockKicker();
    //
    // // }
    //
    // /* SGMII SERDES Configuration complete. Return. */
    // return 0;
    //}

    int StackTest()
    {
    int rc;
    int i;
    HANDLE hCfg;
    QMSS_CFG_T qmss_cfg;
    CPPI_CFG_T cppi_cfg;

    /* Get information about the platform so we can use it in various places */
    memset( (void *) &gPlatformInfo, 0, sizeof(platform_info));
    (void) platform_get_info(&gPlatformInfo);

    (void) platform_uart_init();
    (void) platform_uart_set_baudrate(115200);
    (void) platform_write_configure(PLATFORM_WRITE_ALL);

    /* Clear the state of the User LEDs to OFF */
    for (i=0; i < gPlatformInfo.led[PLATFORM_USER_LED_CLASS].count; i++)
    {
    (void) platform_led(i, PLATFORM_LED_OFF, PLATFORM_USER_LED_CLASS);
    }

    /* Initialize the components required to run this application:
    * (1) QMSS
    * (2) CPPI
    * (3) Packet Accelerator
    */
    /* Initialize QMSS */
    if (platform_get_coreid() == 0)
    {
    qmss_cfg.master_core = 1;
    }
    else
    {
    qmss_cfg.master_core = 0;
    }
    qmss_cfg.max_num_desc = MAX_NUM_DESC;
    qmss_cfg.desc_size = MAX_DESC_SIZE;
    qmss_cfg.mem_region = Qmss_MemRegion_MEMORY_REGION0;
    if (res_mgr_init_qmss (&qmss_cfg) != 0)
    {
    platform_write ("Failed to initialize the QMSS subsystem \n");
    goto main_exit;
    }
    else
    {
    platform_write ("QMSS successfully initialized \n");
    }

    /* Initialize CPPI */
    if (platform_get_coreid() == 0)
    {
    cppi_cfg.master_core = 1;
    }
    else
    {
    cppi_cfg.master_core = 0;
    }
    cppi_cfg.dma_num = Cppi_CpDma_PASS_CPDMA;
    cppi_cfg.num_tx_queues = NUM_PA_TX_QUEUES;
    cppi_cfg.num_rx_channels = NUM_PA_RX_CHANNELS;
    if (res_mgr_init_cppi (&cppi_cfg) != 0)
    {
    platform_write ("Failed to initialize CPPI subsystem \n");
    goto main_exit;
    }
    else
    {
    platform_write ("CPPI successfully initialized \n");
    }


    if (res_mgr_init_pass()!= 0)
    {
    platform_write ("Failed to initialize the Packet Accelerator \n");
    goto main_exit;
    }
    else
    {
    platform_write ("PA successfully initialized \n");
    }

    //
    // THIS MUST BE THE ABSOLUTE FIRST THING DONE IN AN APPLICATION before
    // using the stack!!
    //
    rc = NC_SystemOpen( NC_PRIORITY_LOW, NC_OPMODE_INTERRUPT );
    if( rc )
    {
    platform_write("NC_SystemOpen Failed (%d)\n",rc);
    for(;;);
    }

    // Print out our banner
    platform_write(VerStr);

    //
    // Create and build the system configuration from scratch.
    //

    // Create a new configuration
    hCfg = CfgNew();
    if( !hCfg )
    {
    platform_write("Unable to create configuration\n");
    goto main_exit;
    }

    //
    // THIS MUST BE THE ABSOLUTE FIRST THING DONE IN AN APPLICATION!!
    //
    rc = NC_SystemOpen( NC_PRIORITY_LOW, NC_OPMODE_INTERRUPT );
    if( rc )
    {
    printf("NC_SystemOpen Failed (%d)\n",rc);
    for(;;);
    }

    // Print out our banner
    printf(VerStr);

    //
    // Create and build the system configuration from scratch.
    //

    // Create a new configuration
    hCfg = CfgNew();
    if( !hCfg )
    {
    printf("Unable to create configuration\n");
    goto main_exit;
    }

    // We better validate the length of the supplied names
    if( strlen( DomainName ) >= CFG_DOMAIN_MAX ||
    strlen( HostName ) >= CFG_HOSTNAME_MAX )
    {
    printf("Names too long\n");
    goto main_exit;
    }

    // Add our global hostname to hCfg (to be claimed in all connected domains)
    CfgAddEntry( hCfg, CFGTAG_SYSINFO, CFGITEM_DHCP_HOSTNAME, 0,
    strlen(HostName), (UINT8 *)HostName, 0 );

    // If the IP address is specified, manually configure IP and Gateway
    #ifdef _SCBP6618X_
    /* SCBP6618x always uses DHCP */
    if (0)
    #else
    if (1)//(!platform_get_switch_state(1))
    #endif
    {
    *(sendbuf+1) = 0x11111111;
    CI_IPNET NA;
    CI_ROUTE RT;
    IPN IPTmp;

    // Setup manual IP address
    bzero( &NA, sizeof(NA) );
    NA.IPAddr = inet_addr(LocalIPAddr);
    NA.IPMask = inet_addr(LocalIPMask);
    strcpy( NA.Domain, DomainName );
    NA.NetType = 0;

    // Add the address to interface 1
    CfgAddEntry( hCfg, CFGTAG_IPNET, 1, 0,
    sizeof(CI_IPNET), (UINT8 *)&NA, 0 );

    // Add the default gateway. Since it is the default, the
    // destination address and mask are both zero (we go ahead
    // and show the assignment for clarity).
    bzero( &RT, sizeof(RT) );
    RT.IPDestAddr = 0;
    RT.IPDestMask = 0;
    RT.IPGateAddr = inet_addr(GatewayIP);

    // Add the route
    CfgAddEntry( hCfg, CFGTAG_ROUTE, 0, 0,
    sizeof(CI_ROUTE), (UINT8 *)&RT, 0 );

    // Manually add the DNS server when specified
    IPTmp = inet_addr(DNSServer);
    if( IPTmp )
    CfgAddEntry( hCfg, CFGTAG_SYSINFO, CFGITEM_DHCP_DOMAINNAMESERVER,
    0, sizeof(IPTmp), (UINT8 *)&IPTmp, 0 );
    }
    // Else we specify DHCP
    else
    {
    CI_SERVICE_DHCPC dhcpc;

    // Specify DHCP Service on IF-1
    bzero( &dhcpc, sizeof(dhcpc) );
    dhcpc.cisargs.Mode = CIS_FLG_IFIDXVALID;
    dhcpc.cisargs.IfIdx = 1;
    dhcpc.cisargs.pCbSrv = &ServiceReport;
    CfgAddEntry( hCfg, CFGTAG_SERVICE, CFGITEM_SERVICE_DHCPCLIENT, 0,
    sizeof(dhcpc), (UINT8 *)&dhcpc, 0 );
    }

    //
    // Configure IPStack/OS Options
    //

    // We don't want to see debug messages less than WARNINGS
    rc = DBG_WARN;
    CfgAddEntry( hCfg, CFGTAG_OS, CFGITEM_OS_DBGPRINTLEVEL,
    CFG_ADDMODE_UNIQUE, sizeof(uint), (UINT8 *)&rc, 0 );

    //
    // This code sets up the TCP and UDP buffer sizes
    // (Note 8192 is actually the default. This code is here to
    // illustrate how the buffer and limit sizes are configured.)
    //

    // UDP Receive limit
    rc = 8192;
    CfgAddEntry( hCfg, CFGTAG_IP, CFGITEM_IP_SOCKUDPRXLIMIT,
    CFG_ADDMODE_UNIQUE, sizeof(uint), (UINT8 *)&rc, 0 );

    //
    // Boot the system using this configuration
    //
    // We keep booting until the function returns 0. This allows
    // us to have a "reboot" command.
    //
    do
    {
    rc = NC_NetStart( hCfg, NetworkOpen, NetworkClose, NetworkIPAddr );
    } while( rc > 0 );

    // Delete Configuration
    CfgFree( hCfg );

    // Close the OS
    main_exit:
    NC_SystemClose();
    return(0);
    }


    //
    // System Task Code [ Server Daemon Servers ]
    //
    static HANDLE hHello=0;

    //
    // NetworkOpen
    //
    // This function is called after the configuration has booted
    //
    static void NetworkOpen()
    {
    *(sendbuf+6) = 0x66666666;
    // Create our local server
    // hHello = DaemonNew( SOCK_DGRAM, 0, 7, dtask_udp_hello,
    // OS_TASKPRINORM, OS_TASKSTKNORM, 0, 1 );
    hHello = DaemonNew( SOCK_STREAMNC, 0, 7, dtask_tcp_echo,
    OS_TASKPRINORM, OS_TASKSTKNORM, 0, 3 );
    }

    //
    // NetworkClose
    //
    // This function is called when the network is shutting down,
    // or when it no longer has any IP addresses assigned to it.
    //
    static void NetworkClose()
    {
    *(sendbuf+7) = 0x77777777;
    DaemonFree( hHello );
    }


    //
    // NetworkIPAddr
    //
    // This function is called whenever an IP address binding is
    // added or removed from the system.
    //
    static void NetworkIPAddr( IPN IPAddr, uint IfIdx, uint fAdd )
    {
    IPN IPTmp;

    if( fAdd )
    printf("Network Added: ");
    else
    printf("Network Removed: ");

    // Print a message
    IPTmp = ntohl( IPAddr );
    printf("If-%d:%d.%d.%d.%d\n", IfIdx,
    (UINT8)(IPTmp>>24)&0xFF, (UINT8)(IPTmp>>16)&0xFF,
    (UINT8)(IPTmp>>8)&0xFF, (UINT8)IPTmp&0xFF );
    }

    //
    // Service Status Reports
    //
    // Here's a quick example of using service status updates
    //
    static char *TaskName[] = { "Telnet","HTTP","NAT","DHCPS","DHCPC","DNS" };
    static char *ReportStr[] = { "","Running","Updated","Complete","Fault" };
    static char *StatusStr[] = { "Disabled","Waiting","IPTerm","Failed","Enabled" };
    static void ServiceReport( uint Item, uint Status, uint Report, HANDLE h )
    {
    printf( "Service Status: %-9s: %-9s: %-9s: %03d\n",
    TaskName[Item-1], StatusStr[Status],
    ReportStr[Report/256], Report&0xFF );

    //
    // Example of adding to the DHCP configuration space
    //
    // When using the DHCP client, the client has full control over access
    // to the first 256 entries in the CFGTAG_SYSINFO space.
    //
    // Note that the DHCP client will erase all CFGTAG_SYSINFO tags except
    // CFGITEM_DHCP_HOSTNAME. If the application needs to keep manual
    // entries in the DHCP tag range, then the code to maintain them should
    // be placed here.
    //
    // Here, we want to manually add a DNS server to the configuration, but
    // we can only do it once DHCP has finished its programming.
    //
    if( Item == CFGITEM_SERVICE_DHCPCLIENT &&
    Status == CIS_SRV_STATUS_ENABLED &&
    (Report == (NETTOOLS_STAT_RUNNING|DHCPCODE_IPADD) ||
    Report == (NETTOOLS_STAT_RUNNING|DHCPCODE_IPRENEW)) )
    {
    IPN IPTmp;

    // Manually add the DNS server when specified
    IPTmp = inet_addr(DNSServer);
    if( IPTmp )
    CfgAddEntry( 0, CFGTAG_SYSINFO, CFGITEM_DHCP_DOMAINNAMESERVER,
    0, sizeof(IPTmp), (UINT8 *)&IPTmp, 0 );
    }
    }

  • 建议先看下SGMII SWITCH的SGMII_STATUS 状态寄存器的 LINK 状态标志位有没有LINK UP起来

    然后检查STAT统计模块有没有正常的收发包统计,一步一步排查,光看代码很难发现问题

  • Thomas Yang1 你好!

        我在调试sgmii的时候,现在SGMII_STATUS 状态寄存器的 LINK 状态标志位时没有LINK UP起来,一直处在do..while循环当中,造成没有LINK UP起来的原因主要是什么呢?

  • 没有连上,可能是自动协商没有通过

  • 你好。

    最近我也在进行C6678网口的调试,使用gel初始化之后能够实现和PC端的通信。

    但是现在想不用gel文件来实现板子的初始化,然而网口的bios程序默认分配在DDR3内部运行的,如果不先使用gel文件初始化ddr3,那么程序就跑不到main的位置。

    想请教你是用什么方法来让程序运行到main函数,然后再对DDR3进行初始化的。谢谢

  • 前几天我也遇到这个问题,最后是serdes的时钟配置不对,我把0x51改为0x41就对了.

  • 请问对于这个问题有什么解决办法,同样的问题。