BIST_USB_detect()
{
BIST_PLATFORM=`$GETMODE -fem`
BIST_USB_FILE=/mnt/update_bist.sh
BIST_SIG_FILE=/mnt/BIST_USB/images/BIST_${BIST_PLATFORM}.sig
echo "Checking for BIST in USB"
umount /mnt &>/dev/null
for USB_DEV in /dev/sdb1 /dev/sda1 /dev/sdc1; do
mount -t vfat $USB_DEV /mnt &>/dev/null
BIST_USB_STAT=$?
if [ $BIST_USB_STAT -eq 0 ]; then
break
fi
done
if [ $BIST_USB_STAT -ne 0 ]; then
return
fi
if [ "`$GETMODE -i`" = "production" ]; then
if [ ! -e $BIST_SIG_FILE ]; then
umount /mnt
return
fi
echo -n "BIST USB signature found, validating..."
$SIGTST $BIST_SIG_FILE
if [ $? -ne 0 ]; then
echo "signature FAILED"
return
fi
echo "signature OK"
BIST_SQUASHFS=`grep IMAGE $BIST_SIG_FILE | sed 's/ //g' | cut -d'=' -f2`
if [ ! -e $BIST_SQUASHFS ]; then
echo "BIST squashfs '$BIST_SQUASHFS' not found"
return
fi
echo "Mounting BIST squashfs"
mount -t squashfs -o loop $BIST_SQUASHFS $BIST_PATH
if [ $? -eq 0 ]; then
echo "usb" > $BIST_MODE_FILE
else
echo "BIST squashfs mount failed"
fi
else
if [ ! -e $BIST_USB_FILE ]; then
umount /mnt
return
fi
echo "BIST USB update found"
dos2unix $BIST_USB_FILE
chmod +x $BIST_USB_FILE
$BIST_USB_FILE
echo "usb" > $BIST_MODE_FILE
fi
}