]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ivimm/rvc.git/commitdiff
RVC: Handling M4 message for reverse gear detection master
authorBuddy Liong <a0270631@ti.com>
Tue, 31 Jan 2017 23:01:08 +0000 (17:01 -0600)
committerBuddy Liong <a0270631@ti.com>
Tue, 31 Jan 2017 23:01:08 +0000 (17:01 -0600)
When M4 detects reverse gear, it will send messageQ to HOST (A15).
The message will be used by A15 to set the kernel panic timeout
value. When reverse gear (RVC) is up, then panic timeout should be
set to 0 sec meaning when Android kernel crash, there should not be
recovery as it will affect RVC.
When no reverse gear (RVC is stop), then panic timeout can be set
to any value (default is 5 sec) meaning when Android kernel crash,
recovery should be triggered within the panic timeout value.

Signed-off-by: Buddy Liong <a0270631@ti.com>
appA15HeartBeatHost.c
appA15HeartBeatHost.h

index f2e65094215ab909e539789a75f2c091506e5e0e..e0d898548fa313b70d45644c939d20aaa741ebcf 100644 (file)
@@ -104,7 +104,7 @@ Int App_create(UInt16 remoteProcId)
 
     /* open the remote message queue */
     sprintf(msgqName, App_SlaveMsgQueName, MultiProc_getName(remoteProcId));
-
+    ALOGE("App_create: msgqName %s", msgqName);
     do {
         status = MessageQ_open(msgqName, &Module.slaveQue);
         sleep(1);
@@ -179,17 +179,59 @@ Int App_exec(Void)
     MessageCount++;
     // Get current time of day
     gettimeofday(&tv, NULL);
-    ALOGE("%ld us: App_exec: sending #%d message %d \n", (tv.tv_sec * 1000000) + tv.tv_usec, MessageCount, msg->cmd);
+    ALOGE("%ld us: App_exec: sending #%d message %d \n",
+        (tv.tv_sec * 1000000) + tv.tv_usec, MessageCount, msg->cmd);
 #endif
 
     while (running) {
         /* send START 1st message */
         MessageQ_put(Module.slaveQue, (MessageQ_Msg)msg);
 
-        // Sleep for Microseconds - 500ms
-        usleep(Microseconds);
+        /* Wait for server message within 500ms */
+        status = MessageQ_get(Module.hostQue, (MessageQ_Msg *)&msg,
+            Microseconds);
+        /* Check the message from server that indicates GPIO reverse gear
+         * detected or non-reverse gear detected.
+         * If timeout, then reset the 500ms sleep and resend the A15 heartbeat
+         * to server.
+         * If reverse gear is detected, then set the A15 watchdog/panic
+         * timeout to 0 sec (no recovery/reboot should take place).
+         * If non-reverse is detected, then set the A15 watchdog/panic
+         * timout to 5 sec.
+         */
+        if ((status < 0) && (status != MessageQ_E_TIMEOUT)) {
+            ALOGE("--> App_exec: MessageQ_get FAILED");
+            status = -1;
+            goto leave;
+        }
+
+        if (status == MessageQ_S_SUCCESS) {
+            /* Received a message from server
+             * Extract message payload: check reverse or non-reverse indication
+             */
+            if (msg->cmd == App_CMD_RVC_UP) {
+                ALOGE("--> App_exec: Message received App_CMD_RVC_UP");
+                system("echo 0 > /proc/sys/kernel/panic");
+            }
+            else if (msg->cmd == App_CMD_RVC_DOWN) {
+                ALOGE("--> App_exec: Message received App_CMD_RVC_DOWN");
+                system("echo 5 > /proc/sys/kernel/panic");
+            }
+
+            /* Free the message from M4 -
+             * msg to indicate rvc reverse gear detected or not
+             */
+            MessageQ_free((MessageQ_Msg)msg);
+        }
+
+        if (status == MessageQ_E_TIMEOUT) {
+            /* Receive a TIMEOUT. No message from M4, continue heartbeat
+             */
+            //ALOGE("App_exec: message TIMEOUT, continue heartbeat \n");
+        }
 
-        /* allocate message */
+        /* Allocate message
+         */
         msg = (App_Msg *)MessageQ_alloc(Module.heapId, Module.msgSize);
 
         if (msg == NULL) {
@@ -198,12 +240,13 @@ Int App_exec(Void)
             goto leave;
         }
 
-        /* fill in message payload */
+        /* Fill in message payload */
         msg->cmd = App_CMD_ALIVE;
 #ifdef DEBUG
         MessageCount++;
         gettimeofday(&tv, NULL);
-        ALOGE("%ld us: App_exec: sending #%d App_CMD_ALIVE \n", (tv.tv_sec * 1000000) + tv.tv_usec, MessageCount);
+        ALOGE("%ld us: App_exec: sending #%d App_CMD_ALIVE \n",
+            (tv.tv_sec * 1000000) + tv.tv_usec, MessageCount);
 #endif
     }
 
@@ -221,10 +264,10 @@ Int main(Int argc, Char* argv[])
 
     ALOGE("--> main:");
 
-    /* configure the transport factory */
+    /* Configure the transport factory */
     Ipc_transportConfig(&TransportRpmsg_Factory);
 
-    /* parse command line */
+    /* Parse command line */
     status = Main_parseArgs(argc, argv);
 
     if (status < 0) {
@@ -235,7 +278,7 @@ Int main(Int argc, Char* argv[])
     status = Ipc_start();
 
     if (status >= 0) {
-        /* application create, exec, delete */
+        /* Application create, exec, delete */
         status = Main_main();
 
         /* Ipc finalization */
index 3104510d40a427f5e2eea8faf7a14b29974405f7..7e8a7e0ab90a86ec7ecf72759831b411ebc978af 100644 (file)
@@ -49,6 +49,8 @@ extern "C" {
 #define App_CMD_START           0x00000000
 #define App_CMD_ALIVE           0x01000000
 #define App_CMD_SHUTDOWN        0x02000000
+#define App_CMD_RVC_UP          0x01001000
+#define App_CMD_RVC_DOWN        0x01002000
 
 #define App_MsgHeapId           0
 #define App_HostMsgQueName      "HOST:MsgQ:01"