179 Commits
v1.8 ... v2.4.0

Author SHA1 Message Date
Vadim Mikhailov
014b55ac5d Release version 2.4.0 2021-02-13 16:21:16 -08:00
Vadim Mikhailov
92736a8604 Honor PKG_CONFIG variable if exists
Some build systems want to pass location for pkg-config.

Closes #315.
2021-02-11 17:48:11 -08:00
Vadim Mikhailov
9f1de74523 Clarify that we do not maintain list of unsupported hubs
Closes #312.
2021-02-05 15:40:21 -08:00
Vadim Mikhailov
9b73c8e314 Note that PAUH212 is also supported
Closes #311.
2021-02-05 15:32:05 -08:00
Vadim Mikhailov
fa449eac0b Add a note that D-Link DUB-H4 rev B7+ is not supported
Closes #307.
2021-01-21 13:16:46 -08:00
Vadim Mikhailov
9b5efa0ec0 Simplify code that powers on/off
* Simplified code that powers on/off.
* Fixed minor bug for repeat counter (always once to power off, and opt_repeat times to power on).
* Only warn about USB permissions if no compatible hubs are detected.
  Old behavior would always warn, even if permissions were missing for any hub (even unsupported ones).
2021-01-17 14:34:11 -08:00
comzine
b99a0805bb Added feature toggle mode (#305)
Added feature toggle mode

Co-authored-by: Tobias Weber <comzine@gmail.com>
2021-01-17 11:28:44 -08:00
Vadim Mikhailov
6ac502a07a Add ExSys EX-1113HMS as compatible device
Closes #303.
2021-01-15 09:28:02 -08:00
Vadim Mikhailov
f76dc98653 Refactor README section for Raspberry Pi
Move workaround closer to the question context.
2020-12-16 09:04:26 -08:00
Vadim Mikhailov
592d60b9ab Add a note to Anker AK-68ANHUB-BV7A-0004
Closes #300.
2020-12-16 08:49:30 -08:00
Vadim Mikhailov
4b663f3d15 Add Aukey CB-C59 as compatible device
Closes #299.
2020-12-15 11:43:05 -08:00
Vadim Mikhailov
6a43ea9c5c Add Controlling USB LED Strip to notable projects 2020-12-14 11:30:39 -08:00
Vadim Mikhailov
6f136f17fe Add Port NWUSB01 as compatible device
Closes #298.
2020-12-14 11:23:29 -08:00
Vadim Mikhailov
8d8b66c5c6 Release version 2.3.0 as stable brew tap 2020-12-13 14:56:43 -08:00
Vadim Mikhailov
1b52efddbd Release version 2.3.0 2020-12-13 14:31:05 -08:00
Vadim Mikhailov
71a4274615 Print uhubctl version as last item in --help output 2020-12-13 13:08:32 -08:00
Vadim Mikhailov
d98e6deb6e README clarifications
* Clarify how to build and install
* Clarify USB permissions
* Mention force flag -f
2020-12-13 12:53:28 -08:00
Vadim Mikhailov
ac5a704449 Fix homebrew formula
* Document installing from stable version by default.
* Automatically install pkg-config which benefits getting proper CFLAGS/LDFLAGS.
* Specify license field.
2020-12-11 00:53:40 -08:00
Vadim Mikhailov
1e65ff9b05 Remove MacOS libusb workaround
Now that libusb-1.0.24 is released https://github.com/libusb/libusb/issues/618,
workaround is no longer needed.

Also, replace MacOS X references to just MacOS (since it works on MacOS 11 Big Sur too).

This finally fixes issue #227.
2020-12-10 15:32:44 -08:00
Vadim Mikhailov
77aeb7f30b Implement searching by device description
Add switch --search (-s) to limit hubs by attached device description.
It is recommended to specify search string that is as unique as possible, e.g. device serial number.
It should work for "off" and "cycle" actions, but not for "on" because device would not be visible on USB.

Closes #209.
2020-12-08 18:40:13 -08:00
Vadim Mikhailov
e65d077712 Do not allow just commit id to be used as version
Homebrew is forcing `--no-tags` for cloned repos.
Because we used `git describe --always` brew was choosing raw commit id as version, which is quite bad.
By removing `--always` we will use contents of VERSION file as a backup.
2020-12-08 15:24:41 -08:00
Vadim Mikhailov
0cc09299fe Add a switch to allow operation on unsupported hubs
Show power switching type supported by a hub:

* ppps   - per-port power switching
* ganged - ganged power switching
* nops   - no power switching

Add --force (-f) switch to allow operation on non-ppps hubs.
Use `-f` at your own risk, this most likely will not work to actually switch power.

For ganged hubs, you may need to turn power off for all hub ports to get any effect.
For nops hubs, it is not likely to work at all, but might be useful for informational purposes.

Also, instead of printing recipe on how to fix USB permissions on Linux,
forward user to web page with detailed explanations.

Closes #260, #280.
2020-12-07 18:43:22 -08:00
Vadim Mikhailov
44f963d00f Improve USB2/3 duality matching
Use priority based duality matching.

* Support Raspberry Pi 4B better (as it has USB2 hub one level deeper than its USB3 counterpart).
* Support M1 Macs (as they seem to place all USB devices to bus 2).
* Support Apple mini-dock (it advertises 2 USB2 ports but only 1 USB3 port).
* Should support multiple identical hubs (with the same container id) on Linux.
2020-12-07 11:32:29 -08:00
Vadim Mikhailov
d3a79ace46 Use pkg-config when available
Remove custom handling for different platforms for CFLAGS and LDFLAGS
and prefer using pkg-config when available.
However, this is tested to still build ok on Linux on Mac howebrew
even if pkg-config is not available.

Closes #292, should also simplify issues raised by #142, #147, #289 and 5db248771e.
2020-12-05 21:24:17 -08:00
Vadim Mikhailov
0e733b6901 Add a note that D-Link DUB-H7 rev F is not supported
Closes #291.
2020-12-01 11:37:07 -08:00
Vadim Mikhailov
50d5501d91 Clarify how to configure udev permissions for USB3 hubs 2020-11-27 11:07:36 -08:00
Jim Klimov
9183aef17e Makefile: add support for "SunOS" (e.g. with modern illumos) 2020-11-26 14:56:16 -08:00
Vadim Mikhailov
4b10fdbd24 Add Anker AK-68ANHUB-BV7A-0004 as supported device
Closes #287.
2020-11-25 09:12:04 -08:00
Julius Henke
3cc17baae1 Add Dell S2719DGF to compatible hubs list 2020-11-24 12:09:22 -08:00
Vadim Mikhailov
db8c4a59f3 Document another workaround for getting working libusb on MacOS
Previous workaround of getting working `libusb` on MacOS is no longer supported by Homebrew,
so now recommended fix is to install `libusb` from HEAD.

This workaround will be removed once libusb 1.0.24 is released and is provided by Homebrew by default.
2020-11-11 12:35:59 -08:00
Vadim Mikhailov
77d8851c34 Add Microchip EVB-USB2534BC as supported device
Closes #277.
2020-11-01 10:39:34 -08:00
Vadim Mikhailov
dcb1e611f7 Add Rosonway RSH-16 as compatible device
This hub is built from 5 * 4-port USB chips in daisy chain. Unfortunately, it advertises
identical bos container IDs for all 5 hubs of them, which will cause issues controlling power in USB3 mode -
one would have to call uhubctl twice with `-e` to turn off both USB2 and USB3 hub pair ports properly.

Rosonway also sells this hub under RSHTECH brand in some markets.

Closes #276.
2020-10-23 10:44:06 -07:00
Vadim Mikhailov
a7b5f6b362 Add a note about USB authorization on Linux 2020-10-06 10:54:08 -07:00
Vadim Mikhailov
2a4df4ee6c Warn about possible incompatibility for Dell P2416D 2020-10-06 10:53:57 -07:00
Vadim Mikhailov
f610598227 Fixed accidentally dropped AmazonBasics HUC9002V1ESL
Also split HU900* and HUC900* items to two separate lines to avoid table becoming too wide.
2020-09-14 23:35:18 -07:00
Vadim Mikhailov
3bc22e3cd7 Clarify RPi4B support for USB-C OTG port
Closes #266.
2020-09-09 12:10:17 -07:00
Vadim Mikhailov
0f6218dfb8 Add AmazonBasics HUC9003V1EBL 7-port USB 3.1 hub as supported device
Closes #261.
2020-08-11 20:48:36 -07:00
Vadim Mikhailov
91035987e4 Mention that D-Link DUB-H4 rev F is not supported
Closes #259.
2020-08-05 15:22:25 -07:00
Vadim Mikhailov
c6927085ec Add NVidia Jetson Nano B01 as supported device
Closes #258.
2020-08-01 01:24:40 -07:00
Vadim Mikhailov
5b1ae79b05 Clarify RPi4B firmware requirement and checking current version
Firmware VL805 00137ac was an alpha verson that was never released.
Change firmware requirement to stable version VL805 00137ad,
and provide easy way to check if it is compliant.
2020-07-25 13:34:43 -07:00
Vadim Mikhailov
b8a1b808e7 Remove StarTech ST4200USBM from supported table
There are multiple reports that VBUS off is not supported by ST4200USBM.
Closes #254.
2020-07-06 11:07:26 -07:00
Vadim Mikhailov
f75bda6896 Removed Belkin F5U701-BLK from supported devices list
Unfortunately, F5U701-BLK does not support per-port power switching, as reported in #252.
2020-06-29 18:15:17 -07:00
Vadim Mikhailov
e171813596 Update device table for AmazonBasics 10 port hub HU[C]9002V1{SBL,ESL}
Apparently all following hubs: HU9002V1SBL, HU9002V1ESL, HUC9002V1SBL, HUC9002V1EBL
are almost the same, with C models including USB-C cable.
Update device table to reflect this.

Closes #246.
2020-06-25 13:25:48 -07:00
Vadim Mikhailov
5257d8567d Add D-Link DUB-H7 rev E as supported device
Closes #244.
2020-06-17 16:34:57 -07:00
Vadim Mikhailov
5ee8260c71 Release version 2.2.0 2020-05-22 13:39:47 -07:00
Vadim Mikhailov
8ba36bd8df Improve getting version from git describe
* To determine version, only consider tags starting with v{digit}
* Strip v prefix from version
2020-05-22 13:21:45 -07:00
Vadim Mikhailov
aaf87accad Add Seagate Backup Plus Hub STEL8000100 as supported device
Closes #238.
2020-05-16 15:16:46 -07:00
Sarah Foster
58385b87e6 Update README.md
Just a small typo correction
2020-04-27 22:03:45 -07:00
Vadim Mikhailov
7bf80a08d1 Update Rasperry Pi 4B USB topology note
Apparently, controlling only port 4 is not enough to actually turn power off for RPi4B.
Instead, note that all 4 ports should be turned off. Closes #233.
2020-04-24 17:45:01 -07:00
Vadim Mikhailov
b73213dd6d Mention testing VBUS off in README before reporting new devices 2020-04-14 22:53:38 -07:00
Vadim Mikhailov
e327f5aeb1 Move keyboard/mouse warning to usage section 2020-04-14 22:47:21 -07:00
Vadim Mikhailov
9b824b5587 Add Control USB Lamp With Voice to notable projects
Also fix some broken links.
2020-04-14 22:38:49 -07:00
Vadim Mikhailov
aa864285b1 Add LG Electronics 38WK95C-W as supported device
Closes #231.
2020-04-14 22:15:16 -07:00
Vadim Mikhailov
fa524cf7df Add AmazonBasics HUC9002V1ESL as supported device
AmazonBasics HUC9002V1ESL seems to be EU version of HU9002V1SBL and works the same.
Closes #229.
2020-04-04 13:27:11 -07:00
Vadim Mikhailov
7fd3080f90 Add Raspberry Pi Reboot Router into notable projects 2020-04-04 10:38:40 -07:00
Vadim Mikhailov
e3734e052f Provide workaround for using uhubctl on MacOS Catalina
This provides workaround for issue #227.
Will be fully solved only by https://github.com/libusb/libusb/issues/707.
2020-03-26 21:30:02 -07:00
Vadim Mikhailov
d576db98fb Mention udisksctl in README 2020-02-25 22:21:43 -08:00
Vadim Mikhailov
9e402917dc Add Bytecc BT-UH340 as compatible device
Reported in #217.
2020-02-25 22:11:56 -08:00
Vadim Mikhailov
b0d321a041 Add D-Link DUB-H4 rev E as supported device
Reported in #212.
2020-02-17 11:26:25 -08:00
Vadim Mikhailov
0d2aa24bae Remove statement about proper per-port switching on RPi3B+
Per discussion in issue #215, proper per-port power switching
is not necessarily supported on RPi3B+ secondary hub ports.
2020-02-17 11:21:17 -08:00
Vadim Mikhailov
bd92bcef2f Add a warning and link how to update RPi4B firmware to make power switching work 2020-01-28 11:24:49 -08:00
Vadim Mikhailov
ea70731854 Use in-document anchors to Raspberry Pi usage examples 2020-01-27 23:41:30 -08:00
Vadim Mikhailov
6366aea0bd Refactor Raspberry Pi USB topology table with sub-headers 2020-01-27 23:33:53 -08:00
Vadim Mikhailov
232dcc6f6d Clarify support for different Raspberry Pi models with example commands
* Reformat markdown
* Add example uhubctl commands to turn power off for affected port(s)
* Removed some low level techical details about USB descriptors
2020-01-21 23:58:17 -08:00
Vadim Mikhailov
5691db3379 Add Buffalo BSH4A05U3BK as supported device 2020-01-21 23:04:02 -08:00
Vadim Mikhailov
fae3da7e6f Bump copyright year 2020-01-20 12:14:48 -08:00
Vadim Mikhailov
c79c9ac667 Add Basler 2000036234 as supported device
Reported in #208.
2020-01-20 12:09:36 -08:00
Ryan O'Leary
7f25162ed3 Add AmazonBasics HU9002V1SBL as a Supported Device
Signed-off-by: Ryan O'Leary <ryanoleary@google.com>
2020-01-07 23:01:04 -08:00
Vadim Mikhailov
6f84663c6a Clarify VBUS off requirements for Raspberry Pi 4 2020-01-05 14:05:25 -08:00
Vadim Mikhailov
4aae44ced0 Add support for Raspberry Pi 4
Hack to support Raspberry Pi 4:

* Override ganged power switching reported by USB2 hub as per-port. This is not necessarily true,
  but is consistent with per-port power switching returned by dual USB3 root hub.
  Proper fix is for Raspberry Pi 4 USB firmware to return consistent descriptor information.

* When root USB3 hub is detected on RPi4 without ContainerID, it is assumed to have
  ContainerID of dual USB2 hub, so USB2/3 duality is still working as expected.
  Proper fix would be for USB3 root hub to report correct ContainerID.
2020-01-05 13:43:14 -08:00
Mark Deneen
9857849c0e Update license hash to correct value, fixing yocto building 2019-11-18 13:51:49 -08:00
Vadim Mikhailov
821cdb8833 Update Dell U2415 info 2019-11-15 00:11:09 -08:00
Vadim Mikhailov
c387442b0c Add D-Link DUB-H4 rev B as supported device
Reported in #188.
2019-11-12 17:58:21 -08:00
Vadim Mikhailov
b690bd376a Add Belkin F5U101 as supported device
Reported in #187.
2019-11-12 17:58:21 -08:00
Vadim Mikhailov
c220668adc Add Dell UltraSharp U2415 as supported device
Reported in #191
2019-11-12 12:01:07 -08:00
Karsten Hohmeier
3e10680f22 Fix compile warning about format truncation by increasing buffer size for description 2019-11-05 13:52:24 -08:00
Vadim Mikhailov
39b407a863 Add Juiced Systems 6+1+1 USB 3.0 Gigabit Ethernet Smart Charging Hub (6HUB-01) as supported device
Reported in #184.
2019-11-01 22:27:14 -07:00
Vadim Mikhailov
d227c8326f Don't complain about USB permission problems if we are already root 2019-10-23 22:52:44 -07:00
Vadim Mikhailov
743ecf226b Relax level check when looking for USB2/3 dual hubs
Some devices (notably Raspberry 4B) have USB3 hub that advertises
its USB2 compatibility partner at different depth level.
Raspberry 4B onboard hub doesn't yet support uhubctl directly
(but it should once https://github.com/raspberrypi/linux/issues/3079 is fixed),
but this breaks level check restriction for any external USB3 hub attached to RPi4B
- so this check has been removed.
2019-10-16 23:25:36 -07:00
Vadim Mikhailov
fd611df1e7 Remove Coolgear USBG-4U3MLR2 from supported list
After deeper look, it turns out that this hub doesn't really work,
see more in issue #177.
2019-10-16 23:20:53 -07:00
Vadim Mikhailov
a6cdc3dc4b Remove Plugable USB2-HUB10S from supported list
As reported in issue #181, Plugable USB2-HUB10S does not support per-port power switching.
2019-10-08 18:15:19 -07:00
Vadim Mikhailov
609d0bcae1 Clarify which revisions of D-Link hubs are working 2019-10-05 20:48:00 -07:00
Vadim Mikhailov
54365acb8d Update info for Coolgear USBG-4U3MLR2 2019-10-01 10:33:36 -07:00
Vadim Mikhailov
6e5782c3b7 Add Coolgear USBG-4U3MLR2 as supported device
Reported in #177.
2019-09-26 22:23:07 -07:00
Vadim Mikhailov
59447ce431 Add ThinkPad Ultra Docking Station 40AJ0135EU as supported device
Reported in #176.
2019-09-24 12:47:15 -07:00
Vadim Mikhailov
05647714b6 Apply debian hardening suggestions for Linux
Follow hardening tips per https://wiki.debian.org/Hardening.
We have already applied `-z relro` before, now add `-z now` as well.
2019-09-20 17:43:36 -07:00
Vadim Mikhailov
4818eddc03 FreeBSD is using bNumDeviceCapabilities instead of bNumDeviceCaps
FreeBSD libusb is different from mainline libusb, and needs hacks here and there :-(

This resolves issue #175.
2019-09-20 15:29:30 -07:00
Vadim Mikhailov
c9fa3c68a1 Release version 2.1.0 2019-09-02 23:12:50 -07:00
Vadim Mikhailov
beea0c0fc7 Use longer git hash for dirty version 2019-09-02 23:12:46 -07:00
Vadim Mikhailov
1856ae9d59 Use --location for long option name
Add --location as long option name - it is still backwards compatible with --loc.
2019-09-02 23:09:56 -07:00
Jonathan Liu
2b9b336038 Add Phidgets HUB0003_0 as supported device 2019-08-29 22:25:16 -07:00
Vadim Mikhailov
1961aa02e9 Add explicit workaround for USB device not removed after port power down on Linux 2019-07-31 13:14:24 -07:00
Vadim Mikhailov
5db248771e Add support for NetBSD
This adds support to be able to build and use uhubctl on NetBSD by using pkg-config to get proper CFLAGS and LDFLAGS.
Perhaps we should use pkg-config universally across all platforms,
but I don't want to potentially break support for existing plaftorms
because pkg-config does not seem to be unconditionally available everywhere.
2019-07-26 18:00:49 -07:00
Vadim Mikhailov
9cae5e275f Add ThinkPad X6 Ultrabase as supported device
Reported in #165.
2019-07-23 21:31:20 -07:00
Vadim Mikhailov
324acc66fd Add status for Raspberry 4B support
Added a link to Raspberry 4B issue https://github.com/raspberrypi/linux/issues/3079.
Once this is fixed in firmware, uhubctl should start working on 4B.
2019-07-22 23:21:47 -07:00
Vadim Mikhailov
15f2d37d79 Add buildenlights (red/green project status lights) to notable projects 2019-07-22 22:53:00 -07:00
Vadim Mikhailov
5f8426105c USB2/3 duality: require serial numbers match only if both present
I have observed a hub which had serial number present for USB2 compatibility hub,
but not for USB3, which broke USB2/3 duality handling:

    Current status for hub 4-4 [0451:8140, USB 3.00, 4 ports]
      Port 1: 06a0 power Rx.Detect
      Port 2: 06a0 power Rx.Detect
      Port 3: 06a0 power Rx.Detect
      Port 4: 06a0 power Rx.Detect
    Current status for hub 3-13 [0451:8142 210C08692601, USB 2.10, 4 ports]
      Port 1: 0100 power
      Port 2: 0100 power
      Port 3: 0100 power
      Port 4: 0100 power

This fix will only compare serial numbers if they are both present.
2019-07-15 10:45:21 -07:00
Vadim Mikhailov
945d08e62c Add FAQ
Added FAQ with issues that are often asked  and tend to have duplicate issues opened.
2019-07-13 18:14:55 -07:00
Vadim Mikhailov
078f9ee9c6 Add Dell P2416D 24" QHD Monitor as supported device
Reported in #164.
2019-07-11 11:48:23 -07:00
Vadim Mikhailov
75023dc28c Stop searching if matching device is found
This is minor fix for issue #161.
2019-07-04 10:46:25 -07:00
Vadim Mikhailov
a510d091af Implemented reading ContainerID from BOS descriptor to detect USB2/3 dual devices
Per USB 3.0 spec, chapter 11.2:

> Within a USB 3.0 hub, both the SuperSpeed and USB 2.0 hub devices shall implement in the hub framework
> a common standardized ContainerID to enable software to identify the physical relationship of the hub devices.
> The ContainerID descriptor is a part of the BOS descriptor set.

* Read ContainerID from BOS descriptor.
* get_device_description() now returns struct with vendor, product, serial number as well as full description.
* Use ContainerID to improve finding dual hubs. This seems to work very well on any OS.
  However, this may still fail if two or more identical hubs use the same hardcoded ContainerID
  In this case, we still try to look for other clues like serial number match if possible.

This fixes issue #161.
2019-07-04 00:45:22 -07:00
Vadim Mikhailov
d8f75116c8 Add Dell UltraSharp 1704FPT as supported device
Reported in #157.
2019-06-16 22:50:05 -07:00
Vadim Mikhailov
94a95a7011 Fixed info about Moxa Uport-407 7-port hub 2019-06-16 21:12:17 -07:00
Vadim Mikhailov
04238bf939 Add VID:PID for Moxa Uport-407 and also update release year
This fixes issue #154.
2019-06-15 15:12:18 -07:00
Vadim Mikhailov
a9da51fb1c Fixed help text for level, some code style fixes 2019-05-17 14:38:17 -07:00
mvp
40cdb66d66 Merge pull request #152 from wjzhou/tux/level-match
add a level hub filter
2019-05-17 14:33:00 -07:00
Wujun Zhou
ee0287077b fix %d is used by the printf 2019-05-17 15:47:16 -04:00
Wujun Zhou
798d2323a9 fix help text for level 2019-05-17 15:43:23 -04:00
Wujun Zhou
bd3e398f4e add comment for the same level check in dual 2019-05-17 15:40:39 -04:00
Wujun Zhou
74a5d721c5 use 0 as opt_level wildcard 2019-05-17 15:39:10 -04:00
Wujun Zhou
134decf02b c style change 2019-05-17 15:27:38 -04:00
Wujun Zhou
dab7ab8320 check for level when match dual 2019-05-14 14:30:46 -04:00
Wujun Zhou
1926954998 add level parameter 2019-05-14 11:48:59 -04:00
Vadim Mikhailov
e93d1a06a2 Use version from VERSION file if git describe fails
This fixes issue #100.

We prefer to determine version from git tags (using git describe).
However, sometimes people don't use git or don't have it installed,
which leads to empty version used.
To solve this, we use version from VERSION file as a backup.
2019-04-28 11:38:17 -07:00
Vadim Mikhailov
fc7aabb529 Support fractional seconds for delay
Allow power cycle delay to be fractional seconds, e.g. not only 2 sec,
but also like 0.3 sec or 1.5 sec.
2019-04-16 15:23:19 -07:00
Vadim Mikhailov
f80467f0fb Fixed broken links in notable projects
Unfortunately, goo.gl does not allow to create new short links anymore,
so slowly switching over to bit.ly.
2019-03-18 11:13:06 -07:00
Vadim Mikhailov
8bbf37f301 Add "USB fan for Raspberry Pi" to notable projects 2019-03-14 18:29:26 -07:00
Vadim Mikhailov
ae4be0a9d5 Note that on *BSD gmake should be used to build. 2019-03-05 15:37:54 -08:00
Vadim Mikhailov
00d1a408b8 Fix build on FreeBSD
* FreeBSD has the same issue as Darwin for snprintf, and same ifdef hack to solve.
* FreeBSD's libusb is stuck at 1.0.12, and does not support LIBUSB_DT_SUPERSPEED_HUB.
  Use ifdef hack to bypass.
* FreeBSD does not have libusb_get_parent() - use libusb_get_port_numbers() to detect parent device.
2019-03-05 15:27:13 -08:00
Vadim Mikhailov
c237ec17ba Add explanation how to configure Linux USB udev permissions 2019-02-24 17:17:22 -08:00
Vadim Mikhailov
1773ac2605 Add ESPRESSObin SBUD102 as supported device 2019-02-24 17:13:56 -08:00
Vadim Mikhailov
343e02b634 Improve USB2/3 duality handling
If hub and its dual have identical description except for vid:pid and USB version strings,
we consider this preferred match.
2019-02-24 11:15:22 -08:00
Vadim Mikhailov
f2a50dd4cb Add OctoPrint-USBControl to notable projects 2019-02-15 11:11:13 -08:00
Vadim Mikhailov
2b88680d3b Add TI TUSB4041PAPEVM as supported device
Reported by @rshaub in issue #137.
2019-02-06 12:49:33 -08:00
Vadim Mikhailov
43edb16298 Remove Transcend TS-HUB3K from supported list
Remove Transcend TS-HUB3K from supported list per issue #135 (does not turn off VBUS).
2019-02-06 12:39:17 -08:00
Vadim Mikhailov
21336c7ab1 Remove TP-Link UH700 from supported list
It turns out that TP-Link UH700 does not support VBUS cut off (issue #133).
2019-01-11 11:32:03 -08:00
Vadim Mikhailov
6c4e5cdf75 Add "USB drive data recovery" to notable projects 2019-01-04 15:54:25 -08:00
Vadim Mikhailov
04320872f5 Add support for comma separated list of ranges to port list parser
* Add support for comma separated list of ports, and possibly ranges,
  e.g. it is possible to use syntax like `1,3-5,9-12`.
* Increase MAX_HUB_PORTS to 14.

WARNING: this will break your scripts if you used syntax like `-p 1234` before.
Replace that syntax with `1,2,3,4` or `1-4` instead.
2019-01-04 15:42:33 -08:00
Vadim Mikhailov
2de7def9df Improve USB3 support
* Fixed `uhubctl -l <hub>` displaying unrelated devices for USB 3.
* Some USB3 hubs use USB_SS_PORT_LS_SS_DISABLED when port is off, but some keep USB_SS_PORT_LS_RX_DETECT.
  To handle this, check USB_SS_PORT_STAT_POWER bit to detect if port is off.
2019-01-04 15:42:33 -08:00
Vadim Mikhailov
f2d016a27c Bump copyright year 2019-01-04 15:42:33 -08:00
mvp
72ac02c324 Merge pull request #128 from silum/master
Update company name and add another compatible hub
2018-11-16 10:17:39 -08:00
Deneys S. Maartens
7ad7d21336 README.md: add B+B USH304 2018-11-16 13:46:50 +02:00
Deneys S. Maartens
4b61cb9e0b README.md: update B+B UHR204
- rename 'B&B Electronics' to 'B+B SmartWorx' to reflect recent
rebranding
- add VID:POD
2018-11-16 13:46:41 +02:00
Vadim Mikhailov
cfee02f014 Fix typo, some spelling formatting issues 2018-11-14 22:06:51 -08:00
Vadim Mikhailov
1aaae4bbb8 Update link to https 2018-11-14 21:58:35 -08:00
Vadim Mikhailov
069c67c836 Respect CPPFLAGS
This should fix issue #125.
2018-11-14 21:53:44 -08:00
Vadim Mikhailov
465aa9bb95 Remove Delock 87445 from supported list
According to report from @vkahl: https://github.com/mvp/uhubctl/issues/123,
Delock 87445 is not detected on various Linux systems.

Originally this hub was reported to work in https://github.com/mvp/uhubctl/pull/107.
I don't know if there were different hardware revisions of Delock 87445,
but it is safer to remove it from supported devices list until proven otherwise.

Also, I am skeptical that it will work correctly as it does not have external power supply.
2018-11-14 11:08:24 -08:00
Vadim Mikhailov
a65c576ca3 Add Club3D CSV-3242HD as supported device
Reported by @matthijskooijman in https://github.com/mvp/uhubctl/issues/122.
2018-11-08 09:51:01 -08:00
Vadim Mikhailov
a2b3695595 Add TP-Link UH700 and Transcend TS-HUB3K as supported devices
Reported by @yrjola in https://github.com/mvp/uhubctl/issues/121.
2018-11-01 17:47:10 -07:00
Vadim Mikhailov
7bf08c0f0f Add USB drives with no phantom load to notable projects 2018-10-12 11:26:03 -07:00
mvp
a9474fe12f Add IOI StarTech U3H415E1 as supported device
Reported by serjepatoff in https://github.com/mvp/uhubctl/issues/116.
2018-09-24 22:53:21 -07:00
mvp
bfc4477189 Merge pull request #114 from Linumiz/bb
Add bitbake recipe file for building with Yocto
2018-09-21 14:33:25 -07:00
Parthiban Nallathambi
5a0995b7b2 Add bitbake recipe file for building with Yocto
- bitbake recipe for yocto building, pulls the latest
src from master

Signed-off-by: Parthiban Nallathambi <parthiban@linumiz.com>
2018-09-19 19:07:44 +02:00
Vadim Mikhailov
dda0ab22f2 Add a note about Raspberry Pi compatibility issue with AmazonBasics hubs
Apparently, Amazon basics hubs are not detectable on Raspberry Pi,
which is documented at https://elinux.org/RPi_Powered_USB_Hubs#Problem_USB_Hubs.
Add a note about this in supported devices table.
2018-09-18 17:47:34 -07:00
mvp
de2c0f96cc Add StarTech ST4200USBM as supported device
Reported by Joey Hess in https://github.com/mvp/uhubctl/issues/112.
2018-08-16 20:45:57 -07:00
Vadim Mikhailov
77c7a7ace8 Add build status light to notable projects 2018-07-19 17:51:47 -07:00
Vadim Mikhailov
8eb39a6138 Reformatted notable projects section of README 2018-07-13 13:36:02 -07:00
mvp
32bc22ea4f Add notable projects
Added list of interesting projects that use uhubctl.
2018-07-06 15:33:29 -07:00
mvp
eaa2795025 Add Delock 87445 as supported device
Originally reported in https://github.com/mvp/uhubctl/pull/107.
2018-07-06 15:03:05 -07:00
Vadim Mikhailov
17094135fc j5create JUH470 only works in USB2 mode
Issue #103: j5create JUH470 doesn't turn off in USB3 mode, but seems to work in USB2 mode.
2018-06-15 10:25:59 -07:00
Vadim Mikhailov
4e18d53426 Add D-Link DUB H7 rev D1 (black) as supported device
Add D-Link DUB H7 rev D1 (black) to supported list as reported in issue #104.
2018-06-15 10:22:36 -07:00
mvp
51ff805c79 Add Renesas uPD720202 PCIe USB 3.0 host controller as supported device
Added new device per this report: https://unix.stackexchange.com/q/165447/321945#comment765232_321945.
Perhaps we should replace this with specific products that use Renesas uPD720202 chipset.
2018-05-08 19:55:14 -07:00
mvp
0cfd1f7341 Add Raspberry Pi Model 3 B+ as supported device
Unlike previous models, Raspberry Pi 3 B+ has two internally daisy-chained hubs:

$ uhubctl
Current status for hub 1-1.1 [0424:2514, USB 2.00, 3 ports]
  Port 1: 0503 power highspeed enable connect [0424:7800]
  Port 2: 0100 power
  Port 3: 0100 power
Current status for hub 1-1 [0424:2514, USB 2.00, 4 ports]
  Port 1: 0503 power highspeed enable connect [0424:2514, USB 2.00, 3 ports]
  Port 2: 0503 power
  Port 3: 0100 power
  Port 4: 0100 power

and this would require using `-l 1-1` or `-l 1-1.1` to control ports on specific hub.

However, I don't have actual RPi 3B+ hardware at hand and can't test if per-port power
switching is fully supported - all previous models only supported ganged switching
for ports 2-5.
2018-05-08 19:49:52 -07:00
mvp
e6f102a55d Add columns for port count and USB version into device table
Also clarify what format is used for hub locations.
2018-04-30 16:07:02 -07:00
mvp
003ba1ff66 Code formatting cleanups 2018-04-30 11:49:50 -07:00
mvp
2311a1c76f Fixed displaying duplicate hubs in status output
This should fix issue #91.
2018-04-15 16:50:21 -07:00
mvp
4661d892bf Add Moxa Uport-407 as supported device 2018-04-15 16:05:37 -07:00
mvp
448e84933a Remove mention of building libusb 1.0.22 from head
Now that issue #33 is resolved (libusb-1.0.22 is released and is included in Homebrew),
we can remove workaround mention from README.
2018-04-05 15:17:35 -07:00
mvp
8da851a50d Merge pull request #87 from nunojpg/master
move action to outer loop and hub to inner loop (fixes #86)
2018-04-02 00:16:43 -07:00
Nuno Goncalves
91ba867ce2 move action to outer loop and hub to inner loop (fixes #86)
Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2018-04-02 08:09:31 +01:00
mvp
5efb1487e5 Merge pull request #84 from quintusfelix/master
Add Lindy USB serial converter as supported device
2018-04-01 00:14:07 -07:00
Boerje Sewing
c712868525 Add Lindy USB serial converter as supported device
Signed-off-by: Boerje Sewing <Boerje.Sewing@who-ing.de>
2018-03-28 10:47:48 +02:00
Vadim Mikhailov
fa90f13ba8 Add j5create JUH470 as supported device
This closes issue #78.
2018-03-12 19:34:24 -07:00
Vadim Mikhailov
16ffd56b4b Add Plugable USB3-HUB7C as supported device
Missed to add this model from issue #54.
2018-03-12 19:34:18 -07:00
Vadim Mikhailov
6e05aee30e uhubctl 2.0.0
* Clarify that uhubctl will automatically handle USB3 duality.
* Bump copyright year.
* Mention more Linux distributions where uhubctl was tested to work.
2018-03-10 18:23:01 -08:00
Vadim Mikhailov
812197fe4b Add support for automatic USB2/3 dual power switch
When compatible USB3 hub connected to USB3 upstream port,
it is detected as 2 independent virtual hubs: USB2 and USB3,
and USB devices will be connected to USB2 or USB3 virtual hub
depending on their capabilities and connection speed.

To control power for physical USB3 hubs, we must turn off/on power
on both USB2 and USB3 virtual hubs for power off/on changes to take effect.

Included fixes:

* Enumerate all USB hubs, but mark ones we will work on with actionable flag.
  Because of this, increased max size of hubs array to 128 (maybe need even more?).
* Moved all code that was getting hub info into get_hub_info().
* Display "power" status as first status flag if port is powered.
  (uhubctl is about USB port power, and we should display power as first flag).
* Display "off" status for USB3 port when it is off (was "5gbps SS.Disabled").
  This makes both USB2 and USB3 status to display "off" consistently.
* Added expert option --exact which disables USB3 duality handling.
* Added small wait (150ms) after turning off USB3 port.
  It seems that USB3 reacts slowly to power off command.
  Perhaps we need to implement more deterministic approach for this,
  e.g. keep querying new power state few times until it has finally changed.
  Oddly enough, power on is always instant and does not need waiting.

This fixes issue #72.
2018-03-10 17:37:46 -08:00
Vadim Mikhailov
4d84b62fc3 Add Plugable USB3-HUB7-81X as supported device
Adding this hub to supported list per this report:
https://github.com/mvp/uhubctl/issues/54#issuecomment-369695596
2018-03-01 12:32:09 -08:00
Vadim Mikhailov
60ba7c915d Add Plugable USB3-HUB7BC as supported device
It turns out that with uhubctl improved USB3 support
this hub actually works great if we turn off power
on both USB2 and USB3 virtual hubs ports (see issue #54).
2018-03-01 11:34:59 -08:00
Vadim Mikhailov
eeff46fa0c Clarify support status for AmazonBasics hubs
It turns out that AmazonBasics hubs actually work well -
USB3 hubs require changing power state for both USB2 and USB3
virtual hubs when connected to USB3 upstream port.

Perhaps we should implement changing state for both USB2 and USB3
automatically, but this will be tracked in separate issue.
2018-02-18 13:02:53 -08:00
Vadim Mikhailov
41dadcea34 Add a note about USB 3.0 hubs duality and usage quirks 2018-02-15 18:30:19 -08:00
mvp
bccb920526 Merge pull request #71 from mvp/usb3
USB 3.0 support
2018-02-15 11:46:27 -08:00
Vadim Mikhailov
fb5d521290 Use appropriate power mask for USB2 vs USB3
USB3 should use USB_SS_PORT_STAT_POWER,
which is different from USB2 value USB_PORT_STAT_POWER.

Thanks to Stanislas Bertrand for spotting this bug!
2018-02-14 15:54:23 -08:00
Vadim Mikhailov
8e667cde10 Add support for USB 3.0
* add support for USB 3.0 (superspeed USB)
* use snprintf (which is weird on Mac)
* get device description in unified way
* trim trailing whitespace from vendor/product strings
* finally remove deprecated -i option
* require hub location to change power if more than one supported hub detected
2018-02-13 12:01:33 -08:00
Vadim Mikhailov
022e321f71 Clarify support status for AmazonBasics hubs
AmazonBasics hubs have conflicting reports about
power switching support (issues #17, #26, #50, #54, #57, #58).
Apparently, there are some hardware revisions
that support it properly, and others do not.

To avoid confusion, we say that not all AmazonBasics hubs
work as expected. That said, it would be great to find out
which hardware revisions actually work.
2018-02-02 17:23:02 -08:00
Vadim Mikhailov
91e987527a Add D-Link DUB-H4 rev D1 as supported device 2018-02-02 11:14:37 -08:00
Vadim Mikhailov
a1b7411c49 Add Cypress CY7C65632 HX2VL as supported device 2018-02-01 15:23:17 -08:00
mvp
79e44f13c7 Merge pull request #63 from jlmcgehee21/patch-1
Add 4 Port Amazon Basics Hub
2018-01-15 14:11:42 -08:00
Jeff McGehee
5aaa9c54e8 Add 4 Port Amazon Basics Hub
```
$ uhubctl
Current status for hub 20-1, vendor 2109:2811, 4 ports
   Port 1: 0100 power
   Port 2: 0100 power
   Port 3: 0100 power
   Port 4: 0100 power
```
2018-01-15 10:24:15 -05:00
Vadim Mikhailov
e53d6d2f36 Added note about Raspberry Pi behavior
Raspberry Pi can only use USB port 2 to control power on all ports.
Trying to control any other port is not guaranteed.
For some models, USB port 1 is wired to control Ethernet/Wifi.

Also, mention Mac support issues and workarounds.
2017-10-02 13:03:12 -07:00
7 changed files with 1022 additions and 268 deletions

View File

@@ -1,9 +1,17 @@
class Uhubctl < Formula
desc "control USB hubs powering per-port"
desc "USB hub per-port power control"
homepage "https://github.com/mvp/uhubctl"
head "https://github.com/mvp/uhubctl.git"
url "https://github.com/mvp/uhubctl/archive/v2.3.0.tar.gz"
sha256 "714f733592d3cb6ba8efc84fbc03b1beed2323918ff33aef01cdb956755be7b7"
license "GPL-2.0"
depends_on "libusb"
depends_on "pkg-config" => :build
livecheck do
url :stable
end
def install
system "make"

View File

@@ -1,6 +1,6 @@
uhubctl USB hub per-port power control.
Copyright (c) 2009-2017, Vadim Mikhailov
Copyright (c) 2009-2020, Vadim Mikhailov
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -10,34 +10,35 @@ INSTALL := install
INSTALL_DIR := $(INSTALL) -m 755 -d
INSTALL_PROGRAM := $(INSTALL) -m 755
RM := rm -rf
PKG_CONFIG ?= pkg-config
CC ?= gcc
CFLAGS ?= -g -O0
CFLAGS += -Wall -Wextra -std=c99 -pedantic
GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags)
GIT_VERSION := $(shell git describe --match "v[0-9]*" --abbrev=8 --dirty --tags | cut -c2-)
ifeq ($(GIT_VERSION),)
GIT_VERSION := $(shell cat VERSION)
endif
CFLAGS += -DPROGRAM_VERSION=\"$(GIT_VERSION)\"
# Use hardening options on Linux
ifeq ($(UNAME_S),Linux)
LDFLAGS += -Wl,-z,relro -lusb-1.0
LDFLAGS += -Wl,-zrelro,-znow
endif
ifeq ($(UNAME_S),Darwin)
ifneq ($(wildcard /opt/local/include),)
# MacPorts
CFLAGS += -I/opt/local/include
LDFLAGS += -L/opt/local/lib
endif
# Use pkg-config if available
ifneq (,$(shell which $(PKG_CONFIG)))
CFLAGS += $(shell $(PKG_CONFIG) --cflags libusb-1.0)
LDFLAGS += $(shell $(PKG_CONFIG) --libs libusb-1.0)
else
# But it should still build if pkg-config is not available (e.g. Linux or Mac homebrew)
LDFLAGS += -lusb-1.0
endif
ifeq ($(UNAME_S),FreeBSD)
LDFLAGS += -lusb
endif
PROGRAM = uhubctl
$(PROGRAM): $(PROGRAM).c
$(CC) $(CFLAGS) $@.c -o $@ $(LDFLAGS)
$(CC) $(CPPFLAGS) $(CFLAGS) $@.c -o $@ $(LDFLAGS)
install:
$(INSTALL_DIR) $(DESTDIR)$(sbindir)

364
README.md
View File

@@ -1,11 +1,11 @@
uhubctl
=======
uhubctl is utility to control USB power per-port on smart USB hubs.
`uhubctl` is utility to control USB power per-port on smart USB hubs.
Smart hub is defined as one that implements per-port power switching.
Original idea for this code was inspired by hub-ctrl.c by Niibe Yutaka:
http://www.gniibe.org/development/ac-power-control-by-USB-hub
https://www.gniibe.org/development/ac-power-control-by-USB-hub
Compatible USB hubs
@@ -16,92 +16,374 @@ Some of them are no longer manufactured and can be hard to find.
This is list of known compatible USB hubs:
| Manufacturer | Product | VID:PID | Release | EOL |
|:-------------------|:-------------------------------------------------------|:----------|:--------|:-----|
| AmazonBasics | HU3770V1, 7 Port USB 3.0 Hub with 12V/3A Power Adapter |`2109:2811`| 2013 | |
| Apple | Thunderbolt Display 27" (internal USB hub) | | 2011 | 2016 |
| Apple | USB Keyboard With Numeric Pad (internal USB hub) | | 2011 | |
| Asus | Z87-PLUS Motherboard (onboard USB hubs) | | 2013 | 2016 |
| B&B Electronics | UHR204 | | 2013 | |
| Belkin | F5U701-BLK | | 2008 | 2012 |
| Circuitco | Beagleboard-xM (internal USB hub) |`0424:9514`| 2010 | |
| CyberPower | CP-H420P |`0409:0059`| 2004 | |
| D-Link | DUB-H7 (silver edition only, new black not working) |`2001:F103`| 2005 | 2010 |
| Elecom | U2H-G4S | | 2006 | 2011 |
| Hawking Technology | UH214 | | 2003 | 2008 |
| Lenovo | ThinkPad EU Ultra Dockingstation (40A20090EU) |`17EF:100F`| 2015 | |
| Lenovo | ThinkPad X200 Ultrabase 42X4963 |`17EF:1005`| 2008 | 2011 |
| Linksys | USB2HUB4 | | 2004 | 2010 |
| Maplin | A08CQ |`0409:0059`| 2008 | 2011 |
| Microchip | EVB-USB2517 | | 2008 | |
| Plugable | USB2-HUB10S | | 2010 | |
| Raspberry Pi | Model B+, Model 2 B, Model 3 B | | 2011 | |
| Rosewill | RHUB-210 |`0409:005A`| 2011 | 2014 |
| Sanwa Supply | USB-HUB14GPH | | 2001 | 2003 |
| Sunix | SHB4200MA |`0409:0058`| 2006 | 2009 |
| Targus | PAUH212U | | 2004 | 2009 |
| Manufacturer | Product | Ports | USB | VID:PID | Release | EOL |
|:-------------------|:-----------------------------------------------------|:------|:----|:----------|:--------|:-----|
| AmazonBasics | HU3641V1 ([RPi issue](https://goo.gl/CLt46M)) | 4 | 3.0 |`2109:2811`| 2013 | |
| AmazonBasics | HU3770V1 ([RPi issue](https://goo.gl/CLt46M)) | 7 | 3.0 |`2109:2811`| 2013 | |
| AmazonBasics | HU9003V1EBL | 7 | 3.1 |`2109:2817`| 2018 | |
| AmazonBasics | HU9002V1SBL, HU9002V1ESL | 10 | 3.1 |`2109:2817`| 2018 | |
| AmazonBasics | HUC9002V1SBL, HUC9002V1EBL, HUC9002V1ESL | 10 | 3.1 |`2109:2817`| 2018 | |
| Anker | AK-68ANHUB-BV7A-0004 ([note](https://git.io/JLnZb)) | 7 | 3.0 |`2109:0812`| 2014 | |
| Apple | Thunderbolt Display 27" (internal USB hub) | 6 | 2.0 | | 2011 | 2016 |
| Apple | USB Keyboard With Numeric Pad (internal USB hub) | 3 | 2.0 | | 2011 | |
| Asus | Z87-PLUS Motherboard (onboard USB hub) | 4 | 3.0 | | 2013 | 2016 |
| Aukey | CB-C59 | 4 | 3.1 |`2109:2813`| 2017 | |
| B+B SmartWorx | UHR204 | 4 | 2.0 |`0856:DB00`| 2013 | |
| B+B SmartWorx | USH304 | 4 | 3.0 |`04B4:6506`| 2017 | |
| Basler | 2000036234 | 4 | 3.0 |`0451:8046`| 2016 | |
| Belkin | F5U101 | 4 | 2.0 |`0451:2046`| 2005 | 2010 |
| Buffalo | BSH4A05U3BK | 4 | 3.0 |`05E3:0610`| 2015 | |
| Bytecc | BT-UH340 | 4 | 3.0 |`2109:8110`| 2010 | |
| Circuitco | Beagleboard-xM (internal USB hub) | 4 | 2.0 |`0424:9514`| 2010 | |
| Club3D | CSV-3242HD Dual Display Docking Station | 4 | 3.0 |`2109:2811`| 2015 | |
| CyberPower | CP-H420P | 4 | 2.0 |`0409:0059`| 2004 | |
| Cypress | CY4608 HX2VL development kit | 4 | 2.0 |`04B4:6570`| 2012 | |
| D-Link | DUB-H4 rev B (silver). Note: rev B7+ not supported | 4 | 2.0 |`05E3:0605`| 2005 | 2010 |
| D-Link | DUB-H4 rev D,E (black). Note: rev A,C,F not supported| 4 | 2.0 |`05E3:0608`| 2012 | |
| D-Link | DUB-H7 rev A (silver) | 7 | 2.0 |`2001:F103`| 2005 | 2010 |
| D-Link | DUB-H7 rev D,E (black). Note: rev B,C,F not supported| 7 | 2.0 |`05E3:0608`| 2012 | |
| Dell | P2416D 24" QHD Monitor ([note](https://git.io/JUAu8))| 4 | 2.0 | | 2017 | |
| Dell | S2719DGF 27" WQHD Gaming-Monitor | 5 | 3.1 |`0424:5734`| 2018 | |
| Dell | UltraSharp 1704FPT 17" LCD Monitor | 4 | 2.0 |`0424:A700`| 2005 | 2015 |
| Dell | UltraSharp U2415 24" LCD Monitor | 5 | 3.0 | | 2014 | |
| Elecom | U2H-G4S | 4 | 2.0 | | 2006 | 2011 |
| ExSys | EX-1113HMS | 16 | 3.1 | | 2018 | |
| GlobalScale | ESPRESSObin SBUD102 V5 | 1 | 3.0 |`1D6B:0003`| 2017 | |
| Hawking Technology | UH214 | 4 | 2.0 | | 2003 | 2008 |
| IOI | U3H415E1 | 4 | 3.0 | | 2012 | |
| j5create | JUH470 (works only in USB2 mode) | 3 | 3.0 |`05E3:0610`| 2014 | |
| Juiced Systems | 6HUB-01 | 7 | 3.0 |`0BDA:0411`| 2014 | 2018 |
| LG Electronics | 38WK95C-W monitor | 4 | 3.0 |`0451:8142`| 2018 | |
| Lenovo | ThinkPad Ultra Docking Station (40A20090EU) | 6 | 2.0 |`17EF:100F`| 2015 | |
| Lenovo | ThinkPad Ultra Docking Station (40AJ0135EU) | 7 | 3.1 |`17EF:3070`| 2018 | |
| Lenovo | ThinkPad X200 Ultrabase 42X4963 | 3 | 2.0 |`17EF:1005`| 2008 | 2011 |
| Lenovo | ThinkPad X6 Ultrabase 42W3107 | 4 | 2.0 |`17EF:1000`| 2006 | 2009 |
| Lindy | USB serial converter 4 port | 4 | 1.1 |`058F:9254`| 2008 | |
| Linksys | USB2HUB4 | 4 | 2.0 | | 2004 | 2010 |
| Maplin | A08CQ | 7 | 2.0 |`0409:0059`| 2008 | 2011 |
| Microchip | EVB-USB2517 | 7 | 2.0 | | 2008 | |
| Microchip | EVB-USB2534BC | 4 | 2.0 | | 2013 | |
| Moxa | Uport-407 | 7 | 2.0 |`110A:0407`| 2009 | |
| NVidia | Jetson Nano B01 ([details](https://git.io/JJaFR)) | 4 | 3.0 | | 2019 | |
| Phidgets | HUB0003_0 | 7 | 2.0 |`1A40:0201`| 2017 | |
| Plugable | USB3-HUB7BC | 7 | 3.0 |`2109:0813`| 2015 | |
| Plugable | USB3-HUB7C | 7 | 3.0 |`2109:0813`| 2015 | |
| Plugable | USB3-HUB7-81X | 7 | 3.0 |`2109:0813`| 2012 | |
| Port Inc | NWUSB01 | 4 | 1.1 |`0451:1446`| 1999 | 2003 |
| Raspberry Pi | B+, 2B, 3B ([see below](#raspberry-pi-b2b3b)) | 4 | 2.0 | | 2011 | |
| Raspberry Pi | 3B+ ([see below](#raspberry-pi-3b)) | 4 | 2.0 |`0424:2514`| 2018 | |
| Raspberry Pi | 4B ([see below](#raspberry-pi-4b)) | 4 | 3.0 |`2109:3431`| 2019 | |
| Renesas | uPD720202 PCIe USB 3.0 host controller | 2 | 3.0 | | 2013 | |
| Rosewill | RHUB-210 | 4 | 2.0 |`0409:005A`| 2011 | 2014 |
| Rosonway | RSH-A16 ([note](https://git.io/JTawg)) | 16 | 3.2 |`0bda:0411`| 2020 | |
| Sanwa Supply | USB-HUB14GPH | 4 | 1.1 | | 2001 | 2003 |
| Seagate | Backup Plus Hub STEL8000100 | 2 | 3.0 |`0BC2:AB44`| 2016 | |
| Sunix | SHB4200MA | 4 | 2.0 |`0409:0058`| 2006 | 2009 |
| Targus | PAUH212/PAUH212U | 7 | 2.0 | | 2004 | 2009 |
| Texas Instruments | TUSB4041PAPEVM | 4 | 2.1 |`0451:8142`| 2015 | |
This table is by no means complete.
If your hub works with uhubctl, but is not listed above, please report it
If your hub works with `uhubctl`, but is not listed above, please report it
by opening new issue at https://github.com/mvp/uhubctl/issues,
so we can add it to supported table. In your report, please provide
exact product model and add output from uhubctl.
exact product model and add output from `uhubctl`
and please test VBUS off support as described below in FAQ.
Note that quite a few modern motherboards have built-in root hubs that
do support this feature - you may not even need to buy any external hub.
WARNING: turning off built-in USB ports may cut off your keyboard or mouse,
so be careful what ports you are turning off!
USB 3.0 duality note
====================
If you have USB 3.0 hub connected to USB3 upstream port, it will be detected
as 2 independent virtual hubs: USB2 and USB3, and your USB devices will be connected
to USB2 or USB3 virtual hub depending on their capabilities and connection speed.
To control power for such hubs, it is necessary to turn off/on power on **both** USB2 and USB3
virtual hubs for power off/on changes to take effect. `uhubctl` will try to do this automatically
(unless you disable this behavior with option `-e`).
Unfortunately, while most hubs will cut off data USB connection, some may still not cut off VBUS to port,
which means connected phone may still continue to charge from port that is powered off by `uhubctl`.
Compiling
=========
This utility was tested to compile and work on Linux
(Ubuntu, Redhat/Fedora/CentOS), FreeBSD and Mac OS X.
(Ubuntu/Debian, Redhat/Fedora/CentOS, Arch Linux, Gentoo, openSUSE, Buildroot), FreeBSD, NetBSD, SunOS and MacOS.
While `uhubctl` compiles on Windows, USB power switching does not work on Windows because `libusb`
is using `winusb.sys` driver, which according to Microsoft does not support
[necessary USB control requests](https://social.msdn.microsoft.com/Forums/sqlserver/en-US/f680b63f-ca4f-4e52-baa9-9e64f8eee101).
This may be fixed if `libusb` starts supporting different driver on Windows.
First, you need to install library libusb-1.0 (version 1.0.12 or later):
Note that it is highly recommended to have `pkg-config` installed (many platforms provide it by default).
First, you need to install library libusb-1.0 (version 1.0.12 or later, 1.0.16 or later is recommended):
* Ubuntu: `sudo apt-get install libusb-1.0-0-dev`
* Redhat: `sudo yum install libusb1-devel`
* MacOSX: `brew install libusb`, or `sudo port install libusb-devel`
* MacOS: `brew install libusb`, or `sudo port install libusb-devel`
* FreeBSD: libusb is included by default
* NetBSD: `sudo pkgin install libusb1 gmake pkg-config`
* Windows: TBD?
To compile, simply run `make` - this will generate `uhubctl` binary.
To fetch uhubctl source and compile it:
Alternatively, for macOS you can build an executable with homebrew's custom tap:
git clone https://github.com/mvp/uhubctl
cd uhubctl
make
This should generate `uhubctl` binary.
You can install it in your system as `/usr/sbin/uhubctl` using:
sudo make install
Note that on some OS (e.g. FreeBSD/NetBSD) you need to use `gmake` instead to build.
Also, on MacOS you can install `uhubctl` with all necessary dependencies in one shot using Homebrew tap:
```
brew tap mvp/uhubctl https://github.com/mvp/uhubctl/
brew install --HEAD uhubctl
brew tap mvp/uhubctl https://github.com/mvp/uhubctl
brew install uhubctl
```
To build/install from master branch, use `--HEAD`:
```
brew install uhubctl --HEAD
```
Usage
=====
> :warning: On Linux, use `sudo` or configure USB permissions as described below!
To list all supported hubs:
uhubctl
You can control the power on a USB port(s) like this:
uhubctl -a off -p 235
uhubctl -a off -p 2
This means operate on default smart hub and turn power off (`-a off`, or `-a 0`)
on ports 2,3,5 (`-p 235`). Supported actions are `off`/`on`/`cycle` (or `0`/`1`/`2`).
on port 2 (`-p 2`). Supported actions are `off`/`on`/`cycle`/`toggle` (or `0`/`1`/`2`/`3`).
`cycle` means turn power off, wait some delay (configurable with `-d`) and turn it back on.
Ports can be comma separated list, and may use `-` for ranges e.g. `2`, or `2,4`, or `2-5`, or `1-2,5-8`.
On Linux, you may need to run it with `sudo`, or to configure `udev` USB permissions.
> :warning: Turning off built-in USB ports may cut off your keyboard or mouse,
so be careful which ports you are turning off!
If you have more than one smart USB hub connected, you should choose
specific hub to control using `-l` (location) parameter.
To find hub locations, simply run `uhubctl` without any parameters.
Hub locations look like `b-x.y.z`, where `b` is USB bus number, and `x`, `y`, `z`...
are port numbers for all hubs in chain, starting from root hub for a given USB bus.
This address is semi-stable - it will not change if you unplug/replug (or turn off/on)
USB device into the same physical USB port (this method is also used in Linux kernel).
Linux USB permissions
=====================
On Linux, you should configure `udev` USB permissions (otherwise you will have to run it as root using `sudo uhubctl`).
To fix USB permissions, first run `sudo uhubctl` and note all `vid:pid` for hubs you need to control.
Then, add one or more udev rules like below to file `/etc/udev/rules.d/52-usb.rules` (replace 2001 with your vendor id):
SUBSYSTEM=="usb", ATTR{idVendor}=="2001", MODE="0666"
Note that for USB3 hubs, some hubs use different vendor ID for USB2 vs USB3 components of the same chip,
and both need permissions to make uhubctl work properly. E.g. for Raspberry Pi 4B, you need to add these 2 lines:
SUBSYSTEM=="usb", ATTR{idVendor}=="2109", MODE="0666"
SUBSYSTEM=="usb", ATTR{idVendor}=="1d6b", MODE="0666"
If you don't like wide open mode `0666`, you can restrict access by group like this:
SUBSYSTEM=="usb", ATTR{idVendor}=="2001", MODE="0664", GROUP="dialout"
and then add permitted users to `dialout` group:
sudo usermod -a -G dialout $USER
For your `udev` rule changes to take effect, reboot or run:
sudo udevadm trigger --attr-match=subsystem=usb
FAQ
===
#### _What is USB per-port power switching?_
According to USB 2.0 specification, USB hubs can advertise no power switching,
ganged (all ports at once) power switching or per-port (individual) power switching.
Note that by default `uhubctl` will only detect USB hubs which support per-port power switching
(but you can force it to try operating on unsupported hubs with option `-f`).
You can find what kind of power switching your hardware supports by using `sudo lsusb -v`:
No power switching:
wHubCharacteristic 0x000a
No power switching (usb 1.0)
Per-port overcurrent protection
Ganged power switching:
wHubCharacteristic 0x0008
Ganged power switching
Per-port overcurrent protection
Per-port power switching:
wHubCharacteristic 0x0009
Per-port power switching
Per-port overcurrent protection
#### _How do I check if my USB hub is supported by `uhubctl`?_
1. Run `sudo uhubctl`. If your hub is not listed, it is not supported.
Alternatively, you can run `sudo lsusb -v` and check for
`Per-port power switching` - if you cannot see such line in lsusb output,
hub is not supported.
2. Check for VBUS (voltage) off support: plug a phone, USB light
or USB fan into USB port of your hub.
Try using `uhubctl` to turn power off on that port, and check
that phone stops charging, USB light stops shining or USB fan stops spinning.
If VBUS doesn't turn off, your hub manufacturer did not include circuitry
to actually cut power off. Such hub would still work
to cut off USB data connection, but it cannot turn off power,
and we do not consider this supported device.
3. If tests above were successful, please report your hub
by opening new issue at https://github.com/mvp/uhubctl/issues,
so we can add it to list of supported devices.
Please do not report unsupported hubs, unless it is different
hardware revision of some already listed supported model.
#### _USB devices are not removed after port power down on Linux_
After powering down USB port, udev does not get any event, so it keeps the device files around.
However, trying to access the device files will lead to an IO error.
This is Linux kernel issue. It may be eventually fixed in kernel, see more discussion [here](https://bit.ly/2JzczjZ).
Basically what happens here is that kernel USB driver knows about power off,
but doesn't send notification about it to udev.
You can use this workaround for this issue:
sudo uhubctl -a off -l ${location} -p ${port}
sudo udevadm trigger --action=remove /sys/bus/usb/devices/${location}.${port}/
Device file will be removed by udev, but USB device will be still visible in `lsusb`.
Note that path `/sys/bus/usb/devices/${location}.${port}` will only exist if device was detected on that port.
When you turn power back on, device should re-enumerate properly (no need to call `udevadm` again).
#### _Power comes back on after few seconds on Linux_
Some device drivers in kernel are surprised by USB device being turned off and automatically try to power it back on.
You can use option `-r N` where N is some number from 10 to 1000 to fix this -
`uhubctl` will try to turn power off many times in quick succession, and it should suppress that.
This may be eventually fixed in kernel, see more discussion [here](https://bit.ly/2JzczjZ).
Disabling USB authorization for device in question before turning power off with `uhubctl` should help:
echo 0 > sudo tee /sys/bus/usb/devices/${location}.${port}/authorized
If your device is USB mass storage, invoking `udisksctl` before calling `uhubctl` should help too:
sudo udisksctl power-off --block-device /dev/disk/...`
sudo uhubctl -a off ...
#### _Multiple 4-port hubs are detected, but I only have one 7-port hub connected_
Many hub manufacturers build their USB hubs using basic 4 port USB chips.
E.g. to make 7 port hub, they daisy-chain two 4 port hubs - 1 port is lost to daisy-chaining,
so it makes it 4+4-1=7 port hub. Similarly, 10 port hub could be built as 3 4-port hubs
daisy-chained together, which gives 4+4+4-2=10 usable ports.
Note that you should never try to change power state for ports used to daisy-chain internal hubs together.
Doing so will confuse internal hub circuitry and will cause unpredictable behavior.
#### _Raspberry Pi turns power off on all ports, not just the one I specified_
This is the limitation of Raspberry Pi hardware design.
As a workaround, you can buy any external USB hub from supported list above,
attach it to any USB port of Raspberry Pi, and control power on its ports independently.
For reference, supported Raspberry Pi models have following internal USB topology:
##### Raspberry Pi B+,2B,3B
* Single hub `1-1`, ports 2-5 ganged, all controlled by port `2`:
uhubctl -l 1-1 -p 2 -a 0
Trying to control ports `3`,`4`,`5` will not do anything.
Port `1` controls power for Ethernet+WiFi.
##### Raspberry Pi 3B+
* Main hub `1-1`, all 4 ports ganged, all controlled by port `2` (turns off secondary hub ports as well).
Port `1` connects hub `1-1.1` below, ports `2` and `3` are wired outside, port `4` not wired.
uhubctl -l 1-1 -p 2 -a 0
* Secondary hub `1-1.1` (daisy-chained to main): 3 ports,
port `1` is used for Ethernet+WiFi, and ports `2` and `3` are wired outside.
##### Raspberry Pi 4B
> :warning: If your VL805 firmware is older than `00137ad` (check with `sudo rpi-eeprom-update`),
you have to [update firmware](https://www.raspberrypi.org/documentation/hardware/raspberrypi/booteeprom.md)
to make power switching work on RPi 4B.
* USB2 hub `1`, 1 port, only connects hub `1-1` below.
* USB2 hub `1-1`, 4 ports ganged, dual to USB3 hub `2` below:
uhubctl -l 1-1 -a 0
* USB3 hub `2`, 4 ports ganged, dual to USB2 hub `1-1` above:
uhubctl -l 2 -a 0
* USB2 hub `3`, 1 port, OTG controller. Power switching is [not supported](https://git.io/JUc5Q).
Notable projects using uhubctl
==============================
| Project | Description |
|:---------------------------------------------------------|:------------------------------------------------------|
| [Morse code USB light](https://git.io/fj1F4) | Flash a message in Morse code with USB light |
| [Webcam USB light](https://git.io/fj1FB) | Turn on/off LED when webcam is turned on/off |
| [Cinema Lightbox](https://goo.gl/fjCvkz) | Turn on/off Cinema Lightbox from iOS Home app |
| [Build Status Light](https://goo.gl/3GA82o) | Create a build status light in under 10 minutes |
| [Buildenlights](https://git.io/fj1FC) | GitLab/GitHub project build status as green/red light |
| [Weather Station](https://goo.gl/3b1FzC) | Reset Weather Station when it freezes |
| [sysmoQMOD](https://bit.ly/2VtWrVt) | Reset cellular modems when necessary |
| [Smog Sensor](https://bit.ly/2EMwgCk) | Raspberry Pi based smog sensor power reset |
| [Terrible Cluster](https://goo.gl/XjiXFu) | Power on/off Raspberry Pi cluster nodes as needed |
| [Ideal Music Server](https://bit.ly/39MeVFQ) | Turn off unused USB ports to improve audio quality |
| [USB drives with no phantom load](https://goo.gl/qfrmGK) | Power USB drives only when needed to save power |
| [USB drive data recovery](https://goo.gl/4MddLr) | Recover data from failing USB hard drive |
| [Control power to 3D printer](https://git.io/fh5Tr) | OctoPrint web plugin for USB power control |
| [USB fan for Raspberry Pi](https://bit.ly/2TRV6sM) | Control USB fan to avoid Raspberry Pi overheating |
| [Raspberry Pi Reboot Router](https://bit.ly/3aNbQqs) | Automatically reboot router if internet isn't working |
| [Control USB Lamp With Voice](https://bit.ly/2VtW2SX) | Voice Control of USB Lamp using Siri and Raspberry Pi |
| [Control USB LED Strip](https://bit.ly/3oVWfeZ) | Controlling USB powered LED Light Strip |
Copyright
=========
Copyright (C) 2009-2017 Vadim Mikhailov
Copyright (C) 2009-2020 Vadim Mikhailov
This file can be distributed under the terms and conditions of the
GNU General Public License version 2.

1
VERSION Normal file
View File

@@ -0,0 +1 @@
2.4.0

866
uhubctl.c

File diff suppressed because it is too large Load Diff

20
uhubctl_git.bb Normal file
View File

@@ -0,0 +1,20 @@
DESCRIPTION = "uhubctl - USB hub per-port power control"
HOMEPAGE = "https://github.com/mvp/uhubctl"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
file://LICENSE;md5=a79e6a142b69522fe7757fe7313895eb"
DEPENDS = "libusb1"
RDEPENDS_${PN} = "libusb1"
SRC_URI = "git://github.com/mvp/uhubctl.git"
SRCREV = "${AUTOREV}"
PV = "git"
S = "${WORKDIR}/git"
do_install_append () {
install -d ${D}${bindir}
install -Dm 0755 ${S}/uhubctl ${D}${bindir}/
}
FILES_${PN} += "${bindir}/*"