Introduction
Linux running on A53 core can load the firmware to the remote cores. MCU R5F/ C7X core incase of AM62AX. Refer AM62Ax Academy for more details on how to boot the remotecores. 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 suspend thread which is waiting for next lpm suspend message, break all the loops when gbShutdown == 1
- 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 drivers used
- Deinit system (It will disable the interrupts and stops the tick timer)
- Send acknowledgement to Linux core that the core is ready for shutdown
- Go to WFI / IDLE
DebugP_log(
"[IPC RPMSG ECHO] Closing all drivers and going to WFI ... !!!\r\n");
Drivers_close();
System_deinit();
if (gbShutdownRemotecoreID)
{
}
#if (__ARM_ARCH_PROFILE == 'R') || (__ARM_ARCH_PROFILE == 'M')
__asm__ __volatile__ ("wfi" "\n\t": : : "memory");
#endif
#if defined(BUILD_C7X)
asm(" IDLE");
#endif
This is implemented on IPC RP Message Linux Echo