Greetings all...
I'm working on using the MessageQ on the Concerto between the C28 and the M3 (in that direction only).
My system uses:
Code Composer Studio Version: 5.2.0.00070
SYS\Bios 6.33.5.46
IPC 1.24.3.32
XDC Tools 3.23.3.53
When trying to run the messageQ sample in the sys\bios wizard, everything works great but when I use it in my program, the moment I call "MessageQ_put" over the C28, I get an exception over the M3 as following:
[Cortex_M3_0] ti.sdo.ipc.MessageQ: line 132: assertion failure: A_heapIdInvalid: heapId is invalid
[Cortex_M3_0] xdc.runtime.Error.raise: terminating execution
Here is the code (It won't compile, didn't want to bore you with my code)
The code in the C28 is:
Bool InitMessageQ(Void)
{
Ptr buf;
SizeT blockSize;
UInt numBlocks;
Int32 status;
// Compute the blockSize & numBlocks for the HeapBuf
numBlocks = 1;
int mult = (int)(ceil((float)sizeof(RESULTS_MESSAGE) / sizeof(MessageQ_MsgHeader)));
blockSize = sizeof(MessageQ_MsgHeader) * mult;
// Alloc a buffer from the default heap
buf = Memory_alloc(0, numBlocks * blockSize, 0, NULL);
// Create the heap that is used for allocating MessageQ messages.
HeapBuf_Params_init(&hbparams);
hbparams.align = 0;
hbparams.numBlocks = numBlocks;
hbparams.blockSize = blockSize;
hbparams.bufSize = numBlocks * blockSize;
hbparams.buf = buf;
heapHandle = HeapBuf_create(&hbparams, NULL);
if (heapHandle == NULL) {
System_printf("HeapBuf_create failed\n" );
return FALSE;
}
// Register default system heap with MessageQ
MessageQ_registerHeap((IHeap_Handle)(heapHandle), HEAPID);
// Open the remote message queue. Spin until it is ready.
do {
status = MessageQ_open(remoteQueueName, &remoteQueueId);
// Sleep for 1 clock tick to avoid inundating remote processor
// with interrupts if open failed
if (status < 0) {
Task_sleep(1);
}
} while (status < 0);
/* Allocate a message to be ping-ponged around the processors */
/*msg = MessageQ_alloc(HEAPID, sizeof(RESULTS_MESSAGE));
if (msg == NULL) {
System_printf("MessageQ_alloc failed\n" );
return FALSE;
}*/
return TRUE;
}
void task0()
{
InitMessageQ();
bla bla...
semaphore wait...
/* Allocate a message to be ping-ponged around the processors */
msg = MessageQ_alloc(HEAPID, sizeof(RESULTS_MESSAGE));
if (msg != NULL)
{
res = PR_DETECTION;
PopulateMsg(((RESULTS_MESSAGE*)msg), reg_counter, Sblobs);
status = MessageQ_put(remoteQueueId, msg);
if (status < 0) {
System_printf("MessageQ_put had a failure/error\n");
}
}
The code over the M3 is:
Bool InitMessageQ(Void)
{
Ptr buf;
SizeT blockSize;
UInt numBlocks;
/* Compute the blockSize & numBlocks for the HeapBuf */
numBlocks = 1;
int mult = (int)(ceil((float)sizeof(RESULTS_MESSAGE) / sizeof(MessageQ_MsgHeader)));
blockSize = sizeof(MessageQ_MsgHeader) * mult;
/* Alloc a buffer from the default heap */
buf = Memory_alloc(0, numBlocks * blockSize, 0, NULL);
/*
* Create the heap that is used for allocating MessageQ messages.
*/
HeapBuf_Params_init(&hbparams);
hbparams.align = 0;
hbparams.numBlocks = numBlocks;
hbparams.blockSize = blockSize;
hbparams.bufSize = numBlocks * blockSize;
hbparams.buf = buf;
heapHandle = HeapBuf_create(&hbparams, NULL);
if (heapHandle == NULL) {
System_printf("HeapBuf_create failed\n" );
return FALSE;
}
/* Register default system heap with MessageQ */
MessageQ_registerHeap((IHeap_Handle)(heapHandle), HEAPID);
/* Create the local message queue */
messageQ = MessageQ_create(localQueueName, NULL);
if (messageQ == NULL) {
System_printf("MessageQ_create failed\n" );
return FALSE;
}
return TRUE;
}
void task0()
{
InitMessageQ()
bla bla...
semaphor wait...
status = MessageQ_get(messageQ, &msg, MessageQ_FOREVER);
if (status == MessageQ_S_SUCCESS)
{
RESULTS_MESSAGE* m = (RESULTS_MESSAGE*)msg;
Short msgId = MessageQ_getMsgId(msg);
msgId++;
}
My struct is:
typedef struct RESULTS_MSG_ST {
MessageQ_MsgHeader header; // Required
Short blobsCount;
PROCESSING_RESULT blobsResult[MAX_BLOB_N * 2];
} RESULTS_MESSAGE;
cfg file:
var BIOS = xdc.useModule('ti.sysbios.BIOS');
var MultiProc = xdc.useModule('ti.sdo.utils.MultiProc');
var Hwi = xdc.useModule('ti.sysbios.hal.Hwi');
var Boot = xdc.useModule('ti.catalog.arm.cortexm3.concertoInit.Boot');
var MessageQ = xdc.useModule('ti.sdo.ipc.MessageQ');
var HeapBuf = xdc.useModule('ti.sysbios.heaps.HeapBuf');
var Timestamp = xdc.useModule('xdc.runtime.Timestamp');
MultiProc.setConfig("M3", ["M3", "C28"]);
/*
* The SysStd System provider is a good one to use for debugging
* but does not have the best performance. Use xdc.runtime.SysMin
* for better performance.
*/
var System = xdc.useModule('xdc.runtime.System');
var SysStd = xdc.useModule('xdc.runtime.SysStd');
System.SupportProxy = SysStd;
/* Task that does the notify sending */
var Task = xdc.useModule('ti.sysbios.knl.Task');
var tsk0 = Task.create('&tsk0_func');
tsk0.instance.name = "tsk0";
/* Modules explicitly used in the application */
/*var MessageQ = xdc.useModule('ti.sdo.ipc.MessageQ');
var HeapBuf = xdc.useModule('ti.sysbios.heaps.HeapBuf');*/
/* Use the f28m35x IpcMgr to configure the shared buffers used by IPC */
var IpcMgr = xdc.useModule('ti.sdo.ipc.family.f28m35x.IpcMgr');
IpcMgr.readAddr = 0x2007F000;
IpcMgr.writeAddr = 0x2007F800;
/*
* The M3 has to grant write access to the shared memory that the C28 will be
* writing to.
*/
IpcMgr.sharedMemoryOwnerMask = 0x90;
IpcMgr.sharedMemoryAccess[4] = 1;
IpcMgr.sharedMemoryAccess[7] = 1;
/* Create a semaphore with count 0 */
var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');
var semHandleParams = new Semaphore.Params();
semHandleParams.instance.name = "semHandle";
semHandleParams.eventId = 10;
Program.global.semHandle = Semaphore.create(0, semHandleParams);
/* Create a semaphore with count 1 */
var semLeftParams = new Semaphore.Params();
semLeftParams.instance.name = "semLeft";
semLeftParams.eventId = 11;
Program.global.semLeft = Semaphore.create(1, semLeftParams);
var task1Params = new Task.Params();
task1Params.instance.name = "tsk1";
Program.global.tsk1 = Task.create("&tsk1_func", task1Params);
Program.stack = 2048;
Why the hell is this happening?
Anyone encountered this problem before?
Appreciate the help...
Yoel