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.

CC3135: How to port simplelink drivers to a non-TI platform?

Part Number: CC3135


ti/drivers/net/wifi/slnetifwifi.h file includes ti/net/slnetsock.hwhich in turn calls posix semaphore API which my rtos does not provide. The porting guide, swru455m, does not cover this. What should i do here? I just want to turn on the wifi and make a TCP conection with a server. i dont need any of those http, mqtt and sntp libraries in the net directory. Also why doesn't it make use of the sl_SyncObj* macros which already uses semaphores?

  • Hello,

    The SlNetIf and SlNetSock libraries are helpful if you are writing a portable application, especially if your application has both Wi-Fi and Ethernet. Otherwise, they are not required. You can use the host driver sl_* API calls directly as shown in SWRU455. For example, you can remove those linked libraries from the network_terminal, provisioning, and power_measurement examples with no other changes needed.

    The sl_SyncObj* macros are specific to our device's host driver, but the other libraries are common among other SimpleLink devices. All these libraries use POSIX, which is an IEEE-standard RTOS API layer that makes porting the RTOS easier for customers that want to use these pre-built libraries. Our plugin provides this API layer for TI-RTOS and FreeRTOS, but it can be implemented for any RTOS.

    Best regards,

    Sarah

  • I've gotten it to work but can't get speeds more than 40KiBps. I suspect it has to do with how I'm calling sl_Task. The driver is set to be in non-rtos mode. I create a new thread at startup that will keep on calling the sl_Task function. In the main thread i call the rest of the sl_Start -> sl_Connect -> sl_Send functions. With a TCP server running on my PC, the max speed that it can get is 40 KiBps. If i put it in AP mode and curl the inbuilt HTTP server i can get around 250KiBps. The host is a STM32 L476 Nucleo board. What speed can be expected on a 2.5GHz access point?

  • Hello,

    The max data throughput listed in the CC3135 datasheet is 16 Mbps UDP and 13 Mbps TCP, but this is assuming your host driver layer is also at max throughput. Depending on how often you are calling sl_Task, this may be where you're bottlenecking.

    Why are you calling sl_Task in a thread instead of using the RTOS directly with the driver? What is the priority of the thread calling sl_Task?

    This E2E post may be helpful to explain how we measure throughput in our tests: e2e.ti.com/.../733986

    Best regards,

    Sarah

  • >Why are you calling sl_Task in a thread instead of using the RTOS directly with the driver

    The driver was calling posix APIs which my RTOS did not provide. Ive now made the required changes and now its running the SL_PLATFORM_MULTI_THREADED version of the driver but still the performance is exactly the same.

  • >What is the priority of the thread calling sl_Task

    Its set to higher priority than the main thread. Also unless i call yield() (or a printf) after sl_Send(), it sends a few KiBs and then stalls. Maybe there is something in sl_Send() that is causing the sl_Task() to starve.

  • Hello,

    Can you share how you are calling sl_Send()? Can you test the network_terminal example and compare the behavior?

    Best regards,

    Sarah

  • Here is the code that i used

    #include "mbed.h"
    #include "ti/drivers/net/wifi/device.h"
    #include "ti/drivers/net/wifi/sl_socket.h"
    #include "ti/net/slneterr.h"
    #include "ti/net/slnetsock.h"
    
    void runSlTask()
    {
            sl_Task(nullptr);
    }
    
    int main()
    {
            Thread thread;
            thread.set_priority(osPriorityHigh);
            thread.start(callback(runSlTask));
    
            DigitalOut led(LED1);
            DigitalOut nReset(PC_8, false);
            ThisThread::sleep_for(500);
            nReset = true;
    
            printf("==============\r\n");
    
            auto result = sl_Start(nullptr, nullptr, nullptr);
            const auto sockid = sl_Socket(SL_AF_INET, SL_SOCK_STREAM, 0);
    
            constexpr SlTimeval_t timeVal{ 20, 0 };
    
            auto sockOptSetResult = sl_SetSockOpt(sockid, SL_SOL_SOCKET, SL_SO_RCVTIMEO, &timeVal, sizeof(timeVal));
            if (sockOptSetResult != 0) {
                    printf("ERR\r\n");
                    NVIC_SystemReset();
            }
            constexpr SlSockNonblocking_t enableOption{ 1 };
    
            sockOptSetResult = sl_SetSockOpt(sockid, SL_SOL_SOCKET, SL_SO_NONBLOCKING, (_u8 *)&enableOption, sizeof(enableOption));
            if (sockOptSetResult != 0) {
                    printf("ERR\r\n");
                    NVIC_SystemReset();
            }
    
            SlSockAddrIn_t addr;
            addr.sin_family = SL_AF_INET;
            addr.sin_port = sl_Htons(8888);
    
            addr.sin_addr.s_addr = sl_Htonl(SL_IPV4_VAL(192, 168, 42, 130));
    
            result = SLNETERR_BSD_EALREADY;
    
            constexpr auto POLL_INTERVAL = 2;
            constexpr auto MAX_POLL = 20000;
            constexpr auto MAX_POLL_CONNECT = MAX_POLL;
    
            for (int i = 0; i < MAX_POLL_CONNECT && result == SLNETERR_BSD_EALREADY; i++) {
                    result = sl_Connect(sockid, reinterpret_cast<SlSockAddr_t *>(&addr), sizeof(SlSockAddrIn_t));
                    ThisThread::yield();
                    if (result < 0) {
                            ThisThread::sleep_for(POLL_INTERVAL);
                    }
            }
    
            if (result < 0) {
                    printf("Failed to connect %d\n", result);
                    NVIC_SystemReset();
            }
    
            constexpr auto BUFFER_SIZE = 1 * 1024;
            static char buffer[BUFFER_SIZE];
            std::transform(std::begin(buffer), std::end(buffer), std::begin(buffer),
                           [](char) -> char { return static_cast<char>(std::rand()); });
    
            for (int i = 0; i < 1024 * 1024; i++) {
                    result = SLNETERR_BSD_EAGAIN;
                    for (int k = 0; k < MAX_POLL && result == SLNETERR_BSD_EAGAIN; k++) {
                            {
                                    result = sl_Send(sockid, buffer, sizeof(buffer), 0);
                            }
                            if (result != sizeof(buffer)) {
                                    ThisThread::sleep_for(POLL_INTERVAL);
                            } else {
                                    led = !led;
                            }
                    }
                    ThisThread::yield();
    
                    if (result < 0) {
                            printf("Failed to send%d\n", result);
                            NVIC_SystemReset();
                    }
            }
    
            sl_Close(sockid);
            sl_Stop(0xFFFF);
    }
    

  • Hello,

    Can you clarify what behavior you mean when send stalls? Do you see some packets sent correctly and then no more are sent? Or are you stepping through your code and see a function hanging?

    Please be sure that you have that latest servicepack version flashed.

    Best regards,

    Sarah

  • With the help of DMA, i can get it upto 1.5MiBps.