Skip to content

Commit

Permalink
system/adb: Waiting for enumeration to complete before opening endpoint
Browse files Browse the repository at this point in the history
Env

  esp32s3-devkit:adb

Error

  adbd [3:100]

  NuttShell (NSH)
  nsh> adb_uv_usb_setup (154): failed to open usb device -1 2

Test
  + adb_log("Waiting for %s ..", ep);

  adbd [3:100]

  NuttShell (NSH)
  nsh> adbd_main (161): Waiting for /dev/adb0/ep0 ..

  nsh> ps
    PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK            STACK COMMAND
      0     0   0 FIFO     Kthread   - Ready              0000000000000000 0003008 Idle_Task
      1     0 224 RR       Kthread   - Waiting  Semaphore 0000000000000000 0008080 hpwork 0x3fc8bc00 0x3fc8bc24
      2     2 100 RR       Task      - Running            0000000000000000 0003992 nsh_main
      3     3 100 RR       Task      - Waiting  Semaphore 0000000000000000 0008112 adbd
  nsh>

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
  • Loading branch information
JianyuWang0623 committed Nov 22, 2024
1 parent 365869b commit af78496
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions system/adb/adb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

#include "adb.h"

#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <syslog.h>
#include <nuttx/streams.h>

Expand All @@ -36,6 +39,16 @@
# include "netutils/netinit.h"
#endif

#define ADB_WAIT_EP_READY(ep) \
{ \
struct stat sb; \
\
while (stat(ep, &sb) != 0) \
{ \
usleep(500000); \
}; \
}

/****************************************************************************
* Public Functions
****************************************************************************/
Expand Down Expand Up @@ -144,6 +157,10 @@ int main(int argc, FAR char **argv)
}
#endif /* ADBD_USB_BOARDCTL */

ADB_WAIT_EP_READY("/dev/adb0/ep0");
ADB_WAIT_EP_READY("/dev/adb0/ep1");
ADB_WAIT_EP_READY("/dev/adb0/ep2");

#ifdef CONFIG_ADBD_NET_INIT
/* Bring up the network */

Expand Down

0 comments on commit af78496

Please sign in to comment.