| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
| |
Closes #531
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
| |
clang is pedantic about requiring the l prefix for DWORD, which is a
typedef to unsigned long.
Closes #590
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
| |
Use %zu to print size_t for 64-bit compatibility.
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When queue more usb requests, and more devices working at the same time
256's limitation is easy to reach.
This patch remove such limitation of windows version.
dymatic allocate map fd_table.
each time increase 256 entry if request more fds.
Closes #592
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
| |
Closes #593
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
| |
`usbi_dbg` calls `usbi_backend.clock_gettime`, so `obsd_clock_gettime` should
not call `usbi_dbg`
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
| |
At some point `wrap_sys_device` was added to the `usbi_backend` struct, and
OpenBSD's backend was never updated along with it. Use a designated initializer
for this, so that we can avoid this class of error.
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
On Windows 10 version 1903 and later Windows blocks attempts to open
HID devices with a U2F usage unless running as administrator. This
patch makes the composite_open function ignore when opening the HID
part of a composite device fails.
Closes #603
Signed-off-by: Axel Gembe <derago@gmail.com>
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
On Windows 10 GetVersionEx will return version 10.0 when the running
application has a manifest that declares Windows 10 compatibility.
https://docs.microsoft.com/en-us/windows/win32/sbscs/application-manifests#supportedOS
When no such manifest is found, the call will report version 6.2,
which is Windows 8.
The 6.4 version is returned by early Windows 10 Insider Previews
and Windows Server 2017 Technical Preview 1.
Closes #604
Signed-off-by: Axel Gembe <derago@gmail.com>
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit fixes two bugs in device re-enumeration (enumeration after
init):
- The internal device object (cached device) was being re-used but the
user-visible one was not. This would cause the user to get stale data
when using the device afer reset. Now the (per libusb spec) the
user-visible device object is re-used and updated.
- If multiple libusb contexts were active then only the first context
was handled correctly. Fixed by moving the cached device search
out of process_new_device().
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
says:
4. If any interfaces have been added, removed, or changed since the last
update, increment current, and set revision to 0.
5. If any interfaces have been added since the last public release, then
increment age.
So both current and age must be incremented. The patch in
fde20bb9b7cba0ea6e96db920d0a0169c361ca92 was not complete.
Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
|
|
|
|
|
|
|
|
|
|
|
| |
- Use native API for getting full configuration descriptors instead of
using a raw request
- Implement some callbacks that are mandatory and result in crashes if
not available
Closes #565
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
| |
Closes #561
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In some cases, this is required to avoid eventually getting a
USBD_STATUS_BAD_START_FRAME error back from the Windows USB stack.
This makes the libusbK code match the behaviour of the Linux backend.
It appears that the libusbK backend tried to get this behaviour by
setting StartFrame to 0. However, libusbK docs state that:
"Specifing 0 for KISO_CONTEXT::StartFrame (start transfer ASAP) is
restricted to the first transaction on a newly opened or reset pipe."
Closes #569
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
|
|
| |
This prevents a nasty out-of-bounds read and a likely crash when
the interface number is invalid.
Closes #568
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
According to the USB 3.0 spec (9.3.4), the interface number is in the
lower 8 bits of wIndex.
Note that wIndex must not be modified because some (non-compliant?)
devices actually use the higher 8 bits for custom data with
recipient-interface requests.
Closes #567
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
|
|
| |
These functions were declared as returning int, but failed to actually
return anything, and no one was using their return values anyway.
Closes #562
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
| |
Closes #563
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
| |
Closes #566
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
| |
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
| |
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
| |
Closes #554
Closes #556
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
| |
Closes #557
Closes #555
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
| |
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
| |
Closes #284
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
There are low possiblity to open device before windows complete usb
configuration. Then claim interface will be always failure.
this patch workaround this problem, make sure return device until
windows finish usb configuration.
Closes #505
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Tom Zheng <haidong.zheng@nxp.com>
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We have a case where a device might not be detected by libusb if we plug
it after initializing the library. We were able to reproduce this issue
pretty consistently on a Mac Mini and several MacBook Pros running very
recent macOS versions (Mojave) using the Balena Fin board
(https://www.balena.io/fin/). I don't know if this happens with other
USB devices.
Enabling debug output revealed the following:
```
[ 7.901582] [00004f07] libusb: debug [darwin_get_cached_device] finding cached device for sessionID 0x2a9b5279f04
[ 7.901764] [00004f07] libusb: debug [darwin_get_cached_device] matching sessionID 0x2a9b5279f04 against cached device with sessionID 0x17dbd029b6a
[ 7.901798] [00004f07] libusb: debug [darwin_get_cached_device] matching sessionID 0x2a9b5279f04 against cached device with sessionID 0x1688763269f
[ 7.901818] [00004f07] libusb: debug [darwin_get_cached_device] matching sessionID 0x2a9b5279f04 against cached device with sessionID 0x4c0aefaa
[ 7.901831] [00004f07] libusb: debug [darwin_get_cached_device] matching sessionID 0x2a9b5279f04 against cached device with sessionID 0x0
[ 7.901845] [00004f07] libusb: debug [darwin_get_cached_device] caching new device with sessionID 0x2a9b5279f04
[ 7.903377] [00004f07] libusb: debug [darwin_device_from_service] could not set up plugin for service: out of resources
[ 8.029152] [00000307] libusb: debug [libusb_get_device_list]
```
The "out of resources" error comes from
`IOCreatePlugInInterfaceForService` which will apparently return this
error if the `Start` method of the interface is not success (see
https://github.com/opensource-apple/IOKitUser/blob/b80a5cbc0ebfb5c4954ef6d757918db0e4dc4b7f/IOCFPlugIn.c#L232).
Retrying `IOCreatePlugInInterfaceForService` makes it work for me.
Closes #542
Signed-off-by: Juan Cruz Viotti <juan@balena.io>
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
| |
Closes #530
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
libusb_close() can interrupt transfer to device,
setting dev_handle to NULL.
In this case all async requests should exit gracefully.
Also usbi_signal_transfer_completion() can dereference dev_handle
in this case.
Closes #434
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Improved log message output to MSVC handling by converting multi-byte
string (assumed to be UTF-8) to WCHAR string if UNICODE is defined, if
UNICODE is not defined then multi-byte string is sent to MSVC (Windows
CE defines UNICODE always, so it will use UNICODE case), added check
for 0 to avoid sending trash to MSVC (and possibly crash the process)
if conversion to WCHAR string fails.
Closes #504
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
| |
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
| |
Closes #473
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
|
|
| |
When bmRequestType indicates the recipient is an interface, get
interface number from wIndex.
Closes #398
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
| |
Closes #433
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
| |
Closes #430
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
| |
Closes #423
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
fun()
{
libusb_open()
... sync transfer
libusb_close()
}
two thread call fun infininately.
to speed up crash, enable application verifier
below 20 cycle, assert(fd!=NULL) happen at check_pollfds
below 100 cycle, crash at pollable_fd->overlappend in
winusb_get_overlapped result
with this fix, success fun over 1000 cycles
in handle_events
usbi_mutex_lock()
fds = ctx->pollfds
nfds = ctx->pollfds_cnt;
usbi_mutex_unclock()
usbi_poll()
callback.
usbi poll is not in mutex. pollfds may be change by usbi_add_pollfd
and usbi_remove_pollfd.
Although usbi_add_pollfd and usbi_remove_pollfd hold mutex, but
usbi_poll and callback is not in protext of mutex.
windows use fd as index of fb_table. fb_table may changed by
usbi_remove_pollfd. the map between fd and internal file_descriptor may
be wrong.
this patch added ref count for file_descriptor, only free file_desciptor
and remove it from fb_table when ref count is 0.
ref count will be increase when fds copy with mutex lock.
so fd always index validate file_descriptor.
ref count will be descress before return from handle_events.
the file_descriptor can be free safely at this time.
Closes #521
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
| |
Closes #535
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
'ALWAYS_SEARCH_USER_PATHS = NO'
The warning was: "Traditional headermap style is no longer supported; please migrate to using separate headermaps and set 'ALWAYS_SEARCH_USER_PATHS' to NO."
Also made sure all targets are referencing the xcconfig files.
Closes #532
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
Not all users of libusb use libusb_claim_interface(), and in that
case, the NetBSD backend fails to open() the necessary /dev/ugenX.Y
and will try to send ioctl()s to fd 0, which fortunately fails.
This unbreaks e.g. openocd on NetBSD.
Closes #539
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit fixes the backend of reset device to restore the state
of the device if possible. This fixes a bug introduced in
c14ab5fc4d22749aab9e3534d56012718a0b0f67. The previous commit
was necessary due to changes in the system USB stack that
essentially turned the ResetDevice function into a no-op. This
required libusb to move to USBDevuceReEnumerate to effectively
reset the device. The problem is that both the device handle and
libusb devices became invalid. This commit fixes the bug by
waiting for the re-enumeration to complete then 1) checking
whether the descriptors changed, 2) restoring the active
configuration, and 3) restoring claimed interfaces.
Closes #523
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
|
|
|
| |
%p is for pointers, not integers; therefore added a cast.
Fixes the following warnings:
libusb/core.c:1252:33: Format specifies type 'void *' but the argument has type 'intptr_t' (aka 'long')
libusb/core.c:1276:45: Format specifies type 'void *' but the argument has type 'intptr_t' (aka 'long')
Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
|
|
|
|
|
|
| |
Closes #527
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
| |
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
|
|
|
| |
- added various casts
- added some asserts where the casts made assumptions
- enabled additional warnings in Xcode project (especially -Wshorten-64-to-32)
Closes #509
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
event_handles supposed just run at a thread.
There are re-entry check at begin.
1: if (usbi_handling_events(ctx))
2: return LIBUSB_ERROR_BUSY;
3: usbi_stat_event_handle(ctx);
this code is hold any lock
it is possible two thread check 1 at the same time, then
go through to 3. So two threads will run event_handles.
above 3 line code should hold event_data_lock to avoid above
race condition.
1: usbi_mutex_lock($ctx->event_data_lock);
2: r = 0;
3: if (usbi_handling_events(ctx))
4: r = LIBUSB_ERROR_BUSY;
5: else
6: usbi_start_event_handling(ctx);
7: usbi_mutex_unlock($ctx->event_data_lock);
8: if(r)
9: return r;
check and set in an atomic operations.
Closes #520
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
| |
Closes #526
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Apple changed the definition of kIOUSBInterfaceInterfaceID in the SDK
for macOS 10.14. This looks like it breaks support for building for
older macOS versions when running 10.14. I don't know if the change
was intentional or a mistake but in order to guarantee libusb
builds as it has in the past we can no longer rely on
kIOUSBInterfaceInterfaceID.
Closes #519
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
|
|
| |
Looks like 5 seconds was indeed too long. Shortened the timeout to
1ms instead.
Closes #516
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|