Last active
September 19, 2018 19:41
-
-
Save LeTink/beccc9b7cc465263819e50bd0fbf0a54 to your computer and use it in GitHub Desktop.
set USB3 back to USB2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
One of our standard hardware classes doesn't handle a large number (32) of daisy-chained USB Serials well, it exhausts lanes. | |
As a workaround we set the capabilities of the USB port in question back to lower standards, which seems to do what we want. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/udev/rules.d/ | |
# udev rules to go with set_usb2 | |
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="1a40", ATTR{idProduct}=="0201", TAG+="systemd", ENV{SYSTEMD_WANTS}="set_usb2.service" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/systemd/system/ | |
[Unit] | |
Description=switch USB for serials to USB2 | |
[Service] | |
Type=oneshot | |
RemainAfterExit=no | |
ExecStart=/usr/local/bin/set_usb2.sh | |
[Install] | |
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# this goes in /usr/local/bin/ | |
[ -h /sys/class/tty/ttyUSB0 ] || exit 1 | |
pci_id=$( /usr/bin/realpath /sys/class/tty/ttyUSB0 | awk -F'/' '{print gensub(/....:(.*)/, "\\1","1",$5)}' ) | |
usb_id=$( lspci -n| awk -v id=$pci_id '$0 ~ id {print $3}' ) | |
/usr/bin/setpci -H1 -d $usb_id d0.l=0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment