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/AWR1642: SYS/bios:mailbox

Part Number: AWR1642
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

Hello,

I want to dynamically Create a SYS/bios mailbox ,but I encounter a problem.The complete codes is as follows:

#include <xdc/std.h>

#include <xdc/runtime/Error.h>
#include <xdc/runtime/System.h>

#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Mailbox.h>
#include <ti/sysbios/knl/Event.h>

Event_Handle myEvent;
Task_Handle tsk1;
Task_Handle tsk2;

Mailbox_Handle mbox;
typedef struct{
UInt id;
Char buf[10];
} msg;

msg msgC,msgA,msgB;
/****************************************************************************/
/* */
/* delay */
/* */
/****************************************************************************/
Void Delay(UInt n)
{
UInt i;

for(i=n; i>0; i--);
}

void writerTask(void)
{
Mailbox_post(mbox, &msgA, BIOS_WAIT_FOREVER);
/* implicitly posts Event_Id_00 to myEvent */
}
void isr(void)
{
Event_post(myEvent, Event_Id_01);
}
void readerTask(void)
{
UInt events;
UChar i;
while (1) {/* Wait for either ISR or Mailbox message */
events = Event_pend(myEvent,
Event_Id_NONE, /* andMask = 0 */
Event_Id_00 + Event_Id_01, /* orMask */
BIOS_WAIT_FOREVER); /* timeout */
if (events & Event_Id_00) {
/* Get the posted message.
* Mailbox_pend() will not block since Event_pend()
* has guaranteed that a message is available.
* Notice that the special BIOS_NO_WAIT
* parameter tells Mailbox that Event_pend()
* was used to acquire the available message.
*/
Mailbox_pend(mbox, &msgB, BIOS_NO_WAIT);
System_printf ("The number of circulation is %d!\n", (msgB.id));
for(i=0;i<10;i++)
System_printf ("The number of circulation is %d!\n", (msgB.buf[i]));
}
if (events & Event_Id_01) {
System_printf("The event is ----Event_Id_01----!\n");
}
}
}

/****************************************************************************/
/* */
/* task */
/* */
/****************************************************************************/
Void TaskCore1(UArg a0, UArg a1)
{
UChar i;
System_printf("Enter TaskCore1()\n");
for(;;)
{
// System_printf("TaskCore1()休眠之前*********\n");
// Task_sleep(10);
// System_printf("TaskCore1()休眠之后刚启动*********\n");
// 循环
for(i=0;i<10;i++)
{
// 延时
System_printf ("The number of circulation is %d!\n", i);
System_flush();
Delay(0x002FFFFF);
Delay(0x002FFFFF);
if(i==1)
{
writerTask();
System_printf ("The Event_Id_00 is posted!\n");
}
if(i==5)
{
isr();
System_printf ("The Event_Id_01 is posted!\n");
}
}
}
}

Void TaskCore2(UArg a0, UArg a1)
{
for(;;)
{
System_printf("Enter TaskCore2()\n");
System_flush();
//////////////////////////////////////////
readerTask();
}
}

/****************************************************************************/
/* */
/* 主函数 */
/* */
/****************************************************************************/
Int main()
{
Mailbox_Params mboxParams;
Error_Block eb;

Error_init(&eb);
myEvent = Event_create(NULL, &eb);
if (myEvent == NULL) {
System_abort("Event create failed");
}
System_printf ("The myEvent set up successful!\n");

Mailbox_Params_init(&mboxParams);
mboxParams.readerEvent = myEvent;
/* Assign Event_Id_00 to Mailbox "not empty" event */
mboxParams.readerEventId = Event_Id_00;
mbox = Mailbox_create(sizeof(msg), 50, &mboxParams,NULL);
if (mbox == NULL) {
System_abort("Mailbox create failed");
}
System_printf ("The mboxParams set up successful!\n");
/* Mailbox_create() sets Mailbox's readerEvent to
* counting mode and initial count = 50 */

UChar aa;
(msgC.id)=100;
// circultaion

for(aa=0;aa<10;aa++)
msgC.buf[aa]=aa*aa;

msgA=msgC;

//create two tasks
Task_Params taskParams;
Task_Params_init(&taskParams);
taskParams.priority = 1;
tsk1 = Task_create(TaskCore1, &taskParams, NULL);

Task_Params_init(&taskParams);
taskParams.priority = 2;
tsk2 = Task_create(TaskCore2, &taskParams, NULL);

// 启动 SYS/BIOS 系统
BIOS_start();

return(0);
}

I  rewrite mmw_dss.c based on mmw_caputre demo.there is a error when compile. the errors  as follows:

Undefined reference to 'ti_sysbios_knl_Mailbox_Params__init__S' in file ./dss_main.oe674 .xdchelp /mmw_dss C/C++ Problem

Undefined reference to 'ti_sysbios_knl_Mailbox_pend__E' in file ./dss_main.oe674 .xdchelp /mmw_dss C/C++ Problem

Undefined reference to 'ti_sysbios_knl_Mailbox_post__E' in file ./dss_main.oe674 .xdchelp /mmw_dss C/C++ Problem

when I add the content (var Mailbox = xdc.useModule('ti.sysbios.knl.Mailbox');) to the dss_mmw.cfg file,the project  compile successfully.When debugging ,it encounters the problems as follows:

[C674X_0] The myEvent set up successful!

{module#35}: line 78: error {id:0x10000, args:[0x804a1d, 0x804a1c]}

xdc.runtime.Error.raise: terminating execution

can you help me,thanks very much!

 

 

  • Hi,

    Yes, you need to add the var Mailbox = xdc.useModule('ti.sysbios.knl.Mailbox' into the .cfg file. That tells the kernel to include the module into the link.

    I'm assuming this failed on the Mailbox_create call. How big is you heap? You can look in Tools->ROV->HeapMem->Module to see how big the heap is and how much is free. I'd do this before you call Mailbox_create.

    If that is not the problem, can you set the following in the .cfg file. This will give more information in the error message.

    var Defaults = xdc.useModule('xdc.runtime.Defaults');
    Defaults.common$.namedModule = true;

    var Text = xdc.useModule('xdc.runtime.Text');
    Text.isLoaded = true;

    Todd
  • You can't look in Tools->ROV->HeapMem->Module. I only look Tools-> ROV Classic, then it displays RTOS Object View(ROV),and I can't HeapMem->Module. I use ccs7.2 HeapMem->Module Compiler Environment.

    I set the following in the .cfg file. This result is still wrong.

    var Defaults = xdc.useModule('xdc.runtime.Defaults');
    Defaults.common$.namedModule = true;

    var Text = xdc.useModule('xdc.runtime.Text');
    Text.isLoaded = true;

    The wrong result is still:
    [C674X_0] The myEvent set up successful!
    {module#35}: line 78: error {id:0x10000, args:[0x804a1d, 0x804a1c]}
    xdc.runtime.Error.raise: terminating execution

    I think that this is failed on the Mailbox_create call,because"the mboxParams set up successful!" is not output.The codes as follows:

    System_printf ("The myEvent set up successful!\n");

    Mailbox_Params_init(&mboxParams);
    mboxParams.readerEvent = myEvent;
    /* Assign Event_Id_00 to Mailbox "not empty" event */
    mboxParams.readerEventId = Event_Id_00;
    mbox = Mailbox_create(sizeof(msg), 50, &mboxParams,NULL);
    if (mbox == NULL) {
    System_abort("Mailbox create failed");
    }
    System_printf ("The mboxParams set up successful!\n");
  • Sorry. It was "detailed" not "module"

  • Hello,

    After I debug the codes,displaying as flows:

    I set the following in the .cfg file. This result is still wrong. 

    var Defaults = xdc.useModule('xdc.runtime.Defaults');
    Defaults.common$.namedModule = true;

    var Text = xdc.useModule('xdc.runtime.Text');
    Text.isLoaded = true;

    The wrong result is still:
    [C674X_0] The myEvent set up successful!
    {module#35}: line 78: error {id:0x10000, args:[0x804a1d, 0x804a1c]}
    xdc.runtime.Error.raise: terminating execution

    I think that this is failed on the Mailbox_create call,because"the mboxParams set up successful!" is not output.The codes as follows:

    System_printf ("The myEvent set up successful!\n");

    Mailbox_Params_init(&mboxParams);
    mboxParams.readerEvent = myEvent;
    /* Assign Event_Id_00 to Mailbox "not empty" event */
    mboxParams.readerEventId = Event_Id_00;
    mbox = Mailbox_create(sizeof(msg), 50, &mboxParams,NULL);
    if (mbox == NULL) {
    System_abort("Mailbox create failed");
    }
    System_printf ("The mboxParams set up successful!\n");

  • Are you sure you rebuild the .cfg file? Can you look ROV at the below settings and confirm this on the target?

    Note: you should not be passing in a NULL Error_Block into the create calls. Take a look an example/docs to see how to use Error_Block. Basically you need to initialize an Error_Block and pass it into the create call. The Error_Block can be used as an advanced debug feature.

    Can you attach your .cfg file?

    Todd

  • hello,

          I rebuild my mmw_dss project,but the result is still as follows:

    the dss_mmw.cfg as follows:

    /*
    * Copyright 2016 by Texas Instruments Incorporated.
    *
    * All rights reserved. Property of Texas Instruments Incorporated.
    * Restricted rights to use, duplicate or disclose this code are
    * granted through contract.
    *
    */
    environment['xdc.cfg.check.fatal'] = 'false';

    /********************************************************************
    ************************** BIOS Modules ****************************
    ********************************************************************/
    var Memory = xdc.useModule('xdc.runtime.Memory');
    var BIOS = xdc.useModule('ti.sysbios.BIOS');
    var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
    var Task = xdc.useModule('ti.sysbios.knl.Task');
    var Idle = xdc.useModule('ti.sysbios.knl.Idle');
    var SEM = xdc.useModule('ti.sysbios.knl.Semaphore');
    var Event = xdc.useModule('ti.sysbios.knl.Event');
    var Hwi = xdc.useModule('ti.sysbios.family.c64p.Hwi');
    var System = xdc.useModule('xdc.runtime.System');
    var SysStd = xdc.useModule('xdc.runtime.SysStd');
    var EventCombiner = xdc.useModule('ti.sysbios.family.c64p.EventCombiner');
    var Load = xdc.useModule('ti.sysbios.utils.Load');
    var Mailbox = xdc.useModule('ti.sysbios.knl.Mailbox');
    ///////////////////////////////////////////////////////////
    var Defaults = xdc.useModule('xdc.runtime.Defaults');
    Defaults.common$.namedModule = true;

    var Text = xdc.useModule('xdc.runtime.Text');
    Text.isLoaded = true;

    System.SupportProxy = SysStd;

    /*
    * Enable Event Groups here and registering of ISR for specific GEM INTC is done
    * using EventCombiner_dispatchPlug() and Hwi_eventMap() APIs
    */
    EventCombiner.eventGroupHwiNum[0] = 7;
    EventCombiner.eventGroupHwiNum[1] = 8;
    EventCombiner.eventGroupHwiNum[2] = 9;
    EventCombiner.eventGroupHwiNum[3] = 10;

    /* Default Heap Creation: Local L2 memory */
    var heapMemParams = new HeapMem.Params();
    heapMemParams.size = 16*1024;
    heapMemParams.sectionName = "systemHeap";
    Program.global.heap0 = HeapMem.create(heapMemParams);
    Memory.defaultHeapInstance = Program.global.heap0;

    /* Enable BIOS Task Scheduler */
    BIOS.taskEnabled = true;

    /* do not call update for load - Application will call it at inter-frame boundary */
    Load.updateInIdle = false;

    /*
    var Defaults = xdc.useModule('xdc.runtime.Defaults');
    var Log = xdc.useModule('xdc.runtime.Log');
    var LoggerBuf = xdc.useModule('xdc.runtime.LoggerBuf');
    var loggerBufParams = new LoggerBuf.Params();
    loggerBufParams.numEntries = 1024;
    var logger0 = LoggerBuf.create(loggerBufParams);
    Defaults.common$.logger = logger0;
    var Diags = xdc.useModule('xdc.runtime.Diags');
    Hwi.common$.logger = logger0;
    Hwi.common$.diags_USER1 = Diags.RUNTIME_ON;
    Hwi.common$.diags_USER2 = Diags.RUNTIME_ON;
    */

    /*
    Task.common$.diags_USER1 = Diags.ALWAYS_ON;
    Task.common$.diags_USER2 = Diags.ALWAYS_ON;
    */
    //Program.sectMap[".vecs"] = "VECTORS";

    /* Some options to reduce BIOS code and data size, see BIOS User Guide section
    "Minimizing the Application Footprint" */
    System.maxAtexitHandlers = 0;
    BIOS.swiEnabled = false; /* We don't use SWIs */
    BIOS.libType = BIOS.LibType_Custom;
    Task.defaultStackSize = 1500;
    Task.idleTaskStackSize = 800;
    Program.stack = 1048; /* for isr context */
    var Text = xdc.useModule('xdc.runtime.Text');
    Text.isLoaded = false;

  • hello,
    I create a Error_Block,how do I see its information?
  • Set
    Text.isLoaded = true;

    The last statement in your .cfg is setting it to false. This is wiping out the previous setting.

  • I have set the last statement in your .cfg to false. but debugging is still error!
  • Set it to true!
  • the Console displaying:[C674X_0] The myEvent set up successful!
    ti.sysbios.knl.Semaphore: line 78: assertion failure: A_noEvents: The Event.supportsEvents flag is disabled.
    xdc.runtime.Error.raise: terminating execution
  • Please set the following in the .cfg file

    Semaphore.supportsEvents = true;
  • After I set it true,the console displaying:
    [C674X_0] The myEvent set up successful!
    ti.sysbios.knl.Semaphore: line 78: assertion failure: A_noEvents: The Event.supportsEvents flag is disabled.
    xdc.runtime.Error.raise: terminating execution
  • I thanks very much! I debug successful!