build icon indicating copy to clipboard operation
build copied to clipboard

[Bug]: peripheral port/gadget mode stopped working on orange pi zero lts after upgrading to 6.12

Open schmorp opened this issue 2 months ago • 5 comments

What happened?

First of all, I am sorry if this is the wrong way to report this, but the linux kernel bug report path requires one to jump through a lot of unrelated hoops - I think it sends the wrong message if one wants to make a good faith bug report about an armbian package and is suddenly required to actually run a full armbian image and provide completely unrelated debugging info, making reporting a linux-kernel package bug impractical.

In any case, after upgrading from the 6.1 and 6.6 armbian kernels on my orange pi zero lts to the 6.12.51 kernel, gadget mode stopped working. /sys/class/udc/*/state keeps reporting "not connected".

I tracked it down to a change to the usb host port config (not surprisingly :), and found that this device tree overlay fixes it, when applied to the base sun8i-h2-plus-orangepi-zero.dtb:

/dts-v1/;
/plugin/;

/ {
        compatible = "xunlong,orangepi-zero";

        fragment@0 {
                target = <&ehci0>;
                __overlay__ {
                        // Remove PHY linkage to fix OTG conflict
                        /delete-property/ phys;
                        /delete-property/ phy-names;
                };
        };

        fragment@1 {
                target = <&ohci0>;
                __overlay__ {
                        // Remove PHY linkage to fix OTG conflict
                        /delete-property/ phys;
                        /delete-property/ phy-names;
                };
        };

};

From what I gather, this is part of an attempt to convert this into a normal usb host port with otg functionality.

However, I think the "otg" port on the orange pi zero is not an otg port but simply a peripheral port without the necessary hardware for vbus detection &c. As such, this means that dr_mode should probably also be set to peripheral, but gadget mode works after the above overlay is applied.

As far as I can see, this change is armbian-specific. I apologize in advance if I overlooked it and this is actually an upstream bug.

How to reproduce?

Load g_ether, see that the orange pi is not recognized as a usb device with 6.12, but is with 6.1.

Apply the overlay, reboot, load g_ether, see that it is now recognized.

Branch

main (main development branch)

On which host OS are you running the build script and observing this problem?

Debian 13 Trixie

Are you building on Windows WSL2?

  • [ ] Yes, my Ubuntu/Debian/OtherOS is running on WSL2

Relevant log URL

No response

Code of Conduct

  • [x] I agree to follow this project's Code of Conduct

schmorp avatar Nov 04 '25 20:11 schmorp

Hey @schmorp! 👋

Thanks for opening your first issue with the Armbian project — we’re glad to have you here! 🧡
Your input doesn’t just help us improve the project — it benefits everyone who uses Armbian.

If you'd like to stay informed about project updates or collaborate more closely with the team,
you can optionally share some personal contact preferences at armbian.com/update-data.
This helps us keep in touch without relying solely on GitHub notifications.

Also, don’t forget to ⭐ star the repo to support the work — and welcome aboard! 🚀

github-actions[bot] avatar Nov 04 '25 20:11 github-actions[bot]

A summary of the changes CodeRabbit can apply:

  • Update device-tree patches for kernels 6.12–6.16 to keep dr_mode="peripheral" and delete PHY links from ehci0/ohci0 (preventing PHY sharing) to restore USB gadget mode on Orange Pi Zero LTS — modified files: patch/kernel/archive/sunxi-6.12/patches.armbian/arm-dts-sun8i-h2-plus-orangepi-zero-fix-usb_otg-dr_mode.patch, patch/kernel/archive/sunxi-6.13/patches.armbian/arm-dts-sun8i-h2-plus-orangepi-zero-fix-usb_otg-dr_mode.patch, patch/kernel/archive/sunxi-6.14/patches.armbian/arm-dts-sun8i-h2-plus-orangepi-zero-fix-usb_otg-dr_mode.patch, patch/kernel/archive/sunxi-6.15/patches.armbian/arm-dts-sun8i-h2-plus-orangepi-zero-fix-usb_otg-dr_mode.patch, patch/kernel/archive/sunxi-6.16/patches.armbian/arm-dts-sun8i-h2-plus-orangepi-zero-fix-usb_otg-dr_mode.patch

  • Update arch/arm/boot/dts/allwinner/sun8i-h2-plus-orangepi-zero.dts: replace commit header with Armbian sign-off and improved subject/body explaining USB gadget fix, set &usb_otg dr_mode to "peripheral" (not "otg") to match peripheral-only hardware, and remove the PHY reference (delete-property phys) from &ehci0 and &ohci0 to avoid PHY sharing conflicts so USB gadget mode works.

  • [ ] ✅ Create PR with these edits
  • [ ] 📋 Get copyable edits

coderabbitai[bot] avatar Nov 04 '25 20:11 coderabbitai[bot]

Jira ticket: AR-2779

github-actions[bot] avatar Nov 04 '25 20:11 github-actions[bot]

Just for the heck of it did you do a git blame on the phy links to get an idea when, why and who added them?

EvilOlaf avatar Nov 05 '25 04:11 EvilOlaf

They were added by @The-going at the beginning of this year

leggewie avatar Nov 11 '25 08:11 leggewie