summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonard Göhrs <l.goehrs@pengutronix.de>2022-09-21 15:07:22 +0200
committerLeonard Göhrs <l.goehrs@pengutronix.de>2022-09-22 11:40:03 +0200
commit24e15400065fb245f029eadbc1445975920e2a13 (patch)
tree0f6989cdc60948e254d7c5a6fb5ac1b815af37bd
parentaa7fc0a126b7afb1516d0e7b789917e3ad83b0cd (diff)
Add udev rules for Linux sysfs power switching to README.md
The udev rules for the sysfs case are a bit more complex than those for the libusb based interface, as udev has built-in support for changing permissions on device files but not for sysfs attributes. Instead we have to use chmod / chown to set permissions and owners. You may notice the " || true" parts in the RUN part of the rules in addition to the -f parameters. These are there to make sure that no error is logged by udev even if the disable attribute does not exist. chmod/chown still return an error exit code even with -f if the requested path does not exist. " || true" makes sure this error is not propagated to udev. Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
-rw-r--r--README.md15
1 files changed, 15 insertions, 0 deletions
diff --git a/README.md b/README.md
index 9471e21..980f885 100644
--- a/README.md
+++ b/README.md
@@ -212,11 +212,21 @@ Linux USB permissions
=====================
On Linux, you should configure `udev` USB permissions (otherwise you will have to run it as root using `sudo uhubctl`).
+
+Starting with Linux Kernel 6.0 there is a standard interface to turn USB hub ports on or off,
+and `uhubctl` will try to use it (instead of `libusb`) to set the port status.
+This is why there are additional rules for 6.0+ kernels.
+There is no harm in having these rules on systems running older kernel versions.
+
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"
+ # Linux 6.0 or later (its ok to have this block present in older Linux):
+ SUBSYSTEM=="usb", DRIVER=="hub", \
+ 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:
@@ -227,6 +237,11 @@ If you don't like wide open mode `0666`, you can restrict access by group like t
SUBSYSTEM=="usb", ATTR{idVendor}=="2001", MODE="0664", GROUP="dialout"
+ # Linux 6.0 or later (its ok to have this block present in older Linux):
+ SUBSYSTEM=="usb", DRIVER=="hub", \
+ 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\""
+
and then add permitted users to `dialout` group:
sudo usermod -a -G dialout $USER