-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathreset-usb.sh
executable file
·33 lines (30 loc) · 1.15 KB
/
reset-usb.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh
# Power-cycle the Raspberry Pi USB bus to reset attached USB devices
#
# Released under MIT license. See the accompanying LICENSE.txt file for
# full terms and conditions
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# Raspberry Pi 1 running Raspbian Wheezy
FILE=/sys/devices/platform/bcm2708_usb/buspower
if [ ! -e $FILE ]; then
# Raspberry Pi 2 running Raspbian Jessie
FILE=/sys/devices/platform/soc/3f980000.usb/buspower
fi
if [ -e $FILE ]; then
echo "Power-cycling USB to fix dead Carelink stick"
sleep 0.1
echo 0 > $FILE
sleep 1
echo 1 > $FILE
sleep 2
else
echo "Could not find a known USB power control device. Checking /sys/devices/platform/:"
find /sys/devices/platform/* | grep buspower
fi