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.

TMS320C6672: NDK socket creation fails and I can't get an error code

Part Number: TMS320C6672

Hi,

I have a C6672 DSP and I'm trying to build a TCP server.

In the board initialization part, the code passes the platform_init() function and the QMSS, CPPI, and PA initializations (all of which return zero). I also call fdOpenSession() at the beginning of the task.

Then, when I call the "socket" function with IPv4, stream and TCP parameters, it returns -1. To find out why the socket creation has failed, I call fdError(), which also returns -1; however, there is no relevant error code "-1" for socket creation in header "serrno.h".

Here's a summary of how I try creating the socket:

void TcpTaskFxn(UArg arg1, UArg arg2)
{
    int iStatus = fdOpenSession(TaskSelf());
    if (iStatus != RET_OK)
    {
        /* Error Handling */
    }

    STcpCommand_t inboundMessage = {0};
    SOCKET tcpSocket = CreateTcpServer();

    while (true)
    {
        /* Task loop */
    }
}

SOCKET CreateTcpServer(void)
{
    SOCKET socketId = INVALID_SOCKET;

    /* Open the socket. Use ARPA Internet address format and stream sockets. */
    while (socketId == INVALID_SOCKET)
    {
        socketId = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); /* returns -1 */
        if (socketId == INVALID_SOCKET)
        {
            int iError = fdError(); /* also returns -1 */
        }
    }

    /* ... */
}

I'm also attaching the configuration file here (app.cfg.zip), in case it is needed.

Thanks in advance,
Silacko

  • Hi,

    Your code seems correct.

    Have you tried verifying that your board is initialized correctly? You can do that by running the NIMU_emacExample first.

    Also can you add a breakpoint in your code and step into each of the functions called to track where exactly your system stops working?

    Best Regards,
    Yordan

  • Hi, Yordan,

    Have you tried verifying that your board is initialized correctly? You can do that by running the NIMU_emacExample first.

    I tried building and running the NIMU_emacExample on the board, which yielded the following output:

    QMSS successfully initialized
    CPPI successfully initialized
    PA successfully initialized

    TCP/IP Stack 'Hello World!' Application

    StackTest: using localIp
    Network Added: If-1:10.10.27.4

    Is this the expected result? From my PC, I tried pinging 10.10.27.4 at that state (keeping the DSP core running), but it failed.

    Also can you add a breakpoint in your code and step into each of the functions called to track where exactly your system stops working?

    My code never stops working actually; it just returns an error when I try creating a socket and repeats in an infinite loop.

    Regards,
    Silacko

  • Hi,

    Is this the expected result? From my PC, I tried pinging 10.10.27.4 at that state (keeping the DSP core running), but it failed.

    This is the expected output from the example, however, it seems that your eth port is not initialized correctly. You should be able to ping the board, this is how eth connection is verified & confirmation that the example is running as expected.

    From CCS you should be able to add breakpoint in the code and run step by step to see where exactly your code breaks. It will be useful to add debug prints along the code that will help you localize the problem.

    Best Regards,
    Yordan

  • Hi,

    I don't quite understand what you mean by "where exactly [my] code breaks". Both my code and the NIMU example work without crashing. Where and to what end should I put a breakpoint?

    Regards,
    Silacko

  • Hi, Yordan,

    It's been a while.

    By debugging my code step by step, I noticed that in the "NC_NetStart" function located in <ti/ndk/netctrl/netctrl.c>, the DSP attempts to create a task named "ConfigBoot" with function "NS_BootTask" but fails and quits without starting the scheduler.

    if (!(TaskCreate(NS_BootTask, "ConfigBoot", OS_TASKPRINORM, bootStkSz, (UINT32)hCfg, 0, 0)))
    {

        /* Couldn't create boot task, don't start scheduler, close down stack */
        NetHaltFlag = 1;
        NetReturnCode = -1;
    }

    Why do you think the task creation could fail?

    Thanks in advance,

    Silacko

  • Hi,

    Sorry for the delay. I am not really sure why task creation fails.. Let me consult with the design team. However, note that responses may be delayed due to holidays.

    Best Regards,
    Yordan

  • Hi,

    See the http://software-dl.ti.com/processor-sdk-rtos/esd/docs/latest/rtos/index_Foundational_Components.html#nimu-for-cpsw. NIMU_emacExample Client_evmXXXX _<core>Example project. It calls below to create a TCP server:

    static void NIMU_testNetworkOpen()
    {
    // Create our local servers
    hEcho = DaemonNew( SOCK_STREAMNC, 0, 7, dtask_tcp_echo,
    OS_TASKPRINORM, OS_TASKSTKNORM, 0, 3 );
    hEchoUdp = DaemonNew( SOCK_DGRAM, 0, 7, dtask_udp_echo,
    OS_TASKPRINORM, OS_TASKSTKNORM, 0, 1 );
    hData = DaemonNew( SOCK_STREAM, 0, 1000, dtask_tcp_datasrv,
    OS_TASKPRINORM, OS_TASKSTKNORM, 0, 3 );
    hNull = DaemonNew( SOCK_STREAMNC, 0, 1001, dtask_tcp_nullsrv,
    OS_TASKPRINORM, OS_TASKSTKNORM, 0, 3 );
    hOob = DaemonNew( SOCK_STREAMNC, 0, 999, dtask_tcp_oobsrv,
    OS_TASKPRINORM, OS_TASKSTKNORM, 0, 3 );

    ...}

    Regards, Eric