-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathcreatekeys
executable file
·151 lines (128 loc) · 3.18 KB
/
createkeys
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/bash
#
# pack/pack
# (c) Copyright 2013
# Allwinner Technology Co., Ltd. <www.allwinnertech.com>
# flord wang <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
ROOT_DIR=$TINA_BUILD_TOP/out/$TARGET_BOARD
if [ "x$TARGET_BOARD" = "x" ]; then
echo "Error: please lunch a platform first"
exit 1
fi
echo "$ROOT_DIR"
SELECT_CHIP=$TARGET_PLATFORM
HOST_DIR=$TINA_BUILD_TOP/out/host/bin
export PATH=${HOST_DIR}:$PATH
PLATFORM_LIST="r18 c200s r30 r311 r328s2 r328s3 mr112 mr813 r329 r818 r528 r528rv d1 v853"
function pack_error()
{
echo -e "\033[47;31mERROR: $*\033[0m"
}
function pack_warn()
{
echo -e "\033[47;34mWARN: $*\033[0m"
}
function pack_info()
{
echo -e "\033[0;31;1mINFO: $*\033[0m"
}
show_help()
{
echo "build.sh - this script is used to create all keys defined in the dragon_toc.cfg"
echo "OPTIONS"
echo "-h Display help message"
echo "-c [chip_type] Chip type, e.g. r18,r328s2,mr813..."
}
build_select_chip()
{
if [ "x$SELECT_CHIP" != "x" ]; then
return
fi
local count=0
printf "All valid chip:\n"
for chip in $PLATFORM_LIST; do
chips[$count]=$chip
printf "$count. ${chips[$count]}\n"
let count=$count+1
done
while true; do
read -p "Please select a chip:"
RES=`expr match $REPLY "[0-9][0-9]*$"`
if [ "$RES" -le 0 ]; then
echo "please use index number"
continue
fi
if [ "$REPLY" -ge $count ]; then
echo "too big"
continue
fi
if [ "$REPLY" -lt "0" ]; then
echo "too small"
continue
fi
break
done
SELECT_CHIP=${chips[$REPLY]}
}
createkeys()
{
printf "ready to create keys\n"
echo $PLATFORM_LIST | grep "$SELECT_CHIP"
if [ $? -ne 0 ]
then
pack_error "plat: $SELECT_CHIP is not exist"
exit 1
fi
pack_info "SELECT_CHIP is $SELECT_CHIP\n"
if [ -f ${TINA_BUILD_TOP}/device/config/chips/${SELECT_CHIP}/configs/default/dragon_toc.cfg ] ; then
cp -v ${TINA_BUILD_TOP}/device/config/chips/${SELECT_CHIP}/configs/default/dragon_toc.cfg $ROOT_DIR/dragon_toc.cfg
elif [ -f ${TINA_BUILD_TOP}/device/config/common/sign_config/dragon_toc.cfg ] ; then
cp -v ${TINA_BUILD_TOP}/device/config/common/sign_config/dragon_toc.cfg $ROOT_DIR/dragon_toc.cfg
else
cp -v ${TINA_BUILD_TOP}/target/allwinner/generic/sign_config/dragon_toc.cfg $ROOT_DIR/dragon_toc.cfg
fi
if [ $? -ne 0 ]
then
pack_error "dragon toc config file is not exist"
exit 1
fi
echo "$ROOT_DIR/keys"
dragonsecboot -key $ROOT_DIR/dragon_toc.cfg $ROOT_DIR/keys
if [ $? -ne 0 ]
then
pack_error "dragon toc run error"
rm -rf dragon_toc.cfg
exit 1
fi
printf "\n"
if [ -f ${TINA_BUILD_TOP}/device/config/chips/${SELECT_CHIP}/configs/default/dragon_toc.cfg ]
then
pack_info "use platform[$SELECT_CHIP] toc config to creat keys"
else
pack_info "use default toc config to creat keys"
fi
printf "\n"
rm -rf $ROOT_DIR/dragon_toc.cfg
}
while getopts hc: OPTION
do
case $OPTION in
h) show_help
exit 0
;;
c) SELECT_CHIP=$OPTARG
createkeys
exit 0
;;
*) show_help
exit 0
;;
esac
done
build_select_chip
createkeys