AM62Px MCU+ SDK
09.01.00
Introduction
Linux running on A53 core can load the fimrware to the remote cores. MCU R5F core incase of AM62PX. This section explains how to add support for graceful shutdown on the remotecore.
Implementing graceful shutdown on remotecore
When the following command is used on the Linux to shutdown the remotecore, an IPC message is send to the remote core before shutting it down.
echo stop > /sys/class/remoteproc/remoteproc0/state
To receive and handle this IPC message, register a callback as shown below.
On the callback unblock the RPMessage for all the RPMsg objects used in the code. volatile uint8_t gbShutdown = 0u;
volatile uint8_t gbShutdownRemotecoreID = 0u;
void ipc_rp_mbox_callback(uint16_t remoteCoreId, uint16_t clientId, uint32_t msgValue, void *args)
{
{
{
gbShutdown = 1u;
gbShutdownRemotecoreID = remoteCoreId;
}
}
}
On the main thread where the IPC is happening, break all the loops when gbShutdown == 1
while (1)
{
recvMsgSize = IPC_RPMESSAGE_MAX_MSG_SIZE;
recvMsg, &recvMsgSize,
&remoteCoreId, &remoteCoreEndPt,
if (gbShutdown == 1u)
{
break ;
}
recvMsg, recvMsgSize,
remoteCoreId, remoteCoreEndPt,
}
Then follow the below sequence to go to WFI
Close all the dirvers used
Send acknowledgement to Linux core that the core is ready for shutdown
Deinit system (It will disable the interrupts and stops the tick timer)
Go to WFI / IDLE
Drivers_close();
System_deinit();
__asm__ __volatile__ ("wfi" "\n\t" : : : "memory" );
This is implemented on IPC RP Message Linux Echo
@ IPC_NOTIFY_RP_MBOX_SHUTDOWN
Definition: ipc_notify.h:148
void RPMessage_unblock(RPMessage_Object *obj)
Unblocks RPMessage_recv, for the input object, if it is blocked waiting on messages and users want to...
int32_t IpcNotify_registerClient(uint16_t localClientId, IpcNotify_FxnCallback msgCallback, void *args)
Register a callback to handle messages received from a specific remote core and for a specific local ...
#define NULL
Define NULL if not defined.
Definition: csl_types.h:100
int32_t IpcNotify_sendMsg(uint32_t remoteCoreId, uint16_t remoteClientId, uint32_t msgValue, uint32_t waitForFifoNotFull)
Send message to a specific remote core and specific client ID on that remote core.
#define SystemP_WAIT_FOREVER
Value to use when needing a timeout of infinity or wait forver until resource is available.
Definition: SystemP.h:83
uint16_t RPMessage_getLocalEndPt(const RPMessage_Object *obj)
Return local end point of a RPMessage_Object.
@ IPC_NOTIFY_RP_MBOX_SHUTDOWN_ACK
Definition: ipc_notify.h:149
#define SystemP_SUCCESS
Return status when the API execution was successful.
Definition: SystemP.h:56
#define IPC_NOTIFY_CLIENT_ID_RP_MBOX
Client ID used for remoteproc (RP_MBOX) related messages, this client ID should not be used by other ...
Definition: ipc_notify.h:71
#define DebugP_assert(expression)
Function to call for assert check.
Definition: DebugP.h:175
int32_t RPMessage_recv(RPMessage_Object *obj, void *data, uint16_t *dataLen, uint16_t *remoteCoreId, uint32_t *remoteEndPt, uint32_t timeout)
Blocking API to wait till a message is received from any CPU at the specified local end point.
int32_t RPMessage_send(void *data, uint16_t dataLen, uint16_t remoteCoreId, uint16_t remoteEndPt, uint16_t localEndPt, uint32_t timeout)
Send a message to a remote core at a specified remote end point.