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.

ti.sysbios.gates.GateMutex: line 97: assertion failure: A_badContext: bad

Other Parts Discussed in Thread: SYSBIOS, CC3200

Hi,

I am using CCS5 for my project with SYSBIOS for DSP. When I debug my code for certail unit test I get following error.

Error: ti.sysbios.gates.GateMutex: line 97: assertion failure: A_badContext: bad calling context. See GateMutex API doc for details.

But when I debug the same code using CCS4, I dont get any errors. This makes confusing to me. Does CCS4 and CCS5 works differenntly.

Also, my code works fine in both versions 4 and 5 if I remove the unit testing functionality.

Scenario1:

With Unit testing functinality enabled:

CCS5 TASK A->UnittestFunction()->SWI ----- generates error.

Without Unit test functionality:

CCS5 Hardware ISR function --> SWI ---- works fine.

Scenario 2:

With Unit testing functinality enabled:

CCS4 TASK A->UnittestFunction()->SWI ----- Works fine.

Without Unit test functionality:

CCS4 Hardware ISR function --> SWI ---- works fine.

I had gone through wik forum, as many of developers faced lot of issues, but not similar to this one.

If anybody have answers, please let me know.

Regards,

Sachin

 

 

  • Hi Sachin,

    You are correct that there has been a slight change to GateMutex in SYS/BIOS 6.31 (default in CCS v5).  If you look at the definition of GateMutex API it states

    "GateMutex uses a Semaphore as the resource locking mechanism. Each  GateMutex instance has its own unique Semaphore. This gate can only be  used by a Task as a gate can potentially block. This gate cannot be used  by a Hwi or Swi"

    starting with SYS/BIOS 6.31, an assert has been added to make sure GateMutex is not being called inside a SWI.  This assert will result in the error above.

     

  • Hi Juan,

    Then what is the solution to handle this. As we have coded all the tasks like that only. Can you point me some example documentation on this. Since I need to complete the old unit test cases to rin on new ported code.

     

    Regards,

    Sachin

     

  • Hi Sachin,

    You should not use a mutex (or GateMutex) inside a SWI.  In general, a software interrupt (SWI) is supposed to execute quickly and not block (for example on mutexes).  Can you describe your use case, maybe provide a code snipet or pseudocode to help us provide an appropriate recommendation (example code) of how you can implement your use case.

    If you go to Help-> Help Contents in CCSv5 and search on SWI and GateMutex, you can read some background on using these.  There are also additional modules within the Gate package (e.g. GateSwi) that may be suitable to your use case, but we need more information on your use case to provide a recommendation.

    Regards,

    Juan

  • Thanks for your help. I had to change my code. and I apologize for late reply.

    Since I was using printf in SWI code, which I removed and code started working again.

     

    Regards,

    Sachin

  • Hi,

    I want to execute the following code (every few microseconds):

    Status= sl_Send(socket_descriptor,RawData,sizeof(RawData),0);
    Report("sl_Send_Status = %d. Data sent: %s. sizeof(RawData):%d.\n\r",Status,RawData,sizeof(RawData));

    if(Status < 0)
    {
    UART_PRINT("Transmition Failed!\r\n");
    sl_Close(socket_descriptor);
    }

    that is, to send a packet in the stack bypass mode using a CC3200.

    How can I do that? if possible, please provide a working example. Thanks!

    So far I am creating a clock and on the rising edge I execute the code above. The complete code is:

    Void clk0Fxn(UArg arg0);
    Void clk1Fxn(UArg arg0);

    ...

    in the main

    // Configure and start clock
    Clock_Params clkParams;

    /* Create a periodic Clock Instance with period = 5 system time units */
    Clock_Params_init(&clkParams);
    clkParams.period = 10000; //10s
    clkParams.startFlag = TRUE;
    Clock_create(clk0Fxn, 10000, &clkParams, NULL); 

    /* Create an one-shot Clock Instance with timeout = 11 system time units */
    clkParams.period = 0;
    clkParams.startFlag = FALSE;
    clk2 = Clock_create(clk1Fxn, 11000, &clkParams, NULL);

    Clock_start(clk2);

    ...

    Void clk0Fxn(UArg arg0)
    {

    Status= sl_Send(socket_descriptor,RawData,sizeof(RawData),0);
    Report("sl_Send_Status = %d. Data sent: %s. sizeof(RawData):%d.\n\r",Status,RawData,sizeof(RawData));

    if(Status < 0)
    {
    UART_PRINT("Transmition Failed!\r\n");
    sl_Close(socket_descriptor);
    }

    }

    But when I debug the code I get the following error in the console after 10s:

    ti.sysbios.gates.GateMutex: line 99: assertion failure: A_badContext: bad calling context. See GateMutex API doc for details.
    xdc.runtime.Error.raise: terminating execution

    I guess because I am using a mutex (or GateMutex) inside a SWI. What can I do?

     Note: since this question is answered, and I am afraid therefore nobody will look at it, I opened a new thread:

    http://e2e.ti.com/support/embedded/tirtos/f/355/t/376920.aspx

  • Is there a way to use printf in SWI code? Same thing is happening to me when am making an SWI function. Printf doesn't work.
  • Ankush Jolly said:
    Is there a way to use printf in SWI code? Same thing is happening to me when am making an SWI function. Printf doesn't work.

    Could you please start a new thread for this question?  This thread is very old and the headline doesn't really match your particular issue.

    Regards,

    - Rob