WSL에서 USB 사용하기 (ft. usbipd)

https://github.com/dorssel/usbipd-win

wsl 버전 확인

5.10.60.1 이상만 되니, 버전이 낮다면 wsl –update

Bash
$ uname -a
Linux TP-P14s-G4 5.15.153.1-microsoft-standard-WSL2 #1 SMP Fri Mar 29 23:14:13 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

USB 하드웨어 식별자 데이터 설치

linux-tools 설치하고, 심볼릭 링크 생성

Bash
$ sudo apt install linux-tools-virtual hwdata
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  linux-tools-5.15.0-119 linux-tools-5.15.0-119-generic linux-tools-common
The following NEW packages will be installed:
  hwdata linux-tools-5.15.0-119 linux-tools-5.15.0-119-generic linux-tools-common linux-tools-virtual
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 8261 kB of archives.
After this operation, 28.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
...

$ sudo update-alternatives --install /usr/local/bin/usbip usbip `ls /usr/lib/linux-tools/*/usbip | tail -n1` 20

usbipd-win 설치

PowerShell
PS> winget install --interactive --exact dorssel.usbipd-win

usbipd 확인

PowerShell
PS> usbipd list
Connected:
BUSID  VID:PID    DEVICE                                                        STATE
2-2    17ef:30b0  ThinkPad USB-C Dock Audio, USB 입력 장치                      Not shared
2-3    17ef:30a9  Billboard Device, Vendor Interface                            Not shared
4-1    0403:6001  USB Serial Converter                                          Not shared
4-3    27c6:6594  Goodix MOC Fingerprint                                        Not shared
4-4    30c9:00ad  Integrated Camera, Integrated IR Camera, Camera DFU Device    Not shared
4-10   8087:0033  인텔(R) 무선 Bluetooth(R)                                     Not shared
5-1    0bda:8153  Realtek USB GbE Family Controller                             Not shared
5-2    0b95:1790  ASIX USB to Gigabit Ethernet Family Adapter                   Not shared

Persisted:
GUID                                  DEVICE

내가 필요한 건 4-1 USB Serial Converter
BUSID를 기억해두자

usbipd 확인

wsl에서 사용할 4-1을 bind 시키고, wsl에 attach 시킨다.

PowerShell
PS> usbipd bind --busid 4-1
PS> usbipd attach --wsl --busid 4-1
usbipd: info: Using WSL distribution 'Ubuntu' to attach; the device will be available in all WSL 2 distributions.
usbipd: info: Using IP address 172.27.240.1 to reach the host.

WSL 에서 USB 확인

윈도우에서 usbipd 명령 실행 후에, 필요한 ttyUSB0 생성된 것을 확인

Bash
$ ls -al /dev/tty
tty    tty11  tty15  tty19  tty22  tty26  tty3   tty33  tty37  tty40  tty44  tty48  tty51  tty55  tty59  tty62  tty9   ttyS3
tty0   tty12  tty16  tty2   tty23  tty27  tty30  tty34  tty38  tty41  tty45  tty49  tty52  tty56  tty6   tty63  ttyS0
tty1   tty13  tty17  tty20  tty24  tty28  tty31  tty35  tty39  tty42  tty46  tty5   tty53  tty57  tty60  tty7   ttyS1
tty10  tty14  tty18  tty21  tty25  tty29  tty32  tty36  tty4   tty43  tty47  tty50  tty54  tty58  tty61  tty8   ttyS2

$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

<after usbipd attach --wsl --busid 4-1> 

$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: 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

$ ls -al /dev/tty
tty      tty12    tty17    tty21    tty26    tty30    tty35    tty4     tty44    tty49    tty53    tty58    tty62    ttyS0
tty0     tty13    tty18    tty22    tty27    tty31    tty36    tty40    tty45    tty5     tty54    tty59    tty63    ttyS1
tty1     tty14    tty19    tty23    tty28    tty32    tty37    tty41    tty46    tty50    tty55    tty6     tty7     ttyS2
tty10    tty15    tty2     tty24    tty29    tty33    tty38    tty42    tty47    tty51    tty56    tty60    tty8     ttyS3
tty11    tty16    tty20    tty25    tty3     tty34    tty39    tty43    tty48    tty52    tty57    tty61    tty9     ttyUSB0


guest
2 대댓글
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
dawnsea
2 months ago

오 나두 WSL 쓰는데 ㅎㅎㅎ

2
0
Would love your thoughts, please comment.x
()
x
Scroll to Top