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.

CC3220S-LAUNCHXL: Unable to run the 'subscribe_publish_sample' in the SimpleLink CC32XX SDK AWS IoT Plugin.

Part Number: CC3220S-LAUNCHXL
Other Parts Discussed in Thread: CC3220S

Hello,

I am trying to get the ‘subscribe_publish_sample’ example project for Amazon Web Services (AWS) IoT up and running on a CC3220S LaunchPad board but have not been successful. After making some corrections to the code and project I was eventually able to get the example to build. However, the program fails at run-time somewhere inside the call to sl_Start() that occurs inside setStationMode(), of the module netwifi.c.  The call to sl_Start() never returns.

Specifically I am building the FreeRTOS, GCC variation of the example, using CCS v7 as the IDE.

The example project is imported from the SimpleLink CC32XX SDK AWS IoT Plugin (aws_cc3220_1_00_00_12). I am using the SimpleLink SDK (simplelink_cc32xx_sdk_1_40_00_03) and FreeRTOSv9.0.0.

 

To get the project to build I needed to make the following corrections to the project and files.

In the file

${COM_TI_AWS_CC32XX_INSTALL_DIR}\source\ti\net\socket.h

fixed the paths to three header files and included two missing header files.

#elif defined(NET_SL)

#include <ti/drivers/net/wifi/simplelink.h>
 
#include <ti/drivers/net/wifi/bsd/sys/socket.h> /* SML - fixed path */
//#include <ti/drivers/net/wifi/sys/socket.h>
 
#include <ti/drivers/net/wifi/bsd/errno.h>     /* SML - fixed path */
//#include <ti/drivers/net/wifi/sys/errno.h>
 
#include <ti/drivers/net/wifi/bsd/netdb.h>     /* SML - fixed path */
//#include <ti/drivers/net/wifi/sys/netdb.h>
 
#include <ti\drivers\net\wifi\bsd\netinet\in.h> /* SML - included header file*/
#include <ti\drivers\net\wifi\bsd\arpa\inet.h> /* SML - included  header file */
 
 
#elif defined(NET_NDK)

 In the project linker file CC3220S_LAUNCHXL_FREERTOS.lds

Added the symbol _stack_end

  .stack (NOLOAD) : ALIGN(0x8) {
       _stack = .;
       __stack = .;
       _stack_end = __stack; /* Symbol required by FreeRTOS */
       KEEP(*(.stack))
   } > REGION_STACK AT> REGION_STACK

 

Finally, in the project settings (properties) for the linker (build->GNU Linker) it was necessary to remove the paths from the individual library options and add those paths to the Library search paths.

 For example,

":${COM_TI_SIMPLELINK_CC32XX_SDK_INSTALL_DIR}\source\ti\drivers\net\wifi\gcc\rtos\simplelink.a"

 Changed to:

”:simplelink.a"

 and then the following library search path added to the linker options:

"${COM_TI_SIMPLELINK_CC32XX_SDK_INSTALL_DIR}\source\ti\drivers\net\wifi\gcc\rtos"

 

Has anyone been able to successfully run this AWS sample project.  Can someone suggest why this example does not run?

Thank you,

Steve

  • Hi Steve,

    The aws plugin (aws_cc3220_1_00_00_12) was built for simplelink_cc32xx_sdk_1_30_01_03, and hasn't yet caught up with the new sdk 1.40 update which was just released, which I think is why the examples didn't build directly for you.

    I think you've made all the changes necessary though, but I think you need one amendment in the linker command file.

        .stack (NOLOAD) : ALIGN(0x8) {
            _stack = .;
            __stack = .;
            KEEP(*(.stack))
            . += 0x800;
            _stack_end = .;
            __stack_end = .;
        } > REGION_STACK AT> REGION_STACK
    

    Could you give that a try please?

    ~roger

  • Thank you Roger - that appears to have been the problem.

    I probably should have noticed when I added the symbol __stack_end that there was actually a zero-length stack. Stepping through the code I was seeing what I appeared to be corrupted OS list objects and that would make sense as the stack would have been growing up through the heap. In any case, I seem to be up and running again.

    Thanks again,
    Steve
  • Well, it seems that I am not out of the woods yet. When I ran the example I found that I was unable to connect to the AWS endpoint and I realized that the local time setting was wrong. The problems are related to use of the C Time library <time.h>, specifically use of the functions time() and localtime().

    I traced the issue to the call to SNTP_getTime() that is made inside startNTP(). In particular, the callback function setTime() which is passed into and ultimately called from within SNTP_getTime().

    There are a few problems in setTime(), but I verified that the argument that is passed to it does correctly represent the epoch time, so the code that obtains a time value from the NTP server is working properly.

    The first problem in setTime() is that it makes a call to the system time() function which does not appear to be implemented as the value output by the call to time() is always -1. The call stack shows the following:

    time()

       _gettimeofday_r()

          _gettimeofday()

    From the .map file I see that the function _gettimeofday() is obtained from gettod.o in the library libnosys.a

    I modified the setTime() function to set the ts value to the epoch time passed in through the argument t. This at least provided me with a valid GMT time.

    /*
     *  ======== setTime ========
     */
    void setTime(uint32_t t)
    {
        SlDateTime_t dt;
        struct tm tm;
        struct timespec tspec;
        time_t ts;
    
        tspec.tv_sec = t;
        clock_settime(CLOCK_REALTIME, &tspec);
    
        time(&ts);	/* This always returns -1 */
        
        ts = (time_t) t;	/* Added - use the (correct) epoch time passed in to setTime() */
        
        tm = *localtime(&ts);	/* The resulting tm structure is valid but is a UTC time value */
    
        /* Set system clock on network processor to validate certificate */
        dt.tm_day  = tm.tm_mday;
        /* tm.tm_mon is the month since January, so add 1 to get the actual month */
        dt.tm_mon  = tm.tm_mon + 1;
        /* tm.tm_year is the year since 1900, so add 1900 to get the actual year */
        dt.tm_year = tm.tm_year + 1900;
        dt.tm_hour = tm.tm_hour;
        dt.tm_min  = tm.tm_min;
        dt.tm_sec  = tm.tm_sec;
        sl_DeviceSet(SL_DEVICE_GENERAL, SL_DEVICE_GENERAL_DATE_TIME,
                sizeof(SlDateTime_t), (unsigned char *)(&dt));
    }
    

    A call is then made to the function localtime() which does convert the epoch time and return a pointer to a valid tm structure. However, the time in that structure is always represented as UTC time.

    Setting the system clock on the network processor to a UTC time value allowed me to at least connect to the AWS endpoint, however I do need to be able to obtain the local time.   Also, even with the modification that I made the output to the console still reports the wrong time because it is relying on another call to the time() function, which again always returns -1.

    Is there a way to fix this example so that the C Time library works properly? The other two examples in the SimpleLink CC32XX SDK AWS IoT Plugin (shadow_sample and shadow_sample_console_echo) also rely on the C Time library.

    Thank you,

    Steve