While waiting for 8.09 to mature, I've been setting up an Asus WL500GP with a USB/SD Flash drive.
The flash drive being for polipo proxy cache, samba file share and luci-statistics.
Although the drive is detected and mounted correctly from a cold boot, it fails detection on every second (?) reboot with the only error in the log (without debug set) being:
user.err kernel: hub 1-0:1.0: unable to enumerate USB device on port 1
Adjusting /etc/modules.d/60-usb-storage to include
usb-storage delay_use=12
is not sufficient to fix the issue.
However removing and reloading the ehci-hcd & usb-storage appears to work.
So, prior to a proper kernel fix (?), here is an init script to fix the issue (let's call it a hack )
#!/bin/sh /etc/rc.common
# /etc/init.d/check_usb_storage
# A script (hack) to force reload of USB storage drivers
START=90
USB_STORAGE_DELAY_USE=`grep delay_use /etc/modules.d/*usb-storage* | cut -d'=' -f2`
[ -z "$USB_STORAGE_DELAY_USE" ] && USB_STORAGE_DELAY_USE=5
storage_mounted () {
grep -q usbdrive /proc/mounts
}
wait_for_usb_storage () {
i=$1
while [ $i -ge 0 ] && ! storage_mounted
do
sleep 1
echo "Waiting for USB storage device $i"
i=$(($i-1))
done
storage_mounted
}
start () {
sleep $(($USB_STORAGE_DELAY_USE +1))
if grep -q "^[^#]*usbdrive" /etc/fstab
then
if ! storage_mounted
then
echo "USB storage device not mounted, waiting..."
if ! wait_for_usb_storage $USB_STORAGE_DELAY_USE
then
echo "Attempting to wake USB storage device"
rmmod usb-storage ehci-hcd
insmod ehci-hcd
insmod usb-storage delay_use=$USB_STORAGE_DELAY_USE
if wait_for_usb_storage $(($USB_STORAGE_DELAY_USE +1))
then
echo "USB storage mounted after module reinsert + wait."
else
echo "Unable to mount USB storage after module reinsert + wait."
fi
else
echo "Storage mounted after wait."
fi
else
echo "USB storage already mounted."
fi
else
echo "No USB device set in fstab"
fi
}
Installation:
1. Paste the script above into /etc/init.d/check_usb_storage
2. Mark the script as executable and link it to /etc/rc.d/S21check_usb_storage
3. Set the delay_use variable for usb-storage in /etc/modules.d/60-usb-storage ... my device required a minimum of 12 seconds.
4. Add an entry in /etc/config/fstab for /mnt/usbdrive (determined by /sbin/usb-storage) to include options: 'rw,sync,noatime,noauto'
Notes:
1. There are logical problems and delays in this script that need to be improved.
2. Script has not been extensively tested (yet).