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

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

commit a485d9636b7d100e8a38a9647e1a10e6f55b06d8
Author: wangjianyu3 <[email protected]>
AuthorDate: Mon Oct 13 16:49:39 2025 +0800

    system/nxinit: Add boot support for action
    
    Add support for booting a new application firmware image.
    Depends on `BOARDCTL_BOOT_IMAGE`.
    
    When the built-in boot command of nsh is enabled, the built-in boot
    command of Init will take precedence (see init_builtin_run()). To use
    the built-in boot command of nsh, use: `exec -- sh boot [args...]`.
    
    Referred to nshlib/nsh_syscmds.c: cmd_boot()
    
    Signed-off-by: wangjianyu3 <[email protected]>
---
 system/nxinit/builtin.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/system/nxinit/builtin.c b/system/nxinit/builtin.c
index 6da046b69..807bfb734 100644
--- a/system/nxinit/builtin.c
+++ b/system/nxinit/builtin.c
@@ -25,9 +25,11 @@
  ****************************************************************************/
 
 #include <errno.h>
+#include <inttypes.h>
 #include <stdlib.h>
 #include <string.h>
 #include <spawn.h>
+#include <sys/boardctl.h>
 #include <sys/param.h>
 #include <sys/wait.h>
 
@@ -70,6 +72,10 @@ static int cmd_class_start(FAR struct action_manager_s *am,
                            int argc, FAR char **argv);
 static int cmd_class_stop(FAR struct action_manager_s *am,
                           int argc, FAR char **argv);
+#ifdef CONFIG_BOARDCTL_BOOT_IMAGE
+static int cmd_boot(FAR struct action_manager_s *am,
+                    int argc, FAR char **argv);
+#endif
 
 /****************************************************************************
  * Private Data
@@ -77,6 +83,9 @@ static int cmd_class_stop(FAR struct action_manager_s *am,
 
 static const struct cmd_map_s g_builtin[] =
 {
+#ifdef CONFIG_BOARDCTL_BOOT_IMAGE
+  {"boot", 1, 3, cmd_boot},
+#endif
   {"class_start", 2, 2, cmd_class_start},
   {"class_stop", 2, 2, cmd_class_stop},
   {"exec", 3, 99, cmd_exec},
@@ -93,6 +102,32 @@ static const struct cmd_map_s g_builtin[] =
  * Private Functions
  ****************************************************************************/
 
+#ifdef CONFIG_BOARDCTL_BOOT_IMAGE
+static int cmd_boot(FAR struct action_manager_s *am,
+                    int argc, FAR char **argv)
+{
+  struct boardioc_boot_info_s info;
+
+  UNUSED(am);
+  memset(&info, 0, sizeof(info));
+
+  if (argc > 1)
+    {
+      info.path = argv[1];
+    }
+
+  if (argc > 2)
+    {
+      info.header_size = strtoul(argv[2], NULL, 0);
+    }
+
+  boardctl(BOARDIOC_BOOT_IMAGE, (uintptr_t)&info);
+  init_err("boot image '%s' %" PRIu32 "", info.path ? info.path : "",
+           info.header_size);
+  return -ENOENT;
+}
+#endif
+
 static int cmd_class_start(FAR struct action_manager_s *am,
                            int argc, FAR char **argv)
 {

Reply via email to