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.

RTOS/TM4C129ENCPDT: GatewayMutex_construct and BIOS.runtimeCreatesEnabled

Part Number: TM4C129ENCPDT
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

I prefer to avoid the use of dynamic allocation in embedded systems.  To enforce this in my xxx.cfg file I have:

var BIOS = xdc.useModule('ti.sysbios.BIOS');

BIOS.runtimeCreatesEnabled = false;

In my application code I have statically allocated structures like:

static struct {
    bool initialized;
    GateMutex_Struct gate;
} Crc32State = { false };

During application start up I call XXX_construct on these structures like:

if (!Crc32State.initialized) {
  GateMutex_construct(&Crc32State.gate, NULL);
  Crc32State.initialized = true;
}

*Note that I have also tried this with a statically allocated GateMutex_Params being passed in instead of NULL but it made no difference.

The call to GateMutex_construct fails and reports the error:

ti.sysbios.gates.GateMutex: create policy error
xdc.runtime.Error.raise: terminating execution

If I follow the call stack back I find this code in the automatically generated file Gateway_pem4f.c:

/* construct */
void ti_sysbios_gates_GateMutex_construct(ti_sysbios_gates_GateMutex_Struct *__obj, const ti_sysbios_gates_GateMutex_Params *__paramsPtr )
{
xdc_runtime_Error_raiseX(NULL, ti_sysbios_gates_GateMutex_Module__id__C, NULL, 0, xdc_runtime_Error_E_generic, (xdc_IArg)"create policy error", 0);
}

It seems I have some project option configured wrong.  Isn't the point of the XXX_contruct methods not to require dynamic allocation?

Thanks for your help.

  • Hi Roy,

    Yes, the assert should not be there. What version of TI-RTOS (or SYS/BIOS) are you using? Do you have a sample project that shows this behavior? I just tried it (on TI-RTOS for TivaC 2.16.01..14) and I did not get the assert.

    Todd
  • Roy,

    Did this get resolved?

    Todd
  • Sorry to be slow getting back with you.  I had other work to do.  However, today I put together a project that shows the problem.

    I am using TI-RTOS for TivaC 2.16.0.08

    5775.Sample.zip

  • In the original posting the problem arose with the GateMutex_construct call.  The Sample application triggers the same basic problem but it is using the Mailbox_construct call.  The screenshot below shows the problem in the debugger.

    Thanks for your help.

  • Hi Roy,

    Thanks for the heads-up. I already noticed that. I'm writing up a more complete answer that I'll post later today that covers the reason for both modules behavior.

    Todd
  • Hi Roy,

    Thanks for the example. After looking at it, I realized I made a mistake when trying to reproduce it. I can now.

    Each of the modules in TI-RTOS (actually SYS/BIOS and XDCtools) have a way to describe certain aspects of the module in their .xdc files. I won't go into the details, but the short story is if the module has @InstanceInitStatic in their .xdc file, then the construct can be called if BIOS.runtimeCreatesEnabled = false; (or more specifically if module's creation policy is static). Both Mailbox and GateMutex do not have @InstanceInitStatic in their .xdc file (and thus the error in the generated code).

    So why would you leave out @InstanceInitStatic for a module? If the construct is going to allocate mmory, it should not be called. Looking at both Mailbox and GateMutex, the construct does not require memory allocation. We've actually added @InstanceInitStatic into Mailbox.xdc in newer releases. We should add it into GateMutex also (and should re-evaluate all modules).

    Options for you:
    1. Set BIOS.runtimeCreatesEnabled = true;
    2. Statically create the mailbox and GateMutex instance in the .cfg file.
    3. Modify the product code to add @InstanceInitStatic into Mailbox.xdc and GateMutex.xdc file and rebuild the product from the command line (instructions in the TI-RTOS User Guide). Take a look at Task.xdc to see an example of @InstanceInitStatic addition.

    Fyi: more details are here: rtsc.eclipse.org/.../XDCspec_-_@InstanceInitStatic if you are interested.

    Todd
  • Thanks Todd, I had already discovered that "BIOS.runtimeCreatesEnabled = true;" would allow my code to run but I wanted to follow this to its conclusion to ensure I did not have a problem lurking in the background.