Composite HID device (Linux)


I am trying to configure my Apalis iMX6 Linux SOM to act as a Serial(CDC ACM)/Mass Storage/HID composite USB device.
I have configured the unit as a composite Serial and Mass Storage device using the USB Gadget ConfigFS.
However I am running into problems when trying to add the HID functionality.

When I try to create the HID device using ConfigFS, I get an error:-

root@apalis-imx6:/sys/kernel/config/usb_gadget/g1# mkdir functions/hid.usb0
mkdir: can't create directory 'functions/hid.usb0': No such file or directory

When I look at the USB gadget function drivers, it doesn’t appear there is a driver for HID present:-

root@apalis-imx6:/sys/kernel/config/usb_gadget/g1# ls /lib/modules/4.1.44-2.7.4+gb1555bf/kernel/drivers/usb/gadget/function/
u_ether.ko             usb_f_ecm_subset.ko    usb_f_ncm.ko           usb_f_ss_lb.ko
u_serial.ko            usb_f_eem.ko           usb_f_obex.ko
usb_f_acm.ko           usb_f_fs.ko            usb_f_rndis.ko
usb_f_ecm.ko           usb_f_mass_storage.ko  usb_f_serial.ko

How do I go about installing/adding HID support for ConfigFS?

I have read that FunctionFS can also be used to implement HID devices. Would FunctionFS be a better solution than ConfigFS for implementing the HID portion?

If so, is there any good examples on how to implement a HID device using FunctionFS? This would need to play nicely with the two existing ConfigFS devices (Serial and Mass Storage devices).

Thank you for your time.



Our kernel has not enabled HID support for ConfigFS by default. You have to rebuild a new kernel with CONFIG_USB_CONFIGFS_F_HID enabeld. You can either build the kernel and modules in a separate tree and install them to the rootfs or build a completely new image using OpenEmbedded.

Hi Stefan,

Thanks for the feedback!
I have built the Toradex Yocto project before, but I have never customized the build settings.
Are there any good tutorials on how to customize the Toradex Yocto project? The OpenEmbedded link you provide only talks about building the standard Toradex image.
When I grep the CONFIG_USB_CONFIGFS* options I find they are spread out through the project. So I am uncertain where to add the new setting.

Thanks for your time.




You can use the following command: bitbake virtual/kernel -c menuconfig to enable the HID Support.