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.

CC3200: Accept Error code -100

Part Number: CC3200

Hi,

I trying to build a TCP Server on CC3200MOD Launchpad with multithreading. But there is always accept connection error. The sl_Accept(); returns a value -100 which is not defined as any macro. Can you tell me what type of error is this? and how can i resolve it?

  • Hi,

    Error -100 is SL_API_ABORTED, which is defined in device.h. Some more information on SL_API_ABORTED can be found on other threads in E2E including the following:

    https://e2e.ti.com/support/wireless-connectivity/wifi/f/968/t/551340

    https://e2e.ti.com/support/wireless-connectivity/wifi/f/968/t/695900?CC3200-sl-RecvFrom-returns-error-code-100

    The SL_API_ABORTED error is returned when the SimpleLink host driver detects a fatal error that renders further operation of the Wi-Fi network processor (NWP) impossible. Once the API abort occurs, a MCU reset is required to clear the error condition.

    There are many potential causes for an abort error. On the CC3200, there are a few common causes:

    1. The host driver or its context was corrupted. You should check and ensure that there are no stack overflows, that your pointers are assigned correctly, and that there isn't anything that could be corrupting the host driver.
    2. The host driver tried to execute an operation that was illegal. Depending on how you are performing multithreading, it is possible that your tasks are performing SL API calls that conflict, or change the state of the NWP that affects your sl_Accept() call. Also, you should ensure that you are using the multithread-supported version of the SL library: https://e2e.ti.com/support/wireless-connectivity/wifi/f/968/t/516812
    3. A host driver API was executed in an interrupt context. You cannot call SL APIs in an API context, and that will trigger unexpected behavior in your system.

    If you could follow the instructions here to capture NWP logs and provide them to me for analysis, that would be helpful. That will allow me see the sequence of events that caused the abort.

    Regards,

    Michael

  • Hi,

    I have got the log file of the project. Also,  some code snippet is here.

    void ServerRoutine(void *NewSock)
    {
       char buff[1024];
        int     iStatus;
        int NewSoc=*((int *)NewSock);
        Report("I am in Routine Func");
        
        again: iStatus = sl_Recv(NewSoc, buff, 1024, 0);
            if(iStatus==SL_EAGAIN)
              goto again;
            
            else if( iStatus <= 0 )
            {
              // error
              sl_Close(NewSoc);
              Report("Error on recpetion:%d\n\r",iStatus);
              //ASSERT_ON_ERROR(RECV_ERROR);
            }
            else 
            {       buff[iStatus]='\0';   
                    Report("Data recieved:%s\n\r",buff);
                    Report("Recieved packet successfully\n\r");
                   // close the connected socket after receiving from connected TCP client
                      iStatus = sl_Close(NewSoc); 
                      if(iStatus!=0)
                      Report("Error in closing connection %d\n\r",iStatus);
                      //ASSERT_ON_ERROR(iStatus);
                      NewSoc=-1;
            }
            osi_TaskDelete(NULL);
    }
    
    
    //****************************************************************************
    //
    //! \brief Opening a TCP server side socket and receiving data
    //!
    //! This function opens a TCP socket in Listen mode and waits for an incoming
    //!    TCP connection.
    //! If a socket connection is established then the function will try to read
    //!    1000 TCP packets from the connected client.
    //!
    //! \param[in] port number on which the server will be listening on
    //!
    //! \return     0 on success, -1 on error.
    //!
    //! \note   This function will wait for an incoming connection till
    //!                     one is established
    //
    //****************************************************************************
    void BsdTcpServer(void *para)
    {
        SlSockAddrIn_t  sAddr;
        SlSockAddrIn_t  sLocalAddr;
        
        int             iAddrSize;
        int             iSockID;
        int             iStatus;
        signed short             iNewSockID=-1;
        SlSockNonblocking_t enableOption;
        enableOption.NonblockingEnabled = 1;
        unsigned short usPort=5023;
         long lRetVal = -1;
         int master_socket=-1;
       
        //filling the TCP server socket address
        sLocalAddr.sin_family = SL_AF_INET;
        sLocalAddr.sin_port = sl_Htons((unsigned short)usPort);
        sLocalAddr.sin_addr.s_addr = 0;
    
        // creating a TCP socket
        master_socket = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
        if( master_socket < 0 )
        {
            // error
           //ASSERT_ON_ERROR(SOCKET_CREATE_ERROR);
        }
    
        iAddrSize = sizeof(SlSockAddrIn_t);
    
        // binding the TCP socket to the TCP server address
        iStatus = sl_Bind(master_socket, (SlSockAddr_t *)&sLocalAddr, iAddrSize);
        if( iStatus < 0 )
        {
            // error
            sl_Close(master_socket);
            //ASSERT_ON_ERROR(BIND_ERROR);
        }
    
        // putting the socket for listening to the incoming TCP connection
        iStatus = sl_Listen(master_socket, 0);
        if( iStatus < 0 )
        {
            sl_Close(master_socket);
            //ASSERT_ON_ERROR(LISTEN_ERROR);
        }
    
        // setting socket option to make the socket as non blocking
        iStatus = sl_SetSockOpt(master_socket, SL_SOL_SOCKET, SL_SO_NONBLOCKING, (_u8 *)&enableOption,sizeof(enableOption)); 
        if( iStatus < 0 )
        {
            sl_Close(master_socket);
            //ASSERT_ON_ERROR(SOCKET_OPT_ERROR);
        }
        Report("Starting Server");
     
        // waiting for an incoming TCP connection
        while(1){
            // accepts a connection form a TCP client, if there is any
            // otherwise returns SL_EAGAIN
            while(iNewSockID<0){
                iNewSockID = sl_Accept(master_socket, ( struct SlSockAddr_t *)&sAddr, (SlSocklen_t*)&iAddrSize);         //<----here is accept function
                if( iNewSockID == SL_EAGAIN )
                {
                   MAP_UtilsDelay(1000);
                }
                else if( iNewSockID < 0 && iNewSockID != SL_EAGAIN)
                {
                    // error
                  Report("Accept Error");
                    sl_Close(iNewSockID);
                    sl_Close(master_socket);
                    //ASSERT_ON_ERROR(ACCEPT_ERROR);
                }
            
            }
           
                Report("NEW Client :%d\n\r",iNewSockID);
                    
                    //Creating Task for every accept connection
                lRetVal= osi_TaskCreate(ServerRoutine,(const signed char*)"TCP SERVER Routine",OSI_STACK_SIZE, &iNewSockID , 1, NULL );
                if(lRetVal < 0)
                { 
                  Report("Error in creating task for client :%d",iNewSockID);
                }
                iNewSockID=-1;
         }
          
          
        
        // close the listening socket
        iStatus = sl_Close(master_socket);
        //ASSERT_ON_ERROR(iStatus);   
        
    
       
    }

  • Hi,

    Is your code based off of the tcp_socket example from the SDK? Did you only copy the functions above into your own project, or are you modifying the tcp_socket example project directly? 

    Does the sl_Accept() always result in the -100 abort, with even the first connection to the server causing the abort? Or is it returning -100 before any client even connects?

    Also, can you re-upload the NWP logs? It appears to be inaccessible.

    Regards,

    Michael

  • Hi,

    I'm using WLAN Station example from SDK (as It has FreeRTOS configured) and trying to run a Server on port 5001 using a Socket.

    The sl_Accept() always results in -100 abort and can't able to connect with any client.

    I am not able to attach the log file as there's some issue occuring here.
    Just for confirmation, the log file should not be readable right?

  • Hi,

    The log file will be in a binary format. However, there should be some readable plaintext in the log file. For example, upon a reset the bootloader will open and read some files from the external flash, such as the servicepack.ucf file. You should be able to see some of those filenames in the NWP log, assuming you started recording the logs at reset. 

    Regards,
    Michael

  • Hi,

    I got the log file please let me know the problem. The code snippet is given above and log file is here:

  • Hi,

    Looking at the logs, it seems like you do not have an up to date servicepack flashed on the device. Please download the latest servicepack here: https://www.ti.com/tool/download/CC3200SDK

    then, follow the steps here under "Service Pack Programming" to flash the servicepack. http://processors.wiki.ti.com/index.php/CC3100_%26_CC3200_UniFlash_Quick_Start_Guide

    Try running your program again after you have flashed the latest servicepack.

    Regards,

    Michael

  • Hi,

    I already uploaded the service pack given in  https://www.ti.com/tool/download/CC3200SDK 

    ServicePack version: 1.0.1.13-2.11.0.1

    CC3200SDK version: 1.3.0

    But it's not working.

    I have CC3200MOD LAUNCHXL board.

    You can also look at the code above, maybe I'm missing something.

    Shivam

  • Hi Shivam,

    A few things I note:

    1. What are your task priorities? If the tcp socket task spawned after sl_Accept() is lower priority, then the passed-in socket ID will be set to -1 before the value can be copied in the spawned thread. This will cause an error in the NWP, as you will be trying to read from an invalid socket ID.
    2. You probably don't want to be using MAP_UtilsDelay() in your socket handler function, as that will prevent the scheduler from marking that thread as blocked and allow preempted threads to run. Instead, you should use osi_sleep().

    I copied your code and the general concept works correctly. I have made a few modifications along the lines of the notes above, and it runs as expected. I can connect two TCP clients and transfer data in parallel on my setup with the attached code. Please try running my code and see if that works with your setup.

    /cfs-file/__key/communityserver-discussions-components-files/968/cc3200_5F00_tcp_5F00_server.c

    Regards,

    Michael

  • Hi Michael,

    After applying the changes in the code given by you ( mainly adding ASSERT_ON_ERROR statements which weren't there earlier). I found that the socket isn't even created. The function sl_Socket() is returning SL_API_ABORTED (-100). But still, I couldn't figure out how to get rid of it.

    Shivam.

  • Hi Shivam,

    I have tested my attached code, and it doesn't return an SL_API_ABORTED error when I run it on my setup. Please see my attached CCS project, and build + run that code on your setup. Let me know if you run into the same SL_API_ABORTED error with my project. That project not only has my code but the exact build settings that I used. It also has a binary and .out you can try with your setup as a sanity check. You'll need to use an AP with SSID = "simplelinktest" and password = "wifitest" for the binary to work. 

    /cfs-file/__key/communityserver-discussions-components-files/968/tcpserver_5F00_cc3200_5F00_threaded.7z

    Regards,

    Michael

  • Hello Michael,

    I have got your project. Can't I change the SSID and Password in the code? also, I can't see any code for the purpose in main.c where it is?

    Thank you 

    Shivam

  • Hi Michael,

    I uploaded the code provided by you. The device connects to SSID="simplelinktest" successfully and I was able to connect my first tcp client with it. But the second client fails to connect (it waits till the first on exits). I have got the terminal window, have a look.

  • Hi Shivam,

    There is a bug with the usage of osi_TaskDelete() in ServerRoutine(). After fixing that by ensuring the serverThread deletes its own thread handle (and not NULL), everything works as expected and I can connect multiple TCP clients without issues.

    Please copy and replace these attached files in your project:

    /cfs-file/__key/communityserver-discussions-components-files/968/httpserverapp.h

    /cfs-file/__key/communityserver-discussions-components-files/968/tcpserver.c

    Regards,

    Michael

  • Hi Michael,

    I added the files and code and uploaded it. But still, there is some problem. The program stuck at sl_Socket() every time. As socket isn't created, I can't test it further for multiple clients. This problem was also occurring previously (as I told you) but I don't know why. Its been too long but I'm not able to figure out this problem.

  • Hi Shivam,

    When I test the program on my setup, I do not run into any issues with opening the socket, nor with closing the socket and exiting the thread.

    Attached is the full project CCS project directory that I used without issues. 

    /cfs-file/__key/communityserver-discussions-components-files/968/2514.tcpserver_5F00_cc3200_5F00_threaded.7z

    Please try flashing my .bin onto your CC3200 launchpad or using the debugger to load the .out and see if you have the same issues. The SSID and key needed for your AP is the same as last time.

    Regards,

    Michael

  • Hi Michael,

    This time it worked! Yes, finally it worked. I loaded the .bin file and tested it with 3 clients (Pc, two phones). I can connect all at the same time and send data.

    Thanks a lot for helping me. 

    And my obvious question -how you did that? Please share the code and let me know what big change you made in it.

    Thanks

    Shivam  

  • Hi Shivam,

    I don't remember any one specific big change that made everything work. There were a variety of fixes and adjustments that had to be made. I suggest that you use a folder diff tool to compare my project files against what you have.

    In any case, thanks for letting me know that my code works on your setup.

    Regards,
    Michael

  • Hi Michael,

    I was trying to understand your code and that's why I imported the project into CCS v6 (Earlier I was using IAR). But when build the project I see some errors like:

    After looking the errors I checked include paths which were like this :

    Then I changed all the path to :

    $C:/TI/CC3200SDK_1.3.0/cc3200-sdk/simplelink/   (like this).

    But still, I'm getting the same errors.

    Can you help me?

    Shivam

  • Hi Shivam,

    I am using CCS 9.1 for my CC3200 SDK projects, including the one I provided in my previous post. There could definitely be compatibility issues when taking a project generated for CCS 9 and attempting to build it in CCS 6. I suggest that you install CCS 9 and see if you can import my project into a CCS9 workspace and see if that resolves your issues.

    Regards,

    Michael