simple HID keyboard gadget via configfs
Clone or download
Quentin Young
Quentin Young added context of script, and fixed path error in (ren…
…amed descriptor for script cleanliness)
Latest commit 7ed1a44 Dec 30, 2015


keyboard-gadget is a shell script that sets up a simple HID keyboard gadget via ConfigFS.


The script defines all the configurable data at the beginning; edit to suit your purposes. When you're satisfied, ensure all other gadget modules have been unloaded from the kernel and then:

# ./

This will configure the gadget and bind it to the system UDC driver, which must be set by you. It is one of the variables defined in the beginning of the script and must be the name of one of the special files in /sys/class/udc/.

After it is configured you can write HID reports to /dev/hidg<xx>, a device file created when the ConfigFS gadget is bound to the UDC driver (last line of the script). The host will read them at its leisure as per the USB spec.


  • ConfigFS support must be enabled in the kernel. This must be done at kernel build time. It's usually enabled by default, though.

  • HID support (f_hid) was added in kernel 3.19, so you need >= 3.19 to use ConfigFS to build HID gadgets (and subsequently use this script).