我尝试在 WSL2 Linux (Ubuntu 20.04) 中进行嵌入式系统开发并收到错误:
usbipd: warning: USB filter 'USBPcap' is known to be incompatible with this software; 'bind --force' will be required.
在 powershell 中,当我看到错误“bind --force”时,运行
usbipd wsl list
是必需的(完整输出如下)。
我不确定为什么会发生这种情况并且是必需的,--force 行为没有记录/没有出现在谷歌搜索中。示例:
PS C:\Users\Hidden> usbipd wsl list
BUSID DEVICE STATE
1-3 Logitech USB Input Device, USB Input Device Not attached
1-4 Printer XYZ Series, USB Printing Support, USB Mass Stor... Not attached
1-7 USB Input Device Not attached
1-8 USB Input Device Not attached
1-10 Intel(R) Wireless Bluetooth(R) Not attached
1-11 USB 2.0 Webcam Device Not attached
1-12 Realtek USB 2.0 Card Reader Not attached
usbipd: warning: USB filter 'USBPcap' is known to be incompatible with this software; 'bind --force' will be required.
我正在使用 Windows 11,内部稳定发布通道,并应用了所有补丁。 WSL1 很慢,磁盘绑定不同,它没有 WSLG(所以我无法运行 Linux GUI 软件)
WSL2 有一个主要缺点 - 它目前不支持 USB 设备,除非您遵循 Microsoft C++ 团队高级软件工程师 Ben McMorran 的说明,他撰写了有关 USBIPD 的文章,该工程师使用 TCP 从 Windows 主机导出 USB 设备/Linux 机器的 IP:
https://devblogs.microsoft.com/commandline/connecting-usb-devices-to-wsl/
谷歌搜索发现很少有与 --force 相关的有用提示/其他内容。
我想我应该在这里发布这个问题,以便为其他经历过同样痛苦和挫败感的人展开讨论,需要强制我的 USB 端口。
步骤1.
重新启动所有终端和/或 shell。
第2步。
usbipd 的强制绑定命令如下:
$PS C:\WINDOWS\System32>
usbipd bind --busid <the bus id> -f
您可以使用
命令获取 USB PID 列表。usbipd devices -l
Usbipd 格式必须是 1-int 。我的确切命令如下所示:
PS C:\WINDOWS\system32> usbipd bind --busid 1-11 -f
我遇到了与您完全相同的问题。
我个人,对 wsl 感到沮丧...但是我执行了上面的命令,它修复了 USBCAP 强制绑定软件不匹配标志。
--busid
或 -b
标志对位置敏感,它必须紧接在 usbipd bind
-b
或 --busid <busid>
之后,然后是 -f
或 --force
。
步骤1.
打开管理员 PowerShell:
[Windows key] + [x]
然后按
[a]
...键入以下命令:
wsl --set-version Ubuntu 2
[注意:可以使用命令
wsl -l
找到发行版名称]
如果您使用 debian,请使用
Debian
,如果您使用社区 arch 发行版,请使用 Arch
作为您的发行版。
如果这不起作用并且您最近安装了 Pcap 或 usbcap,请考虑完全重新启动计算机以应用虚拟机管理程序绑定到网络接口所需的隐藏更改。
usbipd: warning: USB filter 'USBPcap' is known to be incompatible with this software; 'bind --force' will be required.
PS C:\WINDOWS\system32> usbipd bind --busid 1-11 -f
usbipd: warning: A reboot may be required before the changes take effect.
PS C:\WINDOWS\system32> usbipd bind --busid 1-11 -f
usbipd: info: Device with busid '1-11' was already shared.
PS C:\WINDOWS\system32> history
Id CommandLine
-- -----------
1 winget install --interactive --exact dorssel.usbipd-win
2 usbipd wsl list
3 usbipd wsl attach --busid 1-11
4 usbipd wsl attach --busid 1-11 bind --force
5 usbipd wsl attach --busid 1-11 bind -d Ubuntu
6 usbipd wsl attach --busid 1-11 -d Ubuntu
7 usbipd wsl attach --busid 11 -d Ubuntu
8 usbipd wsl attach --busid 1-11 -d Ubuntu
9 usbipd wsl attach --busid 1-11 -d Ubuntu --force
10 usbipd wsl attach --busid 1-11 -d Ubuntu -a
11 usbipd wsl attach --busid 1-11 -d Ubuntu -a
12 usbipd wsl attach --busid 1-11 -d Ubuntu
13 usbipd wsl list
14 usbipd bind --busid 1-11 -f
15 usbipd bind --busid 1-11 -f
PS C:\WINDOWS\system32>
不是解决方案:“使用 Windows” Arduino、ESP32 xtensa 等。Linux 下的开发经验是无与伦比的,尤其是 WSLG, 没有烦人的 C:\dir 带有空格的愚蠢行为,请不要建议我在 Windows 中进行开发!
不是解决方案:不,我不会卸载 USBPCap,它是我的 USB 探头或示波器(顺便需要 Windows)所必需的
现在要了解 --force 设置的作用, 这是 CLI:
PS C:\Users\MyHome> usbipd bind
Option '--busid' is required.
usbipd-win 2.1.0
Description:
Registers a single USB device for sharing, so it can be attached to other machines. Unless the --force option is used, shared devices remain available to the host until they are attached to another machine.
Usage:
usbipd bind [options]
Options:
-b, --busid <BUSID> (REQUIRED) Share device having <BUSID>
-f, --force Force binding; the host cannot use the device
-?, -h, --help Show help and usage information
我希望有任何人目前如何使用 usbipd 和/或解决此问题的已知解决方法的示例。显然,--force 可以完成任务,但当任务需要螺丝时,感觉就像使用钉子一样。
我可能会尝试向 winpcap/LibUSBpcap 团队提交问题和/或补丁,任何告诉我如何在不使用 --force 或删除警告的情况下执行此操作的答案肯定会得到标记为已解决的答案。 ;-)
usbipd bind -f 对我来说在 WSL2 上工作得很好。我仍然需要重新编译内核来构建 USB 模块,因为它们不包含在 Win10 中。
另一个选项是为 Windows 和 WSL2/Ubuntu 安装 socat
我使用了 Cygwin 打包的 socat,它使用 Windows 串行端口的 unix 路径,因此 /dev/ttyS3 对应于 COM4。 Socat 仅作为源代码提供,因此您必须在 unix/linux 端口中找到 Windows 版本或编译您自己的版本。
Socat 不需要额外的驱动程序,并且在 WSL 内核缺少模块时非常方便。它还让我能够解决有问题的 Linux USB 串行驱动程序。缺点是Linux端无法控制真正的串口波特率或硬件握手。
窗户:
socat TCP-LISTEN:4444,fork /dev/ttyS3,raw
Linux/WSL2
socat pty,link=/tmp/ttyUSB0,echo=0,raw tcp:172.18.32.1:4444 &
WSL2 我使用“usbipd wsl Attach -b x-y -a”并忽略有关 USBPcap 的警告(Wireshark 需要它)。这似乎适用于大多数事情。
我的虚拟 COM 端口无法在虚拟机内工作,但到目前为止,这是我唯一不能做的事情。我的测试工具运行良好(大部分使用 EP0)。