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.

Issue Dynamically Creating Mailbox with SYS/BIOS v6.34

Other Parts Discussed in Thread: TMS320F2808, CODECOMPOSER

I am new user of the TMS320F2808 DSP developing C application code with Code Composer v5.3.0 and am using the SYS/BIOS v6.34.02.18.  My question is in regards to using the SYS/BIOS’s Mailbox module.  I used the “Minimal Project”example to start with for my platform with an eye on frugal memory use.  I have incremental added CPU Timer, Semaphore and a Mailbox without too much difficulty. The API in question is “Mailbox_create().”   I noticed that when I create a Mailbox dynamically in “main()” before the call to “BIOS_start()” everything works fine, however when I move it into a task and use the same code snippets creation fails .  The code snippets I cite are below:

 

    typedef struct HaloMsg {

        unsigned short mid;      /*## attribute mid */

        unsigned short control;  /*## attribute control */

        unsigned char data[8];    /*## attribute data */

    } HaloMsg;

 

    Mailbox_Params mboxParams;

    Error_Block eb;

 

    Error_init(&eb);

    Mailbox_Params_init(&mboxParams);

 

    mbox = Mailbox_create(sizeof(HaloMsg), 50, &mboxParams, &eb);

    if (mbox == NULL) {

       System_printf("taskFxn(): %s\n", Error_getMsg(&eb) );

        System_abort("Mailbox create failed");

    }

    /* Mailbox_create() sets Mailbox's initial buffer count = 50 */

 

The above code should be eerily similar to what is found on page 116 of the “TI SYS/BIOS v6.34 Real-time Operating System User's Guide”, SPRUEX3L, September 2012.  The documentation on this API within CodeComposer’s help says you can call it from the context of a running task so what am I doing wrong here?

  • Hi --

    I think you should put a breakpoint on the Mailbox_create() call and then use the Tools->RTOS Object View (ROV) tools to check how much memory is free.

    Navigate to the "HeapMem" module and check the size of the available memory. 

    I bet that you need to increase the size of your heap with BIOS.heapSize parameter in the configuration tool.

    Or, for a quicker experiment, change that '50' to '5' and see if that works.   You are need a fair chunk of memory for the mailbox structure you are creating (~500 words I think).

    We probably don't make a very large heap by default.  And the Task_create() is using some for the Task + stack.

    Regards,
    -Karl-

  • Karl,

    Good thought! I created a fresh Minimal project added in 4096 of heap space and updated the linker file to have a separate section "systemHeap", similar to the instructions on page 144 under section 6.7.2 "Specifying the Default System Heap".  Selecting Tools->RTOS Object View & inspect HeapMem I now see:

    address

    label

    buf

    minBlockAlign

    sectionName

    totalSize

    totalFreeSize

    largestFreeSize

    0x0000008c

     

    0xa000

    4

     

    0x1000

    0x0d18

    0x0d18

    Subsequently the problem has NOT occurred and I was able to create the mailbox handle in either main or the task functions.  Problem solved!

    By the way if one goes entirely static configuring modules & creating instances only from the configuration file (.cfg), and disables "Dynamic Instance Creation Support" as a memory saving measure is a "systemHeap" still needed by the BIOS to function properly?  Using the minimal project template disables dynamic memory allocation to begin with (i.e. - No malloc()/free() calls) but would the heap used elsewhere if not by the application code?

    THANKS,

     

  • If you disable "Dynamic Instance Creation", the BIOS will not do any memory allocation.  If your app doesn't do any malloc() or Memory_alloc() calls, then no heap should be required.

    -Karl-

  • Karl,

    Appreciate the focused and timely feedback!

    Thanks!

    Yusuf