libusb icon indicating copy to clipboard operation
libusb copied to clipboard

libusb_get_device_list always return 0 on Mac OSX Mountain Lion (10.8)

Open vominh2012 opened this issue 11 years ago • 4 comments

I had tested libusb 1.0.19 on Mac OSX 10.9, 10.9.5, 10.10.1 everything work fine. But when I try it on Mac OSX 10.8, libusb_get_device_list function always return number device is zero then I try to run examples/listdevs nothing showing.

PS: when update OSX 10.8 to 10.8.5 libusb working correctly

on OSX 10.8 I continue test with others version and get the result below

  • libusb 1.0.12 working fine
  • libusb 1.0.13 working fine
  • libusb 1.0.14 working fine
  • libusb 1.0.15, 1.0.15-rc1 listdevs crash with "Segmentation fault: 11"
  • libusb 1.0.16 not working
  • libusb 1.0.9 working fine and examples/listdevs showing this debug infor:

libusb: 0.000305 info [event_thread_main] creating hotplug event source libusb: 0.000898 info [event_thread_main] thread ready to receive events libusb: 0.001300 debug [usbi_add_pollfd] add fd 4 events 1 libusb: 0.001353 debug [libusb_init] created default context libusb: 0.001366 debug [libusb_get_device_list] libusb: 0.003685 info [process_new_device] allocating new device for location 0x03000000 libusb: 0.003782 debug [darwin_cache_device_descriptor] device descriptor: libusb: 0.003796 debug [darwin_cache_device_descriptor] bDescriptorType: 0x01 libusb: 0.003804 debug [darwin_cache_device_descriptor] bcdUSB: 0x0200 libusb: 0.003811 debug [darwin_cache_device_descriptor] bDeviceClass: 0x09 libusb: 0.003817 debug [darwin_cache_device_descriptor] bDeviceSubClass: 0x00 libusb: 0.003825 debug [darwin_cache_device_descriptor] bDeviceProtocol: 0x01 libusb: 0.003831 debug [darwin_cache_device_descriptor] bMaxPacketSize0: 0x40 libusb: 0.003837 debug [darwin_cache_device_descriptor] idVendor: 0x05ac libusb: 0.003844 debug [darwin_cache_device_descriptor] idProduct: 0x8006 libusb: 0.003850 debug [darwin_cache_device_descriptor] bcdDevice: 0x0200 libusb: 0.003857 debug [darwin_cache_device_descriptor] iManufacturer: 0x02 libusb: 0.003863 debug [darwin_cache_device_descriptor] iProduct: 0x01 libusb: 0.003870 debug [darwin_cache_device_descriptor] iSerialNumber: 0x00 libusb: 0.003876 debug [darwin_cache_device_descriptor] bNumConfigurations: 0x01 libusb: 0.003915 info [darwin_check_configuration] active config: 1, first config: 1 libusb: 0.003930 info [process_new_device] found device with address 1 at 001-05ac-8006-09-00 libusb: 0.005889 info [process_new_device] allocating new device for location 0x00000000 libusb: 0.005965 debug [darwin_cache_device_descriptor] device descriptor: libusb: 0.005979 debug [darwin_cache_device_descriptor] bDescriptorType: 0x01 libusb: 0.005986 debug [darwin_cache_device_descriptor] bcdUSB: 0x0100 libusb: 0.005993 debug [darwin_cache_device_descriptor] bDeviceClass: 0x09 libusb: 0.006000 debug [darwin_cache_device_descriptor] bDeviceSubClass: 0x00 libusb: 0.006008 debug [darwin_cache_device_descriptor] bDeviceProtocol: 0x00 libusb: 0.006014 debug [darwin_cache_device_descriptor] bMaxPacketSize0: 0x08 libusb: 0.006020 debug [darwin_cache_device_descriptor] idVendor: 0x05ac libusb: 0.006027 debug [darwin_cache_device_descriptor] idProduct: 0x8005 libusb: 0.006034 debug [darwin_cache_device_descriptor] bcdDevice: 0x0110 libusb: 0.006081 debug [darwin_cache_device_descriptor] iManufacturer: 0x02 libusb: 0.006090 debug [darwin_cache_device_descriptor] iProduct: 0x01 libusb: 0.006097 debug [darwin_cache_device_descriptor] iSerialNumber: 0x00 libusb: 0.006104 debug [darwin_cache_device_descriptor] bNumConfigurations: 0x01 libusb: 0.006142 info [darwin_check_configuration] active config: 1, first config: 1 libusb: 0.006154 info [process_new_device] found device with address 1 at 001-05ac-8005-09-00 libusb: 0.008187 info [process_new_device] allocating new device for location 0x00200000 libusb: 0.009564 debug [darwin_cache_device_descriptor] device descriptor: libusb: 0.009613 debug [darwin_cache_device_descriptor] bDescriptorType: 0x01 libusb: 0.009621 debug [darwin_cache_device_descriptor] bcdUSB: 0x0110 libusb: 0.009628 debug [darwin_cache_device_descriptor] bDeviceClass: 0x09 libusb: 0.009634 debug [darwin_cache_device_descriptor] bDeviceSubClass: 0x00 libusb: 0.009641 debug [darwin_cache_device_descriptor] bDeviceProtocol: 0x00 libusb: 0.009647 debug [darwin_cache_device_descriptor] bMaxPacketSize0: 0x08 libusb: 0.009653 debug [darwin_cache_device_descriptor] idVendor: 0x0e0f libusb: 0.009660 debug [darwin_cache_device_descriptor] idProduct: 0x0002 libusb: 0.009666 debug [darwin_cache_device_descriptor] bcdDevice: 0x0100 libusb: 0.009674 debug [darwin_cache_device_descriptor] iManufacturer: 0x00 libusb: 0.009680 debug [darwin_cache_device_descriptor] iProduct: 0x01 libusb: 0.009686 debug [darwin_cache_device_descriptor] iSerialNumber: 0x00 libusb: 0.009694 debug [darwin_cache_device_descriptor] bNumConfigurations: 0x01 libusb: 0.009736 info [darwin_check_configuration] active config: 1, first config: 1 libusb: 0.009748 info [process_new_device] found device with address 2 at 002-0e0f-0002-09-00 libusb: 0.011754 info [process_new_device] allocating new device for location 0x00100000 libusb: 0.012682 debug [darwin_cache_device_descriptor] device descriptor: libusb: 0.012731 debug [darwin_cache_device_descriptor] bDescriptorType: 0x01 libusb: 0.012739 debug [darwin_cache_device_descriptor] bcdUSB: 0x0110 libusb: 0.012746 debug [darwin_cache_device_descriptor] bDeviceClass: 0x00 libusb: 0.012752 debug [darwin_cache_device_descriptor] bDeviceSubClass: 0x00 libusb: 0.012759 debug [darwin_cache_device_descriptor] bDeviceProtocol: 0x00 libusb: 0.012765 debug [darwin_cache_device_descriptor] bMaxPacketSize0: 0x08 libusb: 0.012771 debug [darwin_cache_device_descriptor] idVendor: 0x0e0f libusb: 0.012778 debug [darwin_cache_device_descriptor] idProduct: 0x0003 libusb: 0.012784 debug [darwin_cache_device_descriptor] bcdDevice: 0x0102 libusb: 0.012790 debug [darwin_cache_device_descriptor] iManufacturer: 0x01 libusb: 0.012797 debug [darwin_cache_device_descriptor] iProduct: 0x02 libusb: 0.012803 debug [darwin_cache_device_descriptor] iSerialNumber: 0x00 libusb: 0.012881 debug [darwin_cache_device_descriptor] bNumConfigurations: 0x01 libusb: 0.012925 info [darwin_check_configuration] active config: 1, first config: 1 libusb: 0.012937 info [process_new_device] found device with address 3 at 003-0e0f-0003-00-00 libusb: 0.015254 info [process_new_device] allocating new device for location 0x00210000 libusb: 0.017072 debug [darwin_cache_device_descriptor] device descriptor: libusb: 0.017119 debug [darwin_cache_device_descriptor] bDescriptorType: 0x01 libusb: 0.017127 debug [darwin_cache_device_descriptor] bcdUSB: 0x0110 libusb: 0.017133 debug [darwin_cache_device_descriptor] bDeviceClass: 0x00 libusb: 0.017139 debug [darwin_cache_device_descriptor] bDeviceSubClass: 0x00 libusb: 0.017146 debug [darwin_cache_device_descriptor] bDeviceProtocol: 0x00 libusb: 0.017152 debug [darwin_cache_device_descriptor] bMaxPacketSize0: 0x08 libusb: 0.017158 debug [darwin_cache_device_descriptor] idVendor: 0x05ac libusb: 0.017164 debug [darwin_cache_device_descriptor] idProduct: 0x020b libusb: 0.017171 debug [darwin_cache_device_descriptor] bcdDevice: 0x0100 libusb: 0.017177 debug [darwin_cache_device_descriptor] iManufacturer: 0x01 libusb: 0.017183 debug [darwin_cache_device_descriptor] iProduct: 0x02 libusb: 0.017189 debug [darwin_cache_device_descriptor] iSerialNumber: 0x00 libusb: 0.017362 debug [darwin_cache_device_descriptor] bNumConfigurations: 0x01 libusb: 0.017409 info [darwin_check_configuration] active config: 1, first config: 1 libusb: 0.017423 info [process_new_device] found device with address 4 at 004-05ac-020b-00-00 libusb: 0.019244 info [process_new_device] allocating new device for location 0x03100000 libusb: 0.023420 debug [darwin_cache_device_descriptor] device descriptor: libusb: 0.023451 debug [darwin_cache_device_descriptor] bDescriptorType: 0x01 libusb: 0.023455 debug [darwin_cache_device_descriptor] bcdUSB: 0x0200 libusb: 0.023458 debug [darwin_cache_device_descriptor] bDeviceClass: 0x00 libusb: 0.023461 debug [darwin_cache_device_descriptor] bDeviceSubClass: 0x00 libusb: 0.023464 debug [darwin_cache_device_descriptor] bDeviceProtocol: 0x00 libusb: 0.023467 debug [darwin_cache_device_descriptor] bMaxPacketSize0: 0x40 libusb: 0.023471 debug [darwin_cache_device_descriptor] idVendor: 0x1f63 libusb: 0.023474 debug [darwin_cache_device_descriptor] idProduct: 0xf001 libusb: 0.023477 debug [darwin_cache_device_descriptor] bcdDevice: 0x0200 libusb: 0.023480 debug [darwin_cache_device_descriptor] iManufacturer: 0x01 libusb: 0.023483 debug [darwin_cache_device_descriptor] iProduct: 0x02 libusb: 0.023486 debug [darwin_cache_device_descriptor] iSerialNumber: 0x03 libusb: 0.023489 debug [darwin_cache_device_descriptor] bNumConfigurations: 0x01 libusb: 0.023513 info [darwin_check_configuration] active config: 1, first config: 1 libusb: 0.023520 info [process_new_device] found device with address 2 at 002-1f63-f001-00-00 libusb: 0.025228 debug [libusb_get_device_descriptor] 05ac:8006 (bus 3, device 1) libusb: 0.025263 debug [libusb_get_device_descriptor] 05ac:8005 (bus 0, device 1) libusb: 0.025268 debug [libusb_get_device_descriptor] 0e0f:0002 (bus 0, device 2) libusb: 0.025271 debug [libusb_get_device_descriptor] 0e0f:0003 (bus 0, device 3) libusb: 0.025275 debug [libusb_get_device_descriptor] 05ac:020b (bus 0, device 4) libusb: 0.025279 debug [libusb_get_device_descriptor] 1f63:f001 (bus 3, device 2) libusb: 0.025283 debug [libusb_unref_device] destroy device 3.1 libusb: 0.025296 debug [libusb_unref_device] destroy device 0.1 libusb: 0.025301 debug [libusb_unref_device] destroy device 0.2 libusb: 0.025304 debug [libusb_unref_device] destroy device 0.3 libusb: 0.025308 debug [libusb_unref_device] destroy device 0.4 libusb: 0.025312 debug [libusb_unref_device] destroy device 3.2 libusb: 0.025316 debug [libusb_exit] libusb: 0.025319 debug [libusb_exit] destroying default context libusb: 0.025322 debug [usbi_remove_pollfd] remove fd 4 libusb: 0.025400 info [event_thread_main] thread exiting

vominh2012 avatar Jan 02 '15 09:01 vominh2012

Here ./examples/listdevs libusb v1.0.19.10905 debug logging on OSX 10.8

[ 0.000005] [00000f07] libusb: debug [libusb_init] created default context [ 0.000079] [00000f07] libusb: debug [libusb_init] libusb v1.0.19.10905 [ 0.000213] [00000f07] libusb: debug [darwin_get_cached_device] finding cached device for sessionID 0x44016482 [ 0.000256] [00000f07] libusb: debug [darwin_get_cached_device] caching new device with sessionID 0x44016482 [ 0.002803] [00000f07] libusb: debug [darwin_get_cached_device] finding cached device for sessionID 0x17441711e [ 0.002846] [00000f07] libusb: debug [darwin_get_cached_device] caching new device with sessionID 0x17441711e [ 0.004751] [00000f07] libusb: debug [darwin_get_cached_device] finding cached device for sessionID 0x1b5cdb4c7 [ 0.004843] [00000f07] libusb: debug [darwin_get_cached_device] caching new device with sessionID 0x1b5cdb4c7 [ 0.006312] [00000f07] libusb: debug [darwin_get_cached_device] finding cached device for sessionID 0x1bd500342 [ 0.006377] [00000f07] libusb: debug [darwin_get_cached_device] caching new device with sessionID 0x1bd500342 [ 0.015444] [00000f07] libusb: debug [darwin_get_cached_device] finding cached device for sessionID 0x25ecce40940 [ 0.015599] [00000f07] libusb: debug [darwin_get_cached_device] caching new device with sessionID 0x25ecce40940 [ 0.017886] [00000f07] libusb: debug [darwin_get_cached_device] finding cached device for sessionID 0x25edf2e5213 [ 0.017952] [00000f07] libusb: debug [darwin_get_cached_device] caching new device with sessionID 0x25edf2e5213 [ 0.019905] [0000120f] libusb: debug [darwin_event_thread_main] creating hotplug event source [ 0.020466] [0000120f] libusb: debug [darwin_event_thread_main] darwin event thread ready to receive events [ 0.020791] [00000f07] libusb: debug [usbi_add_pollfd] add fd 4 events 1 [ 0.020820] [00000f07] libusb: debug [usbi_add_pollfd] add fd 6 events 1 [ 0.020831] [00000f07] libusb: debug [libusb_get_device_list] [ 0.020887] [00000f07] libusb: debug [libusb_exit] [ 0.020891] [00000f07] libusb: debug [libusb_exit] destroying default context [ 0.020897] [00000f07] libusb: debug [libusb_get_next_timeout] no URBs, no timeout! [ 0.020901] [00000f07] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling [ 0.020913] [00000f07] libusb: debug [handle_events] poll() 2 fds with timeout in 0ms [ 0.020934] [00000f07] libusb: debug [handle_events] poll() returned 0 [ 0.020942] [00000f07] libusb: debug [usbi_remove_pollfd] remove fd 4 [ 0.020960] [00000f07] libusb: debug [usbi_remove_pollfd] remove fd 6 [ 0.021343] [0000120f] libusb: debug [darwin_event_thread_main] darwin event thread exiting

vominh2012 avatar Jan 02 '15 10:01 vominh2012

After investigation I had detect the problem happen with OSX 10.8. When we use IOUSBDeviceInterface500 or IOUSBDeviceInterface550 it will cause cannot detect usb devices, I try to use IOUSBDeviceInterface320 everything working fine. So currently anyone who want compability with OSX 10.8 can force use approriate IOUSBDeviceInterface by remove IOUSBDeviceInterface500/550 define in darwin_usb.h

vominh2012 avatar Jan 08 '15 02:01 vominh2012

Interesting. If 500 and 550 are available then they should have worked. I will add a workaround to use the older version.

-Nathan

On Jan 7, 2015, at 7:56 PM, Tran Huan [email protected] wrote:

After investigation I had detect the problem happen with OSX 10.8. When we use IOUSBDeviceInterface500 or IOUSBDeviceInterface550 it will cause cannot detect usb devices, I try to use IOUSBDeviceInterface320 everything working fine. So currently anyone who want compability with OSX 10.8 can force use approriate IOUSBDeviceInterface by remove IOUSBDeviceInterface500/550 define in darwin_usb.h

— Reply to this email directly or view it on GitHub https://github.com/libusb/libusb/issues/48#issuecomment-69129227.

hjelmn avatar Jan 08 '15 03:01 hjelmn

@tranhuanltv

  1. you mentioned "IOUSBDeviceInterface550", but there is no such thing. You probably meant "IOUSBInterfaceInterface550", right?

  2. IOUSBLib.h says that IOUSBInterfaceInterface550 was added in 10.8.2, so that fits with you saying that it worked in 10.8.5, but not in 10.8.0.

@hjelmn

Your fix to also check deployment target was correct and necessary, but (presumably) because of Tran's typo you guarded kIOUSBDeviceInterfaceID500 too strictly.

I have a PR that revisits your fix it this issue:

https://github.com/libusb/libusb/pull/375

seanm avatar Dec 29 '17 18:12 seanm