Hi, I'm actually using teddy_bear's USB Tomato mod on a WL-520GU (stupid 4 MB flash...), and it includes scsi-stop and scsi-start, and I wanted to share my experience with getting it working.
I used a watt-meter to verify that the disk actually did spin down or up. My setup involves an external enclosure with the following stats.
Code:
Host scsi0: usb-storage
Vendor: JMicron
Product: JM20336 SATA, USB Combo
Serial Number: DA0150217888
Protocol: Transparent SCSI
Transport: Bulk
GUID: 152d23360000da0150217888
Attached: Yes
Port: 1
Bus: 00:03.1-1
Vendor=152d ProdID=2336
This is very similar to one that doesn't work (PID=2338). But I had to do something funny to get mine to work. If I call scsi-stop, the disk spins down, and when I go to access it, the disk becomes inaccessible. If I call scsi-stop and then scsi-start before accessing the disk, it behaves correctly, staying spun down until I go to access it.
There are other Tomato-specific requirements for scsi-stop and scsi-start. You need to put the script in /jffs, and you need the build with awk. Here's the final script with the other Tomato-specific changes.
Code:
#!/bin/sh
if /usr/bin/[ $# -ne 1 ]; then
/bin/echo 1>&2 "Usage: $0 <device>"
exit 1
fi
PERIOD=30
BOUNDARY=1200
SCSISTOP=scsi-stop
SCSISTART=scsi-start
LOGFILE=/tmp/scsi-stop.log
searchstr="disk_io:"
devaddr="(`/bin/ls -l $1 | /usr/bin/awk '{print($5 int($6/16))}'`)"
str=`/bin/grep "$searchstr" /proc/stat | devaddr="$devaddr" /usr/bin/awk -v 'RS= |\n' -F : '{ if($1==ENVIRON["devaddr"]) print($2) }'`
cooltime=0
stopped=0
while true; do
/bin/sleep $PERIOD
newstr=`/bin/grep "$searchstr" /proc/stat | devaddr="$devaddr" /usr/bin/awk -v 'RS= |\n' -F : '{ if($1==ENVIRON["devaddr"]) print($2) }'`
if /usr/bin/[ "$newstr" = "$str" ]; then
cooltime=$(($cooltime + $PERIOD))
if /usr/bin/[ $cooltime -ge $BOUNDARY -a $stopped -eq 0 ]; then
$SCSISTOP $1
$SCSISTART $1
time=`/bin/date '+%b %e %H:%M:%S'`
/bin/echo "$time: Cooled down..." >> $LOGFILE
stopped=1
fi
else
if /usr/bin/[ $cooltime -ne 0 ]; then
time=`/bin/date '+%b %e %H:%M:%S'`
/bin/echo "$time: Disk first used after $cooltime seconds" >> $LOGFILE
fi
cooltime=0
str=$newstr
stopped=0
fi
done