From 94247e93a230da980c36078ef9d09f727f767f2e Mon Sep 17 00:00:00 2001 From: Nicholas Chin Date: Sun, 14 Jan 2024 00:22:32 -0700 Subject: [PATCH] util/find_usbdebug: Fix lsusb -t parsing for usbutils v016 and newer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit e24294ff9ade ("lsusb -t: print ports and busses and devices with same width") [1] in the usbutils repository changed the format of the lsusb -t output, breaking the find_usbdebug.sh script. This commit is present in usbutils version 016 and later. Use the output of lsusb -V to set the parsing patterns based on the version in order to maintain compatibility with older versions of usbutils. A simple integer comparison of the version number is used for this, which will not work with versions older than v001 as those use a 0.nn version number format. However, since v001 was released in late 2010, it is probably safe to assume that no one will be using a version of usbutils older than that. Usbutils v016 was released in late 2023 so there could still conceivably be systems using older versions, such as Ubuntu 22.04 LTS which is on v014. TEST=find_usbdebug.sh works as expected with both lsusb v015 and v017 [1] https://github.com/gregkh/usbutils/commit/e24294ff9ade6dafcd1909763e888d97b377c841 Change-Id: Iffa1238b995d387d6e51459f85ae96da52a5c0ff Signed-off-by: Nicholas Chin Reviewed-on: https://review.coreboot.org/c/coreboot/+/85790 Reviewed-by: Jan Philipp Groß Tested-by: build bot (Jenkins) Reviewed-by: Angel Pons --- util/find_usbdebug/find_usbdebug.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/util/find_usbdebug/find_usbdebug.sh b/util/find_usbdebug/find_usbdebug.sh index 7c893c96a4..460608031e 100755 --- a/util/find_usbdebug/find_usbdebug.sh +++ b/util/find_usbdebug/find_usbdebug.sh @@ -45,8 +45,15 @@ dmesgfile=$1 find_devs_in_tree () { bus=$1 port=$2 - busstr=`printf "Bus %02d" "$bus"` - portstr="Port $port" + + # lsusb -t uses 3 digits for bus/port nunmbers as of version 016 and later + if [ $(lsusb -V | cut -f 3 -d " ") -lt 16 ]; then + busstr=`printf "Bus %02d" "$bus"` + portstr="Port $port" + else + busstr=`printf "Bus %03d" "$bus"` + portstr=`printf "Port %03d" "$port"` + fi hubs_to_ignore="8087:0020 8087:0024 8087:8000 8087:8008" reqlvl=1