Skip to content

Add hidraw backend for FreeBSD#730

Open
aokblast wants to merge 4 commits into
libusb:masterfrom
aokblast:use_hid_raw
Open

Add hidraw backend for FreeBSD#730
aokblast wants to merge 4 commits into
libusb:masterfrom
aokblast:use_hid_raw

Conversation

@aokblast
Copy link
Copy Markdown

FreeBSD support hidraw in Kernel from 13.0.
By using libusb only, we can only see the HID device from usb. To address this, we implement hidraw backend for FreeBSD.

Just like Linux use libudev to handle usb specified HID stuff (like Manufacture), we use libusb to handle it.

Sponsored-by: FreeBSD Foundation

@aokblast
Copy link
Copy Markdown
Author

Currently, some stuff like the Report Descriptor parser and error registry routine are copied from Linux and I think they are platform independent. Can we create a common directory or hidraw directory in code then put them inside?

Have tested by the hidtest program.

@Youw Youw self-requested a review March 27, 2025 10:33
@Youw Youw added enhancement New feature or request bsd FreeBSD, NetBSD, OpenBSD, etc labels Mar 27, 2025
Comment thread freebsd/Makefile-manual
Comment thread libusb/Makefile.in Outdated
Comment thread src/CMakeLists.txt Outdated
Comment thread freebsd/CMakeLists.txt Outdated
Comment thread freebsd/hid.c Outdated
Comment thread freebsd/hid.c Outdated
Comment thread freebsd/hid.c Outdated
Copy link
Copy Markdown
Member

@Youw Youw left a comment

Choose a reason for hiding this comment

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

No more comments

@aokblast aokblast force-pushed the use_hid_raw branch 4 times, most recently from 49a7a62 to 6e7a25a Compare March 27, 2025 14:16
@aokblast
Copy link
Copy Markdown
Author

Thanks for @Youw your review:).

Then, What is your opinion about this?

Currently, some stuff like the Report Descriptor parser and error registry routine are copied from Linux and I think they are platform independent. Can we create a common directory or hidraw directory in code then put them inside?

Have tested by the hidtest program.

@Youw
Copy link
Copy Markdown
Member

Youw commented Mar 27, 2025

Thanks for @Youw your review:).

Then, What is your opinion about this?

Currently, some stuff like the Report Descriptor parser and error registry routine are copied from Linux and I think they are platform independent. Can we create a common directory or hidraw directory in code then put them inside?
Have tested by the hidtest program.

I thinjk that is a good idea, but I don't think it really is nesessary to do so in scope of this PR.
There are really lots of stuff which I'd like to share among beckends, and I think it is going to be some refactoring after all.

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Mar 28, 2025

Nice. This will address the following issue.

@aokblast
Copy link
Copy Markdown
Author

Oops. I forget we have udev-devd stuff. Maybe we should use udev also?

@Youw
Copy link
Copy Markdown
Member

Youw commented Mar 28, 2025

Oops. I forget we have udev-devd stuff. Maybe we should use udev also?

I lost context here. What for? Seem like you have all the functionality implemented already. Aren't you?

@aokblast
Copy link
Copy Markdown
Author

Oops. I forget we have udev-devd stuff. Maybe we should use udev also?

I lost context here. What for? Seem like you have all the functionality implemented already. Aren't you?

Yes, all functionality is fully implemented. I am just thinking if we should use libudev make hidapi more portable.

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Mar 30, 2025

First test under FreeBSD 14.1 Release, under a physical machine (Chuwi mini PC, Intel J4125 CPU, 8GB RAM, 256GB SSD)

There are a few compiler warnings.

mcuee@freebsd14:~/build/hidapi_pr730 $ uname -a
FreeBSD freebsd14 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64

mcuee@freebsd14:~/build/hidapi_pr730 $ cc -v
FreeBSD clang version 18.1.5 (https://github.com/llvm/llvm-project.git llvmorg-18.1.5-0-g617a15a9eac9)
Target: x86_64-unknown-freebsd14.1
Thread model: posix
InstalledDir: /usr/bin

mcuee@freebsd14:~/build/hidapi_pr730 $ make
make  all-recursive
Making all in freebsd
  CC       hid.lo
hid.c:396:24: warning: passing 'uint8_t[255]' (aka 'unsigned char[255]') to parameter of type 'const char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Wpointer-sign]
  396 |                 mbstowcs(namebuffer, buffer, sizeof(namebuffer));
      |                                      ^~~~~~
/usr/include/stdlib.h:107:64: note: passing argument to parameter here
  107 | size_t   mbstowcs(wchar_t * __restrict , const char * __restrict, size_t);
      |                                                                 ^
hid.c:603:1: warning: non-void function does not return a value [-Wreturn-type]
  603 | }
      | ^
hid.c:937:7: warning: passing 'const char *' to parameter of type 'void *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
  937 |         free(dev->device_path);
      |              ^~~~~~~~~~~~~~~~
/usr/include/stdlib.h:101:18: note: passing argument to parameter here
  101 | void     free(void *);
      |                     ^
3 warnings generated.
  CCLD     libhidapi-hidraw.la
Making all in libusb
  CC       hid.lo
  CCLD     libhidapi-libusb.la
Making all in hidtest
  CC       test.o
  CCLD     hidtest-libusb
  CCLD     hidtest-hidraw

@aokblast
Copy link
Copy Markdown
Author

Fix it:). Forget to fix the warning.

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Mar 30, 2025

Somehow hidtest-hidraw will seg fault with the Microchip Simple HID example.

mcuee@freebsd14:~/build/hidapi_pr730 $ sudo ./hidtest/hidtest-hidraw
hidapi test/example tool. Compiled with hidapi version 0.15.0, runtime version 0.15.0.
Compile-time version matches runtime version of hidapi.

Segmentation fault
mcuee@freebsd14:~/build/hidapi_pr730 $ sudo ./hidtest/hidtest-libusb
hidapi test/example tool. Compiled with hidapi version 0.15.0, runtime version 0.15.0.
Compile-time version matches runtime version of hidapi.

Device Found
  type: 04f2 0760
  path: 0-3:1.0
  serial_number: (null)
  Manufacturer: Chicony
  Product:      USB Keyboard
  Release:      100
  Interface:    0
  Usage (page): 0x0 (0x0)
  Bus type: 1 (USB)

  Report Descriptor: (65 bytes)
0x05, 0x01, 0x09, 0x06, 0xa1, 0x01, 0x05, 0x07, 0x19, 0xe0, 
0x29, 0xe7, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 
0x81, 0x02, 0x95, 0x01, 0x75, 0x08, 0x81, 0x01, 0x95, 0x03, 
0x75, 0x01, 0x05, 0x08, 0x19, 0x01, 0x29, 0x03, 0x91, 0x02, 
0x95, 0x05, 0x75, 0x01, 0x91, 0x01, 0x95, 0x06, 0x75, 0x08, 
0x15, 0x00, 0x26, 0xff, 0x00, 0x05, 0x07, 0x19, 0x00, 0x2a, 
0xff, 0x00, 0x81, 0x00, 0xc0, 
Device Found
  type: 04f2 0760
  path: 0-3:1.1
  serial_number: (null)
  Manufacturer: Chicony
  Product:      USB Keyboard
  Release:      100
  Interface:    1
  Usage (page): 0x0 (0x0)
  Bus type: 1 (USB)

  Report Descriptor: (127 bytes)
0x06, 0x01, 0x00, 0x09, 0x80, 0xa1, 0x01, 0x85, 0x01, 0x19, 
0x81, 0x29, 0x83, 0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75, 
0x01, 0x81, 0x02, 0x95, 0x01, 0x75, 0x05, 0x81, 0x01, 0xc0, 
0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x15, 0x00, 
0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 0x19, 0xb5, 0x29, 0xb8, 
0x09, 0xcd, 0x09, 0xe2, 0x09, 0xe9, 0x09, 0xea, 0x81, 0x02, 
0x0a, 0x83, 0x01, 0x0a, 0x8a, 0x01, 0x0a, 0x92, 0x01, 0x0a, 
0x94, 0x01, 0x0a, 0x21, 0x02, 0x1a, 0x23, 0x02, 0x2a, 0x25, 
0x02, 0x81, 0x02, 0x0a, 0x26, 0x02, 0x0a, 0x27, 0x02, 0x0a, 
0x2a, 0x02, 0x95, 0x03, 0x81, 0x02, 0x95, 0x05, 0x81, 0x01, 
0xc0, 0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x02, 
0x25, 0x01, 0x15, 0x00, 0x75, 0x01, 0x95, 0x08, 0x1a, 0xf1, 
0x00, 0x2a, 0xf8, 0x00, 0x81, 0x02, 0xc0, 
Device Found
  type: 1ea7 0064
  path: 0-4:1.0
  serial_number: (null)
  Manufacturer: (null)
  Product:      2.4G Mouse
  Release:      200
  Interface:    0
  Usage (page): 0x0 (0x0)
  Bus type: 1 (USB)

  Report Descriptor: (105 bytes)
0x06, 0xb5, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0xb5, 0x09, 
0x02, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x07, 
0x81, 0x02, 0x09, 0x02, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 
0x08, 0x95, 0x07, 0x91, 0x02, 0xc0, 0x05, 0x01, 0x09, 0x02, 
0xa1, 0x01, 0x85, 0x02, 0x09, 0x01, 0xa1, 0x00, 0x05, 0x09, 
0x19, 0x01, 0x29, 0x08, 0x15, 0x00, 0x25, 0x01, 0x95, 0x08, 
0x75, 0x01, 0x81, 0x02, 0x05, 0x01, 0x09, 0x30, 0x09, 0x31, 
0x16, 0x01, 0xf8, 0x26, 0xff, 0x07, 0x75, 0x0c, 0x95, 0x02, 
0x81, 0x06, 0x09, 0x38, 0x15, 0x81, 0x25, 0x7f, 0x75, 0x08, 
0x95, 0x01, 0x81, 0x06, 0x05, 0x0c, 0x0a, 0x38, 0x02, 0x95, 
0x01, 0x81, 0x06, 0xc0, 0xc0, 
Device Found
  type: 04d8 003f
  path: 0-2:1.0
  serial_number: (null)
  Manufacturer: Microchip Technology Inc.
  Product:      Simple HID Device Demo
  Release:      2
  Interface:    0
  Usage (page): 0x0 (0x0)
  Bus type: 1 (USB)

  Report Descriptor: (28 bytes)
0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x19, 0x01, 0x29, 
0x40, 0x15, 0x01, 0x25, 0x40, 0x75, 0x08, 0x95, 0x40, 0x81, 
0x00, 0x19, 0x01, 0x29, 0x40, 0x91, 0x00, 0xc0, 
Manufacturer String: Microchip Technology Inc.
Product String: Simple HID Device Demo
Unable to read serial number string
Serial Number String: (0) 
  Report Descriptor: (28 bytes)
0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x19, 0x01, 0x29, 
0x40, 0x15, 0x01, 0x25, 0x40, 0x75, 0x08, 0x95, 0x40, 0x81, 
0x00, 0x19, 0x01, 0x29, 0x40, 0x91, 0x00, 0xc0, 
Device Found
  type: 04d8 003f
  path: 0-2:1.0
  serial_number: (null)
  Manufacturer: Microchip Technology Inc.
  Product:      Simple HID Device Demo
  Release:      2
  Interface:    0
  Usage (page): 0x1 (0xff00)
  Bus type: 1 (USB)

Indexed String 1: Microchip Technology Inc.
Unable to send a feature report: hid_error is not implemented yet
Unable to get a feature report: hid_error is not implemented yet
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
read() timeout

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Mar 30, 2025

Fix it:). Forget to fix the warning.

Thanks. The compiler warnings are gone.

The Segfault issue is still there though.

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Apr 27, 2026

I am stilll using VirtualBox VM under Windows 11 for this test, but I have switched the VM back to the default USB configuration (OHCI + EHCI).

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

Then I use my trusted modified Generic PIC USB HID example (modified from the Lakeview Research Generic HID example to add Input/Output/Feature report IDs). It is a Full Speed USB device.

It was mentioned in the following discussion.
#590

FW source code and old libusb test codes are here.
https://github.com/mcuee/picusb/tree/master/lvr_genhid_mod

The device works well under Windows.

PS C:\work\libusb\hidapitester> .\hidapitester_git_winapi.exe --vidpid 0925:7001 --open --buflen 64 -l 3 --send-output 2,1,2  --read-input
Opening device, vid/pid: 0x0925/0x7001
Writing output report of 3-bytes...wrote 3 bytes:
 02 01 02
Reading up to 3-byte input report, 250 msec timeout...read 3 bytes:
 01 01 02
Closing device

PS C:\work\libusb\hidapitester> .\hidapitester_git_winapi.exe --vidpid 0925:7001 --open --buflen 64 -l 3 --send-feature 3,7,8  --read-feature 4
Opening device, vid/pid: 0x0925/0x7001
Writing 3-byte feature report...wrote 3 bytes:
 03 07 08
Reading 3-byte feature report, report_id 4...read 3 bytes:
 04 07 08
Closing device

It also works fine with this PR under FreeBSD VM.

mcuee@freebsdvm:~/build/hidapitester $ sudo ./hidapitester_pr730_hidraw_new  --vidpid 0925:7001 --open --buflen 64 -l 3 --send-output 2,5,6  --read-input
Opening device, vid/pid: 0x0925/0x7001
Writing output report of 3-bytes...wrote 3 bytes:
 02 05 06
Reading up to 3-byte input report, 250 msec timeout...read 3 bytes:
 01 05 06
Closing device

mcuee@freebsdvm:~/build/hidapitester $ sudo ./hidapitester_pr730_hidraw_new  --vidpid 0925:7001 --open --buflen 64 -l 3 --send-output 2,5,6  --read-input
Opening device, vid/pid: 0x0925/0x7001
Writing output report of 3-bytes...wrote 3 bytes:
 02 05 06
Reading up to 3-byte input report, 250 msec timeout...read 3 bytes:
 01 05 06
Closing device

mcuee@freebsdvm:~/build/hidapitester $ sudo ./hidapitester_pr730_hidraw_new  --open --buflen 64 -l 3 --send-feature 3,5,6  --read-feature 4
Opening device, vid/pid:0x0000/0x0000, usagePage/usage: 0/0
Device opened
Writing 3-byte feature report...wrote 3 bytes:
 03 05 06
Reading 3-byte feature report, report_id 4...read 3 bytes:
 04 05 06
Closing device

mcuee@freebsdvm:~/build/hidapitester $ sudo ./hidapitester_pr730_hidraw_new  --open --buflen 64 -l 3 --send-feature 3,5,6  --read-feature 4
Opening device, vid/pid:0x0000/0x0000, usagePage/usage: 0/0
Device opened
Writing 3-byte feature report...wrote 3 bytes:
 03 05 06
Reading 3-byte feature report, report_id 4...read 3 bytes:
 04 05 06
Closing device

mcuee@freebsdvm:~/build/hidapitester $ sudo lsusb -d 0925:7001 -vvv

Bus /dev/usb Device /dev/ugen0.2: ID 0925:7001 Lakeview Research
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0         8
  idVendor           0x0925 Lakeview Research
  idProduct          0x7001
  bcdDevice            0.01
  iManufacturer           1 Lakeview Research
  iProduct                2 Generic HID
  iSerial                 0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           41
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0xc0
      Self Powered
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 No Subclass
      bInterfaceProtocol      0 None
      iInterface              0
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      45
          Report Descriptor: (length is 45)
            Item(Global): Usage Page, data= [ 0x00 0xff ] 65280
                            (null)
            Item(Local ): Usage, data= [ 0x01 ] 1
                            (null)
            Item(Main  ): Collection, data= [ 0x01 ] 1
                            Application
            Item(Global): Logical Minimum, data= [ 0x00 ] 0
            Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
            Item(Global): Report Size, data= [ 0x08 ] 8
            Item(Global): Report Count, data= [ 0x02 ] 2
            Item(Global): Report ID, data= [ 0x01 ] 1
            Item(Local ): Usage, data= [ 0x00 ] 0
                            (null)
            Item(Main  ): Input, data= [ 0x02 0x01 ] 258
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Buffered Bytes
            Item(Global): Report ID, data= [ 0x02 ] 2
            Item(Local ): Usage, data= [ 0x00 ] 0
                            (null)
            Item(Main  ): Output, data= [ 0x02 0x01 ] 258
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Buffered Bytes
            Item(Global): Report ID, data= [ 0x03 ] 3
            Item(Local ): Usage, data= [ 0x00 ] 0
                            (null)
            Item(Main  ): Feature, data= [ 0x02 0x01 ] 258
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Buffered Bytes
            Item(Global): Report ID, data= [ 0x04 ] 4
            Item(Local ): Usage, data= [ 0x00 ] 0
                            (null)
            Item(Main  ): Feature, data= [ 0x02 0x01 ] 258
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Buffered Bytes
            Item(Main  ): End Collection, data=none
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
can't get device qualifier: Input/output error
can't get debug descriptor: Input/output error
Device Status:     0x0001
  Self Powered

@aokblast
Copy link
Copy Markdown
Author

EZ-USB FX2LP

Just buy a EZ-USB FX2LP. I spend two days on configuring stm32h750 + usb3320 and it fails. I think there are some design flaws on stm32h750 as some pin output doesn't follow the ulpi standard.

See: https://community.st.com/t5/stm32-mcus-embedded-software/stm32h750-usb3300-no-signals-on-ulpi/td-p/225293?fbclid=IwY2xjawRdSk5leHRuA2FlbQIxMABicmlkETF1eVg0M2d2OENpV1lWdnpjc3J0YwZhcHBfaWQQMjIyMDM5MTc4ODIwMDg5MgABHr4fjotlcri4aRfLeR3qxxa3_rOWLG8XdiaZHQXLlSejiReV3U-u7F052oj-_aem_DLqIO7VIk_LDjl6YhWkqEw

@aokblast
Copy link
Copy Markdown
Author

I am stilll using VirtualBox VM under Windows 11 for this test, but I have switched the VM back to the default USB configuration (OHCI + EHCI).

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

Then I use my trusted modified Generic PIC USB HID example (modified from the Lakeview Research Generic HID example to add Input/Output/Feature report IDs). It is a Full Speed USB device.

It was mentioned in the following discussion. #590

FW source code and old libusb test codes are here. https://github.com/mcuee/picusb/tree/master/lvr_genhid_mod

The device works well under Windows.

PS C:\work\libusb\hidapitester> .\hidapitester_git_winapi.exe --vidpid 0925:7001 --open --buflen 64 -l 3 --send-output 2,1,2  --read-input
Opening device, vid/pid: 0x0925/0x7001
Writing output report of 3-bytes...wrote 3 bytes:
 02 01 02
Reading up to 3-byte input report, 250 msec timeout...read 3 bytes:
 01 01 02
Closing device

PS C:\work\libusb\hidapitester> .\hidapitester_git_winapi.exe --vidpid 0925:7001 --open --buflen 64 -l 3 --send-feature 3,7,8  --read-feature 4
Opening device, vid/pid: 0x0925/0x7001
Writing 3-byte feature report...wrote 3 bytes:
 03 07 08
Reading 3-byte feature report, report_id 4...read 3 bytes:
 04 07 08
Closing device

It also works fine with this PR under FreeBSD VM.

mcuee@freebsdvm:~/build/hidapitester $ sudo ./hidapitester_pr730_hidraw_new  --vidpid 0925:7001 --open --buflen 64 -l 3 --send-output 2,5,6  --read-input
Opening device, vid/pid: 0x0925/0x7001
Writing output report of 3-bytes...wrote 3 bytes:
 02 05 06
Reading up to 3-byte input report, 250 msec timeout...read 3 bytes:
 01 05 06
Closing device

mcuee@freebsdvm:~/build/hidapitester $ sudo ./hidapitester_pr730_hidraw_new  --vidpid 0925:7001 --open --buflen 64 -l 3 --send-output 2,5,6  --read-input
Opening device, vid/pid: 0x0925/0x7001
Writing output report of 3-bytes...wrote 3 bytes:
 02 05 06
Reading up to 3-byte input report, 250 msec timeout...read 3 bytes:
 01 05 06
Closing device

mcuee@freebsdvm:~/build/hidapitester $ sudo ./hidapitester_pr730_hidraw_new  --open --buflen 64 -l 3 --send-feature 3,5,6  --read-feature 4
Opening device, vid/pid:0x0000/0x0000, usagePage/usage: 0/0
Device opened
Writing 3-byte feature report...wrote 3 bytes:
 03 05 06
Reading 3-byte feature report, report_id 4...read 3 bytes:
 04 05 06
Closing device

mcuee@freebsdvm:~/build/hidapitester $ sudo ./hidapitester_pr730_hidraw_new  --open --buflen 64 -l 3 --send-feature 3,5,6  --read-feature 4
Opening device, vid/pid:0x0000/0x0000, usagePage/usage: 0/0
Device opened
Writing 3-byte feature report...wrote 3 bytes:
 03 05 06
Reading 3-byte feature report, report_id 4...read 3 bytes:
 04 05 06
Closing device

mcuee@freebsdvm:~/build/hidapitester $ sudo lsusb -d 0925:7001 -vvv

Bus /dev/usb Device /dev/ugen0.2: ID 0925:7001 Lakeview Research
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0         8
  idVendor           0x0925 Lakeview Research
  idProduct          0x7001
  bcdDevice            0.01
  iManufacturer           1 Lakeview Research
  iProduct                2 Generic HID
  iSerial                 0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           41
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0xc0
      Self Powered
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 No Subclass
      bInterfaceProtocol      0 None
      iInterface              0
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      45
          Report Descriptor: (length is 45)
            Item(Global): Usage Page, data= [ 0x00 0xff ] 65280
                            (null)
            Item(Local ): Usage, data= [ 0x01 ] 1
                            (null)
            Item(Main  ): Collection, data= [ 0x01 ] 1
                            Application
            Item(Global): Logical Minimum, data= [ 0x00 ] 0
            Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
            Item(Global): Report Size, data= [ 0x08 ] 8
            Item(Global): Report Count, data= [ 0x02 ] 2
            Item(Global): Report ID, data= [ 0x01 ] 1
            Item(Local ): Usage, data= [ 0x00 ] 0
                            (null)
            Item(Main  ): Input, data= [ 0x02 0x01 ] 258
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Buffered Bytes
            Item(Global): Report ID, data= [ 0x02 ] 2
            Item(Local ): Usage, data= [ 0x00 ] 0
                            (null)
            Item(Main  ): Output, data= [ 0x02 0x01 ] 258
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Buffered Bytes
            Item(Global): Report ID, data= [ 0x03 ] 3
            Item(Local ): Usage, data= [ 0x00 ] 0
                            (null)
            Item(Main  ): Feature, data= [ 0x02 0x01 ] 258
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Buffered Bytes
            Item(Global): Report ID, data= [ 0x04 ] 4
            Item(Local ): Usage, data= [ 0x00 ] 0
                            (null)
            Item(Main  ): Feature, data= [ 0x02 0x01 ] 258
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Buffered Bytes
            Item(Main  ): End Collection, data=none
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
can't get device qualifier: Input/output error
can't get debug descriptor: Input/output error
Device Status:     0x0001
  Self Powered

Hi,

I received the EXUSB FX2 last week. I spent the weekend setting up the toolchain, since the SDK is very outdated and Infineon no longer maintains or provides the download link. I’ve fixed the firmware now.

The issue turned out to be quite simple: you forgot to arm EP1OUT the first time. To fix it, add:

EP1OUTBC = anynumber;

at the end of TD_Init().

sudo   ./hidapitester   --open-path /dev/hidraw4 --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. path: /dev/hidraw4
Writing output report of 129-bytes...wrote 129 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 128 bytes:
 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
 00

@aokblast
Copy link
Copy Markdown
Author

aokblast commented May 19, 2026

@mcuee I also did some experiments. FX2 is packet-based, which means if you set MPS = 64 and the report size = 128, it will not work correctly when the device wants to send a short packet (< 64 bytes). The reason is the following:

xHCI assumes there will be 2 packets (128 / 64), so it sends the following sequence to the device:

IN token with size = 64
Device replies with 64 bytes
Host ACK
Another IN token with size = 64
Device replies with another 64 bytes
Host ACK

This completes a full cycle for receiving a 128-byte report from the device.

However, if the device sends a short packet, the sequence becomes:

IN token with size = 64
Device replies with a short packet (== 64 bytes)
Host ACK
Another IN token with size = 64
Device never replies, so xHCI never completes the transfer

As a result, the receive operation eventually hangs and fails.

@mcuee
Copy link
Copy Markdown
Member

mcuee commented May 19, 2026

@aokblast

Thanks a lot for the updates. Let me digest and check again.

The issue turned out to be quite simple: you forgot to arm EP1OUT the first time

You are absolute right here. I have seen strange issues previously with random data for the initial run. I am not the author of the origina FX2HID code. The original auther is Jan Axelson (author of the book "USB Complete").

I also did some experiments. FX2 is packet-based, which means if you set MPS = 64 and the report size = 128, it will not work correctly when the device wants to send a short packet (< 64 bytes).

I am not so sure about this one. Different OS may be different as well. Let me check.

@mcuee
Copy link
Copy Markdown
Member

mcuee commented May 19, 2026

@aokblast

I have some modified EZ-USB FX2HID firmware as well. I am not a programmer myself, please check as well. Thanks.

Modified version of the fx2hid firmware mods (with bug fixes in TD_Init function)
fx2hid_64bytes.zip
fx2hid_128bytes_report.zip
fx2hid_512bytes_packet.zip
fx2hid_512bytes_report.zip
fx2hid_1024bytes_packet.zip

Common files from Cypress
Target.zip

@mcuee
Copy link
Copy Markdown
Member

mcuee commented May 19, 2026

@aokblast

Infineon/Cypress CY3689 and CY3684 download links (you need to register). The clones are mostly copy of CY3689.
https://www.infineon.com/products/universal-serial-bus/usb-2-0-peripheral-controllers/ez-usb-fx2lp-fx2g2-usb-2-0

Screenshot 2026-05-19 170425

@mcuee
Copy link
Copy Markdown
Member

mcuee commented May 21, 2026

xHCI assumes there will be 2 packets (128 / 64), so it sends the following sequence to the device:

@aokblast

BTW, EZ-USB FX2LP is a High Speed USB device, do you mean to say EHCI and not xHCI?

I also did some experiments. FX2 is packet-based, which means if you set MPS = 64 and the report size = 128, it will not work correctly when the device wants to send a short packet (< 64 bytes).

Another thing, I have tested different firmwares. So you may get confused here.

  1. Some of the firwares only have 2 bytes HID reports, like the original FX2HID example (High Speed USB, which also works under Full Speed USB).
  2. Some of the firmwars only have 3 bytes HID reports, like the following USB PIC example (Full Speed USB). I have not tested the later mod with 32Bytes/64Bytes reports.
    https://github.com/mcuee/picusb/tree/master/lvr_genhid_mod
  3. Then I have the modified FX2HID with 64Bytes/128Bytes/512Bytes/1024Bytes firmware. But the 512B/1024B firmware are not well tested across different OS. There may be more bugs inside.

I will carry out tests under FreeBSD over the weekend.

@aokblast
Copy link
Copy Markdown
Author

aokblast commented May 21, 2026

xHCI assumes there will be 2 packets (128 / 64), so it sends the following sequence to the device:

@aokblast

BTW, EZ-USB FX2LP is a High Speed USB device, do you mean to say EHCI and not xHCI?

USB standard is a little bit confusing. You actually attached a USB 2.0 device to xHCI. But since the xHCI controller is a xHCI controller + eHCI controller internally, so...

I also did some experiments. FX2 is packet-based, which means if you set MPS = 64 and the report size = 128, it will not work correctly when the device wants to send a short packet (< 64 bytes).

Another thing, I have tested different firmwares. So you may get confused here.

  1. Some of the firwares only have 2 bytes HID reports, like the original FX2HID example (High Speed USB, which also works under Full Speed USB).
  2. Some of the firmwars only have 3 bytes HID reports, like the following USB PIC example (Full Speed USB). I have not tested the later mod with 32Bytes/64Bytes reports.
    https://github.com/mcuee/picusb/tree/master/lvr_genhid_mod
  3. Then I have the modified FX2HID with 64Bytes/128Bytes/512Bytes/1024Bytes firmware. But the 512B/1024B firmware are not well tested across different OS. There may be more bugs inside.

I will carry out tests under FreeBSD over the weekend.

I found a bug in the FreeBSD xHCI implementation that cause the data only receive bi-transfer in <= 64 byte case. Please also apply this patch while you are testing. https://reviews.freebsd.org/D57146.
I have tried send 64 bytes (report size is 64), send 63 bytes (report size is 64), send 128 bytes (report size is 128), send 63 bytes (report size is 128).

Send 64 bytes (report size is 128) can not be resolved as the problem I have explain previously. There is a flag in libusb call LIBUSB_TRANSFER_ADD_ZERO_PACKET that can solve this problem.

@aokblast
Copy link
Copy Markdown
Author

aokblast commented May 22, 2026

@mcuee 3 bytes also work in both 64 and 128 bytes report. 2 bytes won't work as it is a hard limit in FreeBSD hidraw interface. If you need a ISO image to test, I can build one for you with my patch.

@mcuee
Copy link
Copy Markdown
Member

mcuee commented May 22, 2026

@mcuee 3 bytes also work in both 64 and 128 bytes report. 2 bytes won't work as it is a hard limit in FreeBSD hidraw interface. If you need a ISO image to test, I can build one for you with my patch.

@aokblast
An ISO image (x86_64) will be great. Thanks.

@aokblast
Copy link
Copy Markdown
Author

@mcuee 3 bytes also work in both 64 and 128 bytes report. 2 bytes won't work as it is a hard limit in FreeBSD hidraw interface. If you need a ISO image to test, I can build one for you with my patch.

@aokblast An ISO image (x86_64) will be great. Thanks.

Ok, will build one later. I just merge my patch upstream and need times to build world and kernel.

@aokblast
Copy link
Copy Markdown
Author

@mcuee 3 bytes also work in both 64 and 128 bytes report. 2 bytes won't work as it is a hard limit in FreeBSD hidraw interface. If you need a ISO image to test, I can build one for you with my patch.

@aokblast An ISO image (x86_64) will be great. Thanks.

Ok, will build one later. I just merge my patch upstream and need times to build world and kernel.

Hi, I just send a link to your email. Please take a look.

@mcuee
Copy link
Copy Markdown
Member

mcuee commented May 23, 2026

Thanks a lot for the updates. Let me digest and check again.

The issue turned out to be quite simple: you forgot to arm EP1OUT the first time

You are absolute right here. I have seen strange issues previously with random data for the initial run. I am not the author of the origina FX2HID code. The original auther is Jan Axelson (author of the book "USB Complete").

@aokblast

Great, now this PR works perfectly under your FreeBSD 16.0 Current build (tested with VirtualBox VM first).

mcuee@freebsd16vm:~/build/hidapitester $  ./hidapitester_hidraw_pr730 --open-path /dev/hidraw0 --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,1
06,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. path: /dev/hidraw0
Writing output report of 129-bytes...wrote 129 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 128 bytes:
 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
 00
Closing device

@mcuee
Copy link
Copy Markdown
Member

mcuee commented May 23, 2026

PR #728 also works fine and hidapi git has the issue with #274.

mcuee@freebsd16vm:~/build/hidapitester $  ./hidapitester_libusb_pr728 --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,5
,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 129 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 128 bytes:
 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
 00
Closing device

mcuee@freebsd16vm:~/build/hidapitester $  ./hidapitester_libusb_git --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,
9,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,1
6,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 129 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 64 bytes:
 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
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00
Closing device

@mcuee
Copy link
Copy Markdown
Member

mcuee commented May 23, 2026

@mcuee 3 bytes also work in both 64 and 128 bytes report. 2 bytes won't work as it is a hard limit in FreeBSD hidraw interface. If you need a ISO image to test, I can build one for you with my patch.

Indeed 2 bytes will not work with FreeBSD hidraw backend. libusb backend works fine (git or PR #728)

I will carry out more testing later today and tomorrow.

mcuee@freebsd16vm:~/build/hidapitester $ sudo ./hidapitester_libusb_git --vidpid 0925:1234 --open --buflen 256 -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

mcuee@freebsd16vm:~/build/hidapitester $ sudo ./hidapitester_libusb_pr728 --vidpid 0925:1234 --open --buflen 256 -l 3 --send-output 0,1,2 --read-inp
ut
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

mcuee@freebsd16vm:~/build/hidapitester $ sudo ./hidapitester_hidraw_pr730  --vidpid 0925:1234 --open --buflen 256 -l 3 --send-output 0,1,2 --read-in
put
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 0 bytes:
 00 00 00
Closing device

@aokblast
Copy link
Copy Markdown
Author

Thanks a lot for the updates. Let me digest and check again.

The issue turned out to be quite simple: you forgot to arm EP1OUT the first time

You are absolute right here. I have seen strange issues previously with random data for the initial run. I am not the author of the origina FX2HID code. The original auther is Jan Axelson (author of the book "USB Complete").

@aokblast

Great, now this PR works perfectly under your FreeBSD 16.0 Current build (tested with VirtualBox VM first).

mcuee@freebsd16vm:~/build/hidapitester $  ./hidapitester_hidraw_pr730 --open-path /dev/hidraw0 --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,1
06,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. path: /dev/hidraw0
Writing output report of 129-bytes...wrote 129 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 128 bytes:
 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
 00
Closing device

Thanks! Hope we can merge this patch ASAP:).

@mcuee
Copy link
Copy Markdown
Member

mcuee commented May 24, 2026

Going back to the Generic HID PIC FW example (Full Speed USB device), there are no issues.

mcuee@freebsd16vm:~/build/hidapitester $ uname -a
FreeBSD freebsd16vm 16.0-CURRENT FreeBSD 16.0-CURRENT #0 main-n286042-28d85db46b48-dirty: Fri May 22 16:36:08 CST 2026     blast@blast-devserv:/usr/obj/usr/src/amd64.amd64/sys/GENERIC-NODEBUG amd64

mcuee@freebsd16vm:~/build/hidapitester $ sudo ./hidapitester_hidraw_pr730  --vidpid 0925:7001 --open --buflen 64 -l 3 --send-output 2,3,4,5 --read-input
Opening device, vid/pid: 0x0925/0x7001
Writing output report of 3-bytes...wrote 3 bytes:
 02 03 04
Reading up to 3-byte input report, 250 msec timeout...read 3 bytes:
 01 03 04
Closing device

mcuee@freebsd16vm:~/build/hidapitester $ sudo ./hidapitester_hidraw_pr730 --vidpid 0925:7001 --open --buflen 64 -l 3 --send-feature 3,3,4,5 --read-feature 4
Opening device, vid/pid: 0x0925/0x7001
Writing 3-byte feature report...wrote 3 bytes:
 03 03 04
Reading 3-byte feature report, report_id 4...read 3 bytes:
 04 03 04
Closing device

@mcuee
Copy link
Copy Markdown
Member

mcuee commented May 24, 2026

Going to the original Generic PIC FW (unmodified, from Jan Axelson, Full Speed USB device) with two bytes reoort, it also works.

mcuee@freebsd16vm:~/build/hidapitester $ sudo ./hidapitester_hidraw_pr730  --vidpid 0925:7001 --open --buflen 64 -l 3 --send-output 0,1,2 --read-input
Opening device, vid/pid: 0x0925/0x7001
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

mcuee@freebsd16vm:~/build/hidapitester $ sudo ./hidapitester_libusb_pr728 --vidpid 0925:7001 --open --buflen 64 -l 3 --send-output 0,1,2 --read-inpu
t
Opening device, vid/pid: 0x0925/0x7001
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

@mcuee
Copy link
Copy Markdown
Member

mcuee commented May 24, 2026

@aokblast
I have approved this PR.

@Youw
Please review and I think this is a good addition to hidapi under FreeBSD. Since this is a new backend, it does not affect much other codes. Issues specific to this backend can be fixed within this backend.

@mcuee mcuee requested review from Youw, mcuee and wulf7 May 24, 2026 11:51
@mcuee
Copy link
Copy Markdown
Member

mcuee commented May 24, 2026

@wulf7

Please re-review as well. Thanks.

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

Labels

bsd FreeBSD, NetBSD, OpenBSD, etc enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants