raspberrypi / usbboot

Raspberry Pi USB booting code, moved from tools repository
Apache License 2.0
905 stars 229 forks source link

rpiboot is busy-waiting ?!? #45

Closed laf0rge closed 5 years ago

laf0rge commented 5 years ago

On a fairly high-end i7-6500U based system, rpiboot is consuming 7 to 11 percent of CPU without doing something. What a nightmare. If you're waiting for a USB device to enumerate, you can actually register for events. I don't get why there should ever be any polling or busy-waiting/looping involved.

http://libusb.sourceforge.net/api-1.0/group__libusb__hotplug.html describes how to register a call-back for hot-plug event notification.

ghollingworth commented 5 years ago

Unfortunately this interface is not available for all applicable operating systems and therefore wasn't implemented...

LIBUSB_CAP_HAS_HOTPLUG to confirm that hotplug support is available.