Bug 277799 - libusb should be updated
Summary: libusb should be updated
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: usb (show other bugs)
Version: 14.0-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: Ed Maste
URL: https://reviews.freebsd.org/D45514
Keywords:
Depends on:
Blocks:
 
Reported: 2024-03-19 02:37 UTC by Duane
Modified: 2024-06-28 16:57 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Duane 2024-03-19 02:37:40 UTC
We currently report v1.0.13 which was from 2012.  The external project is currently up to v1.0.27.

For OpenOCD this requires us to lie about the version to get USB support to work (see bug #256491 and bug #277688)
Comment 1 Ed Maste freebsd_committer freebsd_triage 2024-03-19 16:01:14 UTC
It looks like OpenOCD wants at least 1.0.16 so we can start with that.

Comparing headers from 1.0.13 and 1.0.16 some highlights I see (additions unless otherwise noted):

- enum libusb_descriptor_type - LIBUSB_DT_BOS, LIBUSB_DT_DEVICE_CAPABILITY, LIBUSB_DT_SS_ENDPOINT_COMPANION

- some LIBUSB_DT_* #defines

- structs libusb_ss_endpoint_companion_descriptor, libusb_bos_dev_capability_descriptor, libusb_bos_descriptor, libusb_usb_2_0_extension_descriptor, libusb_ss_usb_device_capability_descriptor, libusb_container_id_descriptor

- enums libusb_supported_speed, libusb_usb_2_0_extension_attributes, libusb_ss_usb_device_capability_attributes, libusb_bos_type

- enum libusb_capability - LIBUSB_CAP_HAS_HOTPLUG, LIBUSB_CAP_HAS_HID_ACCESS, LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER

functions libusb_setlocale, libusb_strerror, libusb_get_ss_endpoint_companion_descriptor, libusb_free_ss_endpoint_companion_descriptor, libusb_get_bos_descriptor, libusb_free_bos_descriptor, libusb_get_usb_2_0_extension_descriptor, libusb_free_usb_2_0_extension_descriptor, libusb_get_ss_usb_device_capability_descriptor, libusb_free_ss_usb_device_capability_descriptor, libusb_get_container_id_descriptor, libusb_free_container_id_descriptor, libusb_get_port_numbers, libusb_set_auto_detach_kernel_driver

libusb_hotplug_* typedefs, enums, functions
Comment 2 Ed Maste freebsd_committer freebsd_triage 2024-06-06 13:25:13 UTC
libusb_hotplug_register_callback was added in:

commit 7bdc064b0b644d15bd9614d9e7db5c4279736d75
Author: Hans Petter Selasky <hselasky@FreeBSD.org>
Date:   Wed Jun 22 10:38:41 2016 +0000

    Implement libusb_hotplug_register_callback() and
    libusb_hotplug_deregister_callback() for the LibUSB v1.0 API and
    update the libusb(3) manual page.
    
    Approved by:    re (kib)
    Requested by:   swills
    MFC after:      1 week

This was introduced in Linux libusb between 1.0.15 and 1.0.16.
Comment 3 Ed Maste freebsd_committer freebsd_triage 2024-06-06 13:42:50 UTC
AFAICT OpenOCD's 1.0.16 requirement comes from libjaylink and was introduced in:

https://gitlab.zapb.de/libjaylink/libjaylink/-/commit/4959f4e18a2bb0de21abe66bbfe403b56f599856

which introduced use of

libusb_get_port_numbers
libusb_get_bus_number
The second one has existed forever, and it is apparently the addition of libusb_get_port_numbers that added the 1.0.16 dependency.

libusb_get_port_numbers was introduced in libusb in

commit 4d7789be7e317fb2e89557f959c1a1a69cc01b26
Author: Hans de Goede <hdegoede@redhat.com>
Date:   Fri May 17 10:36:32 2013 +0200

    core: Add a new public libusb_get_port_numbers function
    
    This new function replaces the now deprecated libusb_get_port_path function,
    as that is the only function operating on a libusb_device which also takes
    a libusb_context, which is rather inconsistent.
    
    Note we will keep libusb_get_port_path around in the 1.0.x for the forseeable
    future for ABI compatibility reasons, but it should not be used in any new
    code.
    
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>

and in FreeBSD in

commit a9205626a7e2f89486e637d6187ff99c17efeb10
Author: Ed Maste <emaste@FreeBSD.org>
Date:   Fri Jun 7 13:45:58 2013 +0000

    Add libusb_get_port_numbers
    
    libusbx deprecated libusb_get_port_path and replaced it with
    libusb_get_port_numbers.  The latter omits an extra parameter which was
    unused in the FreeBSD implementation anyway.

(Huh, I don't remember this.)

That said, bumping what we report to 1.0.16 seems reasonable enough; we can fault in any missing but required functionality. Change added to Phabricator review and exp-run requested in see-also PR.
Comment 4 commit-hook freebsd_committer freebsd_triage 2024-06-28 16:20:13 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=5654b42142e1f689b26d405c90379b85f22349a0

commit 5654b42142e1f689b26d405c90379b85f22349a0
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2024-06-06 13:33:44 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2024-06-28 16:18:34 +0000

    libusb: claim to be version 1.0.16

    We are not 100% compatible with 1.0.16, but implement some
    functionality from that version that is required by certain ports.

    PR:             277799
    PR:             279555 (exp-run)
    Event:          Kitchener-Waterloo Hackathon 202406
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D45514

 lib/libusb/libusb-1.0.pc.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)