TinyPilot Mt-viki Switch Issues
Hi,
I've purchased a Mt-viki 4 Port HDMI switch for use with TinyPilot, and while I understand that there is no official support I thought I'd see if you could offer any insights into the cause of this particular problem.
When I plug the USB-C cable from the TinyPilot's Data port to the KVM's Keyboard or Mouse port, I receive the following logs from dmesg
:
[64841.986923] dwc2 fe980000.usb: new device is high-speed
[64842.006823] dwc2 fe980000.usb: new device is high-speed
[64842.214823] dwc2 fe980000.usb: new device is high-speed
[64842.426825] dwc2 fe980000.usb: new device is high-speed
[64842.634873] dwc2 fe980000.usb: new device is high-speed
[64842.847921] dwc2 fe980000.usb: new device is high-speed
[64842.870864] dwc2 fe980000.usb: new device is high-speed
[64843.078864] dwc2 fe980000.usb: new device is high-speed
[64843.286845] dwc2 fe980000.usb: new device is high-speed
[64843.498901] dwc2 fe980000.usb: new device is high-speed
[64844.022900] dwc2 fe980000.usb: new device is high-speed
[64844.042852] dwc2 fe980000.usb: new device is high-speed
[64844.250900] dwc2 fe980000.usb: new device is high-speed
[64844.458898] dwc2 fe980000.usb: new device is high-speed
[64844.666987] dwc2 fe980000.usb: new device is high-speed
[64844.875989] dwc2 fe980000.usb: new device is high-speed
[64844.894988] dwc2 fe980000.usb: new device is high-speed
[64845.106893] dwc2 fe980000.usb: new device is high-speed
[64845.314991] dwc2 fe980000.usb: new device is high-speed
[64845.522979] dwc2 fe980000.usb: new device is high-speed
[64955.655656] dwc2 fe980000.usb: new device is full-speed
[64956.386156] dwc2 fe980000.usb: new device is full-speed
[64956.823811] dwc2 fe980000.usb: new device is full-speed
...
[65205.248324] dwc2 fe980000.usb: new device is high-speed
[65205.420065] dwc2 fe980000.usb: new address 33
[65443.924479] configfs-gadget gadget: End Point Request ERROR: -108
Which repeats several times until it eventually stops attempting to access the USB device. The following lines are logged to the console as well:
[519502.404121] usb 1-9-port2: Cannot enable. Maybve the USB cable is bad?
[519503.260156] usb 1-9-port2: Cannot enable. Maybve the USB cable is bad?
[519503.260312] usb 1-9-port2: Attempt power cycle
[519504.440028] usb 1-9-port2: Cannot enable. Maybve the USB cable is bad?
[519505.300099] usb 1-9-port2: Cannot enable. Maybve the USB cable is bad?
[519505.300273] usb 1-9-port2: unable to enumerate USB device
Nothing interesting is logged by the tinypilot
process when this happens.
Some things I've attempted:
- Tested the KVM Switch with a keyboard and it works as expected
- Using the data ports of the KVM works as expected, however hot keys will not work
Cheers
- David @david2023-03-15 13:39:26.811Z
Hi @bmrb, sorry that you're running into this issue with your KVM.
It sounds like this behavior might be due to how TinyPilot presents itself as a USB device and how your KVM handles keyboard and mouse input.
First, TinyPilot presents itself as a USB hub with a USB keyboard, USB mouse, and USB thumbdrive attached.
Many KVMs (including this Mt-viki) have separate keyboard and mouse ports that expect connections to individual devices. These ports typically don't handle USB devices through a USB hub. However, the data port seems to support USB hubs, since your TinyPilot works (with the exception of hotkey switching). It's likely that hotkey switching only works via the KVM's keyboard USB port - which would explain why hotkeys don't work via the KVM's data port.
I hope that helps! Please let me know if you have any other questions.
- BIn reply tobmrb⬆:Ben @bmrb
Hi David,
I am not sure that's the entire story - if I update the
init-usb-gadget
script to contain the following then I believe the device is presented as a USB keyboard without the associated hub:# Adapted from https://github.com/girst/hardpass-sendHID/blob/master/README.md cd "${USB_GADGET_PATH}" mkdir -p "${USB_DEVICE_DIR}" cd "${USB_DEVICE_DIR}" echo 0x1d6b > idVendor # Linux Foundation echo 0x0104 > idProduct # Multifunction Composite Gadget echo 0x0100 > bcdDevice # v1.0.0 echo 0x0200 > bcdUSB # USB2 mkdir -p "$USB_STRINGS_DIR" echo "6b65796d696d6570690" > "${USB_STRINGS_DIR}/serialnumber" echo "tinypilot" > "${USB_STRINGS_DIR}/manufacturer" echo "Generic USB Keyboard" > "${USB_STRINGS_DIR}/product" # Keyboard mkdir -p "$USB_KEYBOARD_FUNCTIONS_DIR" echo 1 > "${USB_KEYBOARD_FUNCTIONS_DIR}/protocol" # Keyboard echo 0 > "${USB_KEYBOARD_FUNCTIONS_DIR}/subclass" # Boot interface subclass echo 8 > "${USB_KEYBOARD_FUNCTIONS_DIR}/report_length" # Write the report descriptor D=$(mktemp) { echo -ne \\x05\\x01 # Usage Page (Generic Desktop Ctrls) echo -ne \\x09\\x06 # Usage (Keyboard) echo -ne \\xA1\\x01 # Collection (Application) echo -ne \\x05\\x08 # Usage Page (LEDs) echo -ne \\x19\\x01 # Usage Minimum (Num Lock) echo -ne \\x29\\x03 # Usage Maximum (Scroll Lock) echo -ne \\x15\\x00 # Logical Minimum (0) echo -ne \\x25\\x01 # Logical Maximum (1) echo -ne \\x75\\x01 # Report Size (1) echo -ne \\x95\\x03 # Report Count (3) echo -ne \\x91\\x02 # Output (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) echo -ne \\x09\\x4B # Usage (Generic Indicator) echo -ne \\x95\\x01 # Report Count (1) echo -ne \\x91\\x02 # Output (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) echo -ne \\x95\\x04 # Report Count (4) echo -ne \\x91\\x01 # Output (Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) echo -ne \\x05\\x07 # Usage Page (Kbrd/Keypad) echo -ne \\x19\\xE0 # Usage Minimum (0xE0) echo -ne \\x29\\xE7 # Usage Maximum (0xE7) echo -ne \\x95\\x08 # Report Count (8) echo -ne \\x81\\x02 # Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) echo -ne \\x75\\x08 # Report Size (8) echo -ne \\x95\\x01 # Report Count (1) echo -ne \\x81\\x01 # Input (Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position) echo -ne \\x19\\x00 # Usage Minimum (0x00) echo -ne \\x29\\x91 # Usage Maximum (0x91) echo -ne \\x26\\xFF\\x00 # Logical Maximum (255) echo -ne \\x95\\x06 # Report Count (6) echo -ne \\x81\\x00 # Input (Data,Array,Abs,No Wrap,Linear,Preferred State,No Null Position) echo -ne \\xC0 # End Collection } >> "$D" cp "$D" "${USB_KEYBOARD_FUNCTIONS_DIR}/report_desc" mkdir -p "${USB_CONFIG_DIR}" echo 250 > "${USB_CONFIG_DIR}/MaxPower" CONFIGS_STRINGS_DIR="${USB_CONFIG_DIR}/${USB_STRINGS_DIR}" mkdir -p "${CONFIGS_STRINGS_DIR}" echo "Config ${USB_CONFIG_INDEX}: ECM network" > "${CONFIGS_STRINGS_DIR}/configuration" ln -s "${USB_KEYBOARD_FUNCTIONS_DIR}" "${USB_CONFIG_DIR}/" usb_gadget_activate
Before:
After:
I can see that the USB device is successfully presented as a single USB keyboard when plugged into the USB Data port, however the same issue persists when plugged into the USB Keyboard port:
Are there any other troubleshooting steps you can recommend?
Cheers,
Ben
- David @david2023-03-16 15:46:50.559Z
Interesting!
Can you share the specific model of KVM you're using? Did you purchase it recently?
@mike originally mentioned that their MT-VIKI was compatible - I wonder if they have any insight about the behavior here? Perhaps it's a different model of the KVM?
I'm not entirely sure if your keyboard / mouse combo presents as a hub or not. If you have a USB hub and a separate keyboard / mouse at hand it might be useful to try that (if not there's no problem, it's just an idea).
Hi David,
Today I tried various keyboards through a hub and find that none of them work - although the fact that my UHKv2 (and Logitech Unifying receiver) did work is promising in that it's possible to have a keyboard and mouse present themselves without requiring a virtual hub to be used.
I've ordered a USB protocol sniffer/analyzer and will do some further testing when it arrives, and report my findings here.
Cheers,
Ben
- David @david2023-03-17 12:41:02.728Z
I took a look at the USB HID spec, and on page 66 (pdf page 76) it says:
The sample device is a low-speed 105-key keyboard with an integrated pointing
device. This device could be built using just one interface.Which suggests that those devices you mentioned could be built using a single interface. So it sounds like the MT-VIKI might not support hubs with the keyboard USB port - perhaps this KVM is a newer revision with different hardware support?
It would be really interesting to see results from the USB analyzer.
Please keep us updated!
- BIn reply tobmrb⬆:Ben @bmrb
Some further testing shows that USB keyboards (like the UHKv2) that contain both a Mouse and Keyboard (which I assume also present as a hub with multiple devices attached) do work when plugged into the Keyboard port of the KVM:
[595372.512650] usb 1-5.2: new full-speed USB device number 108 using xhci_hcd [595372.734153] usb 1-5.2: New USB device found, idVendor=1d50, idProduct=6124, bcdDevice= 1.02 [595372.735024] usb 1-5.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [595372.735878] usb 1-5.2: Product: UHK 60 v2 [595372.736630] usb 1-5.2: Manufacturer: Ultimate Gadget Laboratories [595372.752464] hid-generic 0003:1D50:6124.000E: hiddev1,hidraw1: USB HID v1.10 Device [Ultimate Gadget Laboratories UHK 60 v2] on usb-0000:00:14.0-5.2/input0 [595372.753617] input: Ultimate Gadget Laboratories UHK 60 v2 as /devices/pci0000:00/0000:00:14.0/usb1/1-5/1-5.2/1-5.2:1.1/0003:1D50:6124.000F/input/input36 [595372.812831] hid-generic 0003:1D50:6124.000F: input,hidraw3: USB HID v1.10 Keyboard [Ultimate Gadget Laboratories UHK 60 v2] on usb-0000:00:14.0-5.2/input1 [595372.814251] input: Ultimate Gadget Laboratories UHK 60 v2 as /devices/pci0000:00/0000:00:14.0/usb1/1-5/1-5.2/1-5.2:1.2/0003:1D50:6124.0010/input/input37 [595372.872781] hid-generic 0003:1D50:6124.0010: input,hidraw4: USB HID v1.10 Device [Ultimate Gadget Laboratories UHK 60 v2] on usb-0000:00:14.0-5.2/input2 [595372.874170] input: Ultimate Gadget Laboratories UHK 60 v2 as /devices/pci0000:00/0000:00:14.0/usb1/1-5/1-5.2/1-5.2:1.3/0003:1D50:6124.0011/input/input38 [595372.932777] hid-generic 0003:1D50:6124.0011: input,hidraw5: USB HID v1.10 Device [Ultimate Gadget Laboratories UHK 60 v2] on usb-0000:00:14.0-5.2/input3 [595372.934389] input: Ultimate Gadget Laboratories UHK 60 v2 as /devices/pci0000:00/0000:00:14.0/usb1/1-5/1-5.2/1-5.2:1.4/0003:1D50:6124.0012/input/input39 [595372.935257] hid-generic 0003:1D50:6124.0012: input,hidraw6: USB HID v1.10 Mouse [Ultimate Gadget Laboratories UHK 60 v2] on usb-0000:00:14.0-5.2/input4 [595372.958495] usbcore: registered new interface driver usbmouse