Hi,
I am trying to use IPC in order to send messages from core0 to core1.
Platform:EVM6678
XDCtools version: 3.20.08.88
IPC: 1.22.05.27
BIOS: 6.31.04.27
CCS Version: 5.0.2
My code is based on the example found in mcsdk_2_00_00_beta2\demos\image_processing
I created a shared region just like in the demo
Code for core0:
int main()
{;
UInt16 core_id;
EVM_init();
core_id = (UInt16) DNUM;
MultiProc_setLocalId(core_id);
Ipc_start();
BIOS_start ();
}
void OpenMSGQ1()
{
HeapBufMP_Handle heapHandle;
HeapBufMP_Params heapBufParams;
Int status;
HeapBufMP_Params_init(&heapBufParams);
heapBufParams.regionId = 0;
heapBufParams.name = IMAGE_PROCESSING_HEAP_NAME;
heapBufParams.numBlocks = NUM_OF_CORES;
heapBufParams.blockSize = sizeof(process_message_t);
heapHandle = HeapBufMP_create(&heapBufParams);
if (heapHandle == NULL) {
printf("Main: HeapBufMP_create failed\n" );
close_n_exit();
}
status = MessageQ_registerHeap((IHeap_Handle)heapHandle, IMAGE_PROCESSING_HEAPID);
if(status != MessageQ_S_SUCCESS) {
printf("Main: MessageQ_registerHeap failed\n" );
close_n_exit();
}
if (mc_process_init(NUM_OF_CORES)) {
printf("mc_process_init returns error\n");
close_n_exit();
}
}
int mc_process_init (int number_of_cores)
{
int i,j;
HeapBufMP_Handle heapHandle;
p_queue_msg = (process_message_t **) calloc(number_of_cores, sizeof(process_message_t *));
if (!p_queue_msg) {
printf("alloc_queue_message: Can't allocate memory for queue message\n");
return -1;
}
for (i = 0; i < number_of_cores; i++) {
p_queue_msg[i] = (process_message_t *) MessageQ_alloc(IMAGE_PROCESSING_HEAPID, sizeof(process_message_t));
if (!p_queue_msg[i]) {
printf("alloc_queue_message: Can't allocate memory for queue message %d\n", i);
return -1;
}
}
max_core = number_of_cores;
memset(slave_queue_name, 0, NUM_OF_CORES*16);
for (i = 0; i < NUM_OF_CORES; i++) {
GET_SLAVE_QUEUE_NAME(slave_queue_name[i], i);
}
HeapBufMP_open(IMAGE_PROCESSING_HEAP_NAME, &heapHandle);
h_receive_queue = MessageQ_create(slave_queue_name[0], NULL);
if (h_receive_queue == NULL) {
printf("MessageQ_create failed\n" );
close_n_exit();
}
for (j = 0; j < number_of_cores; j++) {
do {
i = MessageQ_open(slave_queue_name[j], &queue_id[j]);
} while (i < 0);
printf("MessageQ %s opened\n",slave_queue_name[j]);
}
return 0;
}
Code for core1:
int main()
{
UInt16 core_id = (UInt16) DNUM;
MultiProc_setLocalId(core_id);
Ipc_start();
/* Start the BIOS 6 Scheduler */
BIOS_start ();
}
void setMSGQ(void)
{
char receive_queue_name[16];
HeapBufMP_Handle heapHandle;
Int status;
GET_SLAVE_QUEUE_NAME(receive_queue_name, DNUM);
/* Open the heap created by the other processor. Loop until opened. */
do {
status = HeapBufMP_open(IMAGE_PROCESSING_HEAP_NAME, &heapHandle);
if (status < 0) {
Task_sleep(1);
}
} while (status < 0);
/* Register this heap with MessageQ */
MessageQ_registerHeap((IHeap_Handle)heapHandle, IMAGE_PROCESSING_HEAPID);
/* Create the local message queue */
h_receive_queue = MessageQ_create(receive_queue_name, NULL);
if (h_receive_queue == NULL) {
printf("MessageQ_create failed\n" );
close_n_exit();
}
printf("MessageQ %s created\n",receive_queue_name);
}
the problem is that core1 never returns from the line
status = HeapBufMP_open(IMAGE_PROCESSING_HEAP_NAME, &heapHandle);
What is wrong?