4 years ago.

cc3000_NTP_demo with shield on Arch Max, LPCExpresso4337 and Nucleo F411RE

Hi mbed-gurus and friends,

I have been trying an Adafruit cc3000 shield on those platforms: Arch Max / LPCExpresso4337 / Nucleo F411RE. Each platform obviously has access to the cc3000 chip. It can read the MAC address and Firmware version, connects to the WiFi, and it even gets an IP address via DHCP from the router, which I can ping from the laptop.

The program I use to test is the cc3000_ntp_demo, slightly modified to get GPIO correct for the shield. It uses the libraries: cc3000_hostdriver_mbedsocket, NTPClient, and NVIC_set_all_priorities.

Once it comes to accessing the internet, for example getting the time from an NTP-server, it hangs there, when calling ntp_client.setTime(domain_name, port_number). The problem seems to receive data with the socket. It comes in a loop, because the socket is not readable (DEBUG enabled): .

[CC3000 : HCI TX] Command Sent : 0x1008
[CC3000 : HCI RX] Event Received : 0x1008 - BSD Select
[CC3000 : SOCKET] Select on sock_fd: 0, returns 0. fdSet: 0
[CC3000 : SOCKET] The socket is not readable. _sock_fd: 0


That happens with either of three used platforms, and both with connecting the Adafruit cc3000 module and shield. I thought it could have to do with my router, but running an NTP test via the Arch Max Ethernet port (hardwired) works just fine.

I tried several NTP servers and several Access Points, all with the same result.

The voltages measured on the cc3000 shield power pins look fine: 5.03V and 3.32V. I had an extra power supply connected to the 5V pin, otherwise it would read 4.59V. That didn't do the trick, though.

I'm sure I'm overlooking something. Any help is appreciated on how to troubleshoot this.

The output looks like: .

mbed cc3000 NTP client demo. 
Initialize the interface with DHCP...
Read from cc3000...
Firmware version: 1.32
MAC address     : 08:00:28:57:A0:5A
WiFi parameters:
SSID            : Prakjaroen
Phrase          : A4B5C6D7E8F9
Security        : WPA2
Bring the interface up...
IP              :
Netmask         :
Gateway         :
MAC             :
Connected       : 1
DHCP            : 1
Enabled         : 1
Reading time...
[CC3000 : HCI TX] Command Sent : 0x1001
[CC3000 : HCI RX] Event Received : 0x1001 - Socket
[CC3000 : SOCKET] Socket created (fd: 0 type: 2, protocol: 17)
[CC3000 : HCI TX] Command Sent : 0x1002
[CC3000 : HCI RX] Event Received : 0x1002 - Bind
[CC3000 : HCI TX] Command Sent : 0x1010
[CC3000 : HCI RX] Event Received : 0x1010 - Get Hostname
[CC3000 : SOCKET] remote host address (string):
[CC3000 : SOCKET] remote host address from s_addr :
[CC3000 : SOCKET] port: 123
[CC3000 : HCI RX] Event Received : 0x100F - Send To
[CC3000 : HCI TX] Command Sent : 0x1008
[CC3000 : HCI RX] Event Received : 0x1008 - BSD Select
[CC3000 : SOCKET] Select on sock_fd: 0, returns 0. fdSet: 0
[CC3000 : SOCKET] The socket is not readable. _sock_fd: 0
[CC3000 : HCI TX] Command Sent : 0x1008
[CC3000 : HCI RX] Event Received : 0x1008 - BSD Select
[CC3000 : SOCKET] Select on sock_fd: 0, returns 0. fdSet: 0
[CC3000 : SOCKET] The socket is not readable. _sock_fd: 0


Note: "The socket is not readable. _sock_fd: 0" .

Main.cpp: .

/* mbed Microcontroller Library
 * Copyright (c) 2006-2013 ARM Limited
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.
#include "mbed.h"
#include "cc3000.h"
#include "main.h"
#include "NTPClient.h"

#define CC3000_IRQ   D3  // (D3)
#define CC3000_EN    D5  // (D5)
#define CC3000_CS    D10 // (D10)
#define CC3000_MOSI  D11 // (D11)
#define CC3000_MISO  D12 // (D12)
#define CC3000_SCLK  D13 // (D13)

#define SSID         "Prakjaroen"
#define PHRASE       "A4B5C6D7E8F9"
#define SECURITY     WPA2

#define IP           ""
#define MASK         ""
#define GW           ""
#define DHCP         0
#define STATIC_IP    1
#define IP_INIT      DHCP

using namespace mbed_cc3000;

// cc3000 wifi(irq, en, cs, SPI(mosi, miso, sclk), SSID, PHRASE, WPA2, false);
// +5V  VCC     5V               +5V
// GND  GND     GND              GND
// D8   INT     Interrupt        PA_9
// D9   EN      WiFi Enable      PC_7
// D10  CS      SPI Chip Select  PB_6
// D11  MOSI    SPI MOSI         PA_7
// D12  MISO    SPI MISO         PA_6
// D13  SCK     SPI Clock        PA_5

/* cc3000 module declaration specific for user's board. Check also init() */
#if (MY_BOARD == WIGO)
cc3000 wifi(PTA16, PTA13, PTD0, SPI(PTD2, PTD3, PTC5), SSID, PHRASE, SECURITY, false);
Serial pc(USBTX, USBRX);
cc3000 wifi(p28, p27, p30, SPI(p21, p14, p37), SSID, PHRASE, SECURITY, false);
Serial pc(UART_TX, UART_RX);
cc3000 wifi(CC3000_IRQ, CC3000_EN, CC3000_CS, SPI(CC3000_MOSI, CC3000_MISO, CC3000_SCLK), SSID, PHRASE, SECURITY, false); //SparkFun Board on Arduino pin definitions
//Serial pc(USBTX, USBRX);
Serial pc(P2_10, P2_11); // TX, RX


// array to store RM parameters from EEPROM
unsigned char cRMParamsFromEeprom[128];

// array to store MAC address from EEPROM
unsigned char cMacFromEeprom[6];

 *  \brief NTP client demo
 *  \param  none
 *  \return int
int main() {
    uint8_t firmware_ver[2];
    signed char mac_status = -1;
    unsigned char FW_status = 1;

    init(); /* board dependent init */
    printf("\r\n\r\nmbed cc3000 NTP client demo. \r\n");

    printf("Initialize the interface with a static IP address...\r\n");
    wifi.init(IP, MASK, GW);
    printf("Initialize the interface with DHCP...\r\n");
#endif /* STM32F10X_CL */

    printf("Read from cc3000...\r\n");
    // Read Firmware Version and MAC Address
    FW_status = wifi.read_sp_version(firmware_ver);   // read actual Firmware version
    if(FW_status == 0){
        printf("Firmware version: %d.%d\n\r",firmware_ver[0],firmware_ver[1]);
        mac_status = wifi.get_mac_address(cMacFromEeprom);
        if(mac_status == 0){
            printf("MAC address     : ");
            for(int i = 0; i < 6; i++) {
                printf("%02X", cMacFromEeprom[i]);
                if (i < 5) printf(":");
    } else {
        printf("ERROR: CC3000 not found - check connections !\r\n");

    // WiFi parameters
    printf("WiFi parameters:\r\n");
    printf("SSID            : %s\r\n", SSID);
    printf("Phrase          : %s\r\n", PHRASE);
    printf("Security        : ");
    if (SECURITY == 0) printf("NONE");
    if (SECURITY == 1) printf("WEP");
    if (SECURITY == 2) printf("WPA");
    if (SECURITY == 3) printf("WPA2");
    // Connect to WiFi
    printf("Bring the interface up...\r\n");
    if (wifi.connect(30000) == -1) {
        printf("ERROR: Failed to connect. Please verify connection details and try again.\r\n");
    char *ip     = wifi.getIPAddress();
    char *mask   = wifi.getNetworkMask();
    char *gate   = wifi.getGateway();
    char *mac    = wifi.getMACAddress();
    bool conn    = wifi.is_connected();
    bool dhcp    = wifi.is_dhcp_configured();
    bool enabled = wifi.is_enabled();
    printf("IP              : %s\r\n", ip);
    printf("Netmask         : %s\r\n", mask);
    printf("Gateway         : %s\r\n", gate);
    printf("MAC             : %s\r\n", mac);
    printf("Connected       : %d\r\n", conn);
    printf("DHCP            : %d\r\n", dhcp);
    printf("Enabled         : %d\r\n", enabled);

    // Read time from server
    NTPClient ntp_client;
    // NTP Server Parameters
    char* domain_name = "";
    int   port_number = 123;

    // Read time from server
    printf("Reading time...\r\n");
    if (ntp_client.setTime(domain_name, port_number) == 0)
        printf("Set time successfully.\r\n");
        time_t ct_time;
        char time_buffer[80];    
        ct_time = time(NULL) + 7200; // Summer time - Convert to Europe/Amsterdam Time
        strftime(time_buffer, 80, "%a %d-%b-%Y %T\r\n", localtime(&ct_time));
        printf("Time            : %s\r\n", time_buffer);
        printf("ERROR: Failed set time.\r\n");

    printf("Demo completed.\r\n");

There was an issue and a work around used for the NTP demo, when it was first tested. I don't know if anybody has checked if the demo still works after the many cc3000 firmware updates that have taken place. I will check as soon as i can get some free time, unless someone else jumps in.

posted by David Fletcher 10 Aug 2015
Comment on this question

1 Answer

4 years ago.

Jack, sorry for the delay! I have now had time to check the NTP demo. It appears that i get the same error as you. I have 2 cc3000, they both had old firmware 1.24 and 1.28, even the 1.24 firmware failed in the same place, 1.28 failed on gethostbyname and also the same socket error. I dont know at this point if the error is with TI's firmware or with the host driver, my gut feeling is the firmware is at fault. It appears that the error is the same as the original socket write error (Which is still faulting if used!) I will try looking further, if i get lucky, i will get back to you. Maybe Frank will see this and also take a look.

Hi David, thank you very much! Nice to know it could be reproduced. I found this program CC3300_FW_Update, which updated firmware to 1.32, but it did not solve the issue either.

posted by Jack Berkhout 14 Aug 2015

Yes I know 1.32 gives the same error. I have done some more checks going back to a pre-release host driver, to try and find the bug. The pre-release works with 1.32 sp 1.14 so I think a bug has been introduced into the host driver, it appears to be something to do with read select, but it maybe elsewhere. I will look further. Please raise an issue for Martin to look at.

posted by David Fletcher 14 Aug 2015