浏览代码

[update] openamp.

thread-liu 4 年之前
父节点
当前提交
916bcc141f
共有 1 个文件被更改,包括 37 次插入1 次删除
  1. 37 1
      bsp/stm32/stm32mp157a-st-ev1/board/ports/OpenAMP/drv_openamp.c

+ 37 - 1
bsp/stm32/stm32mp157a-st-ev1/board/ports/OpenAMP/drv_openamp.c

@@ -12,6 +12,7 @@
 
 #ifdef BSP_USING_OPENAMP
 
+#include <finsh.h>
 #include <drv_openamp.h>
 #include <openamp.h>
 #include <virt_uart.h>
@@ -235,7 +236,10 @@ int rt_hw_openamp_init(void)
     
     rt_hw_openamp_register(&dev_openamp, "openamp", 0, NULL);
     
-    rt_console_set_device("openamp");
+    if (RT_CONSOLE_DEVICE_NAME == "openamp")
+    {
+        rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
+    }
 
     return RT_EOK;
 }
@@ -289,4 +293,36 @@ static int creat_openamp_thread(void)
 }
 INIT_APP_EXPORT(creat_openamp_thread);
 
+#ifdef FINSH_USING_MSH
+
+static int console(int argc, char **argv)
+{
+    rt_err_t result = RT_EOK;
+    
+    if (argc > 1)
+    {
+        if (!strcmp(argv[1], "set"))
+        {
+            rt_kprintf("console change to %s\n", argv[2]);
+            rt_console_set_device(argv[2]);
+            finsh_set_device(argv[2]);
+        }
+        else
+        {
+            rt_kprintf("Unknown command. Please enter 'console' for help\n");
+            result = -RT_ERROR;
+        }
+    }
+    else
+    {
+        rt_kprintf("Usage: \n");
+        rt_kprintf("console set <name>   - change console by name\n");
+        result = -RT_ERROR;
+    }
+    return result;
+}
+MSH_CMD_EXPORT(console, set console name);
+
+#endif /* FINSH_USING_MSH */
+
 #endif