Skip to content

netbsd: check not only addr 0 but also addr 1 to find root hubs#780

Merged
Youw merged 1 commit intolibusb:masterfrom
tsutsui:check-addr-1-as-roothub-on-netbsd
Mar 20, 2026
Merged

netbsd: check not only addr 0 but also addr 1 to find root hubs#780
Youw merged 1 commit intolibusb:masterfrom
tsutsui:check-addr-1-as-roothub-on-netbsd

Conversation

@tsutsui
Copy link
Copy Markdown
Contributor

@tsutsui tsutsui commented Mar 17, 2026

On NetBSD xhci(4) uses 'addr 0' for the root hub but all drivers for other host controllers use 'addr 1' for the root hub.
https://gnats.netbsd.org/60073


Tested with ch32fun on NetBSD/i386 10.1 both with xhci(4) and ohci(4).

On NetBSD xhci(4) uses 'addr 0' for the root hub but all drivers for
other host controllers use 'addr 1' for the root hub.
 https://gnats.netbsd.org/60073
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts NetBSD HID device enumeration to find USB root hubs regardless of whether the controller presents the root hub at address 0 (xhci) or address 1 (most other host controllers), improving device discovery on NetBSD (per GNATS 60073).

Changes:

  • Adds a two-step enumeration attempt: probe USB address 0 first, then fall back to address 1 if nothing was found.
  • Introduces state tracking (prev_end) to decide whether to attempt the fallback enumeration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread netbsd/hid.c
@mcuee mcuee added the bsd FreeBSD, NetBSD, OpenBSD, etc label Mar 20, 2026
@Youw Youw merged commit 7e994d8 into libusb:master Mar 20, 2026
18 checks passed
@tsutsui tsutsui deleted the check-addr-1-as-roothub-on-netbsd branch March 20, 2026 21:40
@mcuee
Copy link
Copy Markdown
Member

mcuee commented Apr 25, 2026

Sanity check on the NetBSD backend using a VirtualBox VM.

netbsdvm$ mkdir build_cmake

netbsdvm$ cd build_cmake/

netbsdvm$ cmake ..
-- The C compiler identification is GNU 10.5.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- hidapi: v0.16.0
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Performing Test HIDAPI_ICONV_CONST
-- Performing Test HIDAPI_ICONV_CONST - Failed
-- Found PkgConfig: /usr/pkg/bin/pkg-config (found version "2.4.3")
-- Checking for module 'libusb-1.0>=1.0.9'
--   Found libusb-1.0, version 1.0.29
-- Check for Iconv
-- Performing Test Iconv_IS_BUILT_IN
-- Performing Test Iconv_IS_BUILT_IN - Success
-- Found Iconv: built in to C library
-- Configuring done (2.9s)
-- Generating done (0.1s)
-- Build files have been written to: /home/mcuee/build/hidapi/build_cmake

netbsdvm$ make
[ 25%] Building C object src/netbsd/CMakeFiles/hidapi_netbsd.dir/hid.c.o
[ 50%] Linking C shared library libhidapi-netbsd.so
[ 50%] Built target hidapi_netbsd
[ 75%] Building C object src/libusb/CMakeFiles/hidapi_libusb.dir/hid.c.o
[100%] Linking C shared library libhidapi-libusb.so
[100%] Built target hidapi_libusb

netbsdvm$ cmake .. -D HIDAPI_BUILD_HIDTEST=1
-- hidapi: v0.16.0
-- Check for Iconv
-- Building hidtest
-- Configuring done (0.1s)
-- Generating done (0.2s)
-- Build files have been written to: /home/mcuee/build/hidapi/build_cmake

netbsdvm$ make
[ 33%] Built target hidapi_netbsd
[ 66%] Built target hidapi_libusb
[ 83%] Building C object hidtest/CMakeFiles/hidtest.dir/test.c.o
[100%] Linking C executable hidtest
[100%] Built target hidtest

netbsdvm$ sudo ./hidtest/hidtest
hidapi test/example tool. Compiled with hidapi version 0.16.0, runtime version 0.16.0.
Compile-time version matches runtime version of hidapi.

Device Found
  type: 0925 1234
  path: uhidev1
  serial_number:
  Manufacturer: CYPRESS
  Product:      EZ-USB FX2 HID USBHIDIO
  Release:      0
  Interface:    -1
  Usage (page): 0x1 (0xffa0)
  Bus type: 1 (USB)

  Report Descriptor: (52 bytes)
0x06, 0xa0, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x09, 0x02, 0xa1,
0x00, 0x06, 0xa1, 0xff, 0x09, 0x03, 0x09, 0x04, 0x15, 0x80,
0x25, 0x7f, 0x35, 0x00, 0x45, 0xff, 0x75, 0x08, 0x95, 0x80,
0x81, 0x02, 0x09, 0x05, 0x09, 0x06, 0x15, 0x80, 0x25, 0x7f,
0x35, 0x00, 0x45, 0xff, 0x75, 0x08, 0x95, 0x80, 0x91, 0x02,
0xc0, 0xc0,
unable to open device

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Apr 25, 2026

More complete installation log.

But this does not seem to work.

netbsdvm$ cmake .. -D HIDAPI_BUILD_HIDTEST=1 -DCMAKE_INSTALL_PREFIX=/usr/pkg
-- hidapi: v0.16.0
-- Check for Iconv
-- Building hidtest
-- Configuring done (0.1s)
-- Generating done (0.2s)
-- Build files have been written to: /home/mcuee/build/hidapi/build_cmake

netbsdvm$ make
[ 33%] Built target hidapi_netbsd
[ 66%] Built target hidapi_libusb
[100%] Built target hidtest

netbsdvm$ sudo make install
Password:
[ 33%] Built target hidapi_netbsd
[ 66%] Built target hidapi_libusb
[100%] Built target hidtest
Install the project...
-- Install configuration: "Release"
-- Installing: /usr/pkg/lib/libhidapi-netbsd.so.0.16.0
-- Installing: /usr/pkg/lib/libhidapi-netbsd.so.0
-- Installing: /usr/pkg/lib/libhidapi-netbsd.so
-- Installing: /usr/pkg/include/hidapi/hidapi.h
-- Installing: /usr/pkg/lib/pkgconfig/hidapi-netbsd.pc
-- Installing: /usr/pkg/lib/libhidapi-libusb.so.0.16.0
-- Installing: /usr/pkg/lib/libhidapi-libusb.so.0
-- Set non-toolchain portion of runtime path of "/usr/pkg/lib/libhidapi-libusb.so.0.16.0" to ""
-- Up-to-date: /usr/pkg/lib/libhidapi-libusb.so
-- Up-to-date: /usr/pkg/include/hidapi/hidapi.h
-- Installing: /usr/pkg/include/hidapi/hidapi_libusb.h
-- Installing: /usr/pkg/lib/pkgconfig/hidapi-libusb.pc
-- Old export file "/usr/pkg/lib/cmake/hidapi/libhidapi.cmake" will be replaced.  Removing files [/usr/pkg/lib/cmake/hidapi/libhidapi-release.cmake].
-- Installing: /usr/pkg/lib/cmake/hidapi/libhidapi.cmake
-- Installing: /usr/pkg/lib/cmake/hidapi/libhidapi-release.cmake
-- Installing: /usr/pkg/lib/cmake/hidapi/hidapi-config-version.cmake
-- Installing: /usr/pkg/lib/cmake/hidapi/hidapi-config.cmake
-- Installing: /usr/pkg/bin/hidtest
-- Set non-toolchain portion of runtime path of "/usr/pkg/bin/hidtest" to ""

netbsdvm$ /usr/pkg/bin/hidtest
/usr/pkg/bin/hidtest: Shared object "libhidapi-netbsd.so.0" not found

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Apr 25, 2026

Okay, I can follow the method in avrdude which I found out last time.
https://github.com/avrdudes/avrdude/blob/main/build.sh

netbsdvm$ pwd
/home/mcuee/build/hidapi/build_cmake
netbsdvm$ cmake .. -D HIDAPI_BUILD_HIDTEST=1  -D CMAKE_C_FLAGS=-I/usr/pkg/include -D CMAKE_EXE_LINKER_FLAGS=-R/usr/pkg/lib -DCMAKE_INSTALL_PREFIX=/usr/pkg
-- The C compiler identification is GNU 10.5.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- hidapi: v0.16.0
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Performing Test HIDAPI_ICONV_CONST
-- Performing Test HIDAPI_ICONV_CONST - Failed
-- Found PkgConfig: /usr/pkg/bin/pkg-config (found version "2.4.3")
-- Checking for module 'libusb-1.0>=1.0.9'
--   Found libusb-1.0, version 1.0.29
-- Check for Iconv
-- Performing Test Iconv_IS_BUILT_IN
-- Performing Test Iconv_IS_BUILT_IN - Success
-- Found Iconv: built in to C library
-- Building hidtest
-- Configuring done (5.3s)
-- Generating done (0.3s)
-- Build files have been written to: /home/mcuee/build/hidapi/build_cmake
netbsdvm$ make
[ 16%] Building C object src/netbsd/CMakeFiles/hidapi_netbsd.dir/hid.c.o
[ 33%] Linking C shared library libhidapi-netbsd.so
[ 33%] Built target hidapi_netbsd
[ 50%] Building C object src/libusb/CMakeFiles/hidapi_libusb.dir/hid.c.o
[ 66%] Linking C shared library libhidapi-libusb.so
[ 66%] Built target hidapi_libusb
[ 83%] Building C object hidtest/CMakeFiles/hidtest.dir/test.c.o
[100%] Linking C executable hidtest
[100%] Built target hidtest
netbsdvm$ sudo make install
Password:
[ 33%] Built target hidapi_netbsd
[ 66%] Built target hidapi_libusb
[100%] Built target hidtest
Install the project...
-- Install configuration: "Release"
-- Installing: /usr/pkg/lib/libhidapi-netbsd.so.0.16.0
-- Up-to-date: /usr/pkg/lib/libhidapi-netbsd.so.0
-- Up-to-date: /usr/pkg/lib/libhidapi-netbsd.so
-- Up-to-date: /usr/pkg/include/hidapi/hidapi.h
-- Installing: /usr/pkg/lib/pkgconfig/hidapi-netbsd.pc
-- Installing: /usr/pkg/lib/libhidapi-libusb.so.0.16.0
-- Up-to-date: /usr/pkg/lib/libhidapi-libusb.so.0
-- Set non-toolchain portion of runtime path of "/usr/pkg/lib/libhidapi-libusb.so.0.16.0" to ""
-- Up-to-date: /usr/pkg/lib/libhidapi-libusb.so
-- Up-to-date: /usr/pkg/include/hidapi/hidapi.h
-- Up-to-date: /usr/pkg/include/hidapi/hidapi_libusb.h
-- Installing: /usr/pkg/lib/pkgconfig/hidapi-libusb.pc
-- Installing: /usr/pkg/lib/cmake/hidapi/libhidapi.cmake
-- Installing: /usr/pkg/lib/cmake/hidapi/libhidapi-release.cmake
-- Installing: /usr/pkg/lib/cmake/hidapi/hidapi-config-version.cmake
-- Installing: /usr/pkg/lib/cmake/hidapi/hidapi-config.cmake
-- Installing: /usr/pkg/bin/hidtest
-- Set non-toolchain portion of runtime path of "/usr/pkg/bin/hidtest" to ""

netbsdvm$ sudo /usr/pkg/bin/hidtest
hidapi test/example tool. Compiled with hidapi version 0.16.0, runtime version 0.16.0.
Compile-time version matches runtime version of hidapi.

Device Found
  type: 0925 1234
  path: uhidev1
  serial_number:
  Manufacturer: CYPRESS
  Product:      EZ-USB FX2 HID USBHIDIO
  Release:      0
  Interface:    -1
  Usage (page): 0x1 (0xffa0)
  Bus type: 1 (USB)

  Report Descriptor: (52 bytes)
0x06, 0xa0, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x09, 0x02, 0xa1,
0x00, 0x06, 0xa1, 0xff, 0x09, 0x03, 0x09, 0x04, 0x15, 0x80,
0x25, 0x7f, 0x35, 0x00, 0x45, 0xff, 0x75, 0x08, 0x95, 0x80,
0x81, 0x02, 0x09, 0x05, 0x09, 0x06, 0x15, 0x80, 0x25, 0x7f,
0x35, 0x00, 0x45, 0xff, 0x75, 0x08, 0x95, 0x80, 0x91, 0x02,
0xc0, 0xc0,
unable to open device

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Apr 25, 2026

hidapitester -- again the problem with shared library. Need to see how to fix it.

netbsdvm$ gmake -f Makefile_netbsd_uhid
cc -I/usr/pkg/include -I ../hidapi/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" ../hidapi/netbsd/hid.o hidapitester.o -o hidapitester -L/usr/pkg/lib -lhidapi-netbsd -pthread
netbsdvm$ gmake -f Makefile_netbsd_uhid clean
rm -f ../hidapi/netbsd/hid.o hidapitester.o
rm -f hidapitester

netbsdvm$ gmake -f Makefile_netbsd_uhid
cc -I/usr/pkg/include -I ../hidapi/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" -c ../hidapi/netbsd/hid.c -o ../hidapi/netbsd/hid.o
cc -I/usr/pkg/include -I ../hidapi/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" -c hidapitester.c -o hidapitester.o
cc -I/usr/pkg/include -I ../hidapi/hidapi -DHIDAPITESTER_VERSION=\"""v0.5""\" ../hidapi/netbsd/hid.o hidapitester.o -o hidapitester -L/usr/pkg/lib -lhidapi-netbsd -pthread

netbsdvm$ sudo ./hidapitester
./hidapitester: Shared object "libhidapi-netbsd.so.0" not found

netbsdvm$ diff -u Makefile Makefile_netbsd_uhid
--- Makefile    2026-04-25 17:54:17.323074834 +0800
+++ Makefile_netbsd_uhid        2026-04-25 18:29:33.065111652 +0800
@@ -22,7 +22,9 @@
 ifeq "$(UNAME)" "FreeBSD"
        OS=freebsd
 endif
-
+ifeq "$(UNAME)" "NetBSD"
+        OS=netbsd
+endif

 # construct version string from git tag
 # allow overriding of GIT_TAG for automated builds
@@ -90,6 +92,16 @@

 endif

+########### NetBSD
+ifeq "$(OS)" "netbsd"
+
+CFLAGS += -I/usr/pkg/include
+OBJS = $(HIDAPI_DIR)/netbsd/hid.o
+LIBS += -L/usr/pkg/lib -lhidapi-netbsd -pthread
+EXE=
+
+endif
+
 ############# common

 CFLAGS += -I $(HIDAPI_DIR)/hidapi

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Apr 25, 2026

Again CMake works fine for hidapitester.

netbsdvm$ mkdir build
netbsdvm$ cd build/
netbsdvm$ cmake ..
-- The C compiler identification is GNU 10.5.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- hidapitester version: v0.5
-- Using local HIDAPI from: /home/mcuee/build/hidapitester/../hidapi
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Performing Test HIDAPI_ICONV_CONST
-- Performing Test HIDAPI_ICONV_CONST - Failed
-- Found PkgConfig: /usr/pkg/bin/pkg-config (found version "2.4.3")
-- Checking for module 'libusb-1.0>=1.0.9'
--   Found libusb-1.0, version 1.0.29
-- Check for Iconv
-- Performing Test Iconv_IS_BUILT_IN
-- Performing Test Iconv_IS_BUILT_IN - Success
-- Found Iconv: built in to C library
-- Configuring done (1.8s)
-- Generating done (0.2s)
-- Build files have been written to: /home/mcuee/build/hidapitester/build
netbsdvm$ make
[ 25%] Building C object hidapi/src/netbsd/CMakeFiles/hidapi_netbsd.dir/hid.c.o
[ 50%] Linking C static library libhidapi-netbsd.a
[ 50%] Built target hidapi_netbsd
[ 75%] Building C object CMakeFiles/hidapitester.dir/hidapitester.c.o
[100%] Linking C executable hidapitester
[100%] Built target hidapitester
netbsdvm$ ./hidapitester
Usage:
  hidapitester <cmd> [options]
where <cmd> is one of:
  --vidpid <vid/pid>          Filter by vendorId/productId (comma/slash delim)
  --usagePage <number>        Filter by usagePage
  --usage <number>            Filter by usage
  --serial <string>           Filter by serial number
  --list                      List HID devices (by filters)
  --list-usages               List HID devices w/ usages (by filters)
  --list-detail               List HID devices w/ details (by filters)
  --open                      Open device with previously selected filters
  --open-path <pathstr>       Open device by path (as in --list-detail)
  --close                     Close currently open device
  --get-report-descriptor     Get the report descriptor
  --send-feature <datalist>   Send Feature report (1st byte reportId, if used)
  --read-feature <reportId>   Read Feature report (w/ reportId, 0 if unused)
  --send-output <datalist>    Send Ouput report to device
  --read-input                Read Input reports
  --read-input-forever        Read Input reports in a loop forever
  --read-input-report <reportId>  Read Input report from specific reportId
  --length <len>, -l <len>    Set buffer length in bytes of report to send/read
  --timeout <msecs>           Timeout in millisecs to wait for input reads
  --base <base>, -b <base>    Set decimal or hex buffer print mode
  --width <width> -w <width>  Set number of bytes to print per line
  --quiet, -q                 Print out nothing except when reading data
  --verbose, -v               Print out extra information
  --version                   Print out hidapitester and hidapi version

Notes:
 . Commands are executed in order.
 . --vidpid, --usage, --usagePage, --serial act as filters to --open and --list

Examples:
. List all devices
   hidapitester --list
. List details of all devices w/ vendorId 0x2341
   hidapitester --vidpid 2341 --list-detail
. Open vid/pid xxxx:yyyy, get report descriptor
   hidapitester --vidpid xxxx:yyyy --open --get-report-descriptor
. Open device with usagePage 0xFFAB, send Feature report on reportId 1
   hidapitester -l 9 --usagePage 0xFFAB --open --send-feature 1,99,44,22
. Open vid/pid xxxx:yyyy, send 64-byte Output report, read 64-byte Input report
   hidapitester --vidpid xxxx:yyyy -l 64 --open --send-output 1,2,3 --read-input
. Read Input report continuously with 1500 msec timeout
   hidapitester --vidpid xxxx:yyyy -l 64 -t 1500 --open --read-input-forever
. Send FadeToRGB #FF00FF command to blink(1)
   hidapitester --vidpid 27b8:01ed -l 9 --open --send-feature 1,99,255,0,255

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Apr 25, 2026

Testing of the EZ-USB FX2LP High Speed USB Generic HID device with 128 Bytes Report Length. Unfortunately it does not seem to work.

netbsdvm$ sudo ./hidapitester --list
0925/1234: vendor 0925 - product 1234

netbsdvm$ sudo ./hidapitester --vidpid 0925:1234 --list-detail
0925/1234: vendor 0925 - product 1234
  vendorId:      0x0925
  productId:     0x1234
  usagePage:     0xFFA0
  usage:         0x0001
  serial_number:
  interface:     -1
  path: uhidev1

netbsdvm$ sudo ./hidapitester  --vidpid 0925:1234 --open --buflen 256 -l 129 --send-output 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 129-bytes...wrote -1 bytes:
 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
 80
Reading up to 129-byte input report, 250 msec timeout...read 0 bytes:
Closing device

netbsdvm$ sudo ./hidapitester  --vidpid 0925:1234 --open --buflen 256 -l 128 --send-output 0,1,2,3,4,5,6,7,8,9,10,11,12,
13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,
53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,
93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124
,125,126,127  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 128-bytes...wrote -1 bytes:
 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
Reading up to 128-byte input report, 250 msec timeout...read 0 bytes:
Closing device

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Apr 25, 2026

For the original FX2HID example from Jan Axelson, it also does not seems to work.

  1. Under Windows, it works fine.
PS C:\work\libusb\hidapitester> .\hidapitester_git_winapi.exe --vidpid 0925:1234 --open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote 3 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 2 bytes:
 01 02 00
Closing device
  1. Under NetBSD, it does not seem to work.
netbsdvm$ sudo ./hidapitester  --vidpid 0925:1234 --open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote -1 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 0 bytes:
Closing device

netbsdvm$ sudo ./hidapitester  --vidpid 0925:1234 --open --buflen 64 -l 2 --send-output 1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 2-bytes...wrote -1 bytes:
 01 02
Reading up to 2-byte input report, 250 msec timeout...read 0 bytes:
Closing device

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Apr 25, 2026

@tsutsui

Just wondering what kind of generic USB HID device you have which works with the NetBSD uhid backend. Thanks.

@tsutsui
Copy link
Copy Markdown
Contributor Author

tsutsui commented Apr 25, 2026

Just wondering what kind of generic USB HID device you have which works with the NetBSD uhid backend. Thanks.

I'm using minichlink https://github.com/cnlohr/ch32fun/tree/master/minichlink (WCH risc-v CH32V003 tool) on NetBSD/i386 11.0_RC3 etc.

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Apr 26, 2026

Unfortunately even forcing the device to enumerate as a full speed USB device does not work. That was the issues with PR #730 under FreeBSD.

PS C:\Program Files\Oracle\VirtualBox> .\VBoxManage modifyvm "netbsd101vm" --usb-ohci on --usb-ehci off --usb-xhci off

Run log with the FX2HID default example with two bytes HID Input/Output report.

[mcuee@netbsdvm hidapitester]$ uname -a
NetBSD netbsdvm 10.1 NetBSD 10.1 (GENERIC) #0: Mon Dec 16 13:08:11 UTC 2024  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64

[mcuee@netbsdvm hidapitester]$ sudo ./hidapitester --list
0925/1234: CYPRESS - EZ-USB FX2 HID USBHIDIO
[mcuee@netbsdvm hidapitester]$ sudo ./hidapitester  --vidpid 0925:1234 --list-detail
0925/1234: CYPRESS - EZ-USB FX2 HID USBHIDIO
  vendorId:      0x0925
  productId:     0x1234
  usagePage:     0xFFA0
  usage:         0x0001
  serial_number:
  interface:     -1
  path: uhidev1

[mcuee@netbsdvm hidapitester]$ sudo ./hidapitester  --vidpid 0925:1234 --open --buflen 64 -l 3 --send-output 0,1,2  --read-input
Opening device, vid/pid: 0x0925/0x1234
Writing output report of 3-bytes...wrote -1 bytes:
 00 01 02
Reading up to 3-byte input report, 250 msec timeout...read 0 bytes:
Closing device

[mcuee@netbsdvm hidapitester]$ sudo usbdevs
addr 1: OHCI root hub, NetBSD
 addr 2: USB Tablet, VirtualBox
 addr 3: product 1234, vendor 0925

[mcuee@netbsdvm hidapitester]$ sudo usbdevs -v
Controller /dev/usb0:
addr 1: full speed, self powered, config 1, OHCI root hub(0x0000), NetBSD(0x0000), rev 1.00(0x0100)
 port 1 addr 2: full speed, power 100 mA, config 1, USB Tablet(0x0021), VirtualBox(0x80ee), rev 1.00(0x0100)
 port 2 addr 3: full speed, power 80 mA, config 1, product 1234(0x1234), vendor 0925(0x0925), rev 0.00(0x0000)
 port 3 powered
 port 4 powered
 port 5 powered
 port 6 powered
 port 7 powered
 port 8 powered
 port 9 powered
 port 10 powered
 port 11 powered
 port 12 powered

I will try a physical machine later, and using other generic USB HID device.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bsd FreeBSD, NetBSD, OpenBSD, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants