Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USB_BACKEND_LIBUSB since v3.8 doesn't work on FreeBSD #221

Closed
jbeich opened this issue May 18, 2019 · 29 comments
Closed

USB_BACKEND_LIBUSB since v3.8 doesn't work on FreeBSD #221

jbeich opened this issue May 18, 2019 · 29 comments

Comments

@jbeich
Copy link
Contributor

jbeich commented May 18, 2019

Regressed by 0f8f177.

$ c++ -v
FreeBSD clang version 8.0.0 (tags/RELEASE_800/final 356365) (based on LLVM 8.0.0)
Target: x86_64-unknown-freebsd13.0
Thread model: posix
InstalledDir: /usr/bin
$ aft-mtp-cli
libusb_reset_device failed: libusb_reset_device(_handle): LIBUSB_ERROR_OTHER
libusb_reset_device failed: libusb_reset_device(_handle): LIBUSB_ERROR_OTHER
libusb_reset_device failed: libusb_reset_device(_handle): LIBUSB_ERROR_OTHER
libusb_reset_device failed: libusb_reset_device(_handle): LIBUSB_ERROR_OTHER
libusb_reset_device failed: libusb_reset_device(_handle): LIBUSB_ERROR_OTHER
libusb_reset_device failed: libusb_reset_device(_handle): LIBUSB_ERROR_OTHER
clearing halt for in ep: libusb_clear_halt(_handle, ep->GetAddress()): LIBUSB_ERROR_OTHER
clearing halt for in ep: libusb_clear_halt(_handle, ep->GetAddress()): LIBUSB_ERROR_OTHER
LIBUSB_FUNCTION: libusb_bulk_transfer enter
LIBUSB_FUNCTION: libusb_submit_transfer enter
LIBUSB_FUNCTION: libusb_submit_transfer leave 0
LIBUSB_FUNCTION: libusb_handle_events_timeout_completed enter
LIBUSB_FUNCTION: libusb10_handle_events_sub enter
LIBUSB_TRANSFER: sync I/O done
LIBUSB_FUNCTION: libusb_handle_events_timeout_completed exit
LIBUSB_FUNCTION: libusb_bulk_transfer leave
error: libusb_bulk_transfer(_handle, ep->GetAddress(), const_cast<u8 *>(data.data()), data.size(), &tr, timeout): LIBUSB_ERROR_OTHER
$ android-file-transfer
upload worker started
probing device...
libusb_reset_device failed: libusb_reset_device(_handle): LIBUSB_ERROR_OTHER
probing device...
libusb_reset_device failed: libusb_reset_device(_handle): LIBUSB_ERROR_OTHER
probing device...
libusb_reset_device failed: libusb_reset_device(_handle): LIBUSB_ERROR_OTHER
probing device...
libusb_reset_device failed: libusb_reset_device(_handle): LIBUSB_ERROR_OTHER
probing device...
libusb_reset_device failed: libusb_reset_device(_handle): LIBUSB_ERROR_OTHER
probing device...
libusb_reset_device failed: libusb_reset_device(_handle): LIBUSB_ERROR_OTHER
clearing halt for in ep: libusb_clear_halt(_handle, ep->GetAddress()): LIBUSB_ERROR_OTHER
clearing halt for in ep: libusb_clear_halt(_handle, ep->GetAddress()): LIBUSB_ERROR_OTHER
device found, opening session...
LIBUSB_FUNCTION: libusb_bulk_transfer enter
LIBUSB_FUNCTION: libusb_submit_transfer enter
LIBUSB_FUNCTION: libusb_submit_transfer leave 0
LIBUSB_FUNCTION: libusb_handle_events_timeout_completed enter
LIBUSB_FUNCTION: libusb10_handle_events_sub enter
LIBUSB_TRANSFER: sync I/O done
LIBUSB_FUNCTION: libusb_handle_events_timeout_completed exit
LIBUSB_FUNCTION: libusb_bulk_transfer leave
Process 76821 stopped
* thread #1, name = 'android-file-tra', stop reason = signal SIGABRT
    frame #0: 0x00000008019295da libc.so.7`__sys_thr_kill at thr_kill.S:3
(lldb) bt
* thread #1, name = 'android-file-tra', stop reason = signal SIGABRT
  * frame #0: 0x00000008019295da libc.so.7`__sys_thr_kill at thr_kill.S:3
    frame #1: 0x0000000801928f54 libc.so.7`__raise(s=6) at raise.c:52:10
    frame #2: 0x000000080188a879 libc.so.7`abort at abort.c:67:8
    frame #3: 0x000000080035d039 libcxxrt.so.1`report_failure(err=<unavailable>, thrown_exception=0x0000000803328108) at exception.cc:719:5
    frame #4: 0x00000000002af232 android-file-transfer`mtp::usb::Device::WriteBulk(this=0x0000000805e6e418, ep=0x00000008033280c0, inputStream=0x00007fffffffd388, timeout=10000) at Device.cpp:70:3
    frame #5: 0x00000000002a9892 android-file-transfer`mtp::usb::BulkPipe::Write(this=0x0000000803328078, inputStream=0x00007fffffffd388, timeout=10000) at BulkPipe.cpp:97:12
    frame #6: 0x000000000028f77b android-file-transfer`mtp::PipePacketer::Write(this=0x0000000805e6e4a8, inputStream=0x00007fffffffd388, timeout=10000) at PipePacketer.cpp:36:11
    frame #7: 0x000000000028f7f8 android-file-transfer`mtp::PipePacketer::Write(this=0x0000000805e6e4a8, data=0x00007fffffffd450, timeout=10000) at PipePacketer.cpp:39:4
    frame #8: 0x00000000002831c3 android-file-transfer`mtp::Device::OpenSession(this=0x0000000805e6e4a8, sessionId=1, timeout=10000) at Device.cpp:43:13
    frame #9: 0x000000000025165a android-file-transfer`MainWindow::reconnectToDevice(this=0x00007fffffffe028) at mainwindow.cpp:195:24
    frame #10: 0x0000000000251d88 android-file-transfer`MainWindow::showEvent(this=0x00007fffffffe028, (null)=0x00007fffffffdef8) at mainwindow.cpp:223:8
    frame #11: 0x00000008006d7038 libQt5Widgets.so.5`QWidget::event(QEvent*) + 1368
    frame #12: 0x00000008007f7938 libQt5Widgets.so.5`QMainWindow::event(QEvent*) + 296
    frame #13: 0x00000008006975e3 libQt5Widgets.so.5`QApplicationPrivate::notify_helper(QObject*, QEvent*) + 275
    frame #14: 0x0000000800698c1d libQt5Widgets.so.5`QApplication::notify(QObject*, QEvent*) + 669
    frame #15: 0x000000080163f862 libQt5Core.so.5`QCoreApplication::notifyInternal2(QObject*, QEvent*) + 210
    frame #16: 0x00000008006d590d libQt5Widgets.so.5`QWidgetPrivate::show_helper() + 429
    frame #17: 0x00000008006d6913 libQt5Widgets.so.5`QWidgetPrivate::setVisible(bool) + 1363
    frame #18: 0x000000000024e60e android-file-transfer`main(argc=1, argv=0x00007fffffffe1e0) at main.cpp:69:4
    frame #19: 0x000000000024e10f android-file-transfer`_start(ap=<unavailable>, cleanup=<unavailable>) at crt1.c:76:7
@whoozle
Copy link
Owner

whoozle commented May 18, 2019

I've seen some reports recently regarding SIGABRT on exception for Qt UI. Could you please post output of make VERBOSE=1 or ninja -v?

Could you please comment the whole block below?

		try { USB_CALL(libusb_reset_device(_handle)); }
		catch (std::exception & ex)
		{ error("libusb_reset_device failed: ", ex.what()); }

@jbeich
Copy link
Contributor Author

jbeich commented May 18, 2019

Could you please post output of make VERBOSE=1 or ninja -v?

See build log

Could you please comment the whole block below?

It works. Before reporting I did try to revert the first bad found via bisecting.

@whoozle
Copy link
Owner

whoozle commented May 19, 2019

Do you have any other device to test it with? I just wondering if it's BSD specific or device specific. I can disable reset for BSD, it works OK for me in linux.
This reset/clear halt calls help recover devices which stuck or in error state, and it's recommended by PTP spec.

@whoozle
Copy link
Owner

whoozle commented May 19, 2019

Thanks for the logs, looks OK to me

@whoozle
Copy link
Owner

whoozle commented May 19, 2019

I've disabled reset for FreeBSD in 34b3eee

@whoozle
Copy link
Owner

whoozle commented May 19, 2019

8212742 should fix crash in reconnectToDevice

@jbeich
Copy link
Contributor Author

jbeich commented May 20, 2019

Do you have any other device to test it with?

No.

I just wondering if it's BSD specific or device specific.

Maybe specific to the implementation. libusb_reset_device() is a stub on NetBSD and OpenBSD and part of independent library on FreeBSD (wrapper, method) and DragonFly (wrapper, method).

I've disabled reset for FreeBSD in 34b3eee

Probably needs to be extended to __DragonFly__ as well.

8212742 should fix crash in reconnectToDevice

Thanks. Qt GUI now fails similar to CLI.

$ android-file-transfer
upload worker started
probing device...
libusb_reset_device failed: libusb_reset_device(_handle): LIBUSB_ERROR_OTHER
probing device...
libusb_reset_device failed: libusb_reset_device(_handle): LIBUSB_ERROR_OTHER
probing device...
libusb_reset_device failed: libusb_reset_device(_handle): LIBUSB_ERROR_OTHER
probing device...
libusb_reset_device failed: libusb_reset_device(_handle): LIBUSB_ERROR_OTHER
probing device...
libusb_reset_device failed: libusb_reset_device(_handle): LIBUSB_ERROR_OTHER
probing device...
libusb_reset_device failed: libusb_reset_device(_handle): LIBUSB_ERROR_OTHER
probing device...
libusb_reset_device failed: libusb_reset_device(_handle): LIBUSB_ERROR_OTHER
clearing halt for in ep: libusb_clear_halt(_handle, ep->GetAddress()): LIBUSB_ERROR_OTHER
clearing halt for in ep: libusb_clear_halt(_handle, ep->GetAddress()): LIBUSB_ERROR_OTHER
device found, opening session...
LIBUSB_FUNCTION: libusb_bulk_transfer enter
LIBUSB_FUNCTION: libusb_submit_transfer enter
LIBUSB_FUNCTION: libusb_submit_transfer leave 0
LIBUSB_FUNCTION: libusb_handle_events_timeout_completed enter
LIBUSB_FUNCTION: libusb10_handle_events_sub enter
LIBUSB_TRANSFER: sync I/O done
LIBUSB_FUNCTION: libusb_handle_events_timeout_completed exit
LIBUSB_FUNCTION: libusb_bulk_transfer leave
open session/device info failed:  "libusb_bulk_transfer(_handle, ep->GetAddress(), const_cast<u8 *>(data.data()), data.size(), &tr, timeout): LIBUSB_ERROR_OTHER"
LIBUSB_FUNCTION: libusb_bulk_transfer enter
LIBUSB_FUNCTION: libusb_submit_transfer enter
LIBUSB_FUNCTION: libusb_submit_transfer leave 0
LIBUSB_FUNCTION: libusb_handle_events_timeout_completed enter
LIBUSB_FUNCTION: libusb10_handle_events_sub enter
LIBUSB_TRANSFER: sync I/O done
LIBUSB_FUNCTION: libusb_handle_events_timeout_completed exit
LIBUSB_FUNCTION: libusb_bulk_transfer leave
open session/device info failed:  "libusb_bulk_transfer(_handle, ep->GetAddress(), const_cast<u8 *>(data.data()), data.size(), &tr, timeout): LIBUSB_ERROR_OTHER"
LIBUSB_FUNCTION: libusb_bulk_transfer enter
LIBUSB_FUNCTION: libusb_submit_transfer enter
LIBUSB_FUNCTION: libusb_submit_transfer leave 0
LIBUSB_FUNCTION: libusb_handle_events_timeout_completed enter
LIBUSB_FUNCTION: libusb10_handle_events_sub enter
LIBUSB_TRANSFER: sync I/O done
LIBUSB_FUNCTION: libusb_handle_events_timeout_completed exit
LIBUSB_FUNCTION: libusb_bulk_transfer leave
open session/device info failed:  "libusb_bulk_transfer(_handle, ep->GetAddress(), const_cast<u8 *>(data.data()), data.size(), &tr, timeout): LIBUSB_ERROR_OTHER"

@jbeich
Copy link
Contributor Author

jbeich commented May 20, 2019

This reset/clear halt calls help recover devices which stuck or in error state, and it's recommended by PTP spec.

libusb_reset_device doesn't cause issues in libmtp, libgphoto2, CUPS, etc. @hselasky, can you provide some clues?

$ pkg install git cmake ninja pkgconf
$ git clone https://github.com/whoozle/android-file-transfer-linux/
$ cd android-file-transfer-linux
$ git revert --no-edit 34b3eee2e0dd
$ cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DBUILD_QT_UI=off -DUSB_BACKEND_LIBUSB=on .
$ ninja
$ cli/aft-mtp-cli

Alternatively, install either sysutils/android-file-transfer or sysutils/android-file-transfer-qt5 after applying

Index: sysutils/android-file-transfer/Makefile
===================================================================
--- sysutils/android-file-transfer/Makefile	(revision 502185)
+++ sysutils/android-file-transfer/Makefile	(working copy)
@@ -9,4 +9,3 @@
 PATCH_SITES=	https://github.com/${GH_ACCOUNT}/${GH_PROJECT}/commit/
 PATCHFILES+=	6b969a1600d4.patch:-p1
-PATCHFILES+=	34b3eee2e0dd.patch:-p1
 PATCHFILES+=	82127426b3eb.patch:-p1

@hselasky
Copy link

@jbeich : Hi, Is the USB device opened when executing libusb_reset_device() ? Try to ktrace the program and grep for all USB ioctl's and their return code.

@hselasky
Copy link

@jbeich: It might be that certain features are available only to the super-user. Have you tried running this program as root?

@jbeich
Copy link
Contributor Author

jbeich commented May 20, 2019

Is the USB device opened when executing libusb_reset_device()?

Probably not.

 31142 aft-mtp-cli CALL  openat(AT_FDCWD,0x7fffffffdb40,0x2<O_RDWR>)
 31142 aft-mtp-cli NAMI  "/dev/ugen0.2"
 31142 aft-mtp-cli RET   openat 5
 31142 aft-mtp-cli CALL  openat(AT_FDCWD,0x7fffffffdb40,0x2<O_RDWR>)
 31142 aft-mtp-cli NAMI  "/dev/ugen0.2"
 31142 aft-mtp-cli RET   openat 6
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_PLUGTIME,0x7fffffffdb2c)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_FS_INIT,0x7fffffffdb30)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  write(0x4,0x7fffffffdc0f,0x1)
 31142 aft-mtp-cli GIO   fd 4 wrote 1 byte
       "\0"
 31142 aft-mtp-cli RET   write 1
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_FS_UNINIT,0x7fffffffd8b0)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x5,USB_DEVICEENUMERATE,0x7fffffffd8ac)
 31142 aft-mtp-cli RET   ioctl -1 errno 1 Operation not permitted
 31142 aft-mtp-cli CALL  write(0x2,0x205157,0x1c)
 31142 aft-mtp-cli GIO   fd 2 wrote 28 bytes
       "libusb_reset_device failed: "
 31142 aft-mtp-cli RET   write 28/0x1c
 31142 aft-mtp-cli CALL  write(0x2,0x800aaa018,0x30)
 31142 aft-mtp-cli GIO   fd 2 wrote 48 bytes
       "libusb_reset_device(_handle): LIBUSB_ERROR_OTHER"
 31142 aft-mtp-cli RET   write 48/0x30

Try to ktrace the program and grep for all USB ioctl's and their return code.

$ ktrace aft-mtp-cli >/dev/null 2>&1
$ kdump -r | grep -A1 'ioctl.*USB'
 31142 aft-mtp-cli CALL  ioctl(0x5,USB_READ_DIR,0x7fffffffd9a0)
 31142 aft-mtp-cli RET   ioctl 0
--
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_PLUGTIME,0x7fffffffd984)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_DEVICE_DESC,0x7fffffffd988)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_DEVICEINFO,0x7fffffffdb50)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_DEV_PORT_PATH,0x7fffffffdb28)
 31142 aft-mtp-cli RET   ioctl 0
--
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_PLUGTIME,0x7fffffffd984)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_DEVICE_DESC,0x7fffffffd988)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_DEVICEINFO,0x7fffffffdb50)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_DEV_PORT_PATH,0x7fffffffdb28)
 31142 aft-mtp-cli RET   ioctl 0
--
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_PLUGTIME,0x7fffffffd984)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_DEVICE_DESC,0x7fffffffd988)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_DEVICEINFO,0x7fffffffdb50)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_DEV_PORT_PATH,0x7fffffffdb28)
 31142 aft-mtp-cli RET   ioctl 0
--
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_PLUGTIME,0x7fffffffd984)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_DEVICE_DESC,0x7fffffffd988)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_DEVICEINFO,0x7fffffffdb50)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_DEV_PORT_PATH,0x7fffffffdb28)
 31142 aft-mtp-cli RET   ioctl 0
--
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_PLUGTIME,0x7fffffffd984)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_DEVICE_DESC,0x7fffffffd988)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_DEVICEINFO,0x7fffffffdb50)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_DEV_PORT_PATH,0x7fffffffdb28)
 31142 aft-mtp-cli RET   ioctl 0
--
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_PLUGTIME,0x7fffffffd984)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_DEVICE_DESC,0x7fffffffd988)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_DEVICEINFO,0x7fffffffdb50)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_DEV_PORT_PATH,0x7fffffffdb28)
 31142 aft-mtp-cli RET   ioctl 0
--
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_PLUGTIME,0x7fffffffd984)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_DEVICE_DESC,0x7fffffffd988)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_DEVICEINFO,0x7fffffffdb50)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_DEV_PORT_PATH,0x7fffffffdb28)
 31142 aft-mtp-cli RET   ioctl 0
--
 31142 aft-mtp-cli CALL  ioctl(0x5,USB_READ_DIR,0x7fffffffd9a0)
 31142 aft-mtp-cli RET   ioctl 0
--
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_PLUGTIME,0x7fffffffdb2c)
 31142 aft-mtp-cli RET   ioctl 0
--
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_FS_INIT,0x7fffffffdb30)
 31142 aft-mtp-cli RET   ioctl 0
--
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_FS_UNINIT,0x7fffffffd8b0)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x5,USB_DEVICEENUMERATE,0x7fffffffd8ac)
 31142 aft-mtp-cli RET   ioctl -1 errno 1 Operation not permitted
--
 31142 aft-mtp-cli CALL  ioctl(0x5,USB_GET_FULL_DESC,0x7fffffffdae0)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x5,USB_GET_FULL_DESC,0x7fffffffdae0)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_FS_UNINIT,0x7fffffffdb20)
 31142 aft-mtp-cli RET   ioctl -1 errno 22 Invalid argument
--
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_PLUGTIME,0x7fffffffdb2c)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_FS_INIT,0x7fffffffdb30)
 31142 aft-mtp-cli RET   ioctl 0
--
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_FS_UNINIT,0x7fffffffd8b0)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x5,USB_DEVICEENUMERATE,0x7fffffffd8ac)
 31142 aft-mtp-cli RET   ioctl -1 errno 1 Operation not permitted
--
 31142 aft-mtp-cli CALL  ioctl(0x5,USB_GET_FULL_DESC,0x7fffffffdae0)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x5,USB_GET_FULL_DESC,0x7fffffffdae0)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_FS_UNINIT,0x7fffffffdb20)
 31142 aft-mtp-cli RET   ioctl -1 errno 22 Invalid argument
--
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_GET_PLUGTIME,0x7fffffffdb2c)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_FS_INIT,0x7fffffffdb30)
 31142 aft-mtp-cli RET   ioctl 0
--
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_FS_UNINIT,0x7fffffffd8b0)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x5,USB_DEVICEENUMERATE,0x7fffffffd8ac)
 31142 aft-mtp-cli RET   ioctl -1 errno 1 Operation not permitted
--
 31142 aft-mtp-cli CALL  ioctl(0x5,USB_GET_FULL_DESC,0x7fffffffdae0)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x5,USB_GET_FULL_DESC,0x7fffffffdae0)
 31142 aft-mtp-cli RET   ioctl 0
--
 31142 aft-mtp-cli CALL  ioctl(0x5,USB_DO_REQUEST,0x7fffffffc9f8)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x5,USB_DO_REQUEST,0x7fffffffc9f8)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x5,USB_DO_REQUEST,0x7fffffffc9f8)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x5,USB_DO_REQUEST,0x7fffffffc9f8)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x5,USB_GET_CONFIG,0x7fffffffd4a4)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x5,USB_GET_FULL_DESC,0x7fffffffd460)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x5,USB_GET_FULL_DESC,0x7fffffffd460)
 31142 aft-mtp-cli RET   ioctl 0
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_FS_OPEN,0x7fffffffd468)
 31142 aft-mtp-cli RET   ioctl -1 errno 22 Invalid argument
--
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_FS_OPEN,0x7fffffffd468)
 31142 aft-mtp-cli RET   ioctl -1 errno 22 Invalid argument
--
 31142 aft-mtp-cli CALL  ioctl(0x6,USB_FS_OPEN,0x7fffffffcbc8)
 31142 aft-mtp-cli RET   ioctl -1 errno 22 Invalid argument

Have you tried running this program as root?

Doesn't help:

$ sudo aft-mtp-cli
no mtp device found

$ sudo android-file-transfer
upload worker started
probing device...
probing device...
probing device...
probing device...
probing device...
probing device...
probing device...
(Popup) No MTP device found

@jbeich
Copy link
Contributor Author

jbeich commented May 20, 2019

Closing before libusb_reset_device leads to a crash or no mtp device found. Does it imply the device is open?

--- a/mtp/backend/libusb/usb/Device.cpp
+++ b/mtp/backend/libusb/usb/Device.cpp
@@ -29,6 +29,9 @@ namespace mtp { namespace usb
 
 	Device::Device(ContextPtr context, libusb_device_handle * handle): _context(context), _handle(handle)
 	{
+		libusb_device *dev = libusb_get_device(handle);
+		if (libusb_get_bus_number(dev) == 0 && libusb_get_port_number(dev) == 2)
+			libusb_close(handle);
 		try { USB_CALL(libusb_reset_device(_handle)); }
 		catch (std::exception & ex)
 		{ error("libusb_reset_device failed: ", ex.what()); }
(lldb) bt
* thread #1, name = 'aft-mtp-cli', stop reason = signal SIGBUS: hardware error
  * frame #0: 0x00000008003a2207 libthr.so.3`check_and_init_mutex(mutex=0x0383050700222219, m=0x00007fffffffdad0) at thr_mutex.c:590:7
    frame #1: 0x00000008003a1896 libthr.so.3`__pthread_mutex_lock(mutex=0x0383050700222219) at thr_mutex.c:746:8
    frame #2: 0x00000008003804eb libusb.so.3`libusb_unref_device(dev=0x000000080097a380) at libusb10.c:485:2
    frame #3: 0x00000000002faad8 aft-mtp-cli`mtp::usb::DeviceDescriptor::~DeviceDescriptor(this=0x0000000800346118) at DeviceDescriptor.cpp:52:4
    frame #4: 0x00000000002f7e11 aft-mtp-cli`std::__1::__shared_ptr_emplace<mtp::usb::DeviceDescriptor, std::__1::allocator<mtp::usb::DeviceDescriptor> >::__on_zero_shared(this=0x0000000800346100) at memory:3710:23
    frame #5: 0x00000000002b265a aft-mtp-cli`std::__1::__shared_count::__release_shared(this=0x0000000800346100) at memory:3544:9
    frame #6: 0x00000000002b25ff aft-mtp-cli`std::__1::__shared_weak_count::__release_shared(this=0x0000000800346100) at memory:3586:27
    frame #7: 0x00000000002d6b9c aft-mtp-cli`std::__1::shared_ptr<mtp::usb::DeviceDescriptor>::~shared_ptr(this=0x00000008009ac020) at memory:4522:19
    frame #8: 0x00000000002f6e29 aft-mtp-cli`std::__1::allocator<std::__1::shared_ptr<mtp::usb::DeviceDescriptor> >::destroy(this=0x0000000800347038, __p=0x00000008009ac020) at memory:1881:64
    frame #9: 0x00000000002f6dfd aft-mtp-cli`void std::__1::allocator_traits<std::__1::allocator<std::__1::shared_ptr<mtp::usb::DeviceDescriptor> > >::__destroy<std::__1::shared_ptr<mtp::usb::DeviceDescriptor> >((null)=std::__1::true_type @ 0x00007fffffffdbf8, __a=0x0000000800347038, __p=0x00000008009ac020) at memory:1743:18
    frame #10: 0x00000000002f6dcd aft-mtp-cli`void std::__1::allocator_traits<std::__1::allocator<std::__1::shared_ptr<mtp::usb::DeviceDescriptor> > >::destroy<std::__1::shared_ptr<mtp::usb::DeviceDescriptor> >(__a=0x0000000800347038, __p=0x00000008009ac020) at memory:1596:14
    frame #11: 0x00000000002f6d78 aft-mtp-cli`std::__1::__vector_base<std::__1::shared_ptr<mtp::usb::DeviceDescriptor>, std::__1::allocator<std::__1::shared_ptr<mtp::usb::DeviceDescriptor> > >::__destruct_at_end(this=0x0000000800347028, __new_last=0x00000008009ac000) at vector:427:9
    frame #12: 0x00000000002f6cc8 aft-mtp-cli`std::__1::__vector_base<std::__1::shared_ptr<mtp::usb::DeviceDescriptor>, std::__1::allocator<std::__1::shared_ptr<mtp::usb::DeviceDescriptor> > >::clear(this=0x0000000800347028) at vector:370:29
    frame #13: 0x00000000002f6b67 aft-mtp-cli`std::__1::__vector_base<std::__1::shared_ptr<mtp::usb::DeviceDescriptor>, std::__1::allocator<std::__1::shared_ptr<mtp::usb::DeviceDescriptor> > >::~__vector_base(this=0x0000000800347028) at vector:464:9
    frame #14: 0x00000000002f692a aft-mtp-cli`std::__1::vector<std::__1::shared_ptr<mtp::usb::DeviceDescriptor>, std::__1::allocator<std::__1::shared_ptr<mtp::usb::DeviceDescriptor> > >::~vector(this=0x0000000800347028) at vector:556:5
    frame #15: 0x00000000002f65f4 aft-mtp-cli`mtp::usb::Context::~Context(this=0x0000000800347020) at Context.cpp:45:2
    frame #16: 0x00000000002da54b aft-mtp-cli`std::__1::default_delete<mtp::usb::Context>::operator(this=0x0000000800347078, __ptr=0x0000000800347020)(mtp::usb::Context*) const at memory:2339:5
    frame #17: 0x00000000002da2f0 aft-mtp-cli`std::__1::__shared_ptr_pointer<mtp::usb::Context*, std::__1::default_delete<mtp::usb::Context>, std::__1::allocator<mtp::usb::Context> >::__on_zero_shared(this=0x0000000800347060) at memory:3640:5
    frame #18: 0x00000000002b265a aft-mtp-cli`std::__1::__shared_count::__release_shared(this=0x0000000800347060) at memory:3544:9
    frame #19: 0x00000000002b25ff aft-mtp-cli`std::__1::__shared_weak_count::__release_shared(this=0x0000000800347060) at memory:3586:27
    frame #20: 0x00000000002d63bc aft-mtp-cli`std::__1::shared_ptr<mtp::usb::Context>::~shared_ptr(this=0x00007fffffffded8) at memory:4522:19
    frame #21: 0x00000000002d5f41 aft-mtp-cli`mtp::Device::FindFirst(claimInterface=true) at Device.cpp:144:2
    frame #22: 0x00000000002d3f39 aft-mtp-cli`main(argc=1, argv=0x00007fffffffe210) at cli.cpp:169:13
    frame #23: 0x000000000026c10f aft-mtp-cli`_start(ap=<unavailable>, cleanup=<unavailable>) at crt1.c:76:7
$ aft-mtp-cli
libusb_reset_device failed: libusb_reset_device(_handle): LIBUSB_ERROR_OTHER
libusb_reset_device failed: libusb_reset_device(_handle): LIBUSB_ERROR_OTHER
libusb_reset_device failed: libusb_reset_device(_handle): LIBUSB_ERROR_OTHER
libusb_reset_device failed: libusb_reset_device(_handle): LIBUSB_ERROR_OTHER
libusb_reset_device failed: libusb_reset_device(_handle): LIBUSB_ERROR_OTHER
libusb_reset_device failed: libusb_reset_device(_handle): LIBUSB_ERROR_OTHER
libusb_reset_device failed: libusb_reset_device(_handle): LIBUSB_ERROR_OTHER
Device::Find failed:libusb_get_string_descriptor_ascii: LIBUSB_ERROR_OTHER
no mtp device found

@hselasky
Copy link

hselasky commented May 20, 2019

Can you ktrace when running utility as root?

Also run "usbconfig" to ensure your PTP device is visible.

Please also dump device and config descriptor before and after the utility fails.

@hselasky
Copy link

hselasky commented May 20, 2019

31142 aft-mtp-cli CALL ioctl(0x5,USB_DEVICEENUMERATE,0x7fffffffd8ac)
31142 aft-mtp-cli RET ioctl -1 errno 1 Operation not permitted

Only root users can do this :-(

@jbeich
Copy link
Contributor Author

jbeich commented May 20, 2019

Can you ktrace when running utility as root?

See ktrace.log.txt.

Also run "usbconfig" to ensure your PTP device is visible.

Only ugen0.2 device is MTP-capable.

$ usbconfig
ugen1.1: <0x1b21 XHCI root HUB> at usbus1, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen0.1: <0x8086 XHCI root HUB> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen0.2: <Sony Xperia Z> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (500mA)
ugen0.3: <Logitech USB Laser Mouse> at usbus0, cfg=0 md=HOST spd=LOW (1.5Mbps) pwr=ON (98mA)
ugen0.4: <Microsoft Comfort Curve Keyboard 3000> at usbus0, cfg=0 md=HOST spd=LOW (1.5Mbps) pwr=ON (100mA)
ugen0.5: <CM Storm Quickfire Rapid i> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (100mA)
ugen0.6: <Kingsis Peripherals ZOWIE Gaming mouse> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (100mA)

Please also dump device and config descriptor before and after the utility fails.

$ usbconfig -d ugen0.2 dump_device_desc
ugen0.2: <Sony Xperia Z> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (500mA)

  bLength = 0x0012
  bDescriptorType = 0x0001
  bcdUSB = 0x0200
  bDeviceClass = 0x0000  <Probed by interface class>
  bDeviceSubClass = 0x0000
  bDeviceProtocol = 0x0000
  bMaxPacketSize0 = 0x0040
  idVendor = 0x0fce
  idProduct = 0x5193
  bcdDevice = 0x0228
  iManufacturer = 0x0001  <Sony>
  iProduct = 0x0002  <Xperia Z>
  iSerialNumber = 0x0003  <XXXXXXX>
  bNumConfigurations = 0x0001

$ usbconfig -d ugen0.2 dump_curr_config_desc
ugen0.2: <Sony Xperia Z> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (500mA)


 Configuration index 0

    bLength = 0x0009
    bDescriptorType = 0x0002
    wTotalLength = 0x003e
    bNumInterfaces = 0x0002
    bConfigurationValue = 0x0001
    iConfiguration = 0x0000  <no string>
    bmAttributes = 0x0080
    bMaxPower = 0x00fa

    Interface 0
      bLength = 0x0009
      bDescriptorType = 0x0004
      bInterfaceNumber = 0x0000
      bAlternateSetting = 0x0000
      bNumEndpoints = 0x0003
      bInterfaceClass = 0x00ff  <Vendor specific>
      bInterfaceSubClass = 0x00ff
      bInterfaceProtocol = 0x0000
      iInterface = 0x0004  <MTP>

     Endpoint 0
        bLength = 0x0007
        bDescriptorType = 0x0005
        bEndpointAddress = 0x0082  <IN>
        bmAttributes = 0x0002  <BULK>
        wMaxPacketSize = 0x0200
        bInterval = 0x0000
        bRefresh = 0x0000
        bSynchAddress = 0x0000

     Endpoint 1
        bLength = 0x0007
        bDescriptorType = 0x0005
        bEndpointAddress = 0x0002  <OUT>
        bmAttributes = 0x0002  <BULK>
        wMaxPacketSize = 0x0200
        bInterval = 0x0000
        bRefresh = 0x0000
        bSynchAddress = 0x0000

     Endpoint 2
        bLength = 0x0007
        bDescriptorType = 0x0005
        bEndpointAddress = 0x0083  <IN>
        bmAttributes = 0x0003  <INTERRUPT>
        wMaxPacketSize = 0x001c
        bInterval = 0x0006
        bRefresh = 0x0000
        bSynchAddress = 0x0000


    Interface 1
      bLength = 0x0009
      bDescriptorType = 0x0004
      bInterfaceNumber = 0x0001
      bAlternateSetting = 0x0000
      bNumEndpoints = 0x0002
      bInterfaceClass = 0x00ff  <Vendor specific>
      bInterfaceSubClass = 0x0042
      bInterfaceProtocol = 0x0001
      iInterface = 0x000e  <ADB Interface>

     Endpoint 0
        bLength = 0x0007
        bDescriptorType = 0x0005
        bEndpointAddress = 0x0003  <OUT>
        bmAttributes = 0x0002  <BULK>
        wMaxPacketSize = 0x0200
        bInterval = 0x0000
        bRefresh = 0x0000
        bSynchAddress = 0x0000

     Endpoint 1
        bLength = 0x0007
        bDescriptorType = 0x0005
        bEndpointAddress = 0x0084  <IN>
        bmAttributes = 0x0002  <BULK>
        wMaxPacketSize = 0x0200
        bInterval = 0x0000
        bRefresh = 0x0000
        bSynchAddress = 0x0000

31142 aft-mtp-cli CALL ioctl(0x5,USB_DEVICEENUMERATE,0x7fffffffd8ac)
31142 aft-mtp-cli RET ioctl -1 errno 1 Operation not permitted

Only root users can do this :-(

Also doesn't work inside a jail.

@jbeich
Copy link
Contributor Author

jbeich commented May 20, 2019

... before and after the utility fails.

Do you mean before and after libusb_reset_device? It doesn't change when running as non-root and crashes before as root.

@jbeich
Copy link
Contributor Author

jbeich commented May 20, 2019

@whoozle, does libusb backend (including reset) work fine on macOS?

@hselasky
Copy link

... before and after the utility fails.

Do you mean before and after libusb_reset_device? It doesn't change when running as non-root and crashes before as root.

Can you show where it crashes when running as root?

--HPS

@jbeich
Copy link
Contributor Author

jbeich commented May 23, 2019

Can you show where it crashes when running as root?

On libusb_unref_device, similar to #221 (comment).

(lldb) run
Process 50733 launching
Process 50733 launched: '/tmp/android-file-transfer-linux/cli/aft-mtp-cli' (x86_64)
Process 50733 stopped
* thread #1, name = 'aft-mtp-cli', stop reason = signal SIGBUS: hardware error
    frame #0: 0x00000008003991fa libthr.so.3`mutex_lock_common(m=0x5a5a5a5a5a5a5a5a, abstime=0x0000000000000000, cvattach=<unavailable>, rb_onlist=<unavailable>) at thr_mutex.c:719:30
(lldb) bt
* thread #1, name = 'aft-mtp-cli', stop reason = signal SIGBUS: hardware error
  * frame #0: 0x00000008003991fa libthr.so.3`mutex_lock_common(m=0x5a5a5a5a5a5a5a5a, abstime=0x0000000000000000, cvattach=<unavailable>, rb_onlist=<unavailable>) at thr_mutex.c:719:30
    frame #1: 0x00000008003982a9 libthr.so.3`__pthread_mutex_lock(mutex=0x000000080097a018) at thr_mutex.c:748:9
    frame #2: 0x000000080037822b libusb.so.3`libusb_unref_device(dev=0x0000000800951500) at libusb10.c:485:2
    frame #3: 0x00000000002faa48 aft-mtp-cli`mtp::usb::DeviceDescriptor::~DeviceDescriptor(this=0x0000000800958218) at DeviceDescriptor.cpp:52:4
    frame #4: 0x00000000002f7e01 aft-mtp-cli`std::__1::__shared_ptr_emplace<mtp::usb::DeviceDescriptor, std::__1::allocator<mtp::usb::DeviceDescriptor> >::__on_zero_shared(this=0x0000000800958200) at memory:3710:23
    frame #5: 0x00000000002b264a aft-mtp-cli`std::__1::__shared_count::__release_shared(this=0x0000000800958200) at memory:3544:9
    frame #6: 0x00000000002b25ef aft-mtp-cli`std::__1::__shared_weak_count::__release_shared(this=0x0000000800958200) at memory:3586:27
    frame #7: 0x00000000002d6b8c aft-mtp-cli`std::__1::shared_ptr<mtp::usb::DeviceDescriptor>::~shared_ptr(this=0x0000000800985060) at memory:4522:19
    frame #8: 0x00000000002f6e19 aft-mtp-cli`std::__1::allocator<std::__1::shared_ptr<mtp::usb::DeviceDescriptor> >::destroy(this=0x0000000800979038, __p=0x0000000800985060) at memory:1881:64
    frame #9: 0x00000000002f6ded aft-mtp-cli`void std::__1::allocator_traits<std::__1::allocator<std::__1::shared_ptr<mtp::usb::DeviceDescriptor> > >::__destroy<std::__1::shared_ptr<mtp::usb::DeviceDescriptor> >((null)=std::__1::true_type @ 0x00007fffffffe668, __a=0x0000000800979038, __p=0x0000000800985060) at memory:1743:18
    frame #10: 0x00000000002f6dbd aft-mtp-cli`void std::__1::allocator_traits<std::__1::allocator<std::__1::shared_ptr<mtp::usb::DeviceDescriptor> > >::destroy<std::__1::shared_ptr<mtp::usb::DeviceDescriptor> >(__a=0x0000000800979038, __p=0x0000000800985060) at memory:1596:14
    frame #11: 0x00000000002f6d68 aft-mtp-cli`std::__1::__vector_base<std::__1::shared_ptr<mtp::usb::DeviceDescriptor>, std::__1::allocator<std::__1::shared_ptr<mtp::usb::DeviceDescriptor> > >::__destruct_at_end(this=0x0000000800979028, __new_last=0x0000000800985000) at vector:427:9
    frame #12: 0x00000000002f6cb8 aft-mtp-cli`std::__1::__vector_base<std::__1::shared_ptr<mtp::usb::DeviceDescriptor>, std::__1::allocator<std::__1::shared_ptr<mtp::usb::DeviceDescriptor> > >::clear(this=0x0000000800979028) at vector:370:29
    frame #13: 0x00000000002f6b57 aft-mtp-cli`std::__1::__vector_base<std::__1::shared_ptr<mtp::usb::DeviceDescriptor>, std::__1::allocator<std::__1::shared_ptr<mtp::usb::DeviceDescriptor> > >::~__vector_base(this=0x0000000800979028) at vector:464:9
    frame #14: 0x00000000002f691a aft-mtp-cli`std::__1::vector<std::__1::shared_ptr<mtp::usb::DeviceDescriptor>, std::__1::allocator<std::__1::shared_ptr<mtp::usb::DeviceDescriptor> > >::~vector(this=0x0000000800979028) at vector:556:5
    frame #15: 0x00000000002f65e4 aft-mtp-cli`mtp::usb::Context::~Context(this=0x0000000800979020) at Context.cpp:45:2
    frame #16: 0x00000000002da53b aft-mtp-cli`std::__1::default_delete<mtp::usb::Context>::operator(this=0x0000000800979078, __ptr=0x0000000800979020)(mtp::usb::Context*) const at memory:2339:5
    frame #17: 0x00000000002da2e0 aft-mtp-cli`std::__1::__shared_ptr_pointer<mtp::usb::Context*, std::__1::default_delete<mtp::usb::Context>, std::__1::allocator<mtp::usb::Context> >::__on_zero_shared(this=0x0000000800979060) at memory:3640:5
    frame #18: 0x00000000002b264a aft-mtp-cli`std::__1::__shared_count::__release_shared(this=0x0000000800979060) at memory:3544:9
    frame #19: 0x00000000002b25ef aft-mtp-cli`std::__1::__shared_weak_count::__release_shared(this=0x0000000800979060) at memory:3586:27
    frame #20: 0x00000000002d63ac aft-mtp-cli`std::__1::shared_ptr<mtp::usb::Context>::~shared_ptr(this=0x00007fffffffe948) at memory:4522:19
    frame #21: 0x00000000002d5f31 aft-mtp-cli`mtp::Device::FindFirst(claimInterface=true) at Device.cpp:144:2
    frame #22: 0x00000000002d3f29 aft-mtp-cli`main(argc=1, argv=0x00007fffffffec80) at cli.cpp:169:13
    frame #23: 0x000000000026c10f aft-mtp-cli`_start(ap=<unavailable>, cleanup=<unavailable>) at crt1.c:76:7

@hselasky
Copy link

hselasky commented May 24, 2019

Can you check if you have old libusb libraries installed in your system?

I just did a clone of the git, mkdir build, cd build, cmake .. -DUSB_BACKEND_LIBUSB=ON, make and then:

sudo chmod 0777 /dev/ugenX.Y

./qt/android-file-transfer

It works just fine with my LineageOS Android phone.

Can you check if you have any local patches?

@jbeich
Copy link
Contributor Author

jbeich commented May 24, 2019

Can you check if you have old libusb libraries installed in your system?

No. I've confirmed in pristine 13.0-CURRENT amd64 chroot.

I just did a clone of the git, mkdir build, cd build, cmake .. -DUSB_BACKEND_LIBUSB=ON, make and then:

sudo chmod 0777 /dev/ugenX.Y

./qt/android-file-transfer

#221 (comment) has steps to reproduce.

Can you check if you have any local patches?

Revert of 34b3eee.

@hselasky
Copy link

Hi,

I think it is not a good idea to reset the device upon connect. Only if the device doesn't respond you should do that.

On my Android device I have a menu to select "Use USB to .." charge, supply power, transfer files, ptp

After running libusb_device_reset() the Android device automatically switched to charging mode and the software was unable to connect. In FreeBSD libusb_device_reset() does a full device reset - so called enumeration. I'm not sure about the other platforms that libusb supports, but likely they don't do the same level of reset.

@whoozle : Please remove the libusb_device_reset() from all platforms, or make it optional.

@whoozle
Copy link
Owner

whoozle commented May 24, 2019

@hselasky it looks it's working better for someone, I'll make it optional, I think (off by default as it's pretty disruptive). I've disabled it for FreeBSD anyway.

@whoozle
Copy link
Owner

whoozle commented May 24, 2019

please pull, I've added -R, probably I can add more elaborated logic on this, like if I'm getting timeouts from device, I can try reset and see what happens

@jbeich
Copy link
Contributor Author

jbeich commented May 24, 2019

@whoozle, CLI and Qt UI work fine by default for me. -R in CLI fails like before.

@whoozle
Copy link
Owner

whoozle commented May 24, 2019

it's fine then. As an addition I've added the special dialog in UI, asking for reset/ignore if something unexpected happened during device opening.

@whoozle
Copy link
Owner

whoozle commented May 24, 2019

the same problem reported in #223

@hselasky
Copy link

hselasky commented Jun 4, 2019

Can this issue be closed?

@whoozle
Copy link
Owner

whoozle commented Jun 4, 2019

I think so

@whoozle whoozle closed this as completed Jun 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants