[XU4] Switch USB3.0 ports on/off

Moderators: mdrjr, odroid

[XU4] Switch USB3.0 ports on/off

Unread postby stylon » Fri Jun 10, 2016 5:10 am

On an ODROID-XU4 I'm trying to switch the two USB3.0 ports on/off by software, but so far it didn't work.

According to the schematics, the GL3521 is the USB3.0 Hub for the 2 external USB3.0 ports. lsusb -v shows that the hub has PPPS capability:

Code: Select all
Hub Descriptor:
  bLength              12
  bDescriptorType      42
  nNbrPorts             2
  wHubCharacteristic 0x0009
    Per-port power switching
    Per-port overcurrent protection
  bPwrOn2PwrGood       50 * 2 milli seconds
  bHubContrCurrent    576 milli Ampere
  bHubDecLat          0.0 micro seconds
  wHubDelay          1248 nano seconds
  DeviceRemovable    0x00
 Hub Port Status:
   Port 1: 0000.02a0 5Gbps power Rx.Detect
   Port 2: 0000.02a0 5Gbps power Rx.Detect


Using https://github.com/codazoda/hub-ctrl.c I can change the Hub Port Status flag power, but V_BUS on the port still measures +5V and attached devices don't turn off as expected.

Is my assumption wrong that they can be controlled via software or am I still missing something?

I think that the NCP380HM definitely works as expected: during measurement of V_BUS I shortened it accidently and that port showed the OC (=overcurrent) flag with lsusb -v
stylon
 
Posts: 16
Joined: Sat Sep 28, 2013 7:28 pm
languages_spoken: english
ODROIDs: C1, C1+, C2, U2, U3, HC1, HC2, X2, XU, XU+E, XU4

Re: [XU4] Switch USB3.0 ports on/off

Unread postby odroid » Fri Jun 10, 2016 12:18 pm

We also tried to find a way to control the VBUS power. But we couldn't find it even the load switch(NCP380) works as a circuit protector though. :(
User avatar
odroid
Site Admin
 
Posts: 28697
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: [XU4] Switch USB3.0 ports on/off

Unread postby stylon » Mon Jun 13, 2016 5:37 am

I noticed that the GL3521 is listed under 2 device IDs:

Code: Select all
Bus 006 Device 002: ID 0bda:8153 Realtek Semiconductor Corp.
Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 002: ID 05e3:0616 Genesys Logic, Inc.
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 002: ID 05e3:0610 Genesys Logic, Inc. 4-port hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub


05e3:0616 and 05e3:0610. Although this seems to be expected, 0616 being the USB3.0 hub and 0610 the shadowed USB2.0 hub, hub-ctrl only lists 1 port for the USB3.0 hub and even indicates that it operates at lowspeed. Maybe the hub device descriptors are not set up correctly?

Unfortunately, trying to switch port power on both in various combinations doesn't change anything at the physical port.
stylon
 
Posts: 16
Joined: Sat Sep 28, 2013 7:28 pm
languages_spoken: english
ODROIDs: C1, C1+, C2, U2, U3, HC1, HC2, X2, XU, XU+E, XU4

Re: [XU4] Switch USB3.0 ports on/off

Unread postby odroid » Mon Jun 13, 2016 11:04 am

The enumeration has no issue.
One USB 3.0 port must have a XHCI port as well as an EHCI for backward compatibility.
Code: Select all
odroid@odroid:~$ lsusb                                                         
Bus 006 Device 002: ID 0bda:8153 Realtek Semiconductor Corp.                   
Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub                 
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub                 
Bus 004 Device 002: ID 05e3:0616 Genesys Logic, Inc. hub                       
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub                 
Bus 003 Device 002: ID 05e3:0610 Genesys Logic, Inc. 4-port hub                 
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub                 
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub                 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub                 


odroid@odroid:~$ lsusb -t                                                       
/:  Bus 06.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 5000M             
    |__ Port 1: Dev 2, If 0, Class=Vendor Specific Class, Driver=r8152, 5000M   
/:  Bus 05.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 480M             
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 5000M             
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/2p, 5000M                   
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 480M             
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/2p, 480M                     
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=exynos-ohci/3p, 12M           
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=s5p-ehci/3p, 480M
User avatar
odroid
Site Admin
 
Posts: 28697
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: [XU4] Switch USB3.0 ports on/off

Unread postby hkarel » Sun Dec 04, 2016 9:37 pm

Prompt please whether it was succeeded to solve a problem with power off on USB3 a host?
I would accept option with power off on USB2, but my attempts to make it haven't led to anything. Tension in 5V remains on the USB bus.
hkarel
 
Posts: 1
Joined: Sun Dec 04, 2016 8:24 pm
languages_spoken: russian
ODROIDs: ODROID XU4

Re: [XU4] Switch USB3.0 ports on/off

Unread postby elector » Mon Feb 12, 2018 12:42 am

Sorry for hijacking a old thread. But did you ever work out how to (if possible?) to power off/on a USB port on the XU4?

I'm looking for something similar, to control a switch that in turn controls the a power strip, to turn on/off USB HDD drives.
elector
 
Posts: 6
Joined: Wed Aug 30, 2017 4:43 am
languages_spoken: english
ODROIDs: .
XU4 (video-streaming-project)
XU4Q (backup-server-project)
C2 (LibreELEC and Kodi)

Re: [XU4] Switch USB3.0 ports on/off

Unread postby mad_ady » Mon Feb 12, 2018 2:54 am

You can't turn the usb ports on/off, but you can use a gpio pin + some components and a relay to turn on/off a power switch where the hdds are plugged in. Or use a SonOff and control power over wifi.
User avatar
mad_ady
 
Posts: 4577
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [XU4] Switch USB3.0 ports on/off

Unread postby elector » Mon Feb 12, 2018 2:57 am

Dangit. I could on the old raspberry that my new XU4 is going to replace, bummer.

Oh well, guess I'll have to look at alternative solutions.
elector
 
Posts: 6
Joined: Wed Aug 30, 2017 4:43 am
languages_spoken: english
ODROIDs: .
XU4 (video-streaming-project)
XU4Q (backup-server-project)
C2 (LibreELEC and Kodi)

Re: [XU4] Switch USB3.0 ports on/off

Unread postby rooted » Mon Feb 12, 2018 4:40 am

elector wrote:Sorry for hijacking a old thread. But did you ever work out how to (if possible?) to power off/on a USB port on the XU4?

I'm looking for something similar, to control a switch that in turn controls the a power strip, to turn on/off USB HDD drives.
The gpio and a relay.
User avatar
rooted
 
Posts: 5574
Joined: Fri Dec 19, 2014 9:12 am
Location: Gulf of Mexico, US
languages_spoken: english
ODROIDs: C1, C1+, C2
XU3 Lite, XU4
N1
VU7+
HiFi Shield 2
Smart Power (original)

Re: [XU4] Switch USB3.0 ports on/off

Unread postby elector » Tue Feb 13, 2018 6:02 am

rooted wrote:
elector wrote:Sorry for hijacking a old thread. But did you ever work out how to (if possible?) to power off/on a USB port on the XU4?

I'm looking for something similar, to control a switch that in turn controls the a power strip, to turn on/off USB HDD drives.
The gpio and a relay.


I would like to re-use the USB-controlled-relay-230V-powerstrip-setup I have right now and wonder if something like this would do the trick?

https://www.amazon.co.uk/0-9v-5v-Step-up-Supply-Module-Control/dp/B00D781POM - or any of the other million hits I get when googling "PFM Control DC-DC USB 0.9V-5V to 5V dc Boost Step-up Power Supply Module"

To me it looks like a viable solution, I'm just uncertain if the XU4 can deliver enough amps, can any of you guys enlighten me?

I have never worked with the GPIO's before, so I might be completely wrong here - but I would imagine something like this working:
Following https://wiki.odroid.com/odroid-xu4/hardware/expansion_connectors - Connecting pin 2 (ground) and 4 (I2C_5.SDA) from CON11 and then turning pin 4 on/off to power on/off the USB port.
Though I can't figure out how to map the GPIO numbers to what I see in the Linux under /sys/class/gpio/ I would expect there to be some kind of correlation? I'm seeing these gpio's

Code: Select all
root@odroid:~# ls /sys/class/gpio/
export       gpiochip109  gpiochip135  gpiochip16   gpiochip179  gpiochip203  gpiochip225  gpiochip48  gpiochip69  gpiochip87
gpio31       gpiochip117  gpiochip141  gpiochip165  gpiochip185  gpiochip207  gpiochip24   gpiochip56  gpiochip77  gpiochip93
gpiochip0    gpiochip125  gpiochip149  gpiochip167  gpiochip193  gpiochip215  gpiochip32   gpiochip63  gpiochip8   unexport
gpiochip101  gpiochip133  gpiochip157  gpiochip171  gpiochip198  gpiochip217  gpiochip40   gpiochip67  gpiochip83


PS. I did think about shelling out a bit of cash for a Level Shifter Shield to get a clean 5V GPIO output, but since I'm using the XU4Q (passive cooled) version that board doesn't appear to fit, without retrofitting it even more.
elector
 
Posts: 6
Joined: Wed Aug 30, 2017 4:43 am
languages_spoken: english
ODROIDs: .
XU4 (video-streaming-project)
XU4Q (backup-server-project)
C2 (LibreELEC and Kodi)

Re: [XU4] Switch USB3.0 ports on/off

Unread postby odroid » Tue Feb 13, 2018 9:38 am

You had to export the GPIO number first.
https://wiki.odroid.com/odroid-xu4/appl ... ent_30pins

But I2C and UART pins need a device-tree tweaking before using them in GPIO mode.
Additionally, look into "lsmod" output to check whether other drivers are using some GPIO pins for other purpose or not.
User avatar
odroid
Site Admin
 
Posts: 28697
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: [XU4] Switch USB3.0 ports on/off

Unread postby mad_ady » Tue Feb 13, 2018 3:27 pm

The problem with the xu4's gpio pins is that they operate at 1.8V and that is not enough to trigger a regular relay. You need to check the minimum trigger voltage on your relay, otherwise you'll also need a transistor and two resistors to increase the command voltage.
User avatar
mad_ady
 
Posts: 4577
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [XU4] Switch USB3.0 ports on/off

Unread postby elector » Wed Feb 14, 2018 4:31 am

odroid wrote:You had to export the GPIO number first. https://wiki.odroid.com/odroid-xu4/appl ... ent_30pins

Excellent, that did the trick. Thank you for the link/info.

mad_ady wrote:The problem with the xu4's gpio pins is that they operate at 1.8V and that is not enough to trigger a regular relay.

Yes, I'm aware of that. That is why I'm looking at the step-up USB converter to solved this exact issue.

mad_ady wrote:otherwise you'll also need a transistor and two resistors to increase the command voltage.

I have seen drawings in my various googling's, but I haven't quite been able to figure out how to go by doing this.

I would call myself relative good at soldering and I know my way around resistors and other simple stuff like that. Though I have never been any good at how transistors work other than it's a form if mini switch.


I bought the step-up USB converter today. It works as advertised and delivers 5V from eg. a AA battery just fine, but it looks like the GPIO just don't deliver enough amps to make it work.

I can see that the GPIO is working and it's delivering 1.8V when I connect CON11, pin 2 (ground) and 4 (I2C_5.SDA) and execute the the following commands. So far so good.
Code: Select all
echo 187 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio187/direction
#on
echo 1 > /sys/class/gpio/gpio187/value
#off
echo 0 > /sys/class/gpio/gpio187/value


When I connect the step-up alone the voltage stays at 1.8V on the GPIO side and goes to 5V on the USB side, BUT when I connect a small fan or the USB-Relay the voltage drops to about 0.5V - My conclusion to this is that the XU4 doesn't deliver enough amps, does this sound about right?

Any good advice on how to proceed?

Is it possible to "bundle" two GPIO ports, to deliver 2x the amps? Like GPIO 187 and 188, and then turn them both on? Or maybe that would just fry it?

Any ideas are welcome.
elector
 
Posts: 6
Joined: Wed Aug 30, 2017 4:43 am
languages_spoken: english
ODROIDs: .
XU4 (video-streaming-project)
XU4Q (backup-server-project)
C2 (LibreELEC and Kodi)

Re: [XU4] Switch USB3.0 ports on/off

Unread postby odroid » Wed Feb 14, 2018 9:59 am

The GPIO maximum current should be only a few milli-amp. You might damage the SoC if you connect a heavy load continuously.
You have to use a transistor to drive a large load as other people recommended.
User avatar
odroid
Site Admin
 
Posts: 28697
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID


Return to Hardware and peripherals

Who is online

Users browsing this forum: No registered users and 3 guests