Pular para o conteúdo principal

ADB on WSL

In order to use adb shell with USB devices connected to the Windows Host, you need to share the device via Powershell.

  1. Open Powershell with Administrator rights, list the devices and identify the target:
usbipd list

Output

PS C:\WINDOWS\system32> usbipd list
Connected:
BUSID VID:PID DEVICE STATE
2-3 00aa:000b USB Input Device Not shared
2-4 00ab:000a SAMSUNG Mobile USB CDC Composite Device Not shared
  1. Now with the device BUSID, bind and attach it to the WSL
usbipd bind -b 2-4
usbipd attach --wsl -b 2-4

Outputs

PS C:\WINDOWS\system32> usbipd bind -b 2-4
PS C:\WINDOWS\system32> usbipd attach --wsl -b 2-4
usbipd: info: Using WSL distribution 'ArchLinux' to attach; the device will be available in all WSL 2 distributions.
usbipd: info: Loading vhci_hcd module.
usbipd: info: Detected networking mode 'nat'.
usbipd: info: Using IP address 172.20.48.1 to reach the host.

To verify the attachment, switch back to your Arch Linux WSL terminal and run lsusb. You should now see your Android phone listed in the Linux hardware output.4.Run native Linux ADB:Arch WSL Terminal.Now that Arch Linux has direct control over the physical USB port, you can run the standard Linux ADB commands.

  1. You might need to restart the WSL adb server:
adb kill-server
sudo adb start-server
adb devices

To verify this worked, your phone should prompt you for RSA authorization (if it hasn't already), and the WSL terminal will list it as an attached device.