]> zdv2.bktei.com Git - BK-2020-03.git/blobdiff - user/bkusbreset
feature(user) Add legacy user scripts
[BK-2020-03.git] / user / bkusbreset
diff --git a/user/bkusbreset b/user/bkusbreset
new file mode 100755 (executable)
index 0000000..4e135f9
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/bash
+# script to force reset USB devices
+# soruce: http://billauer.co.il/blog/2013/02/usb-reset-ehci-uhci-linux/
+
+
+if [[ $EUID != 0 ]] ; then
+  echo This must be run as root!
+  exit 1
+fi
+
+for xhci in /sys/bus/pci/drivers/?hci_hcd ; do
+
+  if ! cd $xhci ; then
+    echo Weird error. Failed to change directory to $xhci
+    exit 1
+  fi
+
+  echo Resetting devices from $xhci...
+
+  for i in ????:??:??.? ; do
+    echo -n "$i" > unbind
+    echo -n "$i" > bind
+  done
+done