0
skematic

[Orange Pi Lite] Using micro USB OTG as host for usb camera

Recommended Posts

The problem

I have an USB endoscope camera that works fine with my Orange Pi lite's normal USB port.  However I need both USB port for other devices, so I want to connect this same USB camera,  which was orginally marketed as USB otg camera for android phones, using Opi lite's micro usb otg connector.

 

What have I tried

- In armbian-config menu, I have enabled usbhost0. I believe this overlay is for the usb otg port, but just to be sure I also enabled usbhost1, usbhost2 and usbhost3.

- Using dtc I decompiled sun8i-h3-orangepi-lite.dtb into sun8i-h3-orangepi-lite.dtc.

- In this dtc file, I looked up musb, and changed status = "disabled" to "okay", and added dr_mode = "host", like this

usb@01c19000 {
			compatible = "allwinner,sun8i-h3-musb";
			reg = <0x1c19000 0x400>;
			clocks = <0x6 0x20>;
			resets = <0x6 0x11>;
			interrupts = <0x0 0x47 0x4>;
			interrupt-names = "mc";
			phys = <0x18 0x0>;
			phy-names = "usb";
			extcon = <0x18 0x0>;
			status = "okay";
			linux,phandle = <0x47>;
			phandle = <0x47>;
			dr_mode = "host"
		};

- Again with dtc, I compiled the dts to dtb file which replaced the old one (I've made backup).

- After reboot, this seemed to have done something

root@orangepilite:~$ dmesg |grep musb
[    4.086014] musb-hdrc musb-hdrc.1.auto: MUSB HDRC host driver
[    4.086025] musb-hdrc musb-hdrc.1.auto: new USB bus registered, assigned bus number 9
[    4.086290] usb usb9: Manufacturer: Linux 4.14.78-sunxi musb-hcd
[    4.086295] usb usb9: SerialNumber: musb-hdrc.1.auto

However, when I connect the camera to the usb otg port, it doesn't work. The LED's on the camera doesn't turn on (so there is probably no power coming from the port, also there are no video devices on /dev/.

 

How do I connect my camera to the micro usb port on Orange pi lite?

Share this post


Link to post
Share on other sites
19 hours ago, skematic said:

so there is probably no power coming from the port

USB0 power is controlled by regulator which need to be turned on using PL2 gpio.

Do you have any reference to PL2 in the DTS such as the following ?

       reg_usb0_vbus: usb0-vbus {
               compatible = "regulator-fixed";
               regulator-name = "usb0-vbus";
               regulator-min-microvolt = <5000000>;
               regulator-max-microvolt = <5000000>;
               enable-active-high;
               gpio = <&r_pio 0 2 GPIO_ACTIVE_HIGH>; /* PL2 */
               status = "okay";
       };

 

Share this post


Link to post
Share on other sites
1 hour ago, martinayotte said:

USB0 power is controlled by regulator which need to be turned on using PL2 gpio.

Do you have any reference to PL2 in the DTS such as the following ?

 

 

I have found nothing in terms of PL2. But I have usb0-vbus:

usb0-vbus {
		compatible = "regulator-fixed";
		regulator-name = "usb0-vbus";
		regulator-min-microvolt = <0x4c4b40>;
		regulator-max-microvolt = <0x4c4b40>;
		enable-active-high;
		gpio = <0x16 0x1 0x9 0x0>;
		status = "disabled";
		linux,phandle = <0x76>;
		phandle = <0x76>;
	};

I have changed status to "okay", however still no power coming from the micro-usb port.

 

Dmesg gives

root@orangepilite:~$ dmesg | grep usb0
[    4.241321] usb0-vbus: Failed to request enable GPIO41: -517
[    4.241337] reg-fixed-voltage usb0-vbus: Failed to register regulator: -517
[    4.243768] usb0-vbus: Failed to request enable GPIO41: -517
[    4.243776] reg-fixed-voltage usb0-vbus: Failed to register regulator: -517
[    8.521125] usb0-vbus: Failed to request enable GPIO41: -517
[    8.521140] reg-fixed-voltage usb0-vbus: Failed to register regulator: -517
[   10.025385] usb0-vbus: Failed to request enable GPIO41: -517
[   10.025409] reg-fixed-voltage usb0-vbus: Failed to register regulator: -517
[   10.246952] usb0-vbus: Failed to request enable GPIO41: -517
[   10.246968] reg-fixed-voltage usb0-vbus: Failed to register regulator: -517
[   10.275751] usb0-vbus: Failed to request enable GPIO41: -517
[   10.275768] reg-fixed-voltage usb0-vbus: Failed to register regulator: -517
[   10.354033] usb0-vbus: Failed to request enable GPIO41: -517
[   10.354050] reg-fixed-voltage usb0-vbus: Failed to register regulator: -517
[   10.409584] usb0-vbus: Failed to request enable GPIO41: -517
[   10.409604] reg-fixed-voltage usb0-vbus: Failed to register regulator: -517
[   10.463098] usb0-vbus: Failed to request enable GPIO41: -517
[   10.463118] reg-fixed-voltage usb0-vbus: Failed to register regulator: -517
[   10.465650] usb0-vbus: Failed to request enable GPIO41: -517
[   10.465666] reg-fixed-voltage usb0-vbus: Failed to register regulator: -517
[   10.719307] usb0-vbus: Failed to request enable GPIO41: -517
[   10.719317] reg-fixed-voltage usb0-vbus: Failed to register regulator: -517
[   10.897078] usb0-vbus: Failed to request enable GPIO41: -517
[   10.897100] reg-fixed-voltage usb0-vbus: Failed to register regulator: -517
[   10.913556] usb0-vbus: Failed to request enable GPIO41: -517
[   10.913577] reg-fixed-voltage usb0-vbus: Failed to register regulator: -517
[   11.571752] usb0-vbus: Failed to request enable GPIO41: -517
[   11.571765] reg-fixed-voltage usb0-vbus: Failed to register regulator: -517
[   11.585255] usb0-vbus: Failed to request enable GPIO41: -517
[   11.585273] reg-fixed-voltage usb0-vbus: Failed to register regulator: -517
[   11.591695] usb0-vbus: Failed to request enable GPIO41: -517
[   11.591711] reg-fixed-voltage usb0-vbus: Failed to register regulator: -517

 

Share this post


Link to post
Share on other sites
20 minutes ago, skematic said:

gpio = <0x16 0x1 0x9 0x0>;

It's seems not pointing to PL2 here ...

2 hours ago, martinayotte said:

gpio = <&r_pio 0 2 GPIO_ACTIVE_HIGH>; /* PL2 */

First, cCheck the phandle of r_pio that is really 0x16, if not change it to actual value.

Second, the 0x1 is wrong, it should be 0x0 like I've mentioned, then also the 0x9 which should be 0x2.

 

BTW, the current values found in "usb0-vbus" seems to be default values for some other Allwinner boards, I don't know which one ...

 

Share this post


Link to post
Share on other sites
3 minutes ago, martinayotte said:

for some other Allwinner boards, I don't know which one ...

I found it ! This default was added back in 2014 for the Cubieboard where PB9 is driving it USB regulator...

Share this post


Link to post
Share on other sites
16 minutes ago, martinayotte said:

It's seems not pointing to PL2 here ...

First, cCheck the phandle of r_pio that is really 0x16, if not change it to actual value.

Second, the 0x1 is wrong, it should be 0x0 like I've mentioned, then also the 0x9 which should be 0x2.

 

BTW, the current values found in "usb0-vbus" seems to be default values for some other Allwinner boards, I don't know which one ...

 

 

I've looked for r_pio

r_pio = "/soc/pinctrl@01f02c00";
pinctrl@01f02c00 {
			compatible = "allwinner,sun8i-h3-r-pinctrl";
			reg = <0x1f02c00 0x400>;
			interrupts = <0x0 0x2d 0x4>;
			clocks = <0x26 0x3 0x19 0x1a>;
			clock-names = "apb", "hosc", "losc";
			gpio-controller;
			#gpio-cells = <0x3>;
			interrupt-controller;
			#interrupt-cells = <0x3>;
			linux,phandle = <0x35>;
			phandle = <0x35>;

			ir@0 {
				pins = "PL11";
				function = "s_cir_rx";
				linux,phandle = <0x27>;
				phandle = <0x27>;
			};

			r-i2c {
				pins = "PL0", "PL1";
				function = "s_i2c";
				linux,phandle = <0x28>;
				phandle = <0x28>;
			};

			led_pins@0 {
				pins = "PL10";
				function = "gpio_out";
				linux,phandle = <0x34>;
				phandle = <0x34>;
			};

			key_pins@0 {
				pins = "PL3";
				function = "gpio_in";
				linux,phandle = <0x36>;
				phandle = <0x36>;
			};
		};

So this means I need the phandle 0x35?
 

Like you advised, I went back to usb0-vbus and changed its gpio settings to

gpio = <0x35 0x0 0x2 0x0>;

After a reboot, I checked dmesg

@orangepilite:~$ dmesg |grep usb0
[    4.256055] usb0-vbus: disabling

I think we made some progress, but unfortunately still not working.

 

I have attached my current dts file for reference.

sun8i-h3-orangepi-lite.dts

Share this post


Link to post
Share on other sites
1 hour ago, skematic said:

I think we made some progress, but unfortunately still not working.

Right ! But ... I see in the DTS you've provided that it still have 'dr_mode = "otg"; ' instead of 'dr_mode = "host"; ' , it is maybe the reason ...

Share this post


Link to post
Share on other sites
17 minutes ago, martinayotte said:

Right ! But ... I see in the DTS you've provided that it still have 'dr_mode = "otg"; ' instead of 'dr_mode = "host"; ' , it is maybe the reason ...

Forgot to change it back after I was testing it with different settings! It's now using dr_mode = "host"

 

root@orangepilite:~$ lsusb
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 007 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 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 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 009 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
root@orangepilite:~$ dmesg |grep musb
[    4.096047] musb-hdrc musb-hdrc.1.auto: MUSB HDRC host driver
[    4.096058] musb-hdrc musb-hdrc.1.auto: new USB bus registered, assigned bus number 9
[    4.096386] usb usb9: Manufacturer: Linux 4.14.78-sunxi musb-hcd
[    4.096391] usb usb9: SerialNumber: musb-hdrc.1.auto
root@orangepilite:~$ dmesg |grep usb0
[    4.256204] usb0-vbus: disabling

It still doesn't recognize my usb camera, also no power on the camera leds.

 

PS: I'm not sure if it matters, but during compiling I get these warnings everytime

root@orangepilite:/boot/dtb# sudo dtc -I dts -O dtb -o sun8i-h3-orangepi-lite.dtb sun8i-h3-orangepi-lite.dts
Warning (unit_address_vs_reg): Node /soc/pinctrl@01c20800/mmc0@0 has a unit name, but no reg property
Warning (unit_address_vs_reg): Node /soc/pinctrl@01c20800/mmc0_cd_pin@0 has a unit name, but no reg property
Warning (unit_address_vs_reg): Node /soc/pinctrl@01c20800/mmc1@0 has a unit name, but no reg property
Warning (unit_address_vs_reg): Node /soc/pinctrl@01c20800/spdif@0 has a unit name, but no reg property
Warning (unit_address_vs_reg): Node /soc/pinctrl@01c20800/uart0@0 has a unit name, but no reg property
Warning (unit_address_vs_reg): Node /soc/pinctrl@01c20800/led_pins@0 has a unit name, but no reg property
Warning (unit_address_vs_reg): Node /soc/pinctrl@01f02c00/ir@0 has a unit name, but no reg property
Warning (unit_address_vs_reg): Node /soc/pinctrl@01f02c00/led_pins@0 has a unit name, but no reg property
Warning (unit_address_vs_reg): Node /soc/pinctrl@01f02c00/key_pins@0 has a unit name, but no reg property
Warning (unit_address_vs_reg): Node /opp_table/opp@240000000 has a unit name, but no reg property
Warning (unit_address_vs_reg): Node /opp_table/opp@480000000 has a unit name, but no reg property
Warning (unit_address_vs_reg): Node /opp_table/opp@648000000 has a unit name, but no reg property
Warning (unit_address_vs_reg): Node /opp_table/opp@816000000 has a unit name, but no reg property
Warning (unit_address_vs_reg): Node /opp_table/opp@912000000 has a unit name, but no reg property
Warning (unit_address_vs_reg): Node /opp_table/opp@960000000 has a unit name, but no reg property
Warning (unit_address_vs_reg): Node /opp_table/opp@1008000000 has a unit name, but no reg property
Warning (unit_address_vs_reg): Node /opp_table/opp@1104000000 has a unit name, but no reg property
Warning (unit_address_vs_reg): Node /opp_table/opp@1200000000 has a unit name, but no reg property
Warning (unit_address_vs_reg): Node /opp_table/opp@1296000000 has a unit name, but no reg property

 

Share this post


Link to post
Share on other sites
29 minutes ago, skematic said:

It's now using dr_mode = "host"

Ok ! I'm currently building fresh image for my OPiLite ...

In the mean time, I think what is missing is, in the phy@1c19400 node, the "usb0_vbus-supply = <phandle>;", where phandle should be the one of your reg_usb0_vbus, which is 0x76 from above post ...

If that still doesn't work, I will provide DTS from my build later.

Share this post


Link to post
Share on other sites
16 minutes ago, martinayotte said:

Ok ! I'm currently building fresh image for my OPiLite ...

In the mean time, I think what is missing is, in the phy@1c19400 node, the "usb0_vbus-supply = <phandle>;", where phandle should be the one of your reg_usb0_vbus, which is 0x76 from above post ...

If that still doesn't work, I will provide DTS from my build later.

I appreciate your help! I am looking forward to your follow-up.

Share this post


Link to post
Share on other sites
9 minutes ago, martinayotte said:

Keep a backup of your, and simply try mine out, it should be compatible with 4.14.y, I hope ...

You sir, are a genius! I compiled your dts and all 3 usb ports seem to be working. Thank you so much for your effort!

 

For the sake of understanding, may I ask how you fixed this problem?

Share this post


Link to post
Share on other sites
3 minutes ago, skematic said:

may I ask how you fixed this problem?

In addition for all we've done previously, I've discovered by comparing with OPiOne DTS, which was already working, that OPiLite didn't have "okay" on both usb@01c1a000 and usb@01c1a400...

Share this post


Link to post
Share on other sites

I couldn't help trying to figure out how to make my own dts file work. Turns out, just like you said, adding usb0_vbus-supply  = <0x76>;  (0x76 being usb0-vbus's phandle)

usb0_vbus-supply  = <0x76>; 

In the phy@01c19400 node did the trick!

Share this post


Link to post
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...
0