티스토리 뷰

개발/Linux

WSL USB 디바이스 연결

Dallaenae 2023. 6. 13. 20:34

* 사전 요구 사항
Windows 11 실행(빌드 22000 이상) (Windows 10 지원 가능, https://github.com/dorssel/usbipd-win/wiki/WSL-support)
x64/x86 프로세서가 있는 컴퓨터가 필요합니다. (Arm64는 현재 usbipd-win에서 지원되지 않습니다.)
Linux 배포판이 설치되고 WSL 2로 설정
Linux 커널 5.10.60.1 이상을 실행합니다.

 

* WSL 리스트 및 상태 확인

PS C:\WINDOWS\system32> wsl -l -v
  NAME                   STATE           VERSION
* docker-desktop-data    Stopped         2
  Ubuntu-18.04           Stopped         1
  Ubuntu-20.04           Stopped         2
  docker-desktop         Stopped         2

설치된 배포판이 없다면 Microsoft Store에서 Ubuntu 찾아서 설치

 

* WSL 2 설정

PS C:\WINDOWS\system32> wsl --set-version Ubuntu-20.04 2

 

* USBIPD-WIN 설치

PS C:\WINDOWS\system32> winget install --interactive --exact dorssel.usbipd-win

 

* Linux에서 USBIP 도구 및 하드웨어 데이터베이스 설치

sudo apt install linux-tools-5.4.0-77-generic hwdata
sudo update-alternatives --install /usr/local/bin/usbip usbip /usr/lib/linux-tools/5.4.0-77-generic/usbip 20

 

* WSL 재시작

PS C:\WINDOWS\system32> wsl --shutdown

 

 

* 연결할 디바이스 리스트 확인

PS C:\WINDOWS\system32> usbipd list
Connected:
BUSID  VID:PID    DEVICE                                                        STATE
2-1    046d:c077  USB 입력 장치                                                 Not shared
2-2    04f2:b678  LG Camera                                                     Not shared
2-10   8087:0026  인텔(R) 무선 Bluetooth(R)                                     Not shared
3-1    05e3:0751  USB 대용량 저장 장치                                          Not shared
3-2    0403:6001  USB Serial Converter                                          Not shared
3-3    046d:c34b  USB 입력 장치                                                 Not shared

Persisted:
GUID                                  DEVICE

 

* 연결

PS C:\WINDOWS\system32> usbipd wsl attach --busid 3-2
dmesg
[10508.677800] usb 1-1: SetAddress Request (8) to port 0
[10508.719303] usb 1-1: New USB device found, idVendor=0403, idProduct=6001, bcdDevice= 6.00
[10508.719778] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[10508.720138] usb 1-1: Product: FT232R USB UART
[10508.720402] usb 1-1: Manufacturer: FTDI
[10508.720589] usb 1-1: SerialNumber: A50285BI
[10508.724917] ftdi_sio 1-1:1.0: FTDI USB Serial Device converter detected
[10508.725720] usb 1-1: Detected FT232RL
[10508.728034] usb 1-1: FTDI USB Serial Device converter now attached to ttyUSB0
lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 008: ID 0403:6001 Future Technology Devices International, Ltd FT232 Serial (UART) IC
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

 

* 해제

PS C:\WINDOWS\system32> usbipd wsl detach --busid 3-2

 

 

[참고] WSL이 실행되지 않았을 경우 아래 처럼 오류가 난다. 당연히 사용할 Ubuntu를 실행해야 한다.

PS C:\WINDOWS\system32> usbipd wsl attach --busid 3-2
usbipd: info: Using default WSL distribution 'docker-desktop-data'; specify the '--distribution' option to select a different one.
usbipd: error: The selected WSL distribution is not running; keep a command prompt to the distribution open to leave it running.

 

반응형