Skip to content

Comments

feat: Add USB descriptor customization#758

Open
Braxt0n wants to merge 1 commit intosipeed:mainfrom
Braxt0n:feat/usb-descriptor-customization
Open

feat: Add USB descriptor customization#758
Braxt0n wants to merge 1 commit intosipeed:mainfrom
Braxt0n:feat/usb-descriptor-customization

Conversation

@Braxt0n
Copy link

@Braxt0n Braxt0n commented Feb 17, 2026

What this does

Right now, every NanoKVM shows up to the target machine as sipeed NanoKVM with VID 0x3346 / PID 0x1009. That makes it pretty obvious a KVM is plugged in. This PR adds a USB Descriptor section to Settings > Device that lets you change the manufacturer name, product name, serial number, VID, and PID to whatever you want.

There are 8 built-in presets (generic keyboard/mouse/composite/HID, plus Logitech K120, Logitech Mouse, Microsoft Keyboard, Dell KB216) or you can type in fully custom values. Changes take effect immediately — the target sees a brief USB reconnect, no NanoKVM reboot needed — and they survive reboots.

UI Screenshot

Screenshot 2026-02-17 at 6 49 03 PM

How it works under the hood

The backend reads and writes the Linux USB gadget ConfigFS files under /sys/kernel/config/usb_gadget/g0/. To apply changes it locks HID, unbinds the UDC, writes the new values, and rebinds — same pattern the existing virtual disk mount uses. Boot persistence follows the same approach already used for VID/PID overrides (/boot/usb.vid, /boot/usb.pid), extended to manufacturer, product, and serial.

What changed

  • 3 new API endpoints on /api/hid/usb-descriptor (get, set, restore defaults)
  • S03usbdev init script now reads /boot/usb.{manufacturer,product,serial} at startup
  • New settings UI component with presets, field validation, serial randomizer, and a confirmation modal for VID/PID changes
  • i18n keys added to all 24 locale files

Testing

Tested on hardware. Presets populate correctly, custom values apply and show up in lsusb on the target, VID/PID changes trigger the warning/confirmation flow, serial randomization works, restore defaults cleans everything up, and values persist across reboots.

Addresses #745
Addresses #574
Addresses #104

@Braxt0n Braxt0n force-pushed the feat/usb-descriptor-customization branch from 56654ab to 63d56e4 Compare February 18, 2026 02:17
@Braxt0n Braxt0n marked this pull request as ready for review February 18, 2026 02:51
@Braxt0n Braxt0n force-pushed the feat/usb-descriptor-customization branch 3 times, most recently from ede790b to 2552a1a Compare February 24, 2026 05:53
Allow users to change the USB device name, manufacturer, serial number,
VID, and PID as seen by the target host OS. Changes are applied live via
UDC unbind/rebind (brief USB reconnection) and persisted across reboots
via /boot/usb.* files.

- Backend: 3 new API endpoints (GET/SET/RESTORE) on /api/hid/usb-descriptor
  that read/write Linux USB gadget ConfigFS at /sys/kernel/config/usb_gadget/g0
- Frontend: USB Descriptor settings panel with preset profiles (generic and
  branded devices), custom input fields, serial randomizer, and VID/PID
  change confirmation
- Init: S03usbdev reads /boot/usb.{manufacturer,product,serial} at boot
- i18n: Translation keys added to all 24 locale files

Closes sipeed/NanoKVM-USB#8
@Braxt0n Braxt0n force-pushed the feat/usb-descriptor-customization branch from 2552a1a to cdf4cfb Compare February 24, 2026 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant