OTG & Gadget on Armbian 'current' branch?

Using the top left USB port as a gadget works with Armbian ‘legacy’ 4.4.y kernels. However, if I boot my Rock Pi 4 B+ into the Armbian ‘current’ 5.10.y kernel I can not use the same USB port in OTG mode. I have already attempted to use a patch in the Armbian build process to set dr_mode=“otg” on the appropriate USB device node in Device Tree, but it still doesn’t work.

I have read through a few other threads here which seem to be related, but are from 1-2 years ago. Does the mainline support for Rock Pi 4 include OTG or no?

I realize that is the case and do appreciate all that Armbian has already done to make my tasks simpler.

I am reaching out to the community with this post to see whether or not there have been other attempts and/or efforts to get the OTG port functional on a mainline kernel.

I suspected, based on my own attempts, that driver support and other necessary vendor BSP changes to the legacy 4.4.y kernel have not been ported to the mainline kernels. So, has the community tried to do so or are there plans in the works to do so?

I am asking because I am trying to build a solution using the Rock Pi 4 as a gadget and although it mostly works on the legacy 4.4.y kernel it is causing a number of kernel stack traces related to endpoint stalls. I don’t know what these mean and I am not enough of a Kernel/driver guy to resolve them. So, I decided to check out mainline to see if the same issues existed there, which led me to the current situation.

I am fine with using the legacy Kernel for OTG. However, I might need support to help understand and/or resolve the kernel stack traces I referred to before. Is there a good place for me to file a bug report regarding them?

I’ve spent around 10 hours on this issue. I managed to finally make it work by adding this dts file:

/dts-v1/;
/plugin/;

/ {
        compatible = "rockchip,rk3399";

        fragment@0 {
                target = <&usbdrd_dwc3_0>;
                __overlay__ {
                        dr_mode = "peripheral";
                        compatible = "snps,dwc3";
                        reg = <0x0 0xfe800000 0x0 0x100000>;
                        phys = <&tcphy0_usb3>;
                        phy-names = "usb3-phy";
                        phy_type = "utmi_wide";
                        snps,dis_enblslpm_quirk;
                        snps,dis-u2-freeclk-exists-quirk;
                        snps,dis_u2_susphy_quirk;
                        snps,dis-del-phy-power-chg-quirk;
                        snps,xhci-slow-suspend-quirk;
                };
        };
};

So, write the above to dwc3-0-device.dts and then run:
sudo armbian-add-overlay dwc3-0-device.dts
After this, loading g_ether or g_mass_storage worked fine.

1 Like

@thardie You are a legend! Thank you!

I have added the above DTS patch into my local Armbian build and can verify that it works on linux-5.10.y with dr_mode set to either peripheral or otg.

Upon further testing only dr_mode = "peripheral" works on the 5.10.91 kernel. With dr_mode = "otg" the port doesn’t work at all.