[OPiOne] USB power off


Recommended Posts

Hello friends!

I Am using 3G modem(Huawei E171 connected by OTG cable) on my OPi One for internet, but one problem - modem after few days working freeze. Reboot don't help because not full power off on USB, and after reboot i don't see modem in /dev. Only after physical remove modem and install again it's initialized and work fine.

 

Question: Can i power off USB from cli?

 

# uname -a

Linux orangepione 3.4.113-sun8i #18 SMP PREEMPT Thu Jun 15 02:16:06 CEST 2017 armv7l armv7l armv7l GNU/Linu

 

# lsusb

Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 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 005 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 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 0bda:8179 Realtek Semiconductor Corp. RTL8188EUS 802.11n Wireless Network Adapter
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 12d1:1003 Huawei Technologies Co., Ltd. E220 HSDPA Modem / E230/E270/E870 HSDPA/HSUPA Modem
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

 

# ls /dev/ttyU* (in normal state)

/dev/ttyUSB0  /dev/ttyUSB1

 

Link to post
Share on other sites
Armbian is a community driven open source project. Do you like to contribute your code?

1 hour ago, tkaiser said:

No, not with OPi One (and other H3 boards). AFAIK the only boards that really support this are Olimex boards with A10 or A20 SoC. See also https://forum.armbian.com/topic/1631-marriage-between-a20-and-h3-ups-mode-sunxi-pio-utility/

Yes, I read it and even tried this:

orangepi

PH26<1><0><default><0>

PH22<1><0><default><0>

It is necessary to cut the wire 5V in the OTG cable and connect via a relay :) Last chance.

 

Thank you tkiser for your fast and useful respond.

Link to post
Share on other sites
18 minutes ago, chwe said:

 

Shouldn't this be possible with the OTG Port by toggling PL2?

 

Edit: But restart isn't really a nice approach to solve your issue not?

 

It's very interesting, what i need to do to "pull this trigger"?

 

Restart is acceptable but helpless :) after # reboot modem still frozen

Link to post
Share on other sites
3 hours ago, tkaiser said:

You can make a backup copy of /boot/script.bin, then use bin2fex, change this line to 'usb_drv_vbus_gpio = ', then use fex2bin and see whether your dongle now reacts to sunxi-pio commands...

 

Tried it out this way and then used the usual GPIO sysfs:

root@orangepione:/# echo 354 > /sys/class/gpio/export
root@orangepione:/# echo "out" > /sys/class/gpio/gpio354/direction
root@orangepione:/# echo 1 > /sys/class/gpio/gpio354/value
root@orangepione:/# lsusb
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 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 005 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 003 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 001 Device 002: ID 05e3:0723 Genesys Logic, Inc. GL827L SD/MMC/MS Flash Card Reader
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
root@orangepione:/# echo 0 > /sys/class/gpio/gpio354/value
root@orangepione:/# lsusb
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 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 005 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 003 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 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Calculating the respective sysfs node is following the mainline rule here (even with legacy kernel): https://linux-sunxi.org/GPIO

Link to post
Share on other sites

And this works surprisingly VERY WELL. My Orange Pi powering a Banana Pi (since there we can measure voltage):

 

Orange_Pi_One_powering_something_Banana.

 

The Orange Pi is powered through Xunlong's 5V/3A PSU. And this is how it looks wrt voltage on the Banana Pi (the white cable in between is an 20AWG rated MicroUSB cable):

### Current system health:

Time        CPU    load %cpu %sys %usr %nice %io %irq   CPU   PMIC   DC-IN  C.St.
11:38:12:  960MHz  0.18  10%   6%   2%   0%   2%   0% 48.9°C 30.1°C   5.14V  0/6
11:38:13:  960MHz  0.18  17%  15%   2%   0%   0%   0% 48.7°C 29.9°C   5.12V  0/6
11:38:14:  960MHz  0.18  25%  20%   1%   0%   3%   0% 48.4°C 29.7°C   5.15V  0/6
11:38:15:  960MHz  0.18  10%   8%   2%   0%   0%   0% 48.4°C 30.0°C   5.16V  0/6
11:38:16:  528MHz  0.18  22%  19%   2%   0%   0%   0% 48.2°C 29.9°C   5.15V  0/6
11:38:18:  960MHz  0.32  10%   6%   2%   0%   1%   0% 49.4°C 30.7°C   5.07V  0/6
11:38:20:  960MHz  0.32 100%   7%  92%   0%   0%   0% 50.3°C 31.0°C   5.10V  0/6
11:38:21:  960MHz  0.32  75%   7%  68%   0%   0%   0% 49.1°C 30.2°C   5.15V  0/6
11:38:23:  960MHz  0.38  16%  11%   0%   0%   4%   0% 49.0°C 30.0°C   5.16V  0/6
11:38:24:  528MHz  0.38  11%  10%   1%   0%   0%   0% 48.6°C 30.2°C   5.10V  0/6

Starting at 11:38:18 a short stress test had been started in the background. Voltage still at 5.07V which is just... great.

 

Adding a host powered SSD to Banana Pi of course led to an instant poweroff. But on the Orange Pi it was just a simple CLI command to get the Banana restarted (without SSD connected of course!):

echo 0 > /sys/class/gpio/gpio354/value ; sleep 2 ; echo 1 > /sys/class/gpio/gpio354/value

 

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

Adding a host powered SSD to Banana Pi of course led to an instant poweroff.

If I understand the schematics right,  maximal current on microUSB is set to 680mA (see schematics and here). So you may need a 'minimum consumption setup' to have a chance that SSD running on the banana...

 

12 hours ago, zav said:

modem after few days working freeze

I don't know this your Huawei E171 stick well, to my bad most of the information is in Cyrillic letters so I don't understand anything.  :P

But I think this cellular sticks can be relatively power hungry (I had problems with a cellular stick on an old notebook years ago). Could this be the problem?

Link to post
Share on other sites

Thank you very much tkaiser! Thank you all!

Works great! Problem solved!

 

Message to descendants :) :

1) Taking out of control of the respective driver

# cd /boot

# bin2fex ./bin/orangepione.bin > newbin

# nano ./newbin

Change line 'usb_drv_vbus_gpio = port:PL02<1><0><default><0>' on 'usb_drv_vbus_gpio = '

# rm ./script.bin

# fex2bin ./newbin > script.bin

# rm ./newbin

!REMEMBER! - after reboot power on USB OTG port will be OFF by default!

# reboot

 

2) Export gpio pin PL02.

To obtain the correct number you have to calculate it from the pin name. Use this formula:

(position of letter in alphabet - 1) * 32 + pin number

(HL02) letter L - stay on 12 position in alphabet.

(HL02) pin number - 2

result:

(12-1)*32+2=354

Use GPIO sysfs do next:

# echo 354 > /sys/class/gpio/export

# echo "out" > /sys/class/gpio/gpio354/direction

Power ON

# echo 1 > /sys/class/gpio/gpio354/value

Power OFF

# echo 0 > /sys/class/gpio/gpio354/value

 

Enjoy!

 

Link to post
Share on other sites
38 minutes ago, chwe said:

I don't know this your Huawei E171 stick well, to my bad most of the information is in Cyrillic letters so I don't understand anything.  :P

But I think this cellular sticks can be relatively power hungry (I had problems with a cellular stick on an old notebook years ago). Could this be the problem?

If you knew how Huawei sounds and what it means in Russian, you would understand why it freeze after few days :D. Something like "piece of .... " but worse :D It works normal only as VoIP gateway on asterisk(more than 1 year uptime). I've seen same problem on routers, desktop pc and now here. I think it is modem hardware or software problem.

Link to post
Share on other sites
40 minutes ago, zav said:

# cd /boot/bin

# fex2bin ./newbin > orangepione.bin

 

No, I was talking about touching /boot/script.bin directly for a reason. Since /boot/bin/orangepione.bin (and all other files in this directory) are not under your but our (Armbian's) control. Next update that will be rolled out will overwrite your changes (and this will happen most probably within one week). So overwrite /boot/script.bin with modifications and don't let this be a symbolic link to a file in /boot/bin/

 

BTW: I second @chwe's concern and would suggest testing your dongle on a good USB3 port (known to provide stable 5.x V at 900 mA -- I tested this a while ago with a couple of laptops and a Banana Pro to be able to measure and with almost all PC laptops power situation on the USB3 ports sucked especially when switching the laptop over to battery)

Link to post
Share on other sites
11 minutes ago, tkaiser said:

 

No, I was talking about touching /boot/script.bin directly for a reason. Since /boot/bin/orangepione.bin (and all other files in this directory) are not under your but our (Armbian's) control. Next update that will be rolled out will overwrite your changes (and this will happen most probably within one week). So overwrite /boot/script.bin with modifications and don't let this be a symbolic link to a file in /boot/bin/

 

BTW: I second @chwe's concern and would suggest testing your dongle on a good USB3 port (known to provide stable 5.x V at 900 mA -- I tested this a while ago with a couple of laptops and a Banana Pro to be able to measure and with almost all PC laptops power situation on the USB3 ports sucked especially when switching the laptop over to battery)

1) Ops, i've seen that script.bin it is symlink and decided rewrite original. I will change post.

2) I don't think so. I'm used this dongle on many device. it can work fine one month or can freeze in first day. If I'm not mistaken it consumes ~ 100 mA

Link to post
Share on other sites
Guest
This topic is now closed to further replies.