0
ehelfer

orange pi pc USB otg not working

Recommended Posts

Armbianmonitor:

Hi, 

 

I can't make usb otg works on orange pi pc armbian stretch.  Linux orangepipc 4.19.38-sunxi #5.83 SMP Fri May 3 23:33:25 CEST 2019 armv7l GNU/Linux
At boot there is the following message in dmesg:
 

[    2.252841] usb0-vbus: disabling

 

image.thumb.png.e28b07d60127b5e6493d7a3a59b07476.png

 

I tried to enable usbhost0 with armbianconfig overlays, but it doesn't make a difference. 

Any suggestions ? 
thanks
 

Share this post


Link to post
Share on other sites

Hi, I just would like to make the micro usb port work with g_serial or g_ether as a peripheral (not host).  Tried to put the dr_mode to "peripheral", but I have seen no difference. When I plug the micro usb cable, it is like dead.  Already tried other forums solutions. The host device doesn't detect anything, does not mount /dev/ttyACM0 (and on windows host I have no periphals detected).   I also already tried to power it through GPIO PL2 (by writing directly in the shared memory), but no difference
thanks

Share this post


Link to post
Share on other sites

Check for g_serial module in /etc/modules and check if getty is enabled for /dev/ttyGS0 (g_serial device)

 

On some boards we enable it by default. When this is enabled, you can't have g_ether ... not at the same time.

Share this post


Link to post
Share on other sites

The g_ether   / g_serial module are working, the usb0 interface is working (for g_ether) and the /dev/ttyGS0 (g_serial) are present.  But nothing is detected on the host side when I plug the  usbcable.   I tried to connect it to a raspberry pi and my windows 10, nothing detected. Any ideas why ? I am using the standard armbian image without modifications. 

Share this post


Link to post
Share on other sites
5 hours ago, ehelfer said:

The g_ether   / g_serial module are working, the usb0 interface is working (for g_ether) and the /dev/ttyGS0 (g_serial) are present.  But nothing is detected on the host side when I plug the  usbcable.   I tried to connect it to a raspberry pi and my windows 10, nothing detected. Any ideas why ? I am using the standard armbian image without modifications. 


You need to enable and start getty https://github.com/armbian/build/blob/master/config/sources/sun8i.conf#L30-L41

 

Share this post


Link to post
Share on other sites
9 hours ago, ehelfer said:

Hi, the file  /sys/bus/platform/devices/sunxi_usb_udc/otg_role  doesn't exists. I think it works only on the legacy kernel ?  
g_serial mounted /dev/ttyGS0, but nothing detected on the host. 

 

Share this post


Link to post
Share on other sites

I found this tutorial : https://vjordan.info/log/fpga/nanopi-neo-usb-otg-with-armbian-mainline-4x-kernel.html

and tried to modify the .dtb file without success. The file seems correct to me, but I am not a specialist.    The article mention this patch for orange pi one :  https://github.com/megous/linux/commit/b97b8104c1f61071c6b7c4d6fe7a2eb06517e956     I tried to follow this and activate vbus0 with the PL2 gpio (don't know if it makes sense), but i could not make it work. 

 

 

Share this post


Link to post
Share on other sites

 I used dtc to modify the dr_mode:      

 

(to compile)

dtc -I dts /boot/dtb/sun8i-h3-orangepi-pc.dts -O dtb -o /boot/dtb/sun8i-h3-orangepi-pc.dtb

 

segment of the dts I modified file

 

   usb@1c19000 {
            compatible = "allwinner,sun8i-h3-musb";
            reg = <0x1c19000 0x400>;
            clocks = <0x3 0x20>;
            resets = <0x3 0x11>;
            interrupts = <0x0 0x47 0x4>;
            interrupt-names = "mc";
            phys = <0xc 0x0>;
            phy-names = "usb";
            extcon = <0xc 0x0>;
            status = "okay";
            dr_mode = "otg"; 
            phandle = <0x3f>;
        };

 

I tried the "host" mode  (connecting my keyboard through the usb-otg cable) ,  I got the following errors

 

[ 1259.409939] usb 2-1: new low-speed USB device number 26 using ohci-platform
[ 1259.601958] usb 2-1: device descriptor read/64, error -62
[ 1259.901964] usb 2-1: device descriptor read/64, error -62
[ 1260.197984] usb 2-1: new low-speed USB device number 27 using ohci-platform
[ 1260.389988] usb 2-1: device descriptor read/64, error -62
[ 1260.689998] usb 2-1: device descriptor read/64, error -62
[ 1260.798056] usb usb2-port1: attempt power cycle
[ 1261.302030] usb 2-1: new low-speed USB device number 28 using ohci-platform
[ 1261.718039] usb 2-1: device not accepting address 28, error -62
[ 1261.906058] usb 2-1: new low-speed USB device number 29 using ohci-platform
[ 1262.322070] usb 2-1: device not accepting address 29, error -62
[ 1262.322134] usb usb2-port1: unable to enumerate USB device

In "otg" and "peripheral" modes (peripheral is the mode I would like to use), nothing is detected on the host side (raspberry pi) ,  altough g_serial is running seemingly correctly on the peripheral (orange pi pc)
 

Any ideas ?  I tried both otg-cables and  plain micro usb cables. 

 

thanks

Share this post


Link to post
Share on other sites

It looks like the problem is here:

Spoiler

diff --git a/arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts b/arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts
index 056cb587f..48c7bf48c 100644
--- a/arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts
+++ b/arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts
@@ -223,11 +223,6 @@
        };
 };
 
-&reg_usb0_vbus {
-       gpio = <&r_pio 0 2 GPIO_ACTIVE_HIGH>; /* PL2 */
-       status = "okay";
-};
-
 &uart0 {
        pinctrl-names = "default";
        pinctrl-0 = <&uart0_pins_a>;
@@ -253,13 +248,11 @@
 };
 
 &usb_otg {
-       dr_mode = "otg";
+       dr_mode = "peripheral";
        status = "okay";
 };
 
 &usbphy {
        usb0_id_det-gpios = <&pio 6 12 GPIO_ACTIVE_HIGH>; /* PG12 */
-       usb0_vbus-supply = <&reg_usb0_vbus>;
-       /* VBUS on USB host ports are always on */
        status = "okay";
 };

 

 

+

 

Spoiler

modprobe g_serial
mkdir -p /etc/systemd/system/serial-getty@ttyGS0.service.d
systemctl --no-reload enable serial-getty@ttyGS0.service
systemctl start serial-getty@ttyGS0.service

 

  ___  ____  _   ____   ____         
 / _ \|  _ \(_) |  _ \ / ___|    _   
| | | | |_) | | | |_) | |      _| |_ 
| |_| |  __/| | |  __/| |___  |_   _|
 \___/|_|   |_| |_|    \____|   |_|  
                                     
Welcome to Debian Stretch with Armbian Linux 4.19.57-sunxi
System load:   0.09 0.22 0.11   Up time:       3 min            Local users:   2            
Memory usage:  5 % of 1981MB    IP:            
CPU temp:      50°C             
Usage of /:    3% of 30G    

[ General system configuration (beta): armbian-config ]


igorp@orangepipcplus:~$ w
 17:34:54 up 3 min,  3 users,  load average: 0.09, 0.22, 0.11
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
root     tty1     -                17:32    2:36   0.95s  0.38s -bash
root     ttyS0    -                17:33    1:26   0.50s  0.25s -bash
igorp    ttyGS0   -                17:34    4.00s  0.56s  0.04s w
igorp@orangepipcplus:~$ 

As you can see, I am logged via console, serial console and otg console which is my Linux desktop, dmesg when plugging in:

[269793.111983] usb 3-13.4.1: new high-speed USB device number 44 using xhci_hcd
[269793.212550] usb 3-13.4.1: New USB device found, idVendor=0525, idProduct=a4a7, bcdDevice= 4.19
[269793.212553] usb 3-13.4.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[269793.212554] usb 3-13.4.1: Product: Gadget Serial v2.4
[269793.212556] usb 3-13.4.1: Manufacturer: Linux 4.19.57-sunxi with musb-hdrc
[269793.215761] cdc_acm 3-13.4.1:2.0: ttyACM0: USB ACM device

You can find a working device tree blob in the attachment, so you don't need to recompile.

linux-dtb-next-sunxi_5.90_armhf.deb

 

If you also want root login via this console:

echo "ttyGS0" >> /etc/securetty

 

Share this post


Link to post
Share on other sites

Hi Igor, thanks a lot for instructions that's great. I'm glad you made it work on your device, unfortunately I still have the  issue on mine (nothing detect on the host either on my windows or other linux machines). 

 

I followed your instructions starting with a virgin orangepipc image armbian stretch, did a firmware update, installed the new dtb :

dpkg -i  linux-dtb-next-sunxi_5.90_armhf.deb


root@orangepipc:/boot# ls -l
total 20816
-rw-r--r-- 1 root root 3295977 May  8 12:20 System.map-4.19.38-sunxi
-rw-r--r-- 1 root root     201 Jul  5 10:04 armbianEnv.txt
-rw-r--r-- 1 root root    1536 May  4 00:08 armbian_first_run.txt.template
-rw-r--r-- 1 root root    4882 May  4 00:08 boot-desktop.png
-rw-r--r-- 1 root root  230454 May  4 00:08 boot.bmp
-rw-r--r-- 1 root root    3726 May  4 00:06 boot.cmd
-rw-rw-r-- 1 root root    3798 May  4 00:10 boot.scr
-rw-r--r-- 1 root root  162592 May  8 12:20 config-4.19.38-sunxi
lrwxrwxrwx 1 root root      17 Jul  5 09:53 dtb -> dtb-4.19.57-sunxi
drwxr-xr-x 3 root root   12288 Jul  5 10:19 dtb-4.19.57-sunxi
lrwxrwxrwx 1 root root      17 May  4 00:07 dtb.old -> dtb-4.19.38-sunxi
-rw-r--r-- 1 root root 4954411 Jul  5 09:56 initrd.img-4.19.38-sunxi
-rw-r--r-- 1 root root  176056 Jul  5 09:53 linux-dtb-next-sunxi_5.90_armhf.deb
drwxrwxr-x 2 root root    4096 May  4 00:08 overlay-user
-rw-r--r-- 1 root root       0 Jul  5 10:19 sun8i-h3-orangepi-pc-plus.dts
lrwxrwxrwx 1 root root      21 Jul  5 09:56 uInitrd -> uInitrd-4.19.38-sunxi
-rw-r--r-- 1 root root 4954475 Jul  5 09:56 uInitrd-4.19.38-sunxi
-rwxr-xr-x 1 root root 7489584 May  8 12:20 vmlinuz-4.19.38-sunxi
lrwxrwxrwx 1 root root      21 Jul  5 09:56 zImage -> vmlinuz-4.19.38-sunxi


Then I installed g_serial, seems to work: 

root@orangepipc:/boot/dtb# uname -a
Linux orangepipc 4.19.38-sunxi #5.85 SMP Wed May 8 14:20:48 CEST 2019 armv7l GNU/Linux



root@orangepipc:/boot/dtb# dmesg | grep g_serial
[    4.429565] g_serial gadget: Gadget Serial v2.4
[    4.429576] g_serial gadget: g_serial ready


root@orangepipc:/boot/dtb# ps aux | grep getty
root      1267  0.0  0.1   3692  1156 tty1     Ss+  10:05   0:00 /sbin/agetty --noclear tty1 linux
root      1268  0.0  0.1   3472  1460 ttyS0    Ss+  10:05   0:00 /sbin/agetty --keep-baud 115200,38400,9600 ttyS0 linux
root      1269  0.0  0.1   3472  1552 ttyGS0   Ss+  10:05   0:00 /sbin/agetty --keep-baud 115200,38400,9600 ttyGS0 linux


I decompiled the /boot/dtb-4.19.57-sunxi/sun8i-h3-orangepi-pc-plus.dtb , opened  sun8i-h3-orangepi-pc-plus.dts with notepad++,  and I couldn't find the sections mentioned in your patch (used dtc version 1.5.0 to decompile).  Don't know if it is normal ? seems strange to me (see attached dts files). Do I need to update the kernel to version 4.19.57 ?



I tried with different boards orangepipc, orangepipc+, and micro usb cables / otg cables, so I doubt it is a hardware issue. I can give you remote SSH access to my device if you would like to check things. I'll make armbian a donation once it is working.

 

thanks
 

 

 

sun8i-h3-orangepi-pc.dts sun8i-h3-orangepi-pc-plus.dts

Share this post


Link to post
Share on other sites

Updated to the nightly build kernel, and saw some improvements:


On windows nothing is detected. when the cable is plugged.
On raspberry pi most of the time nothing is detected (similar to windows)

 
I  had once this crash/reboot on the raspberry pi when plugging the otg cable :

Jul  5 13:46:06 WBox kernel: [  383.753841] Indeed it is in host mode hprt0 = 00001501
Jul  5 13:46:06 WBox kernel: [  383.963629] usb 1-1: new high-speed USB device number 6 using dwc_otg
Jul  5 13:46:06 WBox kernel: [  383.963740] Indeed it is in host mode hprt0 = 00001101
Jul  5 13:46:06 WBox kernel: [  384.203831] usb 1-1: New USB device found, idVendor=0424, idProduct=9514
Jul  5 13:46:06 WBox kernel: [  384.203840] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
Jul  5 13:46:06 WBox kernel: [  384.204276] hub 1-1:1.0: USB hub found
Jul  5 13:46:06 WBox kernel: [  384.204327] hub 1-1:1.0: 5 ports detected
Jul  5 13:46:07 WBox kernel: [  384.523621] usb 1-1.1: new high-speed USB device number 7 using dwc_otg
Jul  5 13:46:07 WBox kernel: [  384.653894] usb 1-1.1: New USB device found, idVendor=0424, idProduct=ec00
Jul  5 13:46:07 WBox kernel: [  384.653905] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
Jul  5 13:46:07 WBox kernel: [  384.656652] smsc95xx v1.0.6
Jul  5 13:46:07 WBox mtp-probe: checking bus 1, device 7: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.1"
Jul  5 13:46:07 WBox mtp-probe: bus: 1, device: 7 was not an MTP device
Jul  5 13:46:07 WBox kernel: [  384.746550] smsc95xx 1-1.1:1.0 eth0: register 'smsc95xx' at usb-3f980000.usb-1.1, smsc95xx USB 2.0 Ethernet, b8:27:eb:23:73:87
Jul  5 13:46:07 WBox kernel: [  385.025275] smsc95xx 1-1.1:1.0 eth0: hardware isn't capable of remote wakeup
Jul  5 13:46:07 WBox kernel: [  385.025466] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
Jul  5 13:46:09 WBox kernel: [  386.499921] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
Jul  5 13:46:09 WBox kernel: [  386.500566] smsc95xx 1-1.1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xC5E1
Jul  5 13:48:01 WBox kernel: [    0.000000] Booting Linux on physical CPU 0x0

rarely it works and I can connect from the raspberry host in serial on /dev/ttyACM0.

[  287.293970] usb 1-1.4: new high-speed USB device number 4 using dwc_otg
[  287.424702] usb 1-1.4: New USB device found, idVendor=0525, idProduct=a4a7
[  287.424717] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[  287.424726] usb 1-1.4: Product: Gadget Serial v2.4
[  287.424735] usb 1-1.4: Manufacturer: Linux 4.19.57-sunxi with musb-hdrc
[  287.476847] cdc_acm 1-1.4:2.0: ttyACM0: USB ACM device
[  287.477482] usbcore: registered new interface driver cdc_acm
[  287.477488] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

 

Btw if you can upload a SD image with the modifications,  I'll test it. 
thanks

 

Share this post


Link to post
Share on other sites

Hi Igor, 
Thanks a lot, I think it works now, the connector was a bit loose, that's why it was unstable. I'll bought a new one.

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