mirror of
https://github.com/mvp/uhubctl.git
synced 2026-05-18 17:05:53 +03:00
Compare commits
18 Commits
quiet-opti
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b2c4c211f | ||
|
|
da8a260538 | ||
|
|
a9cd307a4a | ||
|
|
f45034e0d0 | ||
|
|
74ac3e6bc3 | ||
|
|
1117cc7ce2 | ||
|
|
65e3b74e60 | ||
|
|
ceadf4c13a | ||
|
|
ad94660713 | ||
|
|
ca7610ab01 | ||
|
|
c9edaf3da8 | ||
|
|
9a6e6d3a6d | ||
|
|
1af4949ce8 | ||
|
|
5dda8a874b | ||
|
|
786dcb2277 | ||
|
|
fab805bc12 | ||
|
|
a05a250644 | ||
|
|
b3fa9e7e63 |
33
README.md
33
README.md
@@ -27,6 +27,7 @@ This is list of known compatible USB hubs:
|
||||
| AmazonBasics | U3-7HUB (only works for 1 charge port) | 7 | 3.0 |`2109:2813`| 2020 | |
|
||||
| Anker | AK-68ANHUB-BV7A-0004 ([note](https://git.io/JLnZb)) | 7 | 3.0 |`2109:0812`| 2014 | |
|
||||
| Apple | Mac Mini M4 (2 front ports only) | 2 | 3.2 |`05AC:800B`| 2024 | |
|
||||
| Apple | MacBook Air (Late 2010) | 2 | 2.0 |`1D6B:0002`| 2010 | 2020 |
|
||||
| Apple | Pro Display XDR MWPE2LL/A (internal USB hub) | 4 | 2.0 |`05AC:9139`| 2019 | |
|
||||
| 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 | |
|
||||
@@ -41,11 +42,12 @@ This is list of known compatible USB hubs:
|
||||
| BenQ | PD2700U 4K Monitor (works only in USB2 mode) | 4 | 3.0 |`05E3:0610`| 2018 | |
|
||||
| BenQ | PD3220U | 4 | 3.1 |`05E3:0610`| 2019 | |
|
||||
| Bytecc | BT-UH340 ([warning](https://tinyurl.com/BT-UH340-1)) | 4 | 3.0 |`2109:8110`| 2010 | |
|
||||
| Centech | CT-USB4HUB ReTRY HUB | 4 | 3.0 |`0424:2744`| 2017 | |
|
||||
| Centech | CT-USB4HUB ReTRY HUB ([note](https://github.com/mvp/uhubctl/issues/630)) | 4 | 3.0 |`0424:2744`| 2017 | |
|
||||
| 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 | |
|
||||
| Coolgear | USBG-12U2ML | 12 | 2.0 |`05e3:0607`| 2015 | |
|
||||
| Cypress | CY4608 HX2VL ([note](https://tinyurl.com/CY4608-1)) | 4 | 2.0 |`04B4:6570`| 2012 | |
|
||||
| D-Link | DUB-2332 rev A1 | 3 | 3.0 | | 2022 | |
|
||||
| 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). Rev B,C,F,G not supported | 7 | 2.0 |`05E3:0608`| 2012 | |
|
||||
@@ -64,6 +66,7 @@ This is list of known compatible USB hubs:
|
||||
| Hawking Technology | UH214 | 4 | 2.0 | | 2003 | 2008 |
|
||||
| Hewlett Packard | USB-C Dock G5 5TW10AA | 5 | 3.0 |`03F0:076B`| 2019 | |
|
||||
| Hewlett Packard | P5Q58UT | 3 | 3.0 | | 2019 | |
|
||||
| IBM | SK-8815 USB Keyboard | 3 | 1.1 |`04B3:301A`| 2004 | |
|
||||
| Inateck | HB2025A ([USB2 only](https://tinyurl.com/HB2025A-1)) | 4 | 3.1 |`2109:2822`| 2021 | |
|
||||
| IOI | U3H415E1 | 4 | 3.0 | | 2012 | |
|
||||
| j5create | JUH377 ([note](https://tinyurl.com/JUH377)) | 7 | 3.0 | | 2016 | |
|
||||
@@ -77,16 +80,17 @@ This is list of known compatible USB hubs:
|
||||
| LG Electronics | 27UK850-W monitor | 2 | 3.0 | | 2018 | |
|
||||
| LG Electronics | 27UN83A-W monitor | 2 | 3.0 |`0451:8142`| 2020 | |
|
||||
| LG Electronics | 38WK95C-W monitor | 4 | 3.0 |`0451:8142`| 2018 | |
|
||||
| Lenovo | ThinkPad Mini Dock Series 3 (433710U) | 6 | 2.0 |`17EF:100A`| 2016 | |
|
||||
| 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 |
|
||||
| Lenovo | ThinkPlus 4-in-1 USB-C hub 4X90W86497 | 3 | 3.0 | | 2021 | |
|
||||
| Lenovo | ThinkVision T24i-10 Monitor | 4 | 2.0 |`17EF:0610`| 2018 | |
|
||||
| Lenovo | USB-C to 4 Port USB-A Hub | 4 | 2.0 |`17EF:103A`| 2020 | |
|
||||
| Lenovo | USB-C to 4 Port USB-A Hub ([USB2 only](https://github.com/mvp/uhubctl/issues/625)) | 4 | 2.0 |`17EF:103A`| 2020 | |
|
||||
| Lindy | USB serial converter 4 port | 4 | 1.1 |`058F:9254`| 2008 | |
|
||||
| Linksys | USB2HUB4 ([note](https://git.io/JYiDZ)) | 4 | 2.0 | | 2004 | 2010 |
|
||||
| Maplin | A08CQ | 7 | 2.0 |`0409:0059`| 2008 | 2011 |
|
||||
| Maplin | A08CQ ([red ports only](https://tinyurl.com/gh635)) | 7 | 2.0 |`0409:0059`| 2008 | 2011 |
|
||||
| Metadot | Das Keyboard 4 | 2 | 3.0 | | 2014 | |
|
||||
| Microchip | EVB9512 | 2 | 2.0 | | 2009 | |
|
||||
| Microchip | EVB-USB2517 | 7 | 2.0 | | 2008 | |
|
||||
@@ -115,14 +119,17 @@ This is list of known compatible USB hubs:
|
||||
| Rosonway | RSH-A37S | 7 | 3.0 |`2109:2822`| 2021 | |
|
||||
| Rosonway | RSH-A104 ([USB2 only](https://tinyurl.com/RSH-A104)) | 4 | 3.1 |`2109:2822`| 2022 | |
|
||||
| Rosonway | RSH-ST07C ([only 4](https://tinyurl.com/4pjnujrn)) | 7 | 3.0 |`2109:2822`| 2023 | |
|
||||
| Rosonway | RSH-ST10C-6 ([note](https://tinyurl.com/428vpa2f)) | 10 | 3.1 | | 2024 | |
|
||||
| Sanwa Supply | USB-HUB14GPH | 4 | 1.1 | | 2001 | 2003 |
|
||||
| Seagate | Backup Plus Hub STEL8000100 | 2 | 3.0 |`0BC2:AB44`| 2016 | |
|
||||
| Seeed Studio | reTerminal CM4104032 | 2 | 2.0 |`0424:2514`| 2021 | |
|
||||
| Sipolar | A-173 | 7 | 3.0 |`0BDA:0411`| 2016 | |
|
||||
| StarTech | DKT30CSDHPD3 USB-C Travel Dock | 3 | 3.0 |`2109:2817`| 2018 | |
|
||||
| StarTech | HB30A4AIB ([warning](https://tinyurl.com/ycxravwk)) | 4 | 3.0 |`2109:2817`| 2018 | |
|
||||
| StarTech | HB31C2A2CB ([note](https://github.com/mvp/uhubctl/issues/601)) | 5 | 3.0 |`14B0:013D`| 2020 | |
|
||||
| Sunix | SHB4200MA | 4 | 2.0 |`0409:0058`| 2006 | 2009 |
|
||||
| System Talks | Sugoi USB2-HUB4X | 4 | 2.0 | | 2007 | |
|
||||
| System Talks | Sugoi USB2-HUB4X ([warning](https://github.com/mvp/uhubctl/issues/636))|4|2.0| | 2007 | |
|
||||
| Targus | ACH155 (port 3 controls all ports) | 4 | 3.0 | | 2022 | |
|
||||
| Targus | PA095UZ | 2 | 2.0 | | 2004 | |
|
||||
| Targus | PAUH212/PAUH212U | 7 | 2.0 | | 2004 | 2009 |
|
||||
| Texas Instruments | TUSB4041PAPEVM | 4 | 2.1 |`0451:8142`| 2015 | |
|
||||
@@ -159,9 +166,15 @@ For Linux and MacOS uhubctl is available in standard package managers
|
||||
and can be installed with following commands:
|
||||
|
||||
* MacOS: `brew install uhubctl` or `sudo port install uhubctl`
|
||||
- :warning: MacOS 26+ requires [fix](https://github.com/libusb/libusb/pull/1700).
|
||||
Until libusb version 1.0.30 with this fix is released, install libusb from master:
|
||||
|
||||
brew uninstall libusb --ignore-dependencies
|
||||
brew install libusb --head
|
||||
* Ubuntu/Debian/Raspbian: `sudo apt install uhubctl`
|
||||
* Redhat/EPEL/Fedora/CentOS: `sudo yum install uhubctl`
|
||||
* OpenSUSE: `sudo zypper install uhubctl`
|
||||
* FreeBSD: `cd /usr/ports/sysutils/uhubctl && sudo make install`
|
||||
|
||||
However, uhubctl installed from standard package manager may not
|
||||
necessarily be latest version, or even severely lag behind current version.
|
||||
@@ -252,23 +265,23 @@ To fix USB permissions, first run `sudo uhubctl` and note all `vid:pid` for hubs
|
||||
Then, add udev rules like below to file `/etc/udev/rules.d/52-usb.rules`
|
||||
(replace `2001` with your hub vendor id, or completely remove `ATTR{idVendor}` filter to allow any USB hub access):
|
||||
|
||||
SUBSYSTEM=="usb", DRIVER=="usb", MODE="0666", ATTR{idVendor}=="2001"
|
||||
SUBSYSTEM=="usb", DRIVER=="hub|usb", MODE="0666", ATTR{idVendor}=="2001"
|
||||
# Linux 6.0 or later (its ok to have this block present for older Linux kernels):
|
||||
SUBSYSTEM=="usb", DRIVER=="usb", \
|
||||
SUBSYSTEM=="usb", DRIVER=="hub|usb", \
|
||||
RUN="/bin/sh -c \"chmod -f 666 $sys$devpath/*port*/disable || true\""
|
||||
|
||||
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 (or remove idVendor filter):
|
||||
|
||||
SUBSYSTEM=="usb", DRIVER=="usb", MODE="0666", ATTR{idVendor}=="2109"
|
||||
SUBSYSTEM=="usb", DRIVER=="usb", MODE="0666", ATTR{idVendor}=="1d6b"
|
||||
SUBSYSTEM=="usb", DRIVER=="hub|usb", MODE="0666", ATTR{idVendor}=="2109"
|
||||
SUBSYSTEM=="usb", DRIVER=="hub|usb", MODE="0666", ATTR{idVendor}=="1d6b"
|
||||
|
||||
If you don't like wide open mode `0666`, you can restrict access by group like this:
|
||||
|
||||
SUBSYSTEM=="usb", DRIVER=="usb", MODE="0664", GROUP="dialout"
|
||||
SUBSYSTEM=="usb", DRIVER=="hub|usb", MODE="0664", GROUP="dialout"
|
||||
# Linux 6.0 or later (its ok to have this block present for older Linux kernels):
|
||||
SUBSYSTEM=="usb", DRIVER=="usb", \
|
||||
SUBSYSTEM=="usb", DRIVER=="hub|usb", \
|
||||
RUN+="/bin/sh -c \"chown -f root:dialout $sys$devpath/*port*/disable || true\"" \
|
||||
RUN+="/bin/sh -c \"chmod -f 660 $sys$devpath/*port*/disable || true\""
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
# sudo usermod -a -G dialout $USER
|
||||
|
||||
# This is for Linux before 6.0:
|
||||
SUBSYSTEM=="usb", DRIVER=="usb", MODE="0664", GROUP="dialout"
|
||||
SUBSYSTEM=="usb", DRIVER=="hub|usb", MODE="0664", GROUP="dialout"
|
||||
|
||||
# This is for Linux 6.0 or later (ok to keep this block present for older Linux kernels):
|
||||
SUBSYSTEM=="usb", DRIVER=="usb", \
|
||||
SUBSYSTEM=="usb", DRIVER=="hub|usb", \
|
||||
RUN+="/bin/sh -c \"chown -f root:dialout $sys$devpath/*port*/disable || true\"" \
|
||||
RUN+="/bin/sh -c \"chmod -f 660 $sys$devpath/*port*/disable || true\""
|
||||
|
||||
40
uhubctl.c
40
uhubctl.c
@@ -396,15 +396,39 @@ static int ports2bitmap(char* const portlist)
|
||||
static int get_computer_model(char *model, int len)
|
||||
{
|
||||
int fd = open("/sys/firmware/devicetree/base/model", O_RDONLY);
|
||||
if (fd < 0) {
|
||||
return fd;
|
||||
if (fd >= 0) {
|
||||
int bytes_read = read(fd, model, len-1);
|
||||
close(fd);
|
||||
if (bytes_read < 0) {
|
||||
return -1;
|
||||
}
|
||||
model[bytes_read] = 0;
|
||||
} else {
|
||||
// devicetree is not available, try parsing /proc/cpuinfo instead.
|
||||
// most Raspberry Pi have /proc/cpuinfo about 1KB, so 4KB buffer should be plenty:
|
||||
char buffer[4096] = {0}; // fill buffer with all zeros
|
||||
fd = open("/proc/cpuinfo", O_RDONLY);
|
||||
if (fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
int bytes_read = read(fd, buffer, sizeof(buffer)-1);
|
||||
close(fd);
|
||||
if (bytes_read < 0) {
|
||||
return -1;
|
||||
}
|
||||
buffer[bytes_read] = 0;
|
||||
char* model_start = strstr(buffer, "Model\t\t: ");
|
||||
if (model_start == NULL) {
|
||||
return -1;
|
||||
}
|
||||
char* model_name = model_start + 9;
|
||||
char* newline_pos = strchr(model_name, '\n');
|
||||
if (newline_pos != NULL) {
|
||||
*newline_pos = 0;
|
||||
}
|
||||
strncpy(model, model_name, len);
|
||||
model[len-1] = 0;
|
||||
}
|
||||
int bytes_read = read(fd, model, len-1);
|
||||
close(fd);
|
||||
if (bytes_read < 0) {
|
||||
return -1;
|
||||
}
|
||||
model[bytes_read] = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user