jdb
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2160
Joined: Thu Jul 11, 2013 2:37 pm

VL805 firmware release 0137ac - improved USB downstream power switching

Wed Dec 04, 2019 8:27 pm

We've received an updated firmware from VLI that allows for port power control, i.e. turning off downstream USB devices.

The attached zip file contains an updated firmware and patch file. Note: rebooting is required after flashing the new firmware.

Step 1: Flash the firmware to the VLI EEPROM:

Code: Select all

# if not already installed, install the rpi-eeprom package:
sudo apt install rpi-eeprom
sudo vl805 -w vl805_fw_0137ac.bin
sudo reboot

Step 2: build uhubctl
uhubctl can be used to manipulate port power - but needs patching to allow switching of ganged port power. Copy the code patch in the zipfile to the uhubctl directory and apply the patch as shown below. Build, patch and install uhubctl with:

Code: Select all

sudo apt install libusb-1.0-0-dev
git clone https://github.com/mvp/uhubctl
cd uhubctl
# copy the attached patchfile from the zip to the uhubctl directory
git apply uhubctl.patch
make
sudo make install

Step 3:
To power off the downstream ports, both the internal USB2 hub and USB3 root hub need to be powered off, as the external power control pin ORs the two hub power controls together.

Power off:

Code: Select all

sudo uhubctl -e -a 0 -l 2
sudo uhubctl -e -a 0 -l 1-1
power on:

Code: Select all

sudo uhubctl -e -a 1 -l 2
sudo uhubctl -e -a 1 -l 1-1
Please test and report back.
Attachments
vl805_fw_0137ac.zip
(41.46 KiB) Downloaded 42 times
Rockets are loud.
https://astro-pi.org

Jochem
Posts: 3
Joined: Wed Dec 04, 2019 9:05 pm

Re: VL805 firmware release 0137ac - improved USB downstream power switching

Wed Dec 04, 2019 9:26 pm

> Please test and report back.

Reporting back:
1. FW install OK:

Code: Select all

[email protected]:~/uhubctl $ sudo rpi-eeprom-update
BOOTLOADER: up-to-date
CURRENT: ma 18 nov 2019 11:06:55 UTC (1574075215)
 LATEST: ma 18 nov 2019 11:06:55 UTC (1574075215)
VL805: update required
CURRENT: 000137ac
 LATEST: 000137ab
2. patching does not work:

Code: Select all

[email protected]:~/uhubctl $ git apply uhubctl.patch
error: patch failed: uhubctl.c:413
error: uhubctl.c: patch does not apply
[email protected]:~/uhubctl $
Fyi:

Code: Select all

[email protected]:~/uhubctl $ ls -l
totaal 100
-rw-r--r-- 1 pi pi 18092 dec  4 22:02 COPYING
drwxr-xr-x 2 pi pi  4096 dec  4 22:02 Formula
-rw-r--r-- 1 pi pi   706 dec  4 22:02 LICENSE
-rw-r--r-- 1 pi pi  1157 dec  4 22:02 Makefile
-rw-r--r-- 1 pi pi 18294 dec  4 22:02 README.md
-rw-r--r-- 1 pi pi 34771 dec  4 22:02 uhubctl.c
-rw-r--r-- 1 pi pi   543 dec  4 22:02 uhubctl_git.bb
-rw-r--r-- 1 pi pi   916 dec  4 20:35 uhubctl.patch
-rw-r--r-- 1 pi pi    11 dec  4 22:02 VERSION
[email protected]:~/uhubctl $ cat VERSION
v2.1.0-dev
After patching by hand, make and make install and powering off:

Code: Select all

[email protected]:~/uhubctl $ sudo uhubctl -e -a 0 -l 2
Current status for hub 2 [1d6b:0003 Linux 4.19.75-v7l+ xhci-hcd xHCI Host Controller 0000:01:00.0, USB 3.00, 4 ports]
  Port 1: 02a0 power 5gbps Rx.Detect
  Port 2: 02a0 power 5gbps Rx.Detect
  Port 3: 02a0 power 5gbps Rx.Detect
  Port 4: 02a0 power 5gbps Rx.Detect
Sent power off request
New status for hub 2 [1d6b:0003 Linux 4.19.75-v7l+ xhci-hcd xHCI Host Controller 0000:01:00.0, USB 3.00, 4 ports]
  Port 1: 0080 off
  Port 2: 0080 off
  Port 3: 0080 off
  Port 4: 0080 off
[email protected]:~/uhubctl $ sudo uhubctl -e -a 0 -l 1-1
Current status for hub 1-1 [2109:3431 USB2.0 Hub, USB 2.10, 4 ports]
  Port 1: 0100 power
  Port 2: 0100 power
  Port 3: 0100 power
  Port 4: 0100 power
Sent power off request
New status for hub 1-1 [2109:3431 USB2.0 Hub, USB 2.10, 4 ports]
  Port 1: 0000 off
  Port 2: 0000 off
  Port 3: 0000 off
  Port 4: 0000 off
All looks good. But according to my POE port, the same power is delivered before and after, in my case 3,5 watt

trejan
Posts: 899
Joined: Tue Jul 02, 2019 2:28 pm

Re: VL805 firmware release 0137ac - improved USB downstream power switching

Thu Dec 05, 2019 12:03 am

Jochem wrote:
Wed Dec 04, 2019 9:26 pm
All looks good. But according to my POE port, the same power is delivered before and after, in my case 3,5 watt
What do you have plugged into the USB ports?

jdb
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2160
Joined: Thu Jul 11, 2013 2:37 pm

Re: VL805 firmware release 0137ac - improved USB downstream power switching

Thu Dec 05, 2019 7:38 pm

trejan wrote:
Thu Dec 05, 2019 12:03 am
Jochem wrote:
Wed Dec 04, 2019 9:26 pm
All looks good. But according to my POE port, the same power is delivered before and after, in my case 3,5 watt
What do you have plugged into the USB ports?
It goes without saying that you won't notice any device power savings unless you have devices in your USB ports...

The
Jochem wrote:
2. patching does not work:

Code: Select all

[email protected]:~/uhubctl $ git apply uhubctl.patch
error: patch failed: uhubctl.c:413
error: uhubctl.c: patch does not apply
[email protected]:~/uhubctl $
Patch got mangled with DOS line endings (doh). Will fix and post when updated.
Rockets are loud.
https://astro-pi.org

Jochem
Posts: 3
Joined: Wed Dec 04, 2019 9:05 pm

Re: VL805 firmware release 0137ac - improved USB downstream power switching

Thu Dec 05, 2019 8:49 pm

> It goes without saying that you won't notice any device power savings unless you have devices in your USB ports...

I expected a "power down" of the VL805 chip and maybe a big saving like the 200mA with the 3B as is discussed in other threads. Using only ethernet and trying to minimize power drawn by shutting of the main consumers, like WiFi and -i hoped- USB.

Clearly, i missed the "port power control" of the op. Sorry for that..

Jochem
Posts: 3
Joined: Wed Dec 04, 2019 9:05 pm

Re: VL805 firmware release 0137ac - improved USB downstream power switching

Thu Dec 05, 2019 9:08 pm

Anyhow, it seems to work. Baseline 3.5W. After attaching a device the Pi draws 4.2W, shutting the ports off brings it back to the baseline.

tvjon
Posts: 715
Joined: Mon Jan 07, 2013 9:11 am

Re: VL805 firmware release 0137ac - improved USB downstream power switching

Thu Dec 05, 2019 11:02 pm

> Please test and report back.

$ sudo uhubctl -e -a 0 -l 2
Current status for hub 2 [1d6b:0003 Linux 4.19.86-v7l+ xhci-hcd xHCI Host Controller 0000:01:00.0, USB 3.00, 4 ports]
Port 1: 0203 power 5gbps U0 enable connect [0480:a202 TOSHIBA External USB 3.0 20160312012904F]
Port 2: 02a0 power 5gbps Rx.Detect
Port 3: 02a0 power 5gbps Rx.Detect
Port 4: 02a0 power 5gbps Rx.Detect
Sent power off request
New status for hub 2 [1d6b:0003 Linux 4.19.86-v7l+ xhci-hcd xHCI Host Controller 0000:01:00.0, USB 3.00, 4 ports]
Port 1: 0080 off
Port 2: 0080 off
Port 3: 0080 off
Port 4: 0080 off


$ sudo uhubctl -e -a 0 -l 1-1
Current status for hub 1-1 [2109:3431 USB2.0 Hub, USB 2.10, 4 ports]
Port 1: 0503 power highspeed enable connect [0480:a202 TOSHIBA External USB 3.0 20160312012904F]
Port 2: 0100 power
Port 3: 0100 power
Port 4: 0100 power
Sent power off request
New status for hub 1-1 [2109:3431 USB2.0 Hub, USB 2.10, 4 ports]
Port 1: 0000 off
Port 2: 0000 off
Port 3: 0000 off
Port 4: 0000 off



$ sudo uhubctl -e -a 1 -l 2
Current status for hub 2 [1d6b:0003 Linux 4.19.86-v7l+ xhci-hcd xHCI Host Controller 0000:01:00.0, USB 3.00, 4 ports]
Port 1: 0080 off
Port 2: 0080 off
Port 3: 0080 off
Port 4: 0080 off
Sent power on request
New status for hub 2 [1d6b:0003 Linux 4.19.86-v7l+ xhci-hcd xHCI Host Controller 0000:01:00.0, USB 3.00, 4 ports]
Port 1: 02a0 power 5gbps Rx.Detect
Port 2: 02a0 power 5gbps Rx.Detect
Port 3: 02a0 power 5gbps Rx.Detect
Port 4: 02a0 power 5gbps Rx.Detect


$ sudo uhubctl -e -a 1 -l 1-1
Current status for hub 1-1 [2109:3431 USB2.0 Hub, USB 2.10, 4 ports]
Port 1: 0000 off
Port 2: 0000 off
Port 3: 0000 off
Port 4: 0000 off
Sent power on request
New status for hub 1-1 [2109:3431 USB2.0 Hub, USB 2.10, 4 ports]
Port 1: 0100 power
Port 2: 0100 power
Port 3: 0100 power
Port 4: 0100 power


In the file manager, a replicated disc icon appears. Clicking on it produces the error window attached.
Attachments
high.jpg
high.jpg (19.2 KiB) Viewed 696 times
low.jpg
low.jpg (22 KiB) Viewed 696 times
duplicateMount Icon.png
duplicateMount Icon.png (9.78 KiB) Viewed 696 times

trejan
Posts: 899
Joined: Tue Jul 02, 2019 2:28 pm

Re: VL805 firmware release 0137ac - improved USB downstream power switching

Thu Dec 05, 2019 11:06 pm

tvjon wrote:
Thu Dec 05, 2019 11:02 pm
In the file manager, a replicated disc icon appears. Clicking on it produces the error window attached.
You need to unmount your HD first. Turning off the port power is roughly equivalent to you pulling out the USB plug of your Toshiba HD.

tvjon
Posts: 715
Joined: Mon Jan 07, 2013 9:11 am

Re: VL805 firmware release 0137ac - improved USB downstream power switching

Thu Dec 05, 2019 11:10 pm

The only reason I mentioned it was because I *did* unmount the disc as I normally do, before issuing the relevant commands.

However 2 disc icons appeared back.

Also note the spelling error in the window message.

trejan
Posts: 899
Joined: Tue Jul 02, 2019 2:28 pm

Re: VL805 firmware release 0137ac - improved USB downstream power switching

Thu Dec 05, 2019 11:54 pm

tvjon wrote:
Thu Dec 05, 2019 11:10 pm
The only reason I mentioned it was because I *did* unmount the disc as I normally do, before issuing the relevant commands.

However 2 disc icons appeared back.
Oops. Sorry. Does dmesg say anything? Did it start on sda or sdb?

fik
Posts: 14
Joined: Thu Jan 17, 2013 1:34 pm

Re: VL805 firmware release 0137ac - improved USB downstream power switching

Fri Dec 06, 2019 9:31 am

tvjon wrote:
Thu Dec 05, 2019 11:10 pm
The only reason I mentioned it was because I *did* unmount the disc as I normally do, before issuing the relevant commands.
However 2 disc icons appeared back.
What about unmounting and then ejecting the disk before stopping the power?

Code: Select all

echo 1 > /sys/block/sdx/device/delete

andrum99
Posts: 931
Joined: Fri Jul 20, 2012 2:41 pm

Re: VL805 firmware release 0137ac - improved USB downstream power switching

Fri Dec 06, 2019 5:05 pm

Is this firmware update intended to allow Linux to automatically save power by switching off certain USB ports, or will this always need a manual twiddle?

trejan
Posts: 899
Joined: Tue Jul 02, 2019 2:28 pm

Re: VL805 firmware release 0137ac - improved USB downstream power switching

Fri Dec 06, 2019 5:22 pm

andrum99 wrote:
Fri Dec 06, 2019 5:05 pm
Is this firmware update intended to allow Linux to automatically save power by switching off certain USB ports
No. It is for people that want to power cycle their USB devices. All of the ports get turned off/on together though.
andrum99 wrote:
Fri Dec 06, 2019 5:05 pm
will this always need a manual twiddle?
Yep.

goodburner
Posts: 59
Joined: Sun Jun 16, 2019 3:20 am

Re: VL805 firmware release 0137ac - improved USB downstream power switching

Sun Dec 08, 2019 6:13 am

Code: Select all

git apply --ignore-space-change --ignore-whitespace uhubctl.patch
adding --ignore-space-change --ignore-whitespace works for applying the patch.

User avatar
Gavinmc42
Posts: 4057
Joined: Wed Aug 28, 2013 3:31 am

Re: VL805 firmware release 0137ac - improved USB downstream power switching

Sun Dec 08, 2019 7:58 am

It is for people that want to power cycle their USB devices. All of the ports get turned off/on together though.
Could be useful for USB powered Pi Zero's when they are USB booting.
Not sure if there will be mouse/keyboard conflicts, test via VNC?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Return to “Advanced users”