Le Potato - Enable USB OTG for HID (KVM)

Hi,
I am trying to enable USB OTG port for use as a HID device for KVM.

Based on,
https://boot.libre.computer/ci/aml-s905x-cc.dts

usb = “/soc/usb@d0078080”;
dwc2 = “/soc/usb@d0078080/usb@c9100000”;
dwc3 = “/soc/usb@d0078080/usb@c9000000”;

I have added the following overlay for the USB OTG port highlighted above in BOLD.

/dts-v1/;
/plugin/;

/ {
compatible = “libretech,cc”, “amlogic,s905x”, “amlogic,meson-gxl-usb-ctrl”;

    fragment@0 {
            target = <&dwc2>;

            __overlay__ {
                    dr_mode = "otg";
                    status = "okay";
            };
    };

};

The usb-gadget service starts successfully and creates the /dev/hidg0 and /dev/hidg1 devices.

dmesg shows the following log.
[ 2.591463] dwc2 c9100000.usb: supply vusb_d not found, using dummy regulator
[ 2.591672] dwc2 c9100000.usb: supply vusb_a not found, using dummy regulator
[ 2.591906] dwc2 c9100000.usb: Configuration mismatch. dr_mode forced to device
[ 2.591990] dwc2 c9100000.usb: EPs: 7, dedicated fifos, 712 entries in SPRAM
[ 14.898891] dwc2 c9100000.usb: dwc2_hsotg_init_fifo: timeout flushing fifos (GRSTCTL=80000430)
[ 14.910718] dwc2 c9100000.usb: dwc2_core_reset: HANG! Soft Reset timeout GRSTCTL_CSFTRST
[ 14.910909] dwc2 c9100000.usb: bound driver configfs-gadget
[ 14.922404] dwc2 c9100000.usb: dwc2_core_reset: HANG! Soft Reset timeout GRSTCTL_CSFTRST

But unable to write anything to the device. Error is as follows.
echo -ne “\x20\0\xb\0\0\0\0\0” > /dev/hidg0 && echo -ne “\0\0\xc\0\0\0\0\0” > /dev/hidg0 && echo -ne “\0\0\0\0\0\0\0\0” > /dev/hidg0

-bash: echo: write error: Cannot send after transport endpoint shutdown

Can anyone help please?

Don’t have time to play with OTG but here is the driver: dwc2 - drivers/usb/dwc2 - Linux source code (v6.7.3) - Bootlin

You can check to make sure your DT entries are correct for dr_mode. Also some Googling.

Thanks. I am reading up on this now. Are there 2 separate USB bus/controllers on this board? What i mean is does the OTG port (top left port next to ethernet) on a different bus?

lsusb shows this.
Bus 001 Device 003: ID 046d:c52b Logitech, Inc. Unifying Receiver

Bus 001 Device 002: ID 05e3:0610 Genesys Logic, Inc. Hub

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

lsusb -t shows this.
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/2p, 480M
|__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
|__ Port 3: Dev 3, If 0, Class=Human Interface Device, Driver=usbhid, 12M
|__ Port 3: Dev 3, If 1, Class=Human Interface Device, Driver=usbhid, 12M
|__ Port 3: Dev 3, If 2, Class=Human Interface Device, Driver=usbhid, 12M

At this link https://wiki.stmicroelectronics.cn/stm32mpu/index.php?title=USB_overview&direction=prev&oldid=77109,
lsusb -t /* lsusb -t shows the USB class, the driver used and the number of ports and speed of each USB devices */
/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-platform/2p, 480M
|__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
|__ Port 1: Dev 5, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
|__ Port 3: Dev 4, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=dwc2/1p, 480M

dmesg | grep dwc2 shows the below errors.

[ 88.124011] dwc2 c9100000.usb: dwc2_hsotg_init_fifo: timeout flushing fifos (GRSTCTL=80000430)

[ 88.135725] dwc2 c9100000.usb : dwc2_core_reset: HANG! Soft Reset timeout GRSTCTL_CSFTRST

[ 88.135839] dwc2 c9100000.usb: bound driver g_mass_storage

[ 88.147320] dwc2 c9100000.usb : dwc2_core_reset: HANG! Soft Reset timeout GRSTCTL_CSFTRST

Seems like the dwc2 driver needs a patch.

https://community.st.com/s/question/0D53W00000UA60XSAT/mainline-linux-fails-to-set-up-fs-otg

We enabled UDC in our kernels but are experiencing some issues. We are still researching this at the moment.

dwc2 c9100000.usb: dwc2_hsotg_init_fifo: timeout flushing fifos (GRSTCTL=80000430)
dwc2 c9100000.usb: dwc2_core_reset: HANG! Soft Reset timeout GRSTCTL_CSFTRST
dwc2 c9100000.usb: bound driver g_mass_storage
dwc2 c9100000.usb: dwc2_core_reset: HANG! Soft Reset timeout GRSTCTL_CSFTRST

Please see How to enter Device Mode for USB OTG on USB Type A Port on AML-S905X-CC Le Potato

I’m wondering if you have had any success with this? I tried to get tinypilot working. Everything seems to be installed correctly but I can’t seem to get the HID to work. I do the commands that were mentioned on the other post and it seems to identify but nothing more after that.

1 Like

I was able to run pikvm pretty easily using this repo: Releases · Yura80/os · GitHub
I know its not tinypilot but it was easier to setup. You extract and flash the image with raspberry pi imager and then use the top left usb port for your usb to usb cable to the computer you want to control and the top right usb port for you usb-to-hdmi adapter.

Thanks for the confirmation! That is very helpful. Which image did you use from the Yura80? I don’t see an amlogic s905x image. Thanks for any help!

Jacob used the Tritium and Renegade boards. His information is not applicable to Le Potato.

Thank you for the clarification. I was scratching my head on that one!

So if those images don’t work, can you recommend an armbian image for which I could enable OTG and then use this script (GitHub - xe5700/kvmd-armbian: KVMD For Armbian Install Script) to enable using the le potato as a KVM?

We have already posted this. How to enter Device Mode for USB OTG on USB Type A Port on AML-S905X-CC Le Potato