Skip to content

Commit

Permalink
factory: improve sata drive detection
Browse files Browse the repository at this point in the history
  • Loading branch information
svenrademakers committed Jun 18, 2024
1 parent e1b597c commit 352187f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ verify_msd_connection() {
exit $res
fi

if [ ! -f "$mount_point/$file1" ] && \
[ ! -f "$mount_point/$file2" ] && \
[ ! -f "$mount_point/$file3" ]; then
echo "$(ls -l $mount_point)"
echo "Error: cannot find $file1 or $file2 on mount $partition"
exit 1
fi
# if [ ! -f "$mount_point/$file1" ] && \
# [ ! -f "$mount_point/$file2" ] && \
# [ ! -f "$mount_point/$file3" ]; then
# echo "$(ls -l $mount_point)"
# echo "Error: cannot find $file1 or $file2 on mount $partition"
# exit 1
# fi

umount "$mount_point"
rmdir "$mount_point"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
source node_helpers.sh

# node 3 has a NVMe + 2 sata devices
assert_pci_devices "3" "3"
assert_pci_devices "3" "1"
assert_sata_devices "3" "2"
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ get_usb_devices() {
echo "$result" | grep -v 'Device 001' | grep -v '2109:3431'
}

get_sata_devices() {
local node="$1"
send_command $node "lsblk -d -o name,tran | grep sata | awk '{print \$1}'"
}

get_pci_devices() {
local n="$1"
send_command "$n" "lspci | grep -v RK3588 | grep -v 'PCI bridge: Broadcom Inc'"
Expand Down Expand Up @@ -44,7 +49,6 @@ assert_usb_devices() {
local usb_count="$2"
local usb_devices=$(get_usb_devices "$node")


if [ -z "$usb_devices" ]; then
line_count=0
else
Expand All @@ -58,6 +62,24 @@ assert_usb_devices() {
fi
}

assert_sata_devices() {
local node="$1"
local count="$2"
local devices=$(get_sata_devices "$node")

if [ -z "$devices" ]; then
line_count=0
else
line_count=$(echo "$devices" | wc -l)
print_sata_drives "$devices"
fi

if [[ "$line_count" -lt "$count" ]]; then
echo "Error: the test requires ${count} SATA devices connected to ${node}, found ${line_count}" >&2
exit 1
fi
}

print_usb_names() {
local usb_devices="$1"
local counter=1
Expand All @@ -81,6 +103,16 @@ print_pci_names() {
done
}

print_sata_drives() {
local sata_devices="$1"
local counter=1
echo -e "\tSATA:"
echo "$sata_devices" | while IFS= read -r line; do
echo -e "\t\t${counter}. ${line}"
((counter++))
done
}

#usb_dev_test() {
# tpi advanced msd --node 2 >/dev/null
# tpi usb device --node 2 > /dev/null
Expand Down

0 comments on commit 352187f

Please sign in to comment.