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
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
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
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
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
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.
Thanks, will wait for your result.
Just for info:
Also tried to disable the <®_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 = <®_usb1_vbus>;
};
mfg winfried
Tested solution: A64-OLinuXino-1Ge4GW USB OTG with OLIMAGEWe reproduced the problem on A64-OLinuXino-1Ge4GW with kernel 5.10.180-olimex and found the cause.
It is possible to restore safe dual-role operation without rebuilding the complete image. We tested both USB-device mode and USB-host mode.
What is wrongUSB0 PHY0 is shared by MUSB, EHCI0 and OHCI0. The current device tree assigns PHY0 to all three controllers. During boot, EHCI0/OHCI0 requests host mode for PHY0. The sun4i PHY driver then stops following the USB0 ID pin, so normal OTG role switching fails.
The device-tree correction is:
- MUSB remains connected to PHY0 and remains in "otg" mode.
- The "phys" and "phy-names" properties are removed only from EHCI0 and OHCI0.
- The USB0 VBUS regulator is not forced permanently on.
InstallationDownload install-a64-olinuxino-usb0-dual-role.sh (https://ftp.olimex.com/TEMP/A64-OTG-fix/install-a64-olinuxino-usb0-dual-role.sh). Log in as root and run:
cd /root
wget https://ftp.olimex.com/TEMP/A64-OTG-fix/install-a64-olinuxino-usb0-dual-role.sh
chmod 700 /root/install-a64-olinuxino-usb0-dual-role.sh
/root/install-a64-olinuxino-usb0-dual-role.sh
If the script reports that the DTB was installed and the FIT image was rebuilt, disconnect everything from the micro-USB socket and reboot:
reboot
The script verifies the board, creates backups, modifies and checks a temporary DTB, installs it, and rebuilds /boot/kernel.itb.
It also generates the complete readable DTS here:
/root/sun50i-a64-olinuxino-1Ge4GW-usb0-dual-role.dts
Generating the full DTS from the installed DTB is safer than distributing one hard-coded DTS, since phandles and other definitions can change between OLIMAGE kernel packages.
Important limitationFor the moment, boot with the micro-USB socket empty. After Linux has started, insert the OTG adapter.
If the adapter is already inserted during boot, the kernel detects the host role but does not initially enable VBUS. Removing and reinserting the adapter fixes it. This remaining boot-time problem requires a small MUSB driver correction; it cannot be fixed completely by the DTS alone.
Test results- Normal cable to a PC: USB peripheral mode worked, and the board did not drive VBUS.
- OTG adapter inserted after boot: host mode selected and VBUS enabled automatically.
- Low-speed USB mouse enumerated through OHCI0.
- High-speed SanDisk flash drive enumerated through EHCI0 as /dev/sda.
- Removing the OTG adapter disabled VBUS and returned USB0 to the idle role.
Quick checkWith the OTG socket empty:
cat /sys/class/extcon/extcon0/state
Expected result:
USB=0
USB-HOST=0
After Linux has booted, insert the OTG adapter and check:
cat /sys/class/extcon/extcon0/state
lsusb -t
dmesg | tail -n 30
The attached detailed guide contains the manual procedure and recovery commands.
Permanent OLIMAGE fixThe OLIMAGE kernel package should eventually include both corrections:
- Remove the EHCI0/OHCI0 PHY0 claims from the A64-OLinuXino device tree, leaving MUSB responsible for PHY0.
- Make the sunxi MUSB driver synchronize the existing USB-HOST extcon state when it starts, so booting with an OTG adapter already inserted also works.
After that, users should receive the complete fix normally through apt update, apt dist-upgrade, u-boot-install and reboot.
Until the fix is included in OLIMAGE, a future kernel package upgrade can replace the manually corrected DTB, in which case the workaround must be applied again.
Thanks for the solution.
Since my A64 olinuxino REV.E is a a64-olinuxino-2Ge8G not a a64-olonuxino-1Ge8GW, I changed the script:
Exchanged all "1Ge8GW" with "2Ge8G".
It worked fine as described, after reboot reconnect the mouse it lights and get listed with lsusb.
Will do some further checks for now and report if stable and seeing forward to the kernel fix.
Just for information:
Just changed what your script does in the dts tree in linux-olimex kernel and installed the compiled dtb files like described in Olimage-guide.pdf:
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
index 29571559e434..68a2d28226d2 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
@@ -593,8 +593,8 @@ ehci0: usb@1c1a000 {
<&ccu CLK_USB_OHCI0>;
resets = <&ccu RST_BUS_OHCI0>,
<&ccu RST_BUS_EHCI0>;
- phys = <&usbphy 0>;
- phy-names = "usb";
+ /* phys = <&usbphy 0>; */
+ /* phy-names = "usb"; */
status = "disabled";
};
@@ -605,8 +605,8 @@ ohci0: usb@1c1a400 {
clocks = <&ccu CLK_BUS_OHCI0>,
<&ccu CLK_USB_OHCI0>;
resets = <&ccu RST_BUS_OHCI0>;
- phys = <&usbphy 0>;
- phy-names = "usb";
+ /* phys = <&usbphy 0>; */
+ /* phy-names = "usb"; */
status = "disabled";
};
and it behaved the same way, but changing dr_mode to "host" instead of "otg" did not brought up the host mode after boot, so I wait for the kernel patch.
Patch is now live, run apt update and apt dist-upgrade and let me know how it goes.
Confirmed !
Did update and reboot and there was the mouse and Codec:
Bus 004 Device 002: ID 08bb:2902 Texas Instruments PCM2902 Audio Codec
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 04b3:310c IBM Corp. Wheel Mouse
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Thanx a lot.
Just for understanding:
Why the ehci0: (usb@1c1a000) and ohci0: ( usb@1c1a400) does not need any phys ?
The phys property is a software ownership reference, not the physical USB connection.
On A64, PHY0 is shared and dynamically routed:
- Device mode → MUSB
- Host mode → EHCI0/OHCI0
MUSB and the Sun4i PHY driver manage PHY0, VBUS, and role switching. EHCI0/OHCI0 still use PHY0 electrically when it is routed to them, but must not claim it separately because that forces PHY0 permanently into host mode and breaks OTG switching.
This is specific to the A64 chip board which requires different routing (as compared to A20) - PHY0 has to be dual-routed. Fixes are only for the A64 board since the OTG in other Allwinner boards (A20,A13..) works fine. For example A20 uses a different architecture where PHY0 remains attached to MUSB and EHCI/OHCI use separate PHYs.
Thanks, I understand now. ;)