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.

Simple MessageQ application won't work

Other Parts Discussed in Thread: OMAP-L138

Hi,

I am trying to write a simple MessageQ application but with no success. This is my environment:

Board: OMAP-L138 EVM (DA850, LogicPD)

ARM: Angstrom Linux

Host: Ubuntu 10.04

Sys/Bios: 6.34.04

SysLink: 2.21.01

IPC: 1.25.01

XDCTools: 3.24.05

Running examples/ex02_messageq works without any problems. Now I tried to set up a simple application from scratch. This is what I've done:

config.bld:

var SR_0 = {
        name: "SR_0", space: "data", access: "RWX",
        base: 0xC2000000, len: 0x10000,
        comment: "SR#0 Memory (64 KB)"
    };
    
var SR_1 = {
        name: "SR_1", space: "data", access: "RWX",
        base: 0xC2010000, len: 0x20000,
        comment: "SR#1 Memory (128 KB)"
    };

Build.platformTable["ti.platforms.evmOMAPL138:dsp"] = {
    externalMemoryMap: [
        [ SR_0.name, SR_0 ],
        [ SR_1.name, SR_1 ],
        [ "DSP_PROG", {
            name: "DSP_PROG", space: "code/data", access: "RWX",
            base: 0xC3000000, len: 0x800000,
            comment: "DSP Program Memory (8 MB)"
        }]
    ],
    codeMemory:  "DSP_PROG",
    dataMemory:  "DSP_PROG",
    stackMemory: "DSP_PROG",
    l1DMode: "32k",
    l1PMode: "32k",
    l2Mode: "32k"
};

...

Dsp.cfg:

...

/* shared region configuration */
var SharedRegion = xdc.useModule('ti.sdo.ipc.SharedRegion');

/* configure SharedRegion #0 (IPC) */
var SR0Mem = Program.cpu.memoryMap["SR_0"];

SharedRegion.setEntryMeta(0,
    new SharedRegion.Entry({
        name:           "SR0",
        base:           SR0Mem.base,
        len:            SR0Mem.len,
        ownerProcId:    MultiProc.getIdMeta("HOST"),
        cacheEnable:    false,
        isValid:        true
    })
);

/* configure SharedRegion #1 (MessageQ Buffers) */
var SR1Mem = Program.cpu.memoryMap["SR_1"];

SharedRegion.setEntryMeta(1,
    new SharedRegion.Entry({
        name:           "MessageQ Buffers",
        base:           SR1Mem.base,
        len:            SR1Mem.len,
        ownerProcId:    MultiProc.getIdMeta("HOST"),
        cacheEnable:    false,
        isValid:        true
    })
);

....

Host-Application:

void Application_Start(void)
{
    Register_Notify_Callback(LOGGER_NOTIFY_EVENTID, Log_Callback);

    printf("Hello from Application.\n");

    int dspId = MultiProc_getId("DSP");

    // reader does: MessageQ_create(), MessageQ_get(), MessageQ_free() and MessageQ_delete()

    HeapBufMP_Params    heapParams;
    MessageQ_Params     msgqParams;

    // create heap for messages
    HeapBufMP_Params_init(&heapParams);

    heapParams.name = "Heap:1";
    heapParams.regionId = 1; // SR id
    heapParams.blockSize = 64;
    heapParams.numBlocks = 10;

    HeapBufMP_Handle heapHandle = HeapBufMP_create(&heapParams);

    if (heapHandle == NULL)
    {
        printf("Failed to create a HeapBufMP\n");
        return;
    }

    // register heap with MessageQ
    int status = MessageQ_registerHeap((Ptr)(heapHandle), 1);

    if (status < 0)
    {
        printf("Failed to register HeapBufMP with MessageQ\n");
        return;
    }

    MessageQ_Params_init(&msgqParams);
    MessageQ_Handle msqHandle = MessageQ_create("MSQ:1", &msgqParams);

    printf("Sending request\n");
    Request_Data_Stream(dspId);

    printf("Waiting for msg on MSQ:1.\n");
    Data_Msg *msg;

    MessageQ_get(msqHandle, (MessageQ_Msg *)&msg, 2000);
    //printf("Got msg with data: %d", msg->data);
    //MessageQ_free((MessageQ_Msg)msg);


    MessageQ_delete(&msqHandle);
    MessageQ_unregisterHeap(1);
    HeapBufMP_delete(&heapHandle);

    printf("Application finished.\n");
}

DSP-Application:

void Application_Start(void)
{
    int hostId = MultiProc_getId("HOST");

    Register_Notify_Callback(DATA_REQUEST_NOTIFY_EVENTID, Data_Request_Callback);
    notifySem = Semaphore_create(Semaphore_Mode_COUNTING, NULL, NULL);
    Semaphore_pend(notifySem, BIOS_WAIT_FOREVER);

    // writer does MessageQ_open(), MessageQ_alloc(), MessageQ_put() and MessageQ_close()

    MessageQ_QueueId msqId;
    Log_Print("star");

    // Open msgq
    while (MessageQ_open("MSQ:1", &msqId) < 0);
    Log_Print("open");

    // alloc
    Data_Msg *msg = (Data_Msg*) MessageQ_alloc(1, sizeof(Data_Msg));
    Log_Print("allo");

    msg->data = 123;

    // send
    /*if(MessageQ_put(msqId, (MessageQ_Msg)msg)<0)
    {
        Log_Print("ohhh");
        MessageQ_close(&msqId); Semaphore_delete(&notifySem);
        return;
    }
    Log_Print("sent");*/

    // close
    MessageQ_close(&msqId);
    Log_Print("done");
    Semaphore_delete(&notifySem);
}

The console output is:

+ ./slaveloader startup DSP server_dsp.xe674
Attached to slave procId 0.
Loading procId 0.
Loaded file server_dsp.xe674 on slave procId 0.
Started slave procId 0.
+ ./app_host
Hello from Application.
Sending request
DSP-Logger: star
DSP-Logger: open
DSP-Logger: allo
DSP-Logger: done
Waiting for msg on MSQ:1.
Application finished.
Assertion at Line no: 380 in /home/omap/AragoProject/syslinkBios/syslink_2_21_01_05/packages/ti/syslink/utils/hlos/knl/Linux/../../../../../../ti/syslink/utils/hlos/knl/ResTrack.c: (elem == NULL) : failed
+ ./slaveloader shutdown DSP
Stopped slave procId 0.
Unloaded slave procId 0.
Detached from slave procId 0.

But when I uncomment the sending part in the DSP application:

    // send
    if(MessageQ_put(msqId, (MessageQ_Msg)msg)<0)
    {
        Log_Print("ohhh");
        MessageQ_close(&msqId); Semaphore_delete(&notifySem);
        return;
    }
    Log_Print("sent");

I get:

Hello from Application.
Sending requestAssertion at Line no: 1194 in /home/omap/AragoProject/syslinkBios/syslink_2_21_01_05/packages/ti/syslink/utils/hlos/knl/Linux/../../../../../../ti/syslink/ipc/hlos/knl/ListMP.c: (localHeadNext != NULL) : failed

DSP-Logger: star
DSP-Logger: open
Assertion at Line no: 1200 in /home/omap/AragoProject/syslinkBios/syslink_2_21_01_05/packages/ti/syslink/utils/hlos/knl/Linux/../../../../../../ti/syslink/ipc/hlos/knl/ListMP.c: (elem != NULL) : failed
Assertion at Line no: 1601 in /home/omap/AragoProject/syslinkBios/syslink_2_21_01_05/packages/ti/syslink/utils/hlos/knl/Linux/../../../../../../ti/syslink/ipc/hlos/knl/SharedRegion.c: (id < SharedRegion_module->cfg.numEntries) : failed
Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = c0004000
[00000000] *pgd=00000000
Internal error: Oops: 17 [#2] PREEMPT
last sysfs file: /sys/devices/platform/davinci_mmc.0/mmc_host/mmc0/mmc0:0002/block/mmcblk0/dev
Modules linked in: syslink ipv6 minix
CPU: 0    Tainted: G      D      (2.6.37+ #3)
PC is at ListMP_getHead+0x1a8/0x2c8 [syslink]
LR is at SharedRegion_isCacheEnabled+0x148/0x190 [syslink]
pc : [<bf08eff0>]    lr : [<bf082d04>]    psr: 60000013
sp : c7b65ee8  ip : 00000000  fp : c7b65f14
r10: 00000000  r9 : 00000000  r8 : 00000000
r7 : c9ec1900  r6 : 00000000  r5 : c9f31000  r4 : 00000000
r3 : 00000000  r2 : 00000000  r1 : 00060000  r0 : 00000000
Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
Control: 0005317f  Table: c7aec000  DAC: 00000017
Process kernelThread_6 (pid: 598, stack limit = 0xc7b64270)
Stack: (0xc7b65ee8 to 0xc7b66000)
5ee0:                   00000000 6e65706f 6e65706f bf13e224 c9f2e000 00000000
5f00: c9ec1900 00000002 c7b65f3c c7b65f18 bf0a8984 bf08ee58 00000000 00000002
5f20: c9f2e000 00000000 c9ef6000 00000002 c7b65f64 c7b65f40 bf085fb0 bf0a88e8
5f40: 00000000 00000000 c7b65f6c c9eed000 c9ec1800 00000100 c7b65f94 c7b65f68
5f60: bf0a4ac4 bf085efc 00000001 c9ef3000 c9ef3018 c9ef3014 c9ef301c c9ef3020
5f80: 00000000 00000000 c7b65fbc c7b65f98 bf07ff74 bf0a49e4 c7b65fcc c5cdbc38
5fa0: c9ef3000 bf07feec 00000000 00000000 c7b65ff4 c7b65fc0 c005ed74 bf07fefc
5fc0: c5cdbc38 00000000 c9ef3000 00000000 c7b65fd0 c7b65fd0 c5cdbc38 c005ece8
5fe0: c0048220 00000013 00000000 c7b65ff8 c0048220 c005ecf8 00000000 00000000
Backtrace:
[<bf08ee48>] (ListMP_getHead+0x0/0x2c8 [syslink]) from [<bf0a8984>] (_TransportShm_notifyFxn+0xac/0x100 [syslink])
 r8:00000002 r7:c9ec1900 r6:00000000 r5:c9f2e000 r4:bf13e224
[<bf0a88d8>] (_TransportShm_notifyFxn+0x0/0x100 [syslink]) from [<bf085fb0>] (Notify_exec+0xc4/0x110 [syslink])
 r5:00000002 r4:c9ef6000
[<bf085eec>] (Notify_exec+0x0/0x110 [syslink]) from [<bf0a4ac4>] (_NotifyDriverShm_ISR+0xf0/0x144 [syslink])
 r6:00000100 r5:c9ec1800 r4:c9eed000
[<bf0a49d4>] (_NotifyDriverShm_ISR+0x0/0x144 [syslink]) from [<bf07ff74>] (Thread_callback+0x88/0xf8 [syslink])
[<bf07feec>] (Thread_callback+0x0/0xf8 [syslink]) from [<c005ed74>] (kthread+0x8c/0x94)
 r9:00000000 r8:00000000 r7:bf07feec r6:c9ef3000 r5:c5cdbc38
r4:c7b65fcc
[<c005ece8>] (kthread+0x0/0x94) from [<c0048220>] (do_exit+0x0/0x6e0)
 r7:00000013 r6:c0048220 r5:c005ece8 r4:c5cdbc38
Code: e3a01008 e59f2108 e3a03001 ebff800d (e5940000)
Waiting for msg on MSQ:1.
---[ end trace b3f7d1b6dd6a3d89 ]---

I can't figure out what I'm doing wrong. Any hints?

  • Somehow something gets invalidated here in ListMP.c:

    localHeadNext = SharedRegion_getPtr ((SharedRegion_SRPtr)
                                                     (obj->attrs->head.next));
            GT_assert (curTrace, (localHeadNext != NULL));

            /* See if the ListMP_Object was empty */
            if (localHeadNext != (ListMP_Elem *) (&obj->attrs->head)) {
                /* Elem to return */
                elem = localHeadNext;
                GT_assert (curTrace, (elem != NULL));

                if (SharedRegion_isCacheEnabled(SharedRegion_getId(elem))) {
                    /* Invalidate elem */
                    Cache_inv (elem,
                               sizeof (ListMP_Elem),
                               Cache_Type_ALL,
                               TRUE);
                }

  • Hi Firat,

    Gettting the assertion in ResTrack.c line 380, means you have either not deleted a MessageQ, a HeapBufMP, or
    failed to call Notify_unregister (or Notify_unregisterSingle).

    Also, in your DSP side code, you need to register the HeapBufMP heap with MessageQ so that you can allocate the
    message.  You would need to call HeapBufMP_open() to get the heap handle, and then MessageQ_registerHeap(),
    passing the heap id, 1, and the handle returned from HeapBufMP_open().

    Best regards,

        Janet

  • janet said:

    Also, in your DSP side code, you need to register the HeapBufMP heap with MessageQ so that you can allocate the
    message.  You would need to call HeapBufMP_open() to get the heap handle, and then MessageQ_registerHeap(),
    passing the heap id, 1, and the handle returned from HeapBufMP_open().

    Hi Janet,

    greeaat, thank you. It works now. But why do I need to register the Heap twice to the MessageQ. DSP is using the created MessageQ by ARM, that also had registered a Heap with that Queue? Does any participant gets its own "view" of the MessageQ? Ohh wait, I got it. The registration is not MessageQ-Instance specific. Its more a global registration for each MessageQ in ARM-IPC and DSP-IPC, right?

  • Hi Firat,

    You are allocating the message on the DSP, right?  The DSP has its own mapping of heap handles to
    heap Ids, separate from the ARM.  So you need to get the heap handle to map it to the heap Id you want
    to register with MessageQ.

    Best regards,

        Janet