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.

Creating socket is generating exception in Tiva C Series board

Other Parts Discussed in Thread: TM4C1294NCPDT, SYSBIOS, CC3200

Hi,

I am using TM4C1294NCPDT on EK-1294XL board. tirtos_tivac_2_14_04_3, TivaWare_C_Series-2.1.2.111, CCS_6.1.2.00015 versions on Windows 8 64-bit machine.
I have taken HTTP GET example code from TI-RTOS and trying to use simple socket code for GET and POST Request. Issue is whenever it tries to create socket using either socket() or NDK_socket() method it is going into Hardware exception (ti_sysbios_family_arm_m3_Hwi_excHandlerAsm__I). Why it is not allowing to create socket?
Attached is the code.

Thanks,
Bhavesh

7128.POC_Socket.zip

  • Adding:

    I tried with all combination of Sock Type and Protocol for AF_INET. But all are giving same error. Also I have read in CC3200 forum that it is working.
  • Bhavesh,

    Are you seeing a dump of registers when the exception happens?

    Can you please follow the steps at this FAQ to trace back the error?

    Steve

  • Hi Steven,

    When I try to create Socket after httpTask is called as taskHandle, it is not giving any exception dump. Screenshot (Socket_1, Socket_2, Socket_3 ) are attached for Registers and ROV in this case.

    For a change I tried to create socket before creating httpTask, and in this case it is giving me socket with number as 0x2000792C. But when I use this socket to connect() it is generating errors as below:

    l.Task: line 383: E_spOutOfBounds: Task 0x20001418 stack error, SP = 0x2000177c.
    xdc.runtime.Error.raise: terminating execution

    Screenshots are attached. Socket_4 : Register dump after connect is executed. There are no exception shown on ROV window.

    Thanks,
    Bhavesh

  • Adding screen shot of ROV and Debug Trace.

    0x20001418 is address from where Socket methods are being called. 

  • Hi Steven,

    Debugging further I found that Line 383 in task.c at \\tirtos_tivac_2_14_04_31\products\bios_6_42_03_35\packages\ti\sysbios\knl is generating error.
    I am getting following values:
    (UArg)&oldTaskStack = 0x20000674
    (UArg)oldTask->stack) = 0x20001468
    (UArg)(oldTask->stack+oldTask->stackSize) = 0x20001968

    so If condition ((UArg)&oldTaskStack < (UArg)oldTask->stack) is successful and getting error.
    Any idea why this is happening?

    Thanks,
    Bhavesh
  • Bhavesh,

    l.Task: line 383: E_spOutOfBounds: Task 0x20001418 stack error, SP = 0x2000177c.
    xdc.runtime.Error.raise: terminating execution

    That task handle looks to be the dhcpClient task, based on the ROV screen shot you posted.  So, this message means that the stack for that task is overflowing.


    You need to increase the size of that Task.

    Since the NDK's DHCP client task is created as follows, you can do this at config time (in your app's *.cfg file)

        /* Create our DHCP task */
        pLease->dhcpTASK = TaskCreate( (void(*)())dhcpState, "DHCPclient",
                                       OS_TASKPRINORM, OS_TASKSTKLOW,
                                       (UINT32)pLease, 0, 0 );

    The stack size in the create call is set to "OS_TASKSTKLOW".


    You can increase the value for this in your *.cfg file.  Open the file in XGCONF and increase it, as shown in the below screen shot.

    Steve

  • Hi Steven,

    I increased Low Priority NDK Task Stack to 5120 and it stopped giving Stack error. But it is not able to connect to any of the Server.

    I tried with local server at 192.168.0.102 and also for yahoo.com (98.138.253.109) but getting -1 in return which is generally error while connecting. Do we have any method to find a reason for this error?

    Thanks,
    Bhavesh

  • Hi Bhavesh,

    to check errors when connect() returns -1, I use:

    DbgPrintf(DBG_INFO, "connect failed: error = %d\n", errno);

    in ndk/inc/serrno.h or fdError() if your are using legacy sockets layer.

    I hope it helps,
    Sara
  • Hi Bhavesh,

    Yes, when connect returns -1, you must call fdError() or the macro errno (if you are using the BSD sockets version of the NDK APIs). This will return the error code to you.

    Once you have the error code, you can look it up in the file "<ndk installation>/packages/ti/ndk/inc/serrno.h"

    Steve
  • Hi Steve,

    I have done implementation. And it is always returns ECONNREFUSED    61 error whenever it is trying to connect to any of the server. I also checked by creating simple C program on ubuntu which opens connection to local server (192.168.0.102) and it is connecting and sending POST request correctly.

    Also this error is returned for all of Hosts (tried with yahoo, local server,  weather.org server) and working with C code. Any reason why connection is refused?

    Thanks,

    Bhavesh

  • Bhavesh,

    Bhavesh Patel said:
    And it is always returns ECONNREFUSED    61 error whenever it is trying to connect to any of the server

    This usually means that the server doesn't have any socket listening on the port that you specified.

    Can you double check the port you are using in your code?

    Also, you should capture this in Wireshark.  Verify that the port being sent in the TCP SYN packet (first packet of the TCP 3-way handshake) sent to the server shows the correct port in Wireshark.

    Steve