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.

CC3120: Getting File for Embedded Programming

Part Number: CC3120
Other Parts Discussed in Thread: UNIFLASH

Hi, 

We are working on CC3120, And its SDK plugin. 

The CC3120 API replies with -2005 error API BLOCKED over the spi (seems like porting is not successful). Therefore we decided to first load the image through the UART and then check whether the image is properly loaded into cc3120 or not. My question is which file .bin, .hex. or .ucf file has to be moved into SRAM and Sflash of cc3120 using the bootloader mode. I managed to get through steps upto SRAM erase ( http://www.ti.com/lit/ug/swpa230a/swpa230a.pdf ), now i am wondering which file to load since i have limited memory on and off MCU STM32. and at what address of SRAM i should write the image on SRAM and Sflash. 

I tried to search documentation but mostly are removed eg http://www.ti.com/tool/EMBEDDED-PROGRAMMING 

Could you please suggest any documentation for the bootloading image via UART(since in production, uniflash tool usage will not be good idea) and getting API to work.

Thanks in advance.

Ravdeep

  • Hi Ravdeep,

    Please view the CC3120 Production Line Guide: www.ti.com/.../swra569.pdf

    Best regards,
    Kristen
  • Hi Kristen,

    We managed to port the SDK and run the trigger mode example on non-os STM32. From there we found that there are some API which get -2005 response, not all. 

    For example sl_NetAppSet, it gives -2005 error while sl_NetAppGet works. same error is received in HTTP also if in the trigger mode, HTTP is defined as (1) in place of (0)

    Even with SL_FULL defined. 

    _i16 Status;

    SlNetAppDnsClientTime_t Time;

    Time.MaxResponseTime = 2000; // Max DNS retry timeout, DNS request timeout changed every retry,

    Time.NumOfRetries = 30; // number DNS retries before sl_NetAppDnsGetHostByName failed

    Status = sl_NetAppSet(SL_NETAPP_DNS_CLIENT_ID, SL_NETAPP_DNS_CLIENT_TIME, sizeof(Time), (_u8 *)&Time);

    if( Status ) {

    // error
    }

    kindly help with the issue.

    With Regards

    Ravdeep

  • Hi Ravdeep,

    Error -2005 (SL_API_ABORTED) indicates that the host is detecting an error from the NWP or a timeout occurred on the command sent.

    This thread discusses a few debugging steps you could try: e2e.ti.com/.../2419717

    Best regards,
    Kristen
  • Thank you, Kristen,

    It was quite useful. but the problem got automatically solved when i patched the latest SDK plugin October 22, over the previous SDK.

    I am trying Trigger mode example given in the CC3120 plugin, there is one BsdTcpRxOpen() function which opens a TCP socket in Trigger mode.It gives the Fatal error fatal error: no cmd ack detected., this error is given by sl_SetSockOpt(). 

    I tested TCP server where i used sl_Select() before sl_Accept() and i received the Trigger event. But when i try the same for sl_Recv(), there is no trigger event. 

    According to Programming guide, sl_SetSockOpt() has to be used to enable nonblocking mode for working of sl_Select(). but whenever and wherever i call sl_SetSockOpt(), it gives the fatal error: no cmd ack detected. 

    Can you please help me with this.

    Ravdeep

    Referring to page 81 swru455epdf

    www.ti.com/.../swru455e.pdf

    SimpleLink supports:
    • Readfds: On data socket: data arrived. On listen
    socket: indicating new client connected
    • Writefds: only on TCP connect, must configure
    nonblocking socket
    • Exceptfds: not supported

  • Hi Ravdeep,

    Can you verify that along with the latest SimpleLink Wi-Fi SDK Plugin v2.30.00.10, you are also using the latest service pack included with that plugin?

    Best regards,
    Kristen
  • Hi Kristen,

    Yes, this the current version.

    I found that if i call sl_select on two sockets, then interrupt occurs on first one, not on second.
  • Hi Kristen,

    Both SDK and service pack are at from v2.30.00.10.

    Here what i found is that sl_select need to be called only after all the sockets. then only it allows interrupt on all readfds. So is there any function do deselect the interrupt? because i need to keep on adding sockets time to time. and calling select on the last one is unfeasible.

    With Regards,
    Ravdeep
  • Hi Ravdeep,

    I'm not sure if what you are asking for is possible. Trigger mode only supports one select operation simultaneously, as stated in the programmer's guide and API. I do not believe there is a way to "deselect" a socket. Take a look at the Programmer's Guide Section 5.7.2 ( www.ti.com/.../swru455e.pdf ). It gives code examples of using sl_select() to implement trigger mode, the host entering a deep sleep and then waking up due to an event, and then calling sl_select() again to identify which socket has network activity.

    Best regards,
    Kristen
  • Hi Kristen,

    Thanks for helping on this. you are exactly right but the problem is with the select function. if you set the rxset with the socket ID and then you open another socket and add the second socket ID using new select rxset, then the problem comes. The interrupt is only triggered for the first one, not the second one. I found a way to solve that problem, by enabling all the rxset bits at initial then it will call interrupt on all opened sockets.

    I moved on making more code and i got trouble with the sl_NetAppSet function,
    _i16 Status;
    SlNetAppDnsClientTime_t Time;
    Time.MaxResponseTime = 2000; // Max DNS retry timeout, DNS request timeout changed every retry,
    start with 100Ms up to MaxResponseTime Ms
    Time.NumOfRetries = 30; // number DNS retries before sl_NetAppDnsGetHostByName failed
    Status = sl_NetAppSet(SL_NETAPP_DNS_CLIENT_ID, SL_NETAPP_DNS_CLIENT_TIME, sizeof(Time), (_u8
    *)&Time);
    if( Status )
    {
    // error
    }

    The code works fine with all other functions but fail with setting the timout for DNS.
    What i found is that it sets the configurations but gives

    [ERROR] - FATAL ERROR: No Cmd Ack detected [cmd opcode = 0x9c0b]

    status = 0, success with MaxResponseTime = 2000 and NumOfRetries =30

    on application of the command, the fatal error comes but the status returned is 0.

    i am using
    SL_FULL
    SL_MEMORY_MGMT_STATIC

    With Regards,
    Ravdeep
  • Hi Ravdeep,

    Since you are working in non-os mode, are you periodically calling sl_Task() in your main loop to make sure asynchronous events are being processed correctly?

    Thanks,
    Ben M
  • Hi Ben,
    Yes, acutally the problem was with spi_write, if it is called immediately for setting or getting functions (the driver calls spi_write for cmd, data, payload etc many times), then cc3120 is not able to respond. I added delay between writes, then i never get the problem. SPI rate is quite lower then specifications. still it causes problems, but the fix helped me solve it.

    Being working on other stuff (sockets), I am getting one trouble with the Trigger mode. For tcp socket, i am calling select, it works fine with one socket. but when we open multiple socket, then interrupt fails for later opened sockets.

    www.ti.com/.../swru455e.pdf

    I tried one fix which worked for me. before calling the first sl_select, enabling the rxset variable fixed the issue, but i got trouble if the connection is closed by either side. then it again disables all the interrupts. It seems that their is some bug in interrupt handling for sockets. especially with the sl_select function.

    for(int i=0;i<16;i++)
    SL_SOCKET_FD_SET(i, &rxSet);

    sl_select function is ment to help mutliple sockets but it fails to reset or re-enable the trigger event.

    It will be very kind of you if you can help me with this as soon as possible as the product is stuck because of this issue.

    With Regards.

    Ravdeep

  • Hi Ravdeep,

    Ravdeep Boparai said:
    Being working on other stuff (sockets), I am getting one trouble with the Trigger mode. For tcp socket, i am calling select, it works fine with one socket. but when we open multiple socket, then interrupt fails for later opened sockets.

    Are you referring to sockets that are opened after the call to sl_Select is made?

    sl_Select must be called with rxSet specifying all sockets for which, if there is activity, you want the trigger to fire. This is because the system only supports one select operation being in progress at a time. It seems like this is exactly what you call your fix.

    Ravdeep Boparai said:
    I tried one fix which worked for me. before calling the first sl_select, enabling the rxset variable fixed the issue, but i got trouble if the connection is closed by either side.

    Can you clarify what you see happen when the connection is closed? Do you get an interrupt?

    After you receive the trigger (interrupt), you must use a call to sl_Select() to identify the network activity. Then you can re-setup the trigger mode by calling sl_Select() again with a timeout of zero.

    Best,

    Ben M

  • Hi Ben, thank you for the reply.

    You are right about sl_select rxset.

    The code is :

    static _i32 BsdTcpClient_Trigger_Mode()
    {
    _i16 sock[20]={0};
    _i16 Status,Sd,Sd1;
    _u16 nfds;
    SlSockAddrIn_t LocalAddr,Addr;
    SlSockNonblocking_t BlockingOption;
    BlockingOption.NonBlockingEnabled = 1;

    SlTimeval_t timeVal = {0};
    SlFdSet_t rxSet;
    SlFdSet_t wxSet;
    SlFdSet_t exSet;

    LocalAddr.sin_family = SL_AF_INET;
    LocalAddr.sin_port = sl_Htons(5003);
    LocalAddr.sin_addr.s_addr = sl_Htonl(SL_IPV4_VAL(10,100,75,106));
    timeVal.tv_sec = 0;
    timeVal.tv_usec = 0;

    int index = 0;
    //Open TCP server socket
    repeat:
    sock[index] = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
    CLI_Write("sock[index] = %d\n\r",sock[index]);
    if( Sd < 0 )
    {
    CLI_Write(" [TCP ] Create socket Error \n\r");
    ASSERT_ON_ERROR(Sd);
    }

    Status =
    sl_SetSockOpt(sock[index],SL_SOL_SOCKET,SL_SO_NONBLOCKING,(_u8*)&BlockingOption,sizeof(BlockingOption));
    if( Status )
    {

    CLI_Write(" [TCP ] SO_NONBLOCKING socket Error \n\r");
    }


    Status = sl_Connect(sock[index], ( SlSockAddr_t *)&LocalAddr, sizeof(SlSockAddr_t));
    if( Status )
    {

    CLI_Write(" [TCP ] Connect %d\n\r",Status);
    }

    nfds = sock[index] + 1;
    SL_SOCKET_FD_ZERO( &rxSet );
    SL_SOCKET_FD_ZERO( &wxSet );
    SL_SOCKET_FD_ZERO( &exSet );
    SL_SOCKET_FD_SET( sock[index],&rxSet );
    SL_SOCKET_FD_SET( sock[index],&wxSet );
    SL_SOCKET_FD_SET( sock[index],&exSet );
    Status = sl_Select( nfds, NULL, &wxSet, NULL, &timeVal );
    if( Status <0 )
    {
    CLI_Write(" [TCP Server] Select socket Error Status %d \n\r",Status);
    }
    int firsttime=0;
    while(1)
    {

    while(gTriggerModeEventArrived!=TRUE)
    {
    ProcessEvents();
    }
    gTriggerModeEventArrived=FALSE;

    SL_SOCKET_FD_ZERO( &rxSet );
    SL_SOCKET_FD_ZERO( &wxSet );
    SL_SOCKET_FD_ZERO( &exSet );

    Status = sl_Select( nfds, &rxSet, &wxSet, &exSet, &timeVal );
    if( Status <0 )
    {
    CLI_Write(" [TCP Server] Select socket Error Status %d \n\r",Status);
    }

    // if (SL_SOCKET_FD_ISSET(Sd, &wxSet)) I commented this out since either rxSet changes sometimes exset sometimes wxset depending on the recv, close, connect. I will not get any problem because of this since if you see my code, it opens one socket and does not open second untill first one is not close.

    {
    Status = sl_Recv(sock[index], &(uBuf.BsdBuf[0]), 5, 0);
    if( Status < 0)
    {
    if (Status != -11)
    {

    sl_Close(sock[index]);
    CLI_Write(" [TCP Server] Data recv Error \n\r");
    ASSERT_ON_ERROR(Status); //TCP_RECV_ERROR
    }
    }
    }
    CLI_Write(" [TCP Server] %2X %2X %2X %2X %2X\n",uBuf.BsdBuf[0],uBuf.BsdBuf[1],uBuf.BsdBuf[2],uBuf.BsdBuf[3],uBuf.BsdBuf[4]);
    if( Status == 0 && firsttime == 1)              //socket closed.
    {

    index++;
    goto repeat;
    }

    firsttime = 1;
    SL_SOCKET_FD_ZERO( &rxSet );
    SL_SOCKET_FD_ZERO( &wxSet );
    SL_SOCKET_FD_ZERO( &exSet );
    SL_SOCKET_FD_SET( sock[index],&rxSet );
    SL_SOCKET_FD_SET( sock[index],&wxSet );
    SL_SOCKET_FD_SET( sock[index],&exSet );
    Status = sl_Select( nfds, &rxSet, NULL, &exSet, &timeVal );
    if( Status <0 )
    {
    CLI_Write(" [TCP Server] Select socket Error Status %d \n\r",Status);
    }
    }
    }



    int32_t HandleUserApplication()
    {
    // Trigger mode code
    //-----
    BsdTcpClient_Trigger_Mode(); //called at end of the HandleUserApplication function of Trigger mode example code.
    }


    void SimpleLinkSocketTriggerEventHandler(SlSockTriggerEvent_t *pSlTriggerEvent)
    {
    switch(pSlTriggerEvent->Event)
    {
    case SL_SOCKET_TRIGGER_EVENT_SELECT:
    {
    LOG_MESSAGE("Notify User SL_SOCKET_TRIGGER_EVENT_SELECT \n\r");
    gTriggerModeEventArrived = TRUE;
    break;
    }
    default:
    break;
    }
    }


    Here if you see, if i comment sl_close, then it starts working. but still number of the sockets i was able to open were random(sometimes 5, sometimes 12), and interrupt always stops randomly.

    I even called SL_SOCKET_FD_CLR( sock[index],&rxSet ); SL_SOCKET_FD_CLR( sock[index],&wxSet ); SL_SOCKET_FD_CLR( sock[index],&exSet ); instead of sl_close but no difference.

    There is something wrong, i am not able to point out.

    With Regards
    Ravdeep

  • Hi Ravdeep,

    I'm going to close this thread because this issue is being worked on here:
    e2e.ti.com/.../761961

    Best,
    Ben M
  • Hi Ben.

    Thank you, but still i didnt got answer.

    With Regards
    Ravdeep