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-apps.git

commit 53cd8cda1f06d040188877656384a6c9cf6eb765
Author: Xiang Xiao <[email protected]>
AuthorDate: Sun Jan 23 17:45:35 2022 +0800

    system/adb: Support reset to bootloader and recovery mode
    
    Signed-off-by: Xiang Xiao <[email protected]>
---
 system/adb/Kconfig    | 22 ++++++++++++++++------
 system/adb/adb_main.c | 13 ++++++++++++-
 2 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/system/adb/Kconfig b/system/adb/Kconfig
index c9f13e9..87fa0b6 100644
--- a/system/adb/Kconfig
+++ b/system/adb/Kconfig
@@ -49,6 +49,16 @@ config ADBD_TOKEN_SIZE
 
 endif # ADBD_AUTHENTICATION
 
+if BOARDCTL_RESET
+config ADBD_RESET_RECOVERY
+       int "Reset argument for recovery"
+       default 1
+
+config ADBD_RESET_BOOTLOADER
+       int "Reset argument for bootloader"
+       default 2
+endif # BOARDCTL_RESET
+
 if ! BOARDCTL_UNIQUEID
 config ADBD_DEVICE_ID
        string "Default adb device id"
@@ -148,11 +158,11 @@ config ADBD_BOARD_INIT
                Setup board before running adb daemon.
 
 config ADBD_NET_INIT
-    bool "Network initialization"
-    default n
-    depends on NET
-    select NETUTILS_NETINIT
-    ---help---
-        This option enables/disables all network initialization in ADB server.
+       bool "Network initialization"
+       default n
+       depends on NET
+       select NETUTILS_NETINIT
+       ---help---
+               This option enables/disables all network initialization in ADB 
server.
 
 endif # SYSTEM_ADBD
diff --git a/system/adb/adb_main.c b/system/adb/adb_main.c
index ca658fc..ff6c16a 100644
--- a/system/adb/adb_main.c
+++ b/system/adb/adb_main.c
@@ -54,7 +54,18 @@ void adb_log_impl(FAR const char *func, int line, FAR const 
char *fmt, ...)
 void adb_reboot_impl(const char *target)
 {
 #ifdef CONFIG_BOARDCTL_RESET
-  boardctl(BOARDIOC_RESET, 0);
+  if (strcmp(target, "recovery") == 0)
+    {
+      boardctl(BOARDIOC_RESET, CONFIG_ADBD_RESET_RECOVERY);
+    }
+  else if (strcmp(target, "bootloader") == 0)
+    {
+      boardctl(BOARDIOC_RESET, CONFIG_ADBD_RESET_BOOTLOADER);
+    }
+  else
+    {
+      boardctl(BOARDIOC_RESET, 0);
+    }
 #else
   adb_log("reboot not implemented\n");
 #endif

Reply via email to