git: 32e319fbe861 - main - comms/uhd: Patches to fix B200 usability

From: Michael Reifenberger <mr_at_FreeBSD.org>
Date: Fri, 16 Oct 2026 14:40:47 UTC
The branch main has been updated by mr:

URL: https://cgit.FreeBSD.org/ports/commit/?id=32e319fbe8611cb48cd6d94b223b0bea60ef4a5f

commit 32e319fbe8611cb48cd6d94b223b0bea60ef4a5f
Author:     Michael Reifenberger <mr@FreeBSD.org>
AuthorDate: 2026-10-16 14:37:10 +0000
Commit:     Michael Reifenberger <mr@FreeBSD.org>
CommitDate: 2026-10-16 14:40:33 +0000

    comms/uhd: Patches to fix B200 usability
    
    PATCH: clear endpoint halt after FPGA load
    
    PATCH: utils: match serials that are not hex numbers
    This Patch allows UHD to handle the non-hex serials of clone devices
    such as the LibreSDR B210.
    Full hex serials still get compared by value,
    while non-hex ones are being treated as strings.
    
    PR:             290791
    Reported by:    Alexandra Burmistrova
---
 comms/uhd/Makefile                                 |  3 +--
 .../patch-host_cmake_Modules_UHDAtomics.cmake      |  4 ++--
 .../files/patch-host_lib_usrp_b200_b200__impl.cpp  | 18 +++++++++++++++
 .../files/patch-host_lib_utils_serial__number.cpp  | 26 ++++++++++++++++++++++
 4 files changed, 47 insertions(+), 4 deletions(-)

diff --git a/comms/uhd/Makefile b/comms/uhd/Makefile
index cfdd3de9ccf2..caed2ed6726f 100644
--- a/comms/uhd/Makefile
+++ b/comms/uhd/Makefile
@@ -1,8 +1,7 @@
 PORTNAME=	uhd
 DISTVERSIONPREFIX=	v
 DISTVERSION=	4.10.0.0
-PORTREVISION=	1
-#PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	comms hamradio
 DIST_SUBDIR=	${PORTNAME}
 
diff --git a/comms/uhd/files/patch-host_cmake_Modules_UHDAtomics.cmake b/comms/uhd/files/patch-host_cmake_Modules_UHDAtomics.cmake
index ef5f6f1b90be..63d478c5cdc2 100644
--- a/comms/uhd/files/patch-host_cmake_Modules_UHDAtomics.cmake
+++ b/comms/uhd/files/patch-host_cmake_Modules_UHDAtomics.cmake
@@ -1,6 +1,6 @@
---- host/cmake/Modules/UHDAtomics.cmake.orig	2022-05-30 13:45:17 UTC
+--- host/cmake/Modules/UHDAtomics.cmake.orig	2026-10-16 14:05:41 UTC
 +++ host/cmake/Modules/UHDAtomics.cmake
-@@ -102,9 +102,9 @@ macro(CHECK_ATOMICS_LIB_REQUIRED required_var)
+@@ -104,9 +104,9 @@ macro(CHECK_ATOMICS_LIB_REQUIRED required_var)
                      message(FATAL_ERROR "Host compiler must support std::atomic!")
                  endif()
              else()
diff --git a/comms/uhd/files/patch-host_lib_usrp_b200_b200__impl.cpp b/comms/uhd/files/patch-host_lib_usrp_b200_b200__impl.cpp
new file mode 100644
index 000000000000..cef2bd33125d
--- /dev/null
+++ b/comms/uhd/files/patch-host_lib_usrp_b200_b200__impl.cpp
@@ -0,0 +1,18 @@
+--- host/lib/usrp/b200/b200_impl.cpp.orig	2026-10-16 14:05:41 UTC
++++ host/lib/usrp/b200/b200_impl.cpp
+@@ -470,6 +470,15 @@ b200_impl::b200_impl(
+ 
+     _iface->reset_gpif();
+ 
++    {
++        libusb::device_handle::sptr dev_handle(libusb::device_handle::get_cached_handle(
++            std::static_pointer_cast<libusb::special_handle>(handle)->get_device()));
++        dev_handle->clear_endpoints(
++            B200_USB_CTRL_RECV_ENDPOINT, B200_USB_CTRL_SEND_ENDPOINT);
++        dev_handle->clear_endpoints(
++            B200_USB_DATA_RECV_ENDPOINT, B200_USB_DATA_SEND_ENDPOINT);
++    }
++
+     ////////////////////////////////////////////////////////////////////
+     // Create control transport
+     ////////////////////////////////////////////////////////////////////
diff --git a/comms/uhd/files/patch-host_lib_utils_serial__number.cpp b/comms/uhd/files/patch-host_lib_utils_serial__number.cpp
new file mode 100644
index 000000000000..db0a232b25ed
--- /dev/null
+++ b/comms/uhd/files/patch-host_lib_utils_serial__number.cpp
@@ -0,0 +1,26 @@
+--- host/lib/utils/serial_number.cpp.orig	2026-10-16 14:05:41 UTC
++++ host/lib/utils/serial_number.cpp
+@@ -13,13 +13,16 @@ bool serial_numbers_match(const std::string& serial_a,
+ bool serial_numbers_match(const std::string& serial_a, const std::string& serial_b)
+ {
+     try {
+-        const uint32_t a = std::stoi(serial_a, 0, 16);
+-        const uint32_t b = std::stoi(serial_b, 0, 16);
+-        return a == b;
+-    } catch (std::out_of_range& e) {
+-        return false;
+-    } catch (std::invalid_argument& e) {
+-        return false;
++        size_t pos_a          = 0;
++        size_t pos_b          = 0;
++        const unsigned long a = std::stoul(serial_a, &pos_a, 16);
++        const unsigned long b = std::stoul(serial_b, &pos_b, 16);
++        if (pos_a == serial_a.size() && pos_b == serial_b.size()) {
++            return a == b;
++        }
++    } catch (std::out_of_range&) {
++    } catch (std::invalid_argument&) {
+     }
++    return serial_a == serial_b;
+ }
+ }} // namespace uhd::utils