From 53cd8cda1f06d040188877656384a6c9cf6eb765 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Sun, 23 Jan 2022 17:45:35 +0800 Subject: [PATCH] system/adb: Support reset to bootloader and recovery mode Signed-off-by: Xiang Xiao --- 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 c9f13e93e..87fa0b66d 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 ca658fc40..ff6c16a46 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