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


The following commit(s) were added to refs/heads/master by this push:
     new 987cb1ebd adb: support adb boardctl when not composite device
987cb1ebd is described below

commit 987cb1ebd996c80920ef39a37450a846518a0148
Author: zhangyuan21 <[email protected]>
AuthorDate: Sat Jul 29 16:11:39 2023 +0800

    adb: support adb boardctl when not composite device
    
    Signed-off-by: zhangyuan21 <[email protected]>
---
 system/adb/Kconfig    |  9 +++++++++
 system/adb/adb_main.c | 26 +++++++++++++++-----------
 2 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/system/adb/Kconfig b/system/adb/Kconfig
index e5cf32437..bf71297df 100644
--- a/system/adb/Kconfig
+++ b/system/adb/Kconfig
@@ -171,6 +171,15 @@ config ADBD_BOARD_INIT
        ---help---
                Setup board before running adb daemon.
 
+config ADBD_USB_BOARDCTL
+       bool "USB Board Control"
+       depends on BOARDCTL
+       depends on ADBD_USB_SERVER
+       select BOARDCTL_USBDEVCTRL
+       default ADBD_BOARD_INIT
+       ---help---
+               Connect usbdev before running adb daemon.
+
 config ADBD_NET_INIT
        bool "Network initialization"
        default n
diff --git a/system/adb/adb_main.c b/system/adb/adb_main.c
index 6401789f8..9a3676115 100644
--- a/system/adb/adb_main.c
+++ b/system/adb/adb_main.c
@@ -27,7 +27,8 @@
 #include <stdio.h>
 #include <syslog.h>
 
-#if defined(CONFIG_ADBD_BOARD_INIT) || defined (CONFIG_BOARDCTL_RESET)
+#if defined(CONFIG_ADBD_BOARD_INIT) || defined (CONFIG_BOARDCTL_RESET) || \
+    defined(CONFIG_ADBD_USB_BOARDCTL)
 #  include <sys/boardctl.h>
 #endif
 
@@ -77,20 +78,24 @@ int main(int argc, FAR char **argv)
 
 #ifdef CONFIG_ADBD_BOARD_INIT
   boardctl(BOARDIOC_INIT, 0);
+#endif /* CONFIG_ADBD_BOARD_INIT */
 
-#if defined(CONFIG_ADBD_USB_SERVER) && \
-    defined(CONFIG_USBDEV_COMPOSITE) && \
-    defined (CONFIG_BOARDCTL_USBDEVCTRL)
+#ifdef CONFIG_ADBD_USB_BOARDCTL
 
-  /* Setup composite USB device */
+  /* Setup USBADB device */
 
   struct boardioc_usbdev_ctrl_s ctrl;
-  int ret;
+#ifdef CONFIG_USBDEV_COMPOSITE
+  uint8_t usbdev = BOARDIOC_USBDEV_COMPOSITE;
+#else
+  uint8_t usbdev = BOARDIOC_USBDEV_ADB;
+#endif
   FAR void *handle;
+  int ret;
 
   /* Perform architecture-specific initialization */
 
-  ctrl.usbdev   = BOARDIOC_USBDEV_COMPOSITE;
+  ctrl.usbdev   = usbdev;
   ctrl.action   = BOARDIOC_USBDEV_INITIALIZE;
   ctrl.instance = 0;
   ctrl.config   = 0;
@@ -103,9 +108,9 @@ int main(int argc, FAR char **argv)
       return 1;
     }
 
-  /* Initialize the USB composite device device */
+  /* Connect the USB composite device device */
 
-  ctrl.usbdev   = BOARDIOC_USBDEV_COMPOSITE;
+  ctrl.usbdev   = usbdev;
   ctrl.action   = BOARDIOC_USBDEV_CONNECT;
   ctrl.instance = 0;
   ctrl.config   = 0;
@@ -117,8 +122,7 @@ int main(int argc, FAR char **argv)
       printf("boardctl(BOARDIOC_USBDEV_CONTROL) failed: %d\n", ret);
       return 1;
     }
-#endif /* ADBD_USB_SERVER && USBDEV_COMPOSITE && BOARDCTL_USBDEVCTRL */
-#endif /* CONFIG_ADBD_BOARD_INIT */
+#endif /* ADBD_USB_BOARDCTL */
 
 #ifdef CONFIG_ADBD_NET_INIT
   /* Bring up the network */

Reply via email to