Hi,
can anybody help me to understand how to use CMEM? I have following example:
I want to use the ARM for sending the DSP an image to run a median filter. Since I learned from my last thread (https://e2e.ti.com/support/arm/sitara_arm/f/791/p/500457/1822502#1822502) that the MessageQ-method will only allow a payload of 512 Bytes, it is impossible to send a whole picture from the ARM to the DSP with MessageQs. So I want to use CMEM to store the image in the specific CMEM memory and send the DSP only the pointer. But it looks like it is not working and I can't find an example anywhere!!! The CMEM Overview site (http://processors.wiki.ti.com/index.php/CMEM_Overview?keyMatch=cmem&tisearch=Search-EN-Everything) isn't very useful to me. I need to see how the whole thing works and not only some descriptions of the functions...
I am trying this:
ARM
/* allocate message */
msg = (App_Msg *)MessageQ_alloc(Module.heapId, Module.msgSize);
if (msg == NULL) {
status = -1;
goto leave;
}
bufIn = CMEM_alloc(imgSize,&cMemAllocParams);
if(bufIn == NULL)
printf("CMEM_alloc failed!!!\n");
else
printf("CMEM_alloc okay (buf: %p)\n",bufIn);
msg->info.in_data = (uint8_t*)CMEM_getPhys((void*)bufIn);
if(msg->info.in_data == NULL)
printf("CMEM_getPhys failed!!!\n");
else
printf("CMEM_getPhys okay (in: %p)\n",msg->info.in_data);
/* set the return address in the message header */
MessageQ_setReplyQueue(Module.hostQue, (MessageQ_Msg)msg);
printf("Trying MessageQ_put...\n");
/* send the message to the remote processor */
if (MessageQ_put(Module.slaveQue1, (MessageQ_Msg)msg) < 0)
{
printf("MessageQ_put had a failure error\n");
status = -1;
goto leave;
}
printf("MessageQ_put okay!\n");
It seems to work, but with some strange output:
CMEM_alloc okay (buf: 0xa0161000)
[ 161.087851] CMEMK Error: Failed to find a pool which fits 0x4b000
[ 161.097870] CMEMK Error: get_phys: Unable to find phys addr for 0x0
[ 161.109737] CMEMK Error: get_phys: get_user_pages() failed: -14
CMEM_getPhys okay (in: 0xa0000000)
Trying MessageQ_put...
MessageQ_put okay!
DSP:
/* wait for inbound message */
status = MessageQ_get(Module.slaveQue, (MessageQ_Msg *)&msg,
MessageQ_FOREVER);
Log_print0(Diags_ENTRY | Diags_INFO, "--> MessageQ_get okay!");
if (status < 0) {
goto leave;
}
if (msg->info.dataFlag== 1)
{
int i = 0;
msg->info.dataFlag = 0;
Log_print1(Diags_ENTRY | Diags_INFO, "--> msg->info.in_data (%p): ",msg->info.in_data);
median_3x3_cn((unsigned char*)&msg->info.in_data, msg->info.cols,(unsigned char*)&msg->info.out_data);
}
The address for the DSP seems right, but it is not working...wrong data at this address...what did I do wrong?
Here are the CMEM stats "cat /proc/cmem":
root@am57xx-evm:~# cat /proc/cmem
Block 0: Pool 0: 1 bufs size 0xc000000 (0xc000000 requested)
Pool 0 busy bufs:
Pool 0 free bufs:
id 0: phys addr 0xa0000000
Target: EVM AM572x
IPC: 3.40.01.08
Processor SDK Linux: 2.00.01.07
DSP:SYS/BIOS: 6.45.00.19