Jump to content

Recommended Posts

Posted (edited)

Hi,

Board: BPI‑M4 Zero
OS: Armbian (Bookworm), kernel 6.12.35 (current)

This board has two USB‑C ports: one fixed HOST and one OTG. I’d like the OTG port (USB0) to operate as a host as well. I can’t find any Armbian overlay in armbian-config or on the forums that flips USB0 to host.

 

If anyone has this working, it would be cool to let me know :).

Thanks!

Edited by Samor140
Posted

If there is no overlay available you may need to write one by yourself.

I'd start by modifying the device tree itself and set the port in question to host and see if this actually works.

I think armbian-config comes with a device tree editor. Make sure to make a backup beforehand.

  • Solution
Posted

HOST

/dts-v1/;
/plugin/;

/ {
	fragment@0 {
		target = <&usbotg>;
		__overlay__ {
			dr_mode = "host";
		};
	};
};

 

OTG

/dts-v1/;
/plugin/;

/ {
	fragment@0 {
		target = <&usbotg>;
		__overlay__ {
			dr_mode = "otg";
		};
	};
};

 

By default it is set to peripheral.

Posted (edited)

@c0rnelius


Sorry for the late follow-up. Initially I thought everything was fine since the overlay compiled successfully, but once I freed the USB0 port (now using an ups hat for power), I ran into an issue.

I created and applied a custom device tree overlay to force USB into host mode (the one you gave me):

-----------------------------------------
/dts-v1/;
/plugin/;

/ {
    fragment@0 {
        target = <&usbotg>;
        __overlay__ {
            dr_mode = "host";
        };
    };
};

-----------------------------------------

The overlay was compiled and added using armbian-add-overlay, then referenced in /boot/armbianEnv.txt. After rebooting, I confirmed the following:

    - /proc/device-tree/soc/.../dr_mode -> shows host for all USB nodes

    - Power is delivered to the USB ports (LED indicators on devices turn on)

 

However, no USB devices are recognized. I also tried to target directly all known USB controller nodes manually with an overlay (usb@5100000, usb@5101000, usb@5200000, etc.) and forced dr_mode = "host" on each of them. All report host under /proc/device-tree, but:

    - lsusb lists only the root hubs

    - No new logs appear in dmesg when plugging in keyboards or mice (usb0)

    - Devices are never recognized or enumerated

 

So the overlay seems to apply correctly (the peripheral mode is gone), but the USB controller is still non-functional in host mode.

Any ideas or suggestions for further debugging ? I am new with all this stuff an I appreciate the help a lot.

Thanks !

 

Edited by Samor140
Posted

@Samor140

 

I just ran a basic test with a little hand held wireless keyboard+mouse combo and I can't replicate this.

 

lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 002: ID 0413:0308 Leadtek Research, Inc. 
Bus 007 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

cat /proc/device-tree/soc/usb*/dr_mode; echo
host

 

I made some recent changes to the DTS, but I doubt that would be the issue here. Plus I've never heard anyone complain about it before.

Could always see if there is a kernel update available or try the EDGE kernel. Most of the recent work I've been doing is related to EDGE "Bluetooth" and U-Boot.

 

What are you powering the unit with? I haven't seen issue with this unit, but on other h618's I have had USB issues when not using a proper PSU.

 

Posted (edited)

I am currently using the base image from the Armbian website (XFCE Bookworm variant) which is clearly not on the most recent kernel. For the power source, I’m using the Waveshare UPS HAT (C) for Raspberry Pi Zero (5V). I’ve been using the same unit with the Orange Pi Zero 2W and never had any issues with USB host mode, with them it's an official overlay already.

I switched to the Banana Pi because you guys offer better support, and the presence of eMMC was a big plus. So I don’t believe the power source is the issue, since the other USB port has never failed with the UPS.

I currently don't have access to the device, but tomorrow I will switch to the latest kernel and test with edge if necessary. I had previously avoided newer builds because, about two weeks ago, I ran into an issue with modem detection using mmcli on the latest kernel and build. After switching to the older kernel, the one currently available on the website, my modem was detected again with no changes whatsoever.

 

Thanks a lot for the quick response. I’ll follow up tomorrow. Great work, by the way, on the BPi M4 Zero and Armbian in general, you’ve been really active.

Edited by Samor140
Posted (edited)

@c0rnelius

I must be doing something wrong.
I just used armbian-build, built a custom image -> Armbian-unofficial_25.08.0-trunk_Bananapim4zero_bookworm_current_6.12.35_xfce_desktop.

 

Then I did nothing except log in.

 

I then did this:

nano usb0-host.dts

-----------------------------------------
/dts-v1/;
/plugin/;

/ {
    fragment@0 {
        target = <&usbotg>;
        __overlay__ {
            dr_mode = "host";
        };
    };
};

-----------------------------------------

Saved, then ran sudo armbian-add-overlay usb0-host.dts
-> then I rebooted.

 

Once rebooted, using the usual port, everything is detected. But using usb0, nothing is detected.
So it must not be the power source, since the usual port works perfectly.

 

Also, using this particular image, my USB modem (SIM7600G) is not listed when doing dmesg | grep tty.Reverting back to an older kernel fixed that issue. If with the same image you can't replicate any of this, maybe it is my unit that is defective. But that would be weird since i tested with 3 different boards and got the same results.

 

Thanks a lot.

Edited by Samor140
Posted

@Samor140

 

I think, I'm missing a piece of the puzzle.

I built a fresh Armbian IMG and I'm getting the same results as before.

 

So maybe I don't understand exactly what you are trying to do? Which USB-C port are you trying to use here?

Posted

Ok. So I think what I am getting out of this, is you are trying to use the designated PWR / OTG port as a HOST port. I'm not sure that is possible? I would need to investigate. Also I would be interested in knowing what ur u-boot log looks like powering it with that Waveshare.

 

 

Posted (edited)

Maybe I am not expressing myself clearly, sorry for that.
(edit -> i just saw you're new overlay -> trying it right now)
 

I am trying to use the designated PWR / OTG port as a HOST port exactly; this option is called usb0-host with an Orange Pi overlay. I am doing that because I am powering the device from underneath with GPIO. So I want to be able to free both ports to be HOST. The one already designated works fine as intended, but yeah, I want to use the PWR port USB0 as a HOST. I will share u-boot log quite soon.
 

Here is how I do it on the Orange Pi Zero 2W. Both are really similar, using H618, so I was thinking it was possible for the BPI-M4 Zero too:
http://www.orangepi.org/orangepiwiki/index.php?title=Orange_Pi_Zero_2W&mobileaction=toggle_view_desktop#How_to_set_USB0_to_HOST_mode

image.thumb.png.31643369d84c195ec420cf70f5bac9e3.png

 

Edited by Samor140
Posted (edited)

@c0rnelius
 

You're the goat !


It works ! I guess that by activating the two physical USB host controllers with status = "okay", the kernel properly loads the drivers and allows USB devices to function as expected.
Learned something new.

Thanks again!

Edited by Samor140

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines