USB_TEMPLATE(4)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸŽ€ USB_TEMPLATE(4) β€” usb_template: USB device side templates πŸŽ€

okay so bestie, welcome to the Kernel Interfaces Manual page for usb_template β€” this is the USB device side templates manual, and it’s literally your cheat sheet for making a USB device-side driver behave like different gadgets. πŸ’–

πŸ’– NAME πŸ’–

usb_template β€” USB device side templates. iconic. no cap. ✨

✨ SYNOPSIS ✨

To compile this module into the kernel, place the following line in your kernel configuration file:

device usb_template

To load the module at boot time, place the following line in loader.conf(5):

usb_template_load="YES"

πŸ¦‹ DESCRIPTION πŸ¦‹

The usb_template module implements various USB templates that are needed when programming an USB device side driver. Think of it as the main character of your USB gadget setup. 🫢

A USB template consists of an USB device descriptor, one or more USB configuration descriptors, one or more USB interface descriptors, one or more USB endpoint descriptors, USB strings and additional USB descriptors. So it’s giving β€œwhole bundle,” not just a single descriptor. πŸ’…

USB templates are selected using the hw.usb.template sysctl and tunable, or by using the usbconfig(8) set_template subcommand. Changing the hw.usb.template sysctl triggers reenumeration by the USB host; changes to other sysctls may not be visible to the host until reenumeration is performed. that last bit is important, bestie β€” don’t assume the host sees your other sysctl changes until reenumeration happens. πŸ‘€

Available templates are:

  • 0 β€” USB Mass Storage, see cfumass(4)
  • 1 β€” CDC Ethernet, see cdce(4)
  • 2 β€” Media Transfer Protocol (MTP)
  • 3 β€” USB serial port, see umodem(4)
  • 4 β€” USB audio
  • 5 β€” USB keyboard
  • 6 β€” USB mouse
  • 7 β€” USB phone
  • 8 β€” CDC Ethernet and serial port
  • 9 β€” USB MIDI
  • 10 β€” CDC Ethernet, serial port, and storage
  • 11 β€” CDC Ethernet Emulation Model, see cdceem(4)

πŸŽ›οΈ SYSCTL VARIABLES πŸŽ›οΈ

The following variables are available as both sysctl(8) variables and loader(8) tunables:

  • hw.usb.template β€” currently selected template. Set it to -1 to make the device disappear from the USB host point of view. πŸ«₯
  • hw.usb.template_power β€” USB bus power consumption in mA at 5V. Must be between 0 and 500. Setting to 0 marks the device as self-powered. Defaults to 500mA. ⚑
  • hw.usb.templates.N β€” configuration for template number N.
    • hw.usb.templates.N.vendor_id β€” 16-bit vendor identifier (VID), usually assigned by USB-IF.
    • hw.usb.templates.N.product_id β€” 16-bit product identifier (PID).
    • hw.usb.templates.N.manufacturer β€” string containing human-readable manufacturer name.
    • hw.usb.templates.N.product β€” string containing human-readable product name.

πŸ‘€ SEE ALSO πŸ‘€

🌈 STANDARDS 🌈

The usb_template module complies to the USB 1.0, 2.0 and 3.0 standard. periodt. ⭐

🧚 HISTORY 🧚

The usb_template module was written by Hans Petter Selasky <hselasky@FreeBSD.org>. πŸ‘‘


xoxo πŸ’– β€” this is the Debian version, dated August 7, 2019, signing off from the USB_TEMPLATE(4) page. 🫢
πŸ“¦ where this page comes from