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

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

commit 9633580d2c7f64891729655edc1813d36e116c6a
Author: yangsong8 <[email protected]>
AuthorDate: Thu Jul 31 23:00:36 2025 +0800

    apps/fastboot: add switchboot command
    
    The switchboot command can be sent even without enabling sh
    
    Signed-off-by: yangsong8 <[email protected]>
---
 system/fastboot/fastboot.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/system/fastboot/fastboot.c b/system/fastboot/fastboot.c
index c18081c40..41e20b6d8 100644
--- a/system/fastboot/fastboot.c
+++ b/system/fastboot/fastboot.c
@@ -226,6 +226,10 @@ static void fastboot_filedump(FAR struct fastboot_ctx_s 
*ctx,
 static void fastboot_shell(FAR struct fastboot_ctx_s *ctx,
                            FAR const char *arg);
 #endif
+#ifdef CONFIG_BOARDCTL_SWITCH_BOOT
+static void fastboot_switchboot(FAR struct fastboot_ctx_s *context,
+                                FAR const char *arg);
+#endif
 
 /* USB transport */
 
@@ -272,6 +276,9 @@ static const struct fastboot_cmd_s g_oem_cmd[] =
 #ifdef CONFIG_SYSTEM_FASTBOOTD_SHELL
   { "shell",              fastboot_shell            },
 #endif
+#ifdef CONFIG_BOARDCTL_SWITCH_BOOT
+  { "switchboot",         fastboot_switchboot       },
+#endif
 };
 
 #ifdef CONFIG_BOARD_MEMORY_RANGE
@@ -930,6 +937,21 @@ static void fastboot_shell(FAR struct fastboot_ctx_s *ctx,
 }
 #endif
 
+#ifdef CONFIG_BOARDCTL_SWITCH_BOOT
+static void fastboot_switchboot(FAR struct fastboot_ctx_s *context,
+                                FAR const char *arg)
+{
+  if (!arg)
+    {
+      fastboot_fail(context, "Invalid argument");
+      return;
+    }
+
+  boardctl(BOARDIOC_SWITCH_BOOT, (uintptr_t)&arg[0]);
+  fastboot_okay(context, "");
+}
+#endif
+
 static void fastboot_upload(FAR struct fastboot_ctx_s *ctx,
                             FAR const char *arg)
 {

Reply via email to