cannot find any libusb even though 2 are installed
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 560
- Avg merge
- 1h 41m
- Merged PRs (30d)
- 3
Description
First things first, OS: void Linux 5.11.15_1 #1 SMP 1618703302 x86_64 GNU/Linux
PyOCD 0.30.2 installed through Mbed Studio (/home/kyra/.config/Mbed\ Studio/mbed-studio-tools/python/bin/pyocd and so on).
While Mbed Studio correctly identifies (in its target selection etc.) both my STLink (clone) and a board with builtin DFU bootloader (not using the STLink for that one, planning to go directly through the DFU mode), PyOCD doesn't even seem to be able to find a suitable libusb (showing a manual run there because mbed suppresses some info, stacktrace is the same tho):
$ /home/kyra/.config/Mbed\ Studio/mbed-studio-tools/python/bin/pyocd cmd -vv
0000388:WARNING:pyusb_backend:CMSIS-DAPv1 probes may not be detected because no libusb library was found.
0000418:WARNING:common:STLink and CMSIS-DAPv2 probes are not supported because no libusb library was found.
0000450:DEBUG:session:Project directory: /home/kyra
0000450:CRITICAL:__main__:No backend available
Traceback (most recent call last):
File "/home/kyra/.config/Mbed Studio/mbed-studio-tools/python/lib/python3.7/site-packages/pyocd/__main__.py", line 402, in run
self._COMMANDS[self._args.cmd](self)
File "/home/kyra/.config/Mbed Studio/mbed-studio-tools/python/lib/python3.7/site-packages/pyocd/__main__.py", line 808, in do_commander
PyOCDCommander(self._args, cmds).run()
File "/home/kyra/.config/Mbed Studio/mbed-studio-tools/python/lib/python3.7/site-packages/pyocd/commands/commander.py", line 65, in run
if not self.connect():
File "/home/kyra/.config/Mbed Studio/mbed-studio-tools/python/lib/python3.7/site-packages/pyocd/commands/commander.py", line 166, in connect
unique_id=self.args.unique_id,
File "/home/kyra/.config/Mbed Studio/mbed-studio-tools/python/lib/python3.7/site-packages/pyocd/core/helpers.py", line 138, in choose_probe
allProbes = ConnectHelper.get_all_connected_probes(blocking=blocking, unique_id=unique_id)
File "/home/kyra/.config/Mbed Studio/mbed-studio-tools/python/lib/python3.7/site-packages/pyocd/core/helpers.py", line 82, in get_all_connected_probes
allProbes = DebugProbeAggregator.get_all_connected_probes(unique_id=unique_id)
File "/home/kyra/.config/Mbed Studio/mbed-studio-tools/python/lib/python3.7/site-packages/pyocd/probe/aggregator.py", line 64, in get_all_connected_probes
probes += cls.get_all_connected_probes(unique_id, is_explicit)
File "/home/kyra/.config/Mbed Studio/mbed-studio-tools/python/lib/python3.7/site-packages/pyocd/probe/picoprobe.py", line 333, in get_all_connected_probes
return [cls(dev) for dev in PicoLink.enumerate_picoprobes()]
File "/home/kyra/.config/Mbed Studio/mbed-studio-tools/python/lib/python3.7/site-packages/pyocd/probe/picoprobe.py", line 108, in enumerate_picoprobes
return [PicoLink(probe) for probe in core.find(find_all=True, custom_match=FindPicoprobe(uid))]
File "/home/kyra/.config/Mbed Studio/mbed-studio-tools/python/lib/python3.7/site-packages/usb/core.py", line 1299, in find
raise NoBackendError('No backend available')
usb.core.NoBackendError: No backend available
so i have 2 issues here: why does the picoprobe code (which isn't supposed to be used here, i don't even have that probe) crashing pyocd after 2 other devices were only warned about for the same reason? and why is it even thinking libusb to be unavailable?
$ ls -l /lib/libusb*
lrwxrwxrwx 1 root root 19 Nov 20 2018 /lib/libusb-0.1.so.4 -> libusb-0.1.so.4.4.4
-rwxr-xr-x 1 root root 22432 Nov 20 2018 /lib/libusb-0.1.so.4.4.4
-rw-r--r-- 1 root root 208486 Apr 2 19:29 /lib/libusb-1.0.a
lrwxrwxrwx 1 root root 19 Apr 2 19:29 /lib/libusb-1.0.so -> libusb-1.0.so.0.3.0
lrwxrwxrwx 1 root root 19 Apr 2 19:29 /lib/libusb-1.0.so.0 -> libusb-1.0.so.0.3.0
-rwxr-xr-x 1 root root 116824 Apr 2 19:29 /lib/libusb-1.0.so.0.3.0
-rw-r--r-- 1 root root 20626 Nov 20 2018 /lib/libusb.a
lrwxrwxrwx 1 root root 19 Nov 20 2018 /lib/libusb.so -> libusb-0.1.so.4.4.4
lrwxrwxrwx 1 root root 23 Nov 10 04:19 /lib/libusbmuxd-2.0.so.6 -> libusbmuxd-2.0.so.6.0.0
(with /lib, /usr/lib, ... all being symlinked together on this distro)
libusb-1.0 being one of the names usb.backend.libusb1 explicitely tries:
def _load_library(find_library=None):
#...
return usb.libloader.load_locate_library(
('usb-1.0', 'libusb-1.0', 'usb'),
'cygusb-1.0.dll', 'Libusb 1',
win_cls=win_cls,
find_library=find_library, check_symbols=('libusb_init',))
just in case, 32bit versions also exist in /lib32,/usr/lib32,... but i sure hope python won't need those. even the headers are installed and everything:
$ xbps-query -Rs libusb
[*] libgusb-0.3.6_1 GLib wrapper around libusb1
[-] libgusb-devel-0.3.6_1 GLib wrapper around libusb1 - development files
[*] libusb-1.0.24_1 Library which allows userspace access to USB devices
[*] libusb-compat-0.1.5_7 A libusb-0.1 compatibility library
[*] libusb-compat-devel-0.1.5_7 A libusb-0.1 compatibility library - development files
[*] libusb-devel-1.0.24_1 Library which allows userspace access to USB devices - development files
[-] libusbip-5.10.4_4 USB device sharing system over IP network - runtime library
[-] libusbip-devel-5.10.4_4 USB device sharing system over IP network - development files
[*] libusbmuxd-2.0.2_1 USB Multiplex Daemon library
[-] libusbmuxd-devel-2.0.2_1 USB Multiplex Daemon library - development files
[*] libgusb-32bit-0.3.6_1 GLib wrapper around libusb1 (32bit)
[-] libgusb-devel-32bit-0.3.6_1 GLib wrapper around libusb1 - development files (32bit)
[*] libusb-32bit-1.0.24_1 Library which allows userspace access to USB devices (32bit)
[*] libusb-compat-32bit-0.1.5_7 A libusb-0.1 compatibility library (32bit)
[*] libusb-compat-devel-32bit-0.1.5_7 A libusb-0.1 compatibility library - development files (32bit)
[*] libusb-devel-32bit-1.0.24_1 Library which allows userspace access to USB devices - development files (32bit)
[-] libusbip-32bit-5.10.4_4 USB device sharing system over IP network - runtime library (32bit)
[-] libusbip-devel-32bit-5.10.4_4 USB device sharing system over IP network - development files (32bit)
[-] libusbmuxd-32bit-2.0.2_1 USB Multiplex Daemon library (32bit)
[-] libusbmuxd-devel-32bit-2.0.2_1 USB Multiplex Daemon library - development files (32bit)
oh and just to add insult to injury i just realized i'm regularly successfully using pyUSB with that very libusb1 to talk to a device of mine on that very machine.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with pyocd/probe/picoprobe.py and the probe aggregator path shown in the traceback, then inspect PyUSB's usb.backend.libusb1 loader. Reproduce the command with verbose logging and compare the picoprobe failure with the STLink and CMSIS-DAP warnings; done means an unavailable or irrelevant backend does not abort probe discovery and libusb is handled consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100