Thanks for bearing with me. Unfortunately, the documentation you mention doesn’t discuss the kernel config flags (unless I need to read between the lines). I think I found the flag I need from this post: CONFIG_USB_CONFIGFS_F_HID. I still tend to modify flags in GUI since I’m not 100% confident in what I’m doing. So I change two flags: device drivers → USB support → USB gadget support → USB functions configurable through configfs CONFIG_USB_CONFIGFS_F_HID (I turned it on) → HID function (I turned it on since it looks related)
After rebooting, I use the script you mention in another post to stop the device mode: “/opt/nvidia/l4t-usb-device-mode/nvidia nv-l4t-usb-device-mode-stop.sh”.
After that, I attempt to create a keyboard gadget device by using the command sequence that is based on this post, except for excluding rndis.usb0 related stuff (I assume I don’t need it), but with an addition of the keyboard protocol in report_desc:
modprobe libcomposite
mkdir g1
cd g1
echo 0x1d6b > idVendor
echo 0x0104 > idProduct
echo 0x0100 > bcdDevice
echo 0x0200 > bcdUSB
echo 0xEF > bDeviceClass
echo 0x02 > bDeviceSubClass
echo 0x01 > bDeviceProtocol
mkdir -p strings/0x409
echo "deadbeef00115599" > strings/0x409/serialnumber
echo "Something" > strings/0x409/manufacturer
echo "Something" > strings/0x409/product
mkdir -p functions/hid.usb0
echo 1 > functions/hid.usb0/protocol
echo 1 > functions/hid.usb0/subclass
echo 8 > functions/hid.usb0/report_length
echo -ne \\x05\\x01\\x09\\x06\\xa1\\x01\\x05\\x07\\x19\\xe0\\x29\\xe7\\x15\\x00\\x25\\x01\\x75\\x01\\x95\\x08\\x81\\x02\\x95\\x01\\x75\\x08\\x81\\x03\\x95\\x05\\x75\\x01\\x05\\x08\\x19\\x01\\x29\\x05\\x91\\x02\\x95\\x01\\x75\\x03\\x91\\x03\\x95\\x06\\x75\\x08\\x15\\x00\\x25\\x65\\x05\\x07\\x19\\x00\\x29\\x65\\x81\\x00\\xc0 > functions/hid.usb0/report_desc
mkdir -p functions/acm.usb0
mkdir -p functions/acm.usb1
mkdir -p functions/acm.usb2
mkdir -p functions/acm.usb3
mkdir -p configs/c.1
echo 250 > configs/c.1/MaxPower
ln -s functions/rndis.usb0 configs/c.1/
ln -s functions/hid.usb0 configs/c.1/
ln -s functions/acm.usb0 configs/c.1/
ln -s functions/acm.usb1 configs/c.1/
ln -s functions/acm.usb2 configs/c.1/
ln -s functions/acm.usb3 configs/c.1/
echo 1 > os_desc/use
echo 0xcd > os_desc/b_vendor_code
echo MSFT100 > os_desc/qw_sign
ln -s configs/c.1 os_desc
udevadm settle -t 5 || :
ls /sys/class/udc/ > UDC
When I connect the TX2 to my host Ubuntu PC, I notice that the following usb device showing up:
Bus 001 Device 005: ID 1d6b:0104 Linux Foundation Multifunction Composite Gadget
I assume I did at least smth right if I see the above.
Now I use the kernel documentation to test the device. I compile the code mentioned in the documentation (I compile it identical to this repo) and run hid_gadget_test /dev/hidg0 keyboard
expecting to be able to control the host PC through the TX2 keyboard, but the only thing I get is a standard printout on TX2 of what keyboard keys I can use and the following two lines:
recv report: 00
recv report: 00
Pressing any keys on the TX2’s keyboard doesn’t have any effect on the host PC.
How can I figure out what I’m missing?