blob: 5b07d5d612e9643ce99a43d86adaffcd63aeddb6 (
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
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
|
#!/bin/bash
# Copyright 2019 Google Inc. All rights reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
source "${ANDROID_BUILD_TOP}/external/shflags/src/shflags"
DEFINE_string loader1 \
"" "Path to loader1 image (partition 1)" "l"
DEFINE_string env \
"" "Path to env image (partition 2)" "e"
DEFINE_string loader2 \
"" "Path to loader2 image (partition 3)" "u"
DEFINE_string trust \
"" "Path to trust image (partition 4)" "t"
DEFINE_string rootfs \
"" "Path to rootfs image (partition 5)" "r"
DEFINE_string tftp \
"192.168.0.1" "TFTP server address" "f"
DEFINE_string tftpdir \
"/tftpboot" "TFTP server directory" "d"
DEFINE_string version \
"2" "Specify which manifest version to use (default: latest)" "v"
DEFINE_string ethaddr \
"" "MAC address of device to DFU (default: all)" "m"
FLAGS_HELP="USAGE: $0 [flags]"
FLAGS "$@" || exit $?
eval set -- "${FLAGS_ARGV}"
for arg in "$@" ; do
flags_help
exit 1
done
confirm() {
read -r -p "${1:-Are you sure you want to continue? [y/N]} " response
case "$response" in
[yY][eE][sS]|[yY])
true
;;
*)
false
;;
esac
}
createManifest() {
>>manifest.txt
}
addKVToManifest() {
key=$1
value=$2
grep -q "^${key}=" manifest.txt && \
sed -i "s/^${key}=.*/${key}=${value}/" manifest.txt || \
echo "${key}=${value}" >> manifest.txt
}
addShaToManifest() {
key="Sha"
cd "${ANDROID_BUILD_TOP}/device/google/cuttlefish_common"
Sha=`git rev-parse HEAD`
cd -
cd "${ANDROID_BUILD_TOP}/external/u-boot"
Sha="$Sha,`git rev-parse HEAD`"
cd -
cd "${ANDROID_BUILD_TOP}/external/arm-trusted-firmware"
Sha="$Sha,`git rev-parse HEAD`"
cd -
addKVToManifest "${key}" "${Sha}"
}
addPathToManifest() {
key=$1
path=$2
if [ "${path}" != "" ]; then
filename=$(basename $path)
filetype=`file -b --mime-type "${path}"`
if [ "$key" == "UbootEnv" ] && [ "${filetype}" == "application/gzip" ]; then
echo "error: gzip not supported for env images"
fi
if [ "$key" != "UbootEnv" ] && [ "${filetype}" != "application/gzip" ]; then
echo "warning: gzip recommended for all non-env images"
confirm || exit 1
fi
if [ ! "${path}" -ef "${FLAGS_tftpdir}/${filename}" ]; then
cp "${path}" "${FLAGS_tftpdir}/"
fi
else
unset filename
fi
addKVToManifest "${key}" "${filename}"
}
createManifest
addKVToManifest ManifestVersion ${FLAGS_version}
addKVToManifest TftpServer ${FLAGS_tftp}
addKVToManifest DFUethaddr ${FLAGS_ethaddr}
addPathToManifest RootfsImg ${FLAGS_rootfs}
addPathToManifest UbootEnv ${FLAGS_env}
addPathToManifest TplSplImg ${FLAGS_loader1}
addPathToManifest UbootItb ${FLAGS_loader2}
addShaToManifest
|