blob: f80530544fbeae0de223cbf8e44bd6d79cba5e32 (
plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#!/bin/bash
function detect_hw {
if [ ! -d /sys/devices/platform/mts-io/xdot ]; then
echo "XDOT hardware not found"
exit
fi
}
function detect_hw_dev {
if [ ! -h /dev/disk/by-label/XDOT ]; then
echo "XDOT dev hardware not found"
exit
fi
}
function flash {
echo "Flashing new firmware"
cp $FIRMWARE_FILE $TEMP_DIR
}
function mount_xdot {
TEMP_DIR=`mktemp -d`
mount /dev/disk/by-label/XDOT $TEMP_DIR
}
function reset {
mts-io-sysfs store xdot/reset 0
mts-io-sysfs store xdot/reset 1
mts-io-sysfs store xdot/reset -- -1 &>/dev/null
}
function usb_reset {
echo 0 > /sys/bus/usb/devices/1-2.1/authorized
sleep 1
echo 1 > /sys/bus/usb/devices/1-2.1/authorized
}
function clean_up {
umount $TEMP_DIR
rm -fr $TEMP_DIR
}
case "$1" in
"flash")
detect_hw_dev
FIRMWARE_FILE=$2
mts-io-sysfs store xdot/reset -- -1 &>/dev/null
mount_xdot
flash
clean_up
sleep 1
reset
echo done
;;
"mount")
detect_hw_dev
mount_xdot
echo Mounted at $TEMP_DIR
;;
"reset")
detect_hw
reset
;;
"usb-reset")
detect_hw
usb_reset
;;
*) ## If no parameters are given, print which are avaiable.
echo "Usage: $0 {flash|mount|reset|usb-reset}"
;;
esac
|