lpcware

problem with IPC on 4357

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by maszup on Fri Apr 19 02:04:52 MST 2013

Hello

I'm trying to run a simple IPC communication between M4 and M0.
I have LPC4357 Embedded Artists EVB running 
<a title="http://www.embeddedartists.com/products/kits/lpc4357_kit.php" href="http://www.embeddedartists.com/products/kits/lpc4357_kit.php">http://www.embeddedartists.com/products/kits/lpc4357_kit.php</a>
under LPCxpresso (v5.1.2.2065 - recently downloaded).

I have found example of IPC dual core using queues for LPC4357 cpu (without RTOS):
<a title="http://www.lpcware.com/content/nxpfile/an11177-inter-processor-communication-lpc43xx " href="http://www.lpcware.com/content/nxpfile/an11177-inter-processor-communication-lpc43xx%20">http://www.lpcware.com/content/nxpfile/an11177-inter-processor-communication-lpc43xx</a> 
directly here:


<a title="http://sw.lpcware.com/?p=lpc43xx.git;a=tree;f=Examples/DUALCORE/Queue_Demo;h=397e0b718c31c4629070190a23b86a70f47a7547;hb=7c7bb548e35069d9fc913352977cf44b36a73552" href="http://sw.lpcware.com/?p=lpc43xx.git;a=tree;f=Examples/DUALCORE/Queue_Demo;h=397e0b718c31c4629070190a23b86a70f47a7547;hb=7c7bb548e35069d9fc913352977cf44b36a73552">http://sw.lpcware.com/?p=lpc43xx.git;a=tree;f=Examples/DUALCORE/Queue_Demo;h=397e0b718c31c4629070190a23b86a70f47a7547;hb=7c7bb548e35069d9fc913352977cf44b36a73552</a>


where in API file (IPC_queue.c) i changed only the interrupt functions to  

/* interrupt function for the Slave queue */
void M0_M4CORE_IRQHandler(void) {
LPC_CREG-&gt;M4TXEVENT = 0x0;
cmdPending = PENDING;
}

/* interrupt function setting the flags for the application */
/* interrupt to master from slave */
void M0CORE_IRQHandler() {
LPC_CREG-&gt;M0TXEVENT = 0x0;
msgPending = PENDING;
}



So...

I have put the code of M0 into its default flash address 0x1b000000. then I'm debugging M4 in following order:

1. M4 boots and runs SystemInit();

2. M4 goes directly to function cM4restart();

3. There M4 halts slave, configure IPC queue, set M0 shadow register and starts up M0 (I do not load M0's image since it is already loaded into flash)

4. M4 waits for 1st msg from M0 - it gets it

5. M4 checks the 1st msg - status is SUCCESS - everything seems to be fine

6. M4 tries to return from function cM4restart() - it hangs! debugger goes to some unkown address of M0's flash memory 0x1b000338

I have also debugged that M4 enters the M0CORE_IRQHandler() so it gets the interrupt from M0.


I already switched off everything in my code leaving only IPC. Previously I had used UART for debugging, systick in M4 for measuring time in M4, Timer0 in M0 for measuring time in M0. But then i had hard faults in M4. so i left only IPC and tried to debug.

I presume that something is going wrong with interrupts but I'm not sure.

I don't know if below addresses are OK:

/* these addresses specify where the IPC queues shall be located */
#define MASTER_CMD_BLOCK_START 0x20008000
#define SLAVE_MSG_BLOCK_START 0x2000A000

and that the interrupts of IPC have priority = 0.



[B]I have attached exported project from LPCxpresso.[/B]


Below is my cM4restart() function:

void cM4restart(void) {
Status status = ERROR;

IPC_haltSlave();
//lpc_printf("%010d Core M0 stopped\r\n",rtcGetTime_ms());

// setup the queue system
IPC_masterInitQueue(&amp;_hostCmdBufferData[0], MASTER_CMDBUF_SIZE, &amp;_hostMsgBufferData[0], SLAVE_MSGBUF_SIZE);
//lpc_printf("%010d Core M4 IPC initialized\r\n", rtcGetTime_ms());

// Set M0's vector table to point to start of M0 image
LPC_CREG-&gt;M0APPMEMMAP = 0x1B000000;//(unsigned int)&amp;CM0image_start;
//lpc_printf("%010d Core M0 shadow register 0x%X\r\n", rtcGetTime_ms(), LPC_CREG-&gt;M0APPMEMMAP);

IPC_startSlave();
//lpc_printf("%010d Core M0 started\r\n",rtcGetTime_ms());

// wait for the M0 to signal being ready via a message to the command queue
while(!IPC_msgPending())
__WFI();
//lpc_printf("%010d Core M0 IPC ready\r\n", rtcGetTime_ms(),qstatus);

qstatus = IPC_masterPopMsg(&amp;msgBack);
if(qstatus == QVALID) {

msgType = IPC_getMsgType((msgToken*)&amp;msgBack);
if(msgType == MSG_SRV) {
serviceMessage = (srvMsg*) &amp;msgBack;
taskId = serviceMessage-&gt;msgClass.parsedMsg.servicingAnswer.id;
statusInfo = serviceMessage-&gt;msgClass.parsedMsg.servicingAnswer.ss;

if(taskId == CORE_TASK_INIT &amp;&amp; statusInfo) {
//lpc_printf("%010d Core M0 initialized\r\n", rtcGetTime_ms());
status = SUCCESS;
} else {
//err
}
} else {
//err
}
} else {
//err
}

} //here the function does not return - program goes to undefined address


Thank you for any kind of help

Original Attachment has been moved to: sources-M4.zip

Original Attachment has been moved to: sources-M0_1.zip

Outcomes