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.

Sniffer not working when executed from a TI-RTOS task

Other Parts Discussed in Thread: CC3200

Hello, I have developed an sniffer on the CC3200 using the trasnceiver_mode example from the SDK, my sniffer works as expected if used in that project, but now I want to move the sniffer to another project, specifically the wlan_station example.

When running my sniffer from wlan_station the application crashes, it happens just after creating the socket for the sniffer:

int iSoc = sl_Socket(SL_AF_RF, SL_SOCK_RAW, channel);

The error I'm getting is that the debugger ends the execution in a function named loader_exit and it prints an error message through the console:

ti.sysbios.family.arm.m3.Hwi: line 1095: E_hardFault: FORCED
ti.sysbios.family.arm.m3.Hwi: line 1172: E_busFault: IMPRECISERR: Delayed Bus Fault, exact addr unknown, address: e000ed38
Exception occurred in background thread at PC = 0x2000a5fe.
Core 0: Exception occurred in ThreadType_Task.
Task name: {unknown-instance-name}, handle: 0x200188e8.
Task stack base: 0x20018938.
Task stack size: 0x2000.
R0 = 0x0000000c  R8  = 0x200141a4
R1 = 0x0000978f  R9  = 0x00000000
R2 = 0x00000000  R10 = 0xffffffff
R3 = 0x00000001  R11 = 0xffffffff
R4 = 0xfee7fee7  R12 = 0x142c0300
R5 = 0x2001404c  SP(R13) = 0x2001a808
R6 = 0x20014044  LR(R14) = 0x20005bff
R7 = 0x80f44f47  PC(R15) = 0x2000a5fe
PSR = 0x01000000
ICSR = 0x0400f803
MMFSR = 0x00
BFSR = 0x04
UFSR = 0x0000
HFSR = 0x40000000
DFSR = 0x0000000a
MMAR = 0xe000ed34
BFAR = 0xe000ed38
AFSR = 0x00000000
Terminating execution...

If I manually set the PC to 0x2000a5fe the execution line is set to the return of this function:

/*
 *  ======== Task_disable ========
 */
UInt Task_disable()
{
    UInt key = Task_module->locked;

    Task_module->locked = TRUE;
    return (key);
}

Could this has anything to with the fact that now I'm launching my sniffer inside a TI-RTOS task? In the transceiver mode no tasks are used and my code runs ok. Now I'm calling from the TI-RTOS task the functions wifiSnifferSetMode and then wifiSnifferCapture, and the program crashes right after the call to the last one.

This is the sniffer I'm trying to use (I have commented out all the code but the line that creates the socket for debugging):

Pastebin with the .c file of my sniffer ->

It would be great if anybody knows how to fix this or at least point me to the right direction.

Thanks in advance

EDIT: I have uploaded my whole workspace below, just in case anyone wants to recreate the error (it's produced by the creation of the sniffer socket, line 60 of file "wifi_sniffer.c", inside "deusto_libs" folder)

The main function create the task for the gateway, the task function sets the device into station mode, set up a timer, erase the WLAN policies by calling "wifiSnifferSetMode", and then calls "wifiSnifferCapture" which is where the error occurs.

  • Hi Alex,

    There shouldn't be any reason why transceiver mode would not work with TI-RTOS. You might want to try increasing the stack size.

    -Aaron
  • Thank you for your answer!

    I have tried increasing the OSI_STACK_SIZE up to 28672, and still crashing, if I use a bigger value than that

    osi_TaskCreate( runGateway , (const signed char*)"Gateway", OSI_STACK_SIZE, NULL, 1, NULL);

    returns -1, so I guess there is no more space available


    EDIT: I have uploaded my whole workspace to the OP, for making it availabe to anybody who wanted to recreate the error.

  • Hi Alex,

    Are you able to call any other Simplelink API functions within that thread successfully?

    -Aaron

  • Yes, I even use another TCP socket without problem

  • Hi Alex,

    Due to big complexity of your code I was not able find cause of problem. But I expect that is something terribly wrong how do you use RTOS.

    Why I think that? When I added osi_Sleep(100); at line 129 of file "wifi_sniffer.c", then you application stopped crashing. This simple sleep changed time behaviour of your application. This signalise something wrong deep in your code.

    	//Close the socket
    	int ix = sl_Close(iSoc);
    #if 0
    	if(full_storage != 0)
    	{
    		return 1;
    	}
    #endif
    
            /* whith sleep your code not crash */
    	osi_Sleep(100); 
    
    	return 0;
    }
    
    /**
     * Filter the sniffed packages and leave only the ones that we want
     * @param buffer
     * @return
     */

    What you can do now:

    - you need decrease complexity or your code and find root case of problem. This problem is not due to usage RAW socket. RAW socket only show some problem which is hidden somewhere deeper.

    - First thing which will be good to check it that if you not accident call of SL API when is SimpleLink is disabled by sl_Stop().

    Jan

  • I have removed the rtos from my project as I don't really need it and now is working, so I guess this will be the solution.
    Thank you for your answers