From nobody Wed Jul 16 17:50:11 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4bj3VX1xV3z61nGB; Wed, 16 Jul 2025 17:50:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bj3VX16Lvz3TNh; Wed, 16 Jul 2025 17:50:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1752688212; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ey8EQrSugjdQTh56/jVmaj+5JR3W23IWvE5TAnA3ESU=; b=LvT61LbVCOsfFRDkBHWGy3QSgZjI3xY0r1OxeLOe2cYHS8LCSj5KMzj2wwneHkiJYLcyio MDRFMwfGAwCeTLI4BoLF6Vbuq/H2CMK0jjiW7yIADm15pj7Z6txR/Rpj7VNjvwscYIXG5W Q2BkMSEMW3Hsb7NZNmSa1gT+c9GVQd9qPcBHcX2CezbA3H8MxYRiwy1MqolVijZ4lns3Q4 01skwh/djRG95olniY36pl4EXMa5hCRkmwXwz4PHZsaXvPc7lam1RC7oaSEDs3tPJJQkKK az/bpnN60cKyRR6L2fpnz4aGONEMqUXfdcRlZmXPSw4S7a5K3hnOHnisqOtD+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1752688212; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ey8EQrSugjdQTh56/jVmaj+5JR3W23IWvE5TAnA3ESU=; b=Z+Gz0cLfNZI5oZjHwlWmzAIHRKMv6Gk3sgaMot/psMsQkRWXGWeG1yLju0ObCkgvYRpVQc SITYB38B6vaq+0tSbjs4mDALoQWG/Jjr04Ch43GJDvFCIWBVuW6RZyw/AOXbiv2ac6al94 SyOASXDaXpWsuzDeFhobyH1aC3fud9gPy+UoIn0WmPUWYdqKpWDSD1MZeQBesTW7hcFfuq TGFzoJ3CIQ9DDddVsiza4CajByo4kfAZ3C8LBoWq+AKkd+vFoFlRXnzC/TynAZVR2Tar95 pHB6qANRDIQNURPGSTkcSV0AC4OhTcT9Go53Rz0P4NEUrTjXTYat3Qr/aoEeMQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1752688212; a=rsa-sha256; cv=none; b=OOi7qPZRWwtuGMbqbOtJFU+kYAM4p4z5hPrnBHdZDoYgjWRSMC5WLV1Dfjr42Io1BgUUYJ sLM6XFHJpMa0Zv/xaw3D93fzS5rEvlaSrrNc5T4/KPEiAa/yKWaAhYVxib8msSGoOF95+P r6mrge9Fl7P58JM/4+AET4AmPFZbwdBlRBPofpWKWxGZwnWVAvrYYGn2IwOgZ4jX96lFJQ Q+8DeuieMwfnXjpU/HCnc1b7cAB70T4nqmuOqa9wKOd2RjggVLlFk/qalObqCYqoU8HEVG +dIPoEQT4x2CIAb1VHI3Q/iMQRxWYJ1XIY2V7MX/JUjT8zXO3RUA4e/0ElD+kQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4bj3VX0jHYz4d8; Wed, 16 Jul 2025 17:50:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 56GHoCpf015737; Wed, 16 Jul 2025 17:50:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 56GHoBkH015724; Wed, 16 Jul 2025 17:50:11 GMT (envelope-from git) Date: Wed, 16 Jul 2025 17:50:11 GMT Message-Id: <202507161750.56GHoBkH015724@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jesper Schmitz Mouridsen Subject: git: fc618b5f7e58 - main - preliminary usb support for fwget List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jsm X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fc618b5f7e5844b859030d8337b2b272dc20169e Auto-Submitted: auto-generated The branch main has been updated by jsm: URL: https://cgit.FreeBSD.org/src/commit/?id=fc618b5f7e5844b859030d8337b2b272dc20169e commit fc618b5f7e5844b859030d8337b2b272dc20169e Author: Jesper Schmitz Mouridsen AuthorDate: 2025-07-16 17:26:23 +0000 Commit: Jesper Schmitz Mouridsen CommitDate: 2025-07-16 17:49:14 +0000 preliminary usb support for fwget Mostly a copy of pci subsystem support, by replacing pciconf with usbconfig and excluding hardware classes. Approved by: wireless (bz) manpages (ziaee) USB (bz) Differential Revision: https://reviews.freebsd.org/D48678 --- usr.sbin/fwget/Makefile | 2 +- usr.sbin/fwget/fwget.8 | 14 +++++++++++--- usr.sbin/fwget/fwget.sh | 6 +++--- usr.sbin/fwget/usb/Makefile | 10 ++++++++++ usr.sbin/fwget/usb/usb | 43 +++++++++++++++++++++++++++++++++++++++++++ usr.sbin/fwget/usb/usb_ralink | 12 ++++++++++++ 6 files changed, 80 insertions(+), 7 deletions(-) diff --git a/usr.sbin/fwget/Makefile b/usr.sbin/fwget/Makefile index 1cdf0f18230d..4c934aee3413 100644 --- a/usr.sbin/fwget/Makefile +++ b/usr.sbin/fwget/Makefile @@ -2,6 +2,6 @@ PACKAGE= fwget SCRIPTS= fwget MAN= fwget.8 -SUBDIR= pci +SUBDIR= pci usb .include diff --git a/usr.sbin/fwget/fwget.8 b/usr.sbin/fwget/fwget.8 index 7b8b606cc591..86e304775e2d 100644 --- a/usr.sbin/fwget/fwget.8 +++ b/usr.sbin/fwget/fwget.8 @@ -23,7 +23,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd June 27, 2024 +.Dd July 7, 2025 .Dt FWGET 8 .Os .Sh NAME @@ -47,7 +47,11 @@ Dry run, only show needed packages .It Fl v Be more verbose .It Ar subsystem -Hardware subsystem, default pci +Hardware subsystem(s), default is all supported subsystems. +Space separated hardware subsystems, accepts +.Cm pci +and +.Cm usb .El .Sh SEE ALSO .Xr firmware 9 @@ -64,4 +68,8 @@ utility and this manual page were written by .An Emmanuel Vadot Aq Mt manu@FreeBSD.org for Beckhoff Automation GmbH & Co\. KG. .Sh CAVEATS -This utility currently only supports the pci subsystem. +This utility currently only supports the +.Xr pci 4 +and +.Xr usb 4 +subsystems. diff --git a/usr.sbin/fwget/fwget.sh b/usr.sbin/fwget/fwget.sh index 138a2a26bfb1..de1e6fa51f0f 100755 --- a/usr.sbin/fwget/fwget.sh +++ b/usr.sbin/fwget/fwget.sh @@ -35,7 +35,7 @@ usage() Usage: $(basename "$0") [options] [subsystem] Supported subsystems - pci + pci, usb Options: -n -- Do not install packages, only print the results @@ -100,9 +100,9 @@ done shift $(($OPTIND - 1)) subsystems="$@" -# Default searching PCI subsystem +# Default searching PCI and USB subsystem if [ -z "${subsystems}" ]; then - subsystems="pci" + subsystems="pci usb" fi # Fail early on unsupported subsystem diff --git a/usr.sbin/fwget/usb/Makefile b/usr.sbin/fwget/usb/Makefile new file mode 100644 index 000000000000..315e9c743cc8 --- /dev/null +++ b/usr.sbin/fwget/usb/Makefile @@ -0,0 +1,10 @@ +PACKAGE= fwget + +SCRIPTS=usb \ + usb_ralink + +BINDIR= ${LIBEXECDIR}/fwget + +MAN= + +.include diff --git a/usr.sbin/fwget/usb/usb b/usr.sbin/fwget/usb/usb new file mode 100755 index 000000000000..fef6bc76ba89 --- /dev/null +++ b/usr.sbin/fwget/usb/usb @@ -0,0 +1,43 @@ +# +# Copyright 2023 Beckhoff Automation GmbH & Co. KG +# Copyright 2023 Bjoern A. Zeeb +# Copyright 2025 Jesper Schmitz Mouridsen + +# SPDX-License-Identifier: BSD-2-Clause + + +usb_get_vendor() +{ + local hexvendor=$(echo $1 | sed 's/.*idVendor=\(0x[0-9a-z]*\).*/\1/') + case "${hexvendor}" in + 0x148f) echo "ralink" ;; + esac +} + +usb_get_device() +{ + local hexdevice=$(echo $1 | sed 's/.*idProduct=\(0x[0-9a-z]*\).*/\1/') + echo "${hexdevice}" + +} + +usb_search_packages() +{ + local IFS + + oldifs=$IFS + IFS=$'\n' + for fulldevice in $(usbconfig -l dump_device_desc); do + vendor=$(usb_get_vendor "${fulldevice}") + if [ -z "${vendor}" ]; then + continue + fi + device=$(usb_get_device "${fulldevice}") + log_verbose "Trying to match device ${device} and vendor ${vendor} with usb_${vendor}" + if [ -f ${LIBEXEC_PATH}/usb_${vendor} ]; then + . ${LIBEXEC_PATH}/usb_${vendor} + usb_${vendor} ${device} + fi + done + IFS=${oldifs} +} diff --git a/usr.sbin/fwget/usb/usb_ralink b/usr.sbin/fwget/usb/usb_ralink new file mode 100755 index 000000000000..8d3135063011 --- /dev/null +++ b/usr.sbin/fwget/usb/usb_ralink @@ -0,0 +1,12 @@ +# +# Copyright (c) 2025 Jesper Schmitz Mouridsen +# +# SPDX-License-Identifier: BSD-2-Clause + +usb_ralink() +{ + + case "$1" in + 0x7601) addpkg "wifi-firmware-mt7601u-kmod"; return 1 ;; + esac +}