| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
| |
fix "Integer constant not in range of enumerated type 'enum libusb_transfer_status'"
LIBUSB_ERROR_NO_DEVICE doesn't exist on enum libusb_transfer_status
|
| |
|
|
|
|
| |
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
| |
Set fd_size to 0 when freeing the fd_table array.
Closes #614
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
| |
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
| |
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
| |
Make code compliant with C89 so it will compile.
References #609
Closes #611
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If a virtual usb host driver install, but no port on that.
libusb_get_device_list will return failure.
but it should skip this host devices.
the below is virtual host control information
============USB Host Controller =======================
+++++++++++++++++ Device Information ++++++++++++++++++
Device Description : Leostream Corporation Virtual USB
Host Controller
Device Path :
\\?\root#system#0004#{3abf6f2d-71c4-462a-8a92-1e6861e6af27}
Device ID : ROOT\SYSTEM\0004
Hardware IDs : *lsusbdhcDevice
Driver KeyName :
{4d36e97d-e325-11ce-bfc1-08002be10318}\0049
(GUID_DEVCLASS_SYSTEM)
Driver :
\SystemRoot\System32\drivers\lsusbdbus.sys (Version: 6.3.2.2570
Date: 2018-11-12)
Driver Inf : C:\WINDOWS\inf\oem25.inf
Legacy BusType : Internal
Class : System
Class GUID :
{4d36e97d-e325-11ce-bfc1-08002be10318} (GUID_DEVCLASS_SYSTEM)
Interface GUID :
{3abf6f2d-71c4-462a-8a92-1e6861e6af27}
(GUID_DEVINTERFACE_USB_HOST_CONTROLLER)
Service : lsusbdbus
Enumerator : ROOT
Location Info : -
Manufacturer Info : Leostream Corporation
Capabilities : 0x00 (-)
Status : 0x0180200B (DN_ROOT_ENUMERATED,
DN_DRIVER_LOADED, DN_STARTED, DN_DISABLEABLE, DN_NT_ENUMERATOR,
DN_NT_DRIVER)
Problem Code : 0
Power State : D0 (supported: D0, D3)
HcInfo0 Error : ERROR_INVALID_FUNCTION
Roothub Symbolic Link : LSUSBDBUS
BusStatistics Error : ERROR_INVALID_FUNCTION
DriverVersion Error : ERROR_INVALID_FUNCTION
BandwidthInfo Error : ERROR_INVALID_FUNCTION
PowerInfo Error : ERROR_INVALID_FUNCTION
Closes #608
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
It is possible a file descriptor to be removed due to a close and the
same file descriptor value to be added during the same event loop. This
can cause the backend to get a stale revent and incorrectly remove the
file descriptor.
This commit addresses the issue by delaying the actual removal of the
ipollfds entry until just before the backend handle_events is called.
handle_events then goes through the list of closed fds and clears out
the revents associated with the closed file descriptor.
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit adds an additional check to synchronous transfer
progression to prevent accessing a potentially deleted context. This
access can occur if a code calls libusb_close() then libusb_exit()
from one thread while another thread is in a synchronous transfer.
Note that this is likely a user error. The application should wait
for all transfers to complete before calling libusb_close(). This
commit is being offered as a best-effort attempt to prevent the
invalid access and return a useful error to the application.
There may still be a window where an invalid access is possible.
This commit is a work around until a better fix is available.
References #610
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
| |
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>
|