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.

TMS320C6678: HeapBufMP_E_NOTFOUND error when using HeapBufMP and MessageQ

Part Number: TMS320C6678
Other Parts Discussed in Thread: SYSBIOS

I am trying to create a simple program that sends an integer value from Core 0 to Core 1 as i am just a beginner using this board. I have no experience with IPC before this and cant find simple examples like what i am trying to create. Currently i am trying to implement a Master program on Core 0 that allocates the message to shared memory and a Slave program on Core 1 that takes this message and prints the integer value sent. For both of these programs i have used a cfg file from a seperate IPC example as i am not confident enough to change many of the parameters as of yet. Both programs build and debug fine on their respective cores however when i try to find the Heap in Core 1 that was created by Core 0, by using HeapBufMP_open(), i am getting the HeapBufMP_E_NOTFOUND error (-5), i am not sure why i am getting error as this method seems to work fine in other examples, below is the master.c, slave.c and their respective configs. 

Master.c

#include <xdc/std.h>
#include <xdc/cfg/global.h>

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

#include <ti/ipc/Ipc.h>
#include <ti/ipc/MultiProc.h>
#include <ti/ipc/MessageQ.h>
#include <ti/ipc/SharedRegion.h>
#include <ti/ipc/HeapBufMP.h>
//#include <../include/HeapBufMP.h>

#include <ti/platform/platform.h>

#include <ti/sysbios/Bios.h>

#include <ti/csl/csl_chip.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>

#define HEAPID 0

typedef struct{
    MessageQ_MsgHeader header;
    Int message;
}myMsg;

Int status;
Uint16 selfId;
//SharedRegion_Entry entry;
Char localQueueName[10];
Char remoteQueueName[10];


Int main(Int argc, Char* argv[]){

    selfId = CSL_chipReadReg(CSL_CHIP_DNUM);  // determine the coreID

    System_printf("%s starting\n", MultiProc_getName(selfId));

    /* Call Ipc_start() */
    status = Ipc_start();
    if (status < 0) {
        System_abort("Ipc_start failed!\n");
    }

    BIOS_start();

    return 0;
}

Void messageQ_Master(UArg arg0, UArg arg1){

    HeapBufMP_Handle heapHandle;
    HeapBufMP_Params heapBufMPParams;
    MessageQ_QueueId   QueueId;
    MessageQ_Handle messageQ = NULL;
    MessageQ_Msg msg;

    /* get region 0 information */
    //SharedRegion_getEntry(0, &entry);

    /* Create the heap that will be used to allocate messages. */
    HeapBufMP_Params_init(&heapBufMPParams);
    heapBufMPParams.regionId      = 0;        // use default region
    heapBufMPParams.name          = "myHeap";
    heapBufMPParams.numBlocks     = 1;
    heapBufMPParams.blockSize     = sizeof(myMsg);
    heapBufMPParams.gate          = NULL;     // use system gate
    heapHandle = HeapBufMP_create(&heapBufMPParams);
    if (heapHandle == NULL) {
        System_abort("HeapBufMP_create failed\n");
    }

    messageQ = MessageQ_create(localQueueName, NULL);
    if (messageQ == NULL){
        System_abort("MessageQ_create failed\n");
        }

    /* Register this heap with MessageQ */
    MessageQ_registerHeap((IHeap_Handle)heapHandle, HEAPID);

    do {
        status = MessageQ_open(remoteQueueName, &QueueId);
        if (status < 0){
        Task_sleep(1);
            }
        }while (status < 0);

    msg = MessageQ_alloc(HEAPID, sizeof(myMsg));

    ((myMsg*)msg)->message = 1;

    status = MessageQ_put(QueueId, msg);

    System_printf("message sent = %d\n", ((myMsg*)msg)->message);

    BIOS_exit(0);
}

Master.cfg

var Semaphore     = xdc.useModule('ti.sysbios.knl.Semaphore');
var Task = xdc.useModule('ti.sysbios.knl.Task');
Semaphore.supportsEvents = false;

var System   = xdc.useModule('xdc.runtime.System');
var SysStd   = xdc.useModule('xdc.runtime.SysStd');
System.SupportProxy = SysStd;
System.extendedFormats = "%$S%f";

var BIOS = xdc.useModule('ti.sysbios.BIOS');
BIOS.clockEnabled = false;
BIOS.heapSize = 0x8000;

Program.sectMap[".msgQ_ptrs"] = new Program.SectionSpec();
Program.sectMap[".msgQ_ptrs"] = "L2SRAM";

Program.sectMap["platform_lib"] = new Program.SectionSpec();
Program.sectMap["platform_lib"] = "L2SRAM";

var PlatformLib = xdc.loadPackage('ti.platform.evmc6678l');

var cslSettings = xdc.useModule ('ti.csl.Settings');

var cacheEnabled = true;  
var cacheLineSize = 128;
var procName = null;
var procNameList = [];

var Settings                = xdc.module('ti.sdo.ipc.family.Settings');
var Cache                	= xdc.useModule('ti.sysbios.family.c66.Cache');
var MessageQ                = xdc.useModule('ti.sdo.ipc.MessageQ');
var Notify                  = xdc.module('ti.sdo.ipc.Notify');
var Ipc                     = xdc.useModule('ti.sdo.ipc.Ipc');
var HeapBufMP = xdc.useModule('ti.sdo.ipc.heaps.HeapBufMP');
Notify.SetupProxy           = xdc.module(Settings.getNotifySetupDelegate());
MessageQ.SetupTransportProxy= xdc.module(Settings.getMessageQSetupDelegate());

/* Use shared memory IPC */
MessageQ.SetupTransportProxy = xdc.module('ti.sdo.ipc.transports.TransportShmSetup');

Program.global.TRANSPORTSETUP = MessageQ.SetupTransportProxy.delegate$.$name;

switch (Program.platformName) {                                                                   
    case "ti.sdo.ipc.examples.platforms.evm6678.core0":
    case "ti.platforms.evm6678":    
        Program.global.USING_C6678 = 1;    
		Program.global.maxNumCores = 8;
        procNameList = ["CORE0", "CORE1", "CORE2", "CORE3", "CORE4", "CORE5", "CORE6", "CORE7"];
        Program.global.shmBase = 0x0C000000;
        Program.global.shmSize =  0x00200000;
        break;
    case "ti.sdo.ipc.examples.platforms.evm6670.core0":
    case "ti.platforms.evm6670":    
        Program.global.USING_C6670 = 1;    
				Program.global.maxNumCores = 4;
        procNameList = ["CORE0", "CORE1", "CORE2", "CORE3"];
        Program.global.shmBase = 0x0C000000;
        Program.global.shmSize = 0x00200000;
        break;
    case "ti.sdo.ipc.examples.platforms.evm6670.core0":
    case "ti.platforms.evm6657":    
        Program.global.USING_C6657 = 1;    
				Program.global.maxNumCores = 2;
        procNameList = ["CORE0", "CORE1"];
        Program.global.shmBase = 0x0C000000;
        Program.global.shmSize = 0x00200000;
        break;        
    default:
        throw("Unsupported platform: " + Program.platformName);
}
var MultiProc = xdc.useModule('ti.sdo.utils.MultiProc');
MultiProc.setConfig(procName, procNameList);

Program.global.DEVICENAME = Program.cpu.deviceName;
Program.global.PROCNAMES = procNameList.join(",");
Program.global.BUILDPROFILE = Program.build.profile;

var SharedRegion = xdc.useModule('ti.sdo.ipc.SharedRegion');
SharedRegion.translate = true;
SharedRegion.setEntryMeta(0,
    { base: Program.global.shmBase, 
      len: Program.global.shmSize,
      ownerProcId: 0,
      isValid: true,
      cacheEnable: cacheEnabled,
      cacheLineSize: cacheLineSize,  /* Aligns allocated messages to a cache line */
      createHeap: true,
      name: "internal_shared_mem",
    });
var task0Params = new Task.Params();
task0Params.instance.name = "task";
Program.global.task = Task.create("&messageQ_Master", task0Params);
Task.allBlockedFunc = Task.allBlockedFunction;
BIOS.heapTrackEnabled = false;

Slave.c

#include <xdc/std.h>
#include <xdc/cfg/global.h>

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

#include <ti/ipc/Ipc.h>
#include <ti/ipc/MultiProc.h>
#include <ti/ipc/MessageQ.h>
#include <ti/ipc/SharedRegion.h>
#include <ti/ipc/HeapBufMP.h>

#include <ti/platform/platform.h>

#include <ti/sysbios/Bios.h>

#include <ti/csl/csl_chip.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>

#define HEAPID 0

typedef struct{
    MessageQ_MsgHeader header;
    Int message;
}myMsg;

Int status;
Uint16 selfId;
//SharedRegion_Entry entry;
Char remoteQueueName[10];


Int main(Int argc, Char* argv[]){

    selfId = CSL_chipReadReg(CSL_CHIP_DNUM);  // determine the coreID

    System_printf("%s starting\n", MultiProc_getName(selfId));

    /* Call Ipc_start() */
    status = Ipc_start();
    if (status < 0) {
        System_abort("Ipc_start failed!\n");
    }

    /* get region 0 information */
    //SharedRegion_getEntry(0, &entry);

    System_printf("main\n");
    BIOS_start();

    return 0;
}

Void messageQ_Slave(UArg arg0, UArg arg1){

    HeapBufMP_Handle heapHandle;
    MessageQ_QueueId   QueueId;
    MessageQ_Handle messageQ = NULL;
    MessageQ_Msg msg;

    System_printf("task\n");
    /* Open heap created by other processor. Loop until open. */
    do {
        status = HeapBufMP_open("myHeap", &heapHandle);
        //System_printf("%d\n", status);
    }
    while (status < 0);

    /* Register this heap with MessageQ */
    MessageQ_registerHeap((IHeap_Handle)heapHandle, HEAPID);


    messageQ = MessageQ_create(remoteQueueName, NULL);
    if (messageQ == NULL){
           System_abort("MessageQ_create failed\n");
           }

    do {
         status = MessageQ_open(remoteQueueName, &QueueId);
         if (status < 0){
         Task_sleep(1);
             }
         }while (status < 0);


    status = MessageQ_get(messageQ, &msg, MessageQ_FOREVER);
    if(status<0){
        System_printf("this should not happen since timeout is forever");
    }


    System_printf("Message sent by master is %d: \n", ((myMsg*)msg)->message);

    MessageQ_free(msg);

    //HeapBufMP_free(heapHandle, ,sizeof(myMsg))

    BIOS_exit(0);
}

Slave.cfg

var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');
var Task = xdc.useModule('ti.sysbios.knl.Task');
var Memory = xdc.useModule('xdc.runtime.Memory');
Semaphore.supportsEvents = false;

var System = xdc.useModule('xdc.runtime.System');
var SysStd = xdc.useModule('xdc.runtime.SysStd');
System.SupportProxy = SysStd;
System.extendedFormats = "%$S%f";

var BIOS = xdc.useModule('ti.sysbios.BIOS');
BIOS.clockEnabled = false;
BIOS.heapSize = 0x8000;

Program.sectMap[".msgQ_ptrs"] = new Program.SectionSpec();
Program.sectMap[".msgQ_ptrs"] = "L2SRAM";

Program.sectMap["platform_lib"] = new Program.SectionSpec();
Program.sectMap["platform_lib"] = "L2SRAM";

var PlatformLib = xdc.loadPackage('ti.platform.evmc6678l');

var cslSettings = xdc.useModule ('ti.csl.Settings');

var cacheEnabled = true;
var cacheLineSize = 128;
var procName = null;
var procNameList = [];

var Settings = xdc.module('ti.sdo.ipc.family.Settings');
var Cache = xdc.useModule('ti.sysbios.family.c66.Cache');
var MessageQ = xdc.useModule('ti.sdo.ipc.MessageQ');
var Notify = xdc.module('ti.sdo.ipc.Notify');
var Ipc = xdc.useModule('ti.sdo.ipc.Ipc');
var HeapBufMP = xdc.useModule('ti.sdo.ipc.heaps.HeapBufMP');
Notify.SetupProxy = xdc.module(Settings.getNotifySetupDelegate());
MessageQ.SetupTransportProxy= xdc.module(Settings.getMessageQSetupDelegate());

/* Use shared memory IPC */
MessageQ.SetupTransportProxy = xdc.module('ti.sdo.ipc.transports.TransportShmSetup');

Program.global.TRANSPORTSETUP = MessageQ.SetupTransportProxy.delegate$.$name;

switch (Program.platformName) {
case "ti.sdo.ipc.examples.platforms.evm6678.core0":
case "ti.platforms.evm6678":
Program.global.USING_C6678 = 1;
Program.global.maxNumCores = 8;
procNameList = ["CORE0", "CORE1", "CORE2", "CORE3", "CORE4", "CORE5", "CORE6", "CORE7"];
Program.global.shmBase = 0x0C000000;
Program.global.shmSize = 0x00200000;
break;
case "ti.sdo.ipc.examples.platforms.evm6670.core0":
case "ti.platforms.evm6670":
Program.global.USING_C6670 = 1;
Program.global.maxNumCores = 4;
procNameList = ["CORE0", "CORE1", "CORE2", "CORE3"];
Program.global.shmBase = 0x0C000000;
Program.global.shmSize = 0x00200000;
break;
case "ti.sdo.ipc.examples.platforms.evm6670.core0":
case "ti.platforms.evm6657":
Program.global.USING_C6657 = 1;
Program.global.maxNumCores = 2;
procNameList = ["CORE0", "CORE1"];
Program.global.shmBase = 0x0C000000;
Program.global.shmSize = 0x00200000;
break;
default:
throw("Unsupported platform: " + Program.platformName);
}
var MultiProc = xdc.useModule('ti.sdo.utils.MultiProc');
MultiProc.setConfig(procName, procNameList);

Program.global.DEVICENAME = Program.cpu.deviceName;
Program.global.PROCNAMES = procNameList.join(",");
Program.global.BUILDPROFILE = Program.build.profile;

var SharedRegion = xdc.useModule('ti.sdo.ipc.SharedRegion');
SharedRegion.translate = true;
SharedRegion.setEntryMeta(0,
{ base: Program.global.shmBase,
len: Program.global.shmSize,
ownerProcId: 0,
isValid: true,
cacheEnable: cacheEnabled,
cacheLineSize: cacheLineSize, /* Aligns allocated messages to a cache line */
createHeap: true,
name: "internal_shared_mem",
});
var task0Params = new Task.Params();
task0Params.instance.name = "task";
Program.global.task = Task.create("&messageQ_Slave", task0Params);
Task.allBlockedFunc = Task.allBlockedFunction;
BIOS.heapTrackEnabled = false;

Any help with this would be much appreciated!

Thanks in advance

 

 

 

 

  • Hello Pearse,

    Can you confirm that you are using Ipc.ProcSync_ALL? And if so, try removing the cores that aren't being used by IPC in procNameList so that it doesn't try to attach to every core.

    Also, set a breakpoint before HeapBufMP_open and go to Tools > ROV Classic > Ipc and make sure the cores are attached. You should see "true" in the "attached" column.
  • Hi Sahin,

    Thanks for your advice the program is now able to find the heap however this has led to a seperate issue, the program is now getting stuck in a loop at the MessageQ_get() function call as the timeout is set forever, if the cores are attached and the heap has been found why is the program having issues getting the message from the queue? The code is still the same as above.

    Pearse