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

Normally, the top USB Type A port next to the Ethernet port is in host mode. This port is device mode capable for the USB OTG spec but USB Type A does not have the ID pin necessary to do OTG negotiation. The switch from host to device mode must be done manually and the dwc2 driver has to be re-probed.

echo device | sudo tee /sys/bus/platform/drivers/dwc3-meson-g12a/d0078080.usb/usb_role/d0078080.usb-role-switch/role
echo c9100000.usb | sudo tee /sys/bus/platform/drivers/dwc2/unbind
echo c9100000.usb | sudo tee /sys/bus/platform/drivers/dwc2/bind

Please note that if the board is backpowered via the USB 5V pin, the board is unable to reset power via regulator. Please use the SoC watchdog to reset the board or block the 5V pin on the cable.

To make the USB port device mode on boot, merge the usb-device-mode overlay in the libretech-wiring-tool.

sudo ldto merge usb-device-mode
sudo reboot
2 Likes

Thank you for the instructions. The device tree shows that both c9000000 (host mode) and c9100000 (peripheral mode) are under d0078080 (host mode). Will changing the usb_role of d0078080 to device affect c9000000.usb which used dwc3 in host mode?

We haven’t tried. Update to the latest kernel before you try the instructions above.

Tried this and does not work. Here is the log entries from dmesg | grep usb
[ 176.597068] dwc3-meson-g12a d0078080.usb: Broken manual OTG switch
[ 176.597107] dwc3-meson-g12a d0078080.usb: switching to Device Mode
[ 208.076972] dwc2 c9100000.usb: supply vusb_d not found, using dummy regulator
[ 208.077427] dwc2 c9100000.usb: supply vusb_a not found, using dummy regulator
[ 208.077909] dwc2 c9100000.usb: EPs: 7, dedicated fifos, 712 entries in SPRAM
[ 266.699684] dwc2 c9100000.usb: bound driver g_mass_storage

The mass storage does not appear on the connected (via USB-A to USB-A cable) host computer.

Did you update the kernel and reset your ldto changes before trying the instructions above?

I am using armbian bullseye CLI latest version. Had to defreeze kernel upgrade. I have now completed the upgrade and mass storage works now !!
HID (Keyboard/Mouse) also works ! The other USB ports function in host mode as well. THANK YOU FOR THE SUPPORT !

Before upgrade uname -a

Linux lepotato 5.19.17-meson64 #22.11.1 SMP PREEMPT Wed Nov 30 11:05:42 UTC 2022 aarch64 GNU/Linux

After Upgrade uname -a

Linux lepotato 6.0.13-meson64 #22.11.2 SMP PREEMPT Sun Dec 18 16:52:19 CET 2022 aarch64 GNU/Linux

Armbian is a different beast altogether. A lot of our guides do not work on it due to differences in configuration.

Thank you, verified it’s working fine on Ubuntu 22.04.1. Could you please say how to enable OTG upon boot?

Try setting the kernel command line parameters via GRUB. https://www.kernel.org/doc/Documentation/devicetree/bindings/usb/generic.txt

Could you please help me with it? My best guess was dtoverlay=d0078080.usb,dr_mode=device but it’s wrong.

I’ve enabled device mode using overlays, will do a separate post with steps described :).

1 Like

Any luck with the HOWTO? I’m struggling to figure this out myself.

@olehb007 @librecomputer - I’m having difficulty as well getting device mode enabled. What file needed editing and with what text?

@raghu_mp Now that you have managed to enable otg on le potato, were you able to install TinyPilot on it?

How would we craft and implement a device tree overlay using ldto for OTG on boot?
I’m also trying to run tinypilot on a le potato without realizing how difficult this is without the workings of config.txt due to changes by Libre computer to how it works.
I’ve seen posts by @raghu_mp and @olehb007 but no followups on working configs through multiple threads.
We’d like to see a working config for the public so the next person doesn’t have to spend an entire day to go to sleep with no progress made overall.

You can use libretech-wiring-tool: GitHub - libre-computer-project/libretech-wiring-tool

sudo ./ldto merge usb-device-mode
sudo reboot
1 Like

sudo apt update
sudo apt upgrade
armbian-config >> system >> firmware >> update then reboot

echo device | sudo tee /sys/bus/platform/drivers/dwc3-meson-g12a/d0078080.usb/usb_role/d0078080.usb-role-switch/role
echo c9100000.usb | sudo tee /sys/bus/platform/drivers/dwc2/unbind
echo c9100000.usb | sudo tee /sys/bus/platform/drivers/dwc2/bind

should work now, tested on armbian using the usb port top left closest to ethernet port

1 Like