-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathflash_tool.sh
executable file
·103 lines (88 loc) · 2.08 KB
/
flash_tool.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
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash -e
LOCALPATH=$(pwd)
OUT=${LOCALPATH}/out
TOOLPATH=${LOCALPATH}/rkbin/tools
EXTLINUXPATH=${LOCALPATH}/build/extlinux
CHIP=""
DEVICE=""
IMAGE=""
DEVICE=""
SEEK=""
PATH=$PATH:$TOOLPATH
source $LOCALPATH/build/partitions.sh
usage() {
echo -e "\nUsage: emmc: build/flash_tool.sh -c rk3288 -p system -i out/system.img \n"
echo -e " sdcard: build/flash_tool.sh -c rk3288 -d /dev/sdb -p system -i out/system.img \n"
}
finish() {
echo -e "\e[31m FLASH IMAGE FAILED.\e[0m"
exit -1
}
trap finish ERR
while getopts "c:t:s:d:p:r:d:i:h" flag
do
case $flag in
c)
CHIP="$OPTARG"
;;
d)
DEVICE="$OPTARG"
;;
i)
IMAGE="$OPTARG"
if [ ! -e ${IMAGE} ] ; then
echo -e "\e[31m CAN'T FIND IMAGE \e[0m"
usage
exit
fi
;;
p)
PARTITIONS="$OPTARG"
BPARTITIONS=`echo $PARTITIONS| tr 'a-z' 'A-Z'`
SEEK=${BPARTITIONS}_START
eval SEEK=\$$SEEK
if [ -n "$(echo $SEEK| sed -n "/^[0-9]\+$/p")" ];then
echo "PARTITIONS OFFSET: $SEEK sectors."
else
echo -e "\e[31m INVAILD PARTITION.\e[0m"
exit
fi
;;
esac
done
if [ ! $IMAGE ] ; then
usage
exit
fi
if [ ! -e ${EXTLINUXPATH}/${CHIP}.conf ] ; then
CHIP="rk3288"
fi
flash_upgt()
{
if [ "${CHIP}" == "rk3288" ] ; then
sudo upgrade_tool db ${LOCALPATH}/rkbin/rk32/RK3288UbootLoader_V2.30.06.bin
elif [ "${CHIP}" == "rk3036" ] ; then
sudo upgrade_tool db ${LOCALPATH}/rkbin/rk30//RK3036MiniLoaderAll_V2.19.bin
elif [ "${CHIP}" == "rk3399" ] ; then
sudo upgrade_tool db ${LOCALPATH}/rkbin/rk33/RK3399MiniLoaderAll_V1.05.bin
elif [ "${CHIP}" == "rk3228" ] ; then
sudo upgrade_tool db ${LOCALPATH}/rkbin/rk33/RK3328MiniLoaderAll_V1.05.bin
fi
sudo upgrade_tool wl ${SEEK} ${IMAGE}
sudo upgrade_tool rd
if [ "${CHIP}" == "rk3399" ] ; then
echo "Please enter maskrom agagin to flash bootloader"
read -p "Press any key to continue... " -n1 -s
sudo upgrade_tool ul ${LOCALPATH}/rkbin/rk33/RK3399MiniLoaderAll_V1.05.bin
sudo upgrade_tool rd
fi
}
flash_sdcard()
{
sudo dd if=${IMAGE} of=${DEVICE} seek=${SEEK} conv=notrunc
}
if [ ! $DEVICE ] ; then
flash_upgt
else
flash_sdcard
fi