-
Notifications
You must be signed in to change notification settings - Fork 74
/
burn-tool
executable file
·70 lines (59 loc) · 1.22 KB
/
burn-tool
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
#!/bin/bash
set -e -o pipefail
BASE=$(dirname "$(readlink -fm "$0")")
AML_BURN_TOOL="$BASE/aml-flash-tool/aml-burn-tool"
RK_BURN_TOOL="$BASE/rk-flash-tool/rk-burn-tool"
KHADAS_BURN_TOOL="/usr/local/bin/$(basename $0)"
IMAGE=
VENDER=
RED='\033[0;31m'
RESET='\033[m'
error_msg() {
echo -e "$RED"ERROR:"$RESET" $1
}
usage() {
echo -e "Usage:"
echo -e "Burn VIMs image: $0 [-v aml] [-b <VIM1|VIM2|VIM3>] -i <path-to-image>"
echo -e "Burn Edge: $0 -v rk -i <path-to-image>"
}
if [ ! -L $KHADAS_BURN_TOOL ]; then
error_msg "Please install `basename $0`. Execute 'INSTALL' script to install it."
exit 1
fi
while getopts "v:i:b:h" flag; do
case $flag in
v)
VENDER="$OPTARG"
;;
i)
IMAGE="$OPTARG"
;;
b)
BOARD="$OPTARG"
;;
h)
usage
exit
;;
esac
done
if [ ! -f "$IMAGE" ]; then
error_msg "Image '$IMAGE' doesn't exist!"
usage
exit -1
fi
# Default VENDER amlogic
VENDER=${VENDER:-aml}
if [ "$VENDER" == "rk" ]; then
echo "Try to burn Rockchip image..."
$RK_BURN_TOOL -i "$IMAGE"
elif [ "$VENDER" == "aml" ]; then
# Default BOARD VIM1
BOARD=${BOARD:-VIM1}
echo "Try to burn Amlogic image..."
$AML_BURN_TOOL -b "$BOARD" -i "$IMAGE"
else
error_msg "Unsupported vender: '$VENDER'!"
usage
exit -1
fi