Use USB OTG in host mode

Started by frm, November 25, 2025, 12:51:07 PM

Previous topic - Next topic

frm

Hi,
Can I change the configuration of the microUSB OTG in my OLinuxino A64 to use it in "host mode" instead of "pheripheral mode" ?

I only found this post https://www.olimex.com/forum/index.php?topic=4990.0 which mentions a FEX file somewhere... and it's dated 2016

Thanks

LubOlimex

Hardware-wise it is possible since there is USB0-ID wire/signal. So the port supports both device and host mode, it is real OTG.

Software-wise I don't think the Olimage image supports it, so some changes to the image are required.

The info you found applies to older sunxi-based images, that used fex files, it does not apply to the Olimage Linux which uses mainline. You'd have to edit dts/dtb. Refer to the Olimage guide, there is info on how to change dts/dtb or kernel:

https://raw.githubusercontent.com/OLIMEX/OLINUXINO/master/DOCUMENTS/OLIMAGE/Olimage-guide.pdf
Technical support and documentation manager at Olimex

frm

Quote from: LubOlimex on November 26, 2025, 09:18:28 AMSoftware-wise I don't think the Olimage image supports it, so some changes to the image are required.

This is really a pity. Right now I don't want to go through the lengthy process of rebuilding the kernel and the image myself, so I'll just use a basic USB hub to expand the single USB host port. It makes the whole setup much less compact thought :-(

Thanks

winfried

Since also need this for my A64 Rev.E , to connect a keyboard on the mini USB-OTG, USB-A already used by another device:

Quote from: LubOlimex on November 26, 2025, 09:18:28 AMYou'd have to edit dts/dtb. Refer to the Olimage guide, there is info on how to change dts/dtb or kernel:

Installed the crosscompiler and can make dtb. So what I have to edit ?

found in arch/arm64/boot/dts/allwinner/sun50i-a64-olinuxino-1G.dts

&usb_otg {
        dr_mode = "otg";
        status = "okay";
};

I cannot figure out what to change, or what mode to define and where to find the documentation for this.

Any hint ?

mfg winfried
---- Atelier Algorythmics --- [url="http://algo.mur.at/"]http://algo.mur.at/[/url] ----

winfried

#4
First report:

- Measured that the USB-OTG Pin is set to GND with OTG cable and made the mouse test. So the OTG functionality seems to be broken.

Changed the devicetree:

&usb_otg {
        dr_mode = "host"; /* set to host from otg */
        status = "okay";
};

Result:
3 seconds after boot mouse is detected and is powered  and after 33 second usb0-vbus is disabled and mouse is disconnected. So there is somewhere a timeout or the like.

Suspected the autosuspend, disabling, but still something in the system switches of the usb0-vbus, so disabled "USB Autosuspend" in Linux (Runtime Power Management).

in /boot/uEnv.txt put the line
optargs=usbcore.autosuspend=-1but this did not help.

What also is suspect is that there is a

/sys/devices/platform/usb1-vbusbut no
/sys/devices/platform/usb0-vbus
So I stop for today, any hint is welcome
---- Atelier Algorythmics --- [url="http://algo.mur.at/"]http://algo.mur.at/[/url] ----

LubOlimex

The problem is the powering. I used AI to analyze what can be done and got it working if I force it in host mode but that is dangerous (in case you want device mode at some point). I will see if I can get it working properly in dual mode and will give you some instructions.
Technical support and documentation manager at Olimex

winfried

Thanks, will wait for your result.

Just for info:
Also tried to disable the <&reg_drivevbus> for the _vbus-supply ind dts, but didnt help.

&usbphy {
status = "okay";
usb0_id_det-gpios = <&pio 7 9 GPIO_ACTIVE_HIGH>; /* PH9 */
usb0_vbus_det-gpios = <&pio 7 6 GPIO_ACTIVE_HIGH>; /* PH6 */
usb0_vbus-supply = <>; /* Remove or disable ID pin detection if it forces power-off */
usb1_vbus-supply = <&reg_usb1_vbus>;
};

mfg winfried
---- Atelier Algorythmics --- [url="http://algo.mur.at/"]http://algo.mur.at/[/url] ----