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.

CC3000 hangs almost everywhere

I am posting this since I am not able to debug it anymore. I read everything multiple times, but still I have no reliable solution. We added a 30 seconds timeout to reset the board anytime it hangs in the event_handler waiitng for a response, but this is to the point I get more reset per day than succesful connections.

So, on ourboard the cc3000 hangs often in the following points:

recv: this is almost solved. Now I close and reopen the connecton multiple times (almost anytime before sending and expecting a response. TO NOTE: here no timeout set and no select() function helped. It was still hanging in the eventhandler very often. With the select in place, often the SELECT function would hang.

connect(): this is the most frequent one.  No way to make it timing out. I tried re-setting the timeout to 20 seconds, but nothing, the handler timeout gets called first.

gethostbyname: this was very frequent and I think alternates with the connect problem one. It got better waiting for the DHCP part to the completed on connection (at least I think), but it still happens. I even implement 2 retries, and they helped a lot(since ususally the first time fails, but the second one works)..but still..from time to time, it hangs there. I don't think there is anything I can do here.

Now I am at the point that I disconnect, reset the module, reconnect only when I really need to send some data through wifi. Is the anything else I can try? I am using the latest patch programmer, of course.

We are thinking about desoldering and return our 1000 cc3000 to TI if we don't find a solution. 

  • Hi Fabrizio,

    What is the host driver version that you are using? And also please share the service pack version. Please note that the service pack and host driver should match as per the table here (processors.wiki.ti.com/.../CC3000_Release_Notes).

    For the connect issue, can you please share the logs (showing command/event pair) from the host driver along with the wireshark logs?

    Regards,
    Raghavendra
  • Hi Raghavendra,

    We are using driver version 16, with the 1.14 patch programmer (service pack 1.32).

    Now we are in the following situation: gethostname fails very often, with no recovery but trying to power cycle the cc3000. If I use the direct ip..I have the connect failing often (a little less), but this will hang in the event_handler. The gethostbyname rarely hangs.


    We made some tests, and we discovered that we are not sure the sockets close gracefully when I close the closesocket, but I am trying to not have more than one open and I open and close every time I need to send something.

    Please see our code below for the connect. Do you see any mistake? For wireshark, we are having problems in setting it up. we see many things, but we are not able to see the CC3000 packets. Any suggestion on this? I tried with monitor mode or promiscuos mode, wired and wireless..but we just see some broadcast and some QOS packets from the CC3000 and to it.

    Thanks for the help.

    static long acp_server_initial_connect(unsigned int port)
    {
    long sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
    tNetappIpconfigRetArgs test_config;
    memset(&test_config,0,sizeof(tNetappIpconfigRetArgs));
    uint32_t rcvTimeout = 5000;
    unsigned long server_ip;
    sockaddr serv_addr;

    if ( sock == -1 )
    {
    return -1;
    }

    // Set Receive timeout
    if ( setsockopt( sock, SOL_SOCKET, SOCKOPT_RECV_TIMEOUT, &rcvTimeout, sizeof(rcvTimeout) ) < 0 )
    {
    //closesocket(sock);
    return -1;
    }

    serv_addr.sa_family = AF_INET;
    serv_addr.sa_data[0] = (port & 0xFF00) >> 8;
    serv_addr.sa_data[1] = (port & 0x00FF);

    char * hname = ACP_SERVER;

    netapp_ipconfig(&test_config);

    acp_server_printf("acp_server: gethostbyname STARTED \n");


    if( gethostbyname(hname, strlen(hname), &server_ip) <= 0)
    {
    acp_server_printf("acp_server: gethostbyname FAILED - retrying \n");
    //closesocket(sock);
    delay_us(100000);
    if( gethostbyname(hname, strlen(hname), &server_ip) <= 0){
    acp_server_printf("acp_server: gethostbyname FAILED - retry 2 \n");
    delay_us(100000);
    if( gethostbyname(hname, strlen(hname), &server_ip) <= 0)
    return -1;
    }
    }


    serv_addr.sa_data[5] = (uint8_t) LONG_BYTE_N(server_ip, 0);
    serv_addr.sa_data[4] = (uint8_t) LONG_BYTE_N(server_ip, 1);
    serv_addr.sa_data[3] = (uint8_t) LONG_BYTE_N(server_ip, 2);
    serv_addr.sa_data[2] = (uint8_t) LONG_BYTE_N(server_ip, 3);

    acp_server_printf("acp_server: start connect() \n");
    if ( connect ( sock, &serv_addr, sizeof(serv_addr) ) < 0 )
    {
    acp_server_printf("acp_server: connect() FAILED \n");
    //closesocket(sock);
    return -1;
    }

    acp_server_printf("Connected to SOCKET %ld \n", sock);

    return sock;
    }


    CONNECTION function:

    bool wifiConnect(void) {

    ulSmartConfigFinished = 0;
    ulCC3000Connected = 0;
    ulCC3000DHCP = 0;
    OkToDoShutDown=0;
    timer_t t[1];

    // Use any connection method
    wlan_ioctl_set_connection_policy(DISABLE, ENABLE, ENABLE);

    // reset the CC3000
    wlan_stop();

    // Clear chip select
    SPI_CS_PORT_OUT |= SPI_CS_PIN; //high
    timer_delay(100);

    wlan_start(0);

    // Blink until we get an address
    //led_startBlink(LEDS, 500);



    //Wait until CC3000 is connected
    timer_init(t, 15000);

    timer_start(t);
    while (!timer_expired(t)){

    if(ulCC3000Connected == 1
    && ulCC3000DHCP ==1
    )
    {
    // Blink twice once we finish
    led_allOn();
    timer_delay(100);
    led_allOff();
    timer_delay(100);
    led_allOn();
    timer_delay(100);
    led_allOff();

    // Mask out all non-required events
    wlan_set_event_mask(HCI_EVNT_WLAN_KEEPALIVE|HCI_EVNT_WLAN_UNSOL_INIT|HCI_EVNT_WLAN_ASYNC_PING_REPORT);

    return true;
    }
    }

    return false;

    }


    Here an example of LOG

    acp_server: gethostbyname STARTED
    acp_server: gethostbyname FAILED - retrying
    acp_server: gethostbyname FAILED - retry 2
    acp_file: datasock failed to open during AUTHENTICATION
    acp_server: gethostbyname STARTED
    acp_server: gethostbyname FAILED - retrying
    acp_server: gethostbyname FAILED - retry 2
    acp_file: datasock failed to open during AUTHENTICATION
    acp_server: gethostbyname STARTED
    acp_server: gethostbyname FAILED - retrying
    acp_server: gethostbyname FAILED - retry 2
    acp_file: datasock failed to open during AUTHENTICATION
    acp_server: gethostbyname STARTED
    acp_server: gethostbyname FAILED - retrying
    acp_server: gethostbyname FAILED - retry 2
    acp_file: datasock failed to open during AUTHENTICATION
    acp_server: gethostbyname STARTED
    acp_server: gethostbyname FAILED - retrying
    acp_server: gethostbyname FAILED - retry 2
    acp_file: datasock failed to open during AUTHENTICATION
    acp_server: gethostbyname STARTED
    acp_server: gethostbyname FAILED - retrying
    acp_server: gethostbyname FAILED - retry 2
    acp_file: datasock failed to open during AUTHENTICATION
    acp_server: gethostbyname STARTED
    acp_server: gethostbyname FAILED - retrying
    acp_server: gethostbyname FAILED - retry 2
    acp_file: datasock failed to open during AUTHENTICATION
    acp_server: gethostbyname STARTED
    acp_server: gethostbyname FAILED - retrying
    acp_server: gethostbyname FAILED - retry 2
    acp_file: datasock failed to open during AUTHENTICATION
    acp_file: datasock failed to open during AUTHENTICATION
    acp_file: datasock failed to open during AUTHENTICATION
    acp_file: datasock failed to open during AUTHENTICATION
    acp_file: AUTHENTICATION SOCKET OPEN FAILED 10 times - cc3000_power_cycle
    acp_server: gethostbyname STARTED
    acp_server: start connect()
    Connected to SOCKET 0
  • Hi Fabrizio,

    I will try this on my setup and get back to you.
    Can you please confirm the return type of gethostbyname?

    Regards,
    Raghavendra
  • I got the following result from the gethostbyname when failing. As you can see..in this case a retry worked. What does -95 mean?

    Here the log:

    acp_server: gethostbyname STARTED
    acp_server: gethostbyname FAILED returned -95 - retrying
    acp_server: gethostbyname SUCCESS - value: 1
    acp_server: start connect()
    Connected to SOCKET 0
    acp_file: connecting to 25:4c:92:39:cd:20
    acp: status - establish ok


    I modified the retry structure like this to print the result:

    long int n = 0;

    if((n = gethostbyname(hname, strlen(hname), &server_ip)) <= 0)
    {
    acp_server_printf("acp_server: gethostbyname FAILED returned %ld - retrying \n",n);
    //closesocket(sock);
    delay_us(100000);
    if((n = gethostbyname(hname, strlen(hname), &server_ip)) <= 0){
    acp_server_printf("acp_server: gethostbyname FAILED returned %ld - retrying 2 \n",n);
    delay_us(100000);
    if((n = gethostbyname(hname, strlen(hname), &server_ip)) <= 0){
    acp_server_printf("acp_server: gethostbyname FAILED returned %ld \n",n);
    return -1;
    }

    }
    }

    acp_server_printf("acp_server: gethostbyname SUCCESS - value: %ld \n", n);
  • And here 1 minute later..the connect hanging after a gethostbyname success. I am trying with all the


    CLOSING SOCKET 0 - result: 0

    acp_server: gethostbyname STARTED
    acp_server: gethostbyname SUCCESS - value: 1
    acp_server: start connect()
    hci: event handler timeout -27972ýacp: mtu 266 bytes
    main: Reset Cause = 0



    I even got a different number from gethostbyname: -161

    acp_server: gethostbyname STARTED
    acp_server: gethostbyname FAILED returned -161 - retrying
    acp_server: gethostbyname SUCCESS - value: 1
    acp_server: start connect()
    Connected to SOCKET 0
    acp_file: Time received 1426891391
  • I am adding another log. This is very strange since it seems the closing of the socket FAILED after a successful GET call for the server timestamp. Then I get the same error on the succesful gethostbyname and the following retry stuck the hci event handler. 

    After 10 time out, It supposedly reset...but it did not and the printf got stuck.

    Connected: ip assigned 192.168.1.6
    acp_server: gethostbyname STARTED
    acp_server: gethostbyname SUCCESS - value: 1
    acp_server: start connect()
    Connected to SOCKET 0
    acp_file: Time received 1427105416

    CLOSING SOCKET 0 - result: -99

    acp_server: gethostbyname STARTED
    acp_server: gethostbyname FAILED returned -99 - retrying
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    hci: event handler timeout
    h

  • Hi Fabrizio,

    The error code -95 is ARP_REQUEST_FAILED. You can check all the error codes in error_codes.h in the host driver.
    If you get this error code you can do a re-try.

    But rest of the errors are strange. If you look at the error code they do not correlate. Can you please pull a dump from the SPI driver and check if the same error codes are propagated to the driver as well?

    I have tried the above scenario and it works for me. Would it be possible to try this with SDK 1.12 and service pack 1.26?

    Regards,
    Raghavendra