Jump to content

microUSB won't work "out of the box" as USB Host in BananaPi M2 Berry


Roman555
Go to solution Solved by Roman555,

Recommended Posts

Hi everyone!
To cut long story short I have to make a microUSB port work as USB Host. I found out that there is a patch that will bring the port up.

Last year I managed to build a full custom image for my board using armbian documentation. I've already successfully upgraded software upto

Armbian 23.8.1 Bullseye with Linux 6.1.53-current-sunxi

So I'm going to build custom kernel with the patch applied to arch/arm/boot/dts/sun8i-r40.dtsi

https://github.com/Vutlan/linux-sunxi/commit/e0b16f86b91b5b03c4acd041aa2d45eb688378b2#diff-fb8cf9a1a0b868557516caf54f4e966b

 

ehci0: usb@1c14000 {
	compatible = "allwinner,sun8i-r40-ehci", "generic-ehci";
	reg = <0x01c14000 0x100>;
	interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>;
	clocks = <&ccu CLK_BUS_EHCI0>;
	resets = <&ccu RST_BUS_EHCI0>;
	phys = <&usbphy 0>;
	phy-names = "usb";
	status = "disabled";
};

ohci0: usb@1c14400 {
	compatible = "allwinner,sun8i-r40-ohci", "generic-ohci";
	reg = <0x01c14400 0x100>;
	interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>;
	clocks = <&ccu CLK_BUS_OHCI0>,
		<&ccu CLK_USB_OHCI0>;
	phys = <&usbphy 0>;
	phy-names = "usb";
	status = "disabled";
};

 

The main question : Am I going to move in a right direction ?

 

What I've already done:

- "git pull" in armbian/build directory.

Now I'm trying to build a kernel from the edge branch (because 6.1.y kernel is in the edge branch) for BananaPi M2 Ultra. During the compilation the script is trying to add RTL8811CU and ask for someone's github credentials. When I've feed it with my credentials it is answered that "remote: Support for password authentication was removed on August 13, 2021." So it's been failed.

Mayby I should remove old clonned local repository and re-clone it from github again ?

 

Although u-boot has been built successfully. But it's an earlier branch than installed - 23.02.0-trunk.

What should I build at all to make microUSB port work as USB Host ? Or maybe it's possible to make necessary changes in my current configuration, isn't it ?

 

Any suggestions are welcome

 

P.S. I've already removed an old armbian/build folder and clonned again. Script compile.sh works well, there's no question about github credentials.

Edited by Roman555
Link to comment
Share on other sites

So I ejected my current microsd and inserted an old one with an old system and the new builded debs.

To install: # dpkg -i <package.deb>

listed in order to install

linux-image-current-sunxi_23.11.0-trunk_armhf__6.1.63.deb
linux-u-boot-bananapim2ultra-current_23.11.0-trunk_armhf.deb
linux-dtb-current-sunxi_23.11.0-trunk_armhf__6.1.63.deb
bullseye/base-files_23.11.0-trunk-11.1+deb11u8-bullseye_armhf.deb
armbian-bsp-cli-bananapim2ultra-current_23.11.0-trunk_armhf.deb
armbian-bsp-cli-bananapim2ultra_23.11.0-trunk_armhf.deb
armbian-firmware_23.11.0-trunk_all.deb

After successful rebooting I got Armbian-unofficial 23.11.0-trunk Bullseye with Linux 6.1.63-current-sunxi

And you know - nothing changed - the mUSB port still didn't work.

Then I decided to check a corresponding dts file (the original file was preserved) :

# cp /boot/dtb/sun8i-r40-bananapi-m2-ultra.dtb{,.orig}

# dtc -I dtb -O dts /boot/dtb/sun8i-r40-bananapi-m2-ultra.dtb -o /boot/dtb/sun8i-r40-bananapi-m2-ultra.dts

And what I saw in /boot/dtb/sun8i-r40-bananapi-m2-ultra.dts  that microUSB port was disabled:

usb@1c14000 {
	compatible = "allwinner,sun8i-r40-ehci\0generic-ehci";
	reg = <0x1c14000 0x100>;
	interrupts = <0x00 0x27 0x04>;
	clocks = <0x05 0x2f>;
	resets = <0x05 0x17>;
	phys = <0x21 0x00>;
	phy-names = "usb";
	status = "disabled";
	phandle = <0x5e>;
};

usb@1c14400 {
	compatible = "allwinner,sun8i-r40-ohci\0generic-ohci";
	reg = <0x1c14400 0x100>;
	interrupts = <0x00 0x28 0x04>;
	clocks = <0x05 0x32 0x05 0x7f>;
	phys = <0x21 0x00>;
	phy-names = "usb";
	status = "disabled";
	phandle = <0x5f>;
};

So "disabled" was replaced with "okay" and dts was converted back into dtb :

# dtc -I dts -O dtb /boot/dtb/sun8i-r40-bananapi-m2-ultra.dts -o /boot/dtb/sun8i-r40-bananapi-m2-ultra.dtb

 

After rebooting the microUSB started working as USB Host :

root@myhostname:~# lsusb
Bus 005 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 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 0bda:9210 Realtek Semiconductor Corp. RTL9210 M.2 NVME Adapter
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

 

Now I'm going to change only the dtb file in my current system (armbian 23.8.1) and see whether it helps or not.

 

BTW, when I ran the old system I saw CPU temp was shown (it is not in the current system)

 

P.S. You may ask why it's all for. Because a USB NVME SSD draws a lot of power. It causes sudden shutdowns of the board. IMO the only way to solve the problem is to power a USB NVME SSD directly from a main power source (I have a good power source (PS), I measured and controlled the voltage and current during load testing and also I tried to exchange the PS but it didn't help)

Edited by Roman555
Link to comment
Share on other sites

  • Solution

Now about my current system. The improvement was done and the system works well with a USB NVME SSD (no sudden shutdowns - power is distributed from a PS via onboard SATA conn to microUSB, not via SY6280AAC or AXP221S as usual 4xUSB-A are connected).

 

Because both kernels were from the same branch (6.1.y) I thought dts files could be exchanged. The new dtb file was converted from new dts file.

# dtc -I dts -O dtb /boot/dtb/sun8i-r40-bananapi-m2-ultra.dts -o /boot/dtb/sun8i-r40-bananapi-m2-ultra.dtb

# reboot

 

I'd like to mention that the difference between both sun8i-r40-bananapi-m2-ultra.dts was significant. I don't think it could be done by hand. I attached both - old (no-microusb) and new dts files so you will be able compare them if you want. IMO, in general, installing a new compiled custom kernel from deb files is more robust way. I hope armbian's guru-s will comment it someday and suggest an easier method

sun8i-r40-bananapi-m2u.dts.zip

Edited by Roman555
Link to comment
Share on other sites

Easier method: create an device tree overlay and use the same.

 

/dts-v1/;
/plugin/;

&{/soc} {
	ehci0: usb@1c14000 {
		compatible = "allwinner,sun8i-r40-ehci", "generic-ehci";
		reg = <0x01c14000 0x100>;
		interrupts = <0x00 0x27 0x04>;
		clocks = <&ccu 0x2f>;
		resets = <&ccu 0x17>;
		phys = <&usbphy 0>;
		phy-names = "usb";
		status = "okay";
	};

	ohci0: usb@1c14400 {
		compatible = "allwinner,sun8i-r40-ohci", "generic-ohci";
		reg = <0x01c14400 0x100>;
		interrupts = <0x00 0x28 0x04>;
		clocks = <&ccu 0x32>,
			<&ccu 0x7f>;
		phys = <&usbphy 0>;
		phy-names = "usb";
		status = "okay";
	};
};

 

Assuming I didn't left any syntax errors in the above overlay, you should be able to create a dts file with the above content and then use "sudo armbian-add-overlay <dts-filename>" to enable the same

Link to comment
Share on other sites

Thank you, Gunjan Gupta!

I suppose to apply the suggested overlay method someday when/if future possible updates will broke my custom fixes.

 

P.S. I also found a solution for a broken CPU temperature sensor. I think I have to create a new topic to not mess this one

Link to comment
Share on other sites

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