system/adb: Support reset to bootloader and recovery mode

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-01-23 17:45:35 +08:00 committed by Petro Karashchenko
parent 41c8342927
commit 53cd8cda1f
2 changed files with 28 additions and 7 deletions

View File

@ -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

View File

@ -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