diff options
author | Antonio Borneo <borneo.antonio@gmail.com> | 2023-12-10 21:35:10 +0100 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2024-01-06 13:50:24 +0000 |
commit | b7173732471c230a7fdc56efe23be35f60dbaae9 (patch) | |
tree | 7ad42aa77a3099825bdb20fe6db1f44d33492f39 | |
parent | 5c53034d85480d0855394c4683733f61b27b6c5e (diff) | |
download | riscv-openocd-b7173732471c230a7fdc56efe23be35f60dbaae9.zip riscv-openocd-b7173732471c230a7fdc56efe23be35f60dbaae9.tar.gz riscv-openocd-b7173732471c230a7fdc56efe23be35f60dbaae9.tar.bz2 |
doc: usb_adapters: update the script for unavailable reports
When Linux HID driver binds the USB endpoints of the adapter,
'lsusb' fails to read all the reports and prints
** UNAVAILABLE **
Detect this case and alert the user, providing also the proper
command to unbind the driver before running the script again.
Put this test at the end of the output, so user can easily see it.
Change-Id: Iaca00040e666b62ceebe4b842a24932799bde56a
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reported-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/8046
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
-rwxr-xr-x | doc/usb_adapters/dump.sh | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/doc/usb_adapters/dump.sh b/doc/usb_adapters/dump.sh index 1ecfb40..557ef7f 100755 --- a/doc/usb_adapters/dump.sh +++ b/doc/usb_adapters/dump.sh @@ -1,6 +1,22 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0-or-later +hid_unavailable_report() { + a=$(echo $1 | tr '[:lower:]' '[:upper:]') + b=$(basename $(dirname $(ls -d /sys/bus/usb/drivers/usbhid/*/*:$a.*))) + + echo "" + echo "ATTENTION!" + echo "Unable to read completely the USB descriptors." + echo "Please run the following command(s) and then run this script again" + for i in $b; do + echo " sudo sh -c \"echo -n $i > /sys/bus/usb/drivers/usbhid/unbind\"" + done + echo "" + echo "Please notice that the USB device will not function after the above" + echo "operations; you should unplug and replug it to get it working again." +} + devs=$(lsusb -d $1:$2 | wc -l) case "$devs" in 0 ) @@ -22,3 +38,5 @@ echo '' echo '# Optional comment' lsusb -v -d $1:$2 | sed 's/ *$//' + +lsusb -v -d $1:$2 2>&1 | grep -Fq '** UNAVAILABLE **' && (hid_unavailable_report $1:$2 > /dev/stderr) |