You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/08/22 14:53:34 UTC

[incubator-nuttx] branch master updated: arch/sim: set CMDLINE env to the argument user pass to nuttx

This is an automated email from the ASF dual-hosted git repository.

pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new b60704614e arch/sim: set CMDLINE env to the argument user pass to nuttx
b60704614e is described below

commit b60704614e97293fd937d83b08cabf12da6992a2
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Fri Aug 19 20:49:15 2022 +0800

    arch/sim: set CMDLINE env to the argument user pass to nuttx
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 arch/sim/src/sim/up_initialize.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/arch/sim/src/sim/up_initialize.c b/arch/sim/src/sim/up_initialize.c
index bad99bc98a..d64a94814b 100644
--- a/arch/sim/src/sim/up_initialize.c
+++ b/arch/sim/src/sim/up_initialize.c
@@ -31,12 +31,30 @@
 #include <nuttx/spi/spi_flash.h>
 #include <nuttx/spi/qspi_flash.h>
 
+#include <stdlib.h>
+
 #include "up_internal.h"
 
 /****************************************************************************
  * Private Functions
  ****************************************************************************/
 
+#ifndef CONFIG_DISABLE_ENVIRON
+static void up_init_cmdline(void)
+{
+  char cmdline[ARG_MAX] = "";
+  int i;
+
+  for (i = 1; i < g_argc; i++)
+    {
+      strlcat(cmdline, g_argv[i], sizeof(cmdline));
+      strlcat(cmdline, " ", sizeof(cmdline));
+    }
+
+  setenv("CMDLINE", cmdline, true);
+}
+#endif
+
 /****************************************************************************
  * Name: up_init_smartfs
  *
@@ -226,6 +244,10 @@ void up_initialize(void)
   pm_initialize();
 #endif
 
+#ifndef CONFIG_DISABLE_ENVIRON
+  up_init_cmdline();
+#endif
+
   /* Register some tty-port to access tty-port on sim platform */
 
   up_uartinit();