---
name: "usb_template"
section: "4"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/usb_template"
---

# usb\_template(4)

USB device side templates

## NAME

**usb\_template** – USB device side templates

## 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)](/loader.conf/5.md):

```
usb_template_load="YES"
```

## DESCRIPTION

The **usb\_template** module implements various USB templates that are needed when programming an USB device side driver. 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. USB templates are selected using the *hw.usb.template* sysctl and tunable, or by using the [usbconfig(8)](/usbconfig/8.md) **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.

Available templates are:

| | |
| --- | --- |
| *Value* | *Description* |
| 0 | USB Mass Storage, see |
| 1 | CDC Ethernet, see |
| 2 | Media Transfer Protocol (MTP) |
| 3 | USB serial port, see |
| 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 |

## SYSCTL VARIABLES

The following variables are available as both [sysctl(8)](/sysctl/8.md) variables and [loader(8)](/loader/8.md) tunables:

- *hw.usb.template*

  Currently selected template. Set 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

[cfumass(4)](/cfumass/4.md), [usb(4)](/usb/4.md), [usfs(4)](/usfs/4.md), [usbconfig(8)](/usbconfig/8.md)

## STANDARDS

The **usb\_template** module complies to the USB 1.0, 2.0 and 3.0 standard.

## HISTORY

The **usb\_template** module was written by Hans Petter Selasky ⟨*hselasky@FreeBSD.org*⟩.
