-
Notifications
You must be signed in to change notification settings - Fork 1
/
oot.sh
executable file
·253 lines (220 loc) · 6.3 KB
/
oot.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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
#!/usr/bin/bash
set -e
_self_dir=$(dirname "${BASH_SOURCE[0]}")
if [ -z "$ANDROID_BUILD_TOP" ]; then
ANDROID_ROOT=$(realpath "$_self_dir/../")
echo "WARNING: ANDROID_BUILD_TOP not set, guessing root at $ANDROID_ROOT"
else
ANDROID_ROOT=$(realpath "$ANDROID_BUILD_TOP")
fi
function usage {
echo 'USAGE:'
echo -e "\t$0 [FLAGS] <device> [<device>...]\t(Example for akatsuki: $0 akatsuki)"
echo
echo 'FLAGS:'
echo -e '\t-c <compiler> Select a compiler to use.'
echo -e '\t Currently supported compilers are gcc, linaro_gcc and clang (defaults to clang).'
echo -e '\t-f Flash the kernel after compiling (using fastboot).'
echo -e '\t-s Separate per-device kernel tmp dir instead of per-platform.'
echo -e '\t-h, --help Show the usage of the tool'
}
while getopts 'c:fsh-:' OPT; do
case ${OPT} in
-)
case ${OPTARG} in
help)
usage
exit
;;
*)
echo "$0: illegal option -- ${OPTARG}"
echo && usage
exit 1
;;
esac
;;
c)
if [[ -f "$_self_dir/setup_$OPTARG.sh" ]]; then
_compiler=${OPTARG}
else
echo "Compiler '${OPTARG}' unknown or not implemented"
exit 1
fi
;;
f)
_fastboot_flash=true
;;
s)
_separate_kernel_dir=true
;;
h)
usage
exit
;;
*)
echo && usage
exit 1
;;
esac
done
shift $(( OPTIND - 1 ))
if (( "$#" == 0 )); then
usage
exit 1
fi
# Default to clang
if [[ -z "${_compiler}" ]]; then
_compiler=clang
fi
# Platform common
BOARD_KERNEL_BASE=0x00000000
BOARD_KERNEL_PAGESIZE=4096
BOARD_KERNEL_TAGS_OFFSET=0x01E00000
BOARD_RAMDISK_OFFSET=0x02000000
for _device in "$@"; do
unset BOARD_KERNEL_CMDLINE _platform _has_dtbo _recovery_ramdisk _verity_file _verity_key_id
BOARD_KERNEL_CMDLINE+=" lpm_levels.sleep_disabled=1"
BOARD_KERNEL_CMDLINE+=" service_locator.enable=1"
BOARD_KERNEL_CMDLINE+=" androidboot.hardware=${_device}"
_kernel_major=4
_kernel_minor=14
# Device specific
case ${_device} in
suzu|kugo)
_platform=loire
;;
lilac|maple|poplar)
_platform=yoshino
;;
discovery|pioneer|voyager)
_platform=nile
;;
akari|akatsuki|apollo)
_platform=tama
;;
kirin|mermaid)
_platform=ganges
;;
bahamut|griffin)
_platform=kumano
;;
pdx201)
_platform=seine
;;
pdx20[36])
_platform=edo
_kernel_minor=19
;;
pdx213)
_platform=lena
_kernel_minor=19
;;
pdx21[45])
_platform=sagami
_kernel_major=5
_kernel_minor=4
;;
pdx22[34])
_soc=sm8450
_platform=nagara
_kernel_major=5
_kernel_minor=10
;;
pdx225)
_soc=sm6375
_platform=murray
_kernel_major=5
_kernel_minor=4
;;
*)
echo "Device '${_device}' unknown or not implemented"
exit 1
;;
esac
# Verity
case ${_platform} in
yoshino|nile|ganges)
_verity_file=build/target/product/security/verity.x509.pem
_verity_key_id=$(openssl x509 -in $_verity_file -text | grep keyid | sed 's/://g' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]' | sed 's/keyid//g')
BOARD_KERNEL_CMDLINE+=" veritykeyid=id:$_verity_key_id"
;;
esac
# Platform specific
case ${_platform} in
yoshino)
_recovery_ramdisk=false
;;
tama)
_has_dtbo=true
BOARD_KERNEL_CMDLINE+=" msm_drm.dsi_display0=dsi_panel_somc_${_platform}_cmd:config0"
BOARD_KERNEL_CMDLINE+=" androidboot.bootdevice=1d84000.ufshc"
BOARD_KERNEL_CMDLINE+=" swiotlb=2048"
;;
kumano)
_has_dtbo=true
BOARD_KERNEL_CMDLINE+=" msm_drm.blhack_dsi_display0=dsi_panel_somc_${_platform}_cmd:config0"
BOARD_KERNEL_CMDLINE+=" androidboot.bootdevice=1d84000.ufshc"
BOARD_KERNEL_CMDLINE+=" swiotlb=2048"
;;
seine)
_has_dtbo=true
_recovery_ramdisk=false
BOARD_KERNEL_CMDLINE+=" msm_drm.blhack_dsi_display0=dsi_panel_somc_${_platform}_cmd:config0"
;;
edo)
_has_dtbo=true
_recovery_ramdisk=false
BOARD_KERNEL_CMDLINE+=" msm_drm.blhack_dsi_display0=dsi_panel_somc_${_platform}_cmd:config0"
BOARD_KERNEL_CMDLINE+=" androidboot.bootdevice=1d84000.ufshc"
BOARD_KERNEL_CMDLINE+=" swiotlb=2048"
;;
lena)
_has_dtbo=true
_recovery_ramdisk=false
BOARD_KERNEL_CMDLINE+=" msm_drm.blhack_dsi_display0=dsi_panel_somc_${_platform}_cmd:config0"
BOARD_KERNEL_CMDLINE+=" androidboot.bootdevice=1d84000.ufshc"
BOARD_KERNEL_CMDLINE+=" swiotlb=2048"
;;
sagami)
_has_dtbo=true
_has_vendor_boot=true
_mkbootimg_args=(--header_version 1)
BOARD_KERNEL_CMDLINE+=" root=/dev/mmcblk0" # sdcard
BOARD_KERNEL_CMDLINE+=" androidboot.bootdevice=1d84000.ufshc"
BOARD_KERNEL_CMDLINE+=" swiotlb=2048"
;;
nagara)
_has_dtbo=true
_has_vendor_boot=true
_mkbootimg_args=(--header_version 4)
BOARD_KERNEL_CMDLINE+=" root=/dev/mmcblk0" # sdcard
BOARD_KERNEL_CMDLINE+=" swiotlb=2048"
;;
murray)
_has_dtbo=true
_has_vendor_boot=true
_mkbootimg_args=(--header_version 3)
BOARD_KERNEL_CMDLINE+=" root=/dev/mmcblk0" # sdcard
BOARD_KERNEL_CMDLINE+=" androidboot.bootdevice=4804000.ufshc"
BOARD_KERNEL_CMDLINE+=" swiotlb=2048"
;;
esac
# Options
# _permissive=true
# shellcheck source=./compile.sh
. "$_self_dir/compile.sh"
_boot_out=${_device}-boot.img
# shellcheck source=./create_images.sh
. "$_self_dir/create_images.sh"
if [ "$_fastboot_flash" = "true" ]; then
echo "==> Flashing $_boot_out"
fastboot flash boot "$_boot_out"
if [ "$_has_dtbo" = "true" ]; then
echo "==> Flashing $_dtbo_out"
fastboot flash dtbo "$_dtbo_out"
fi
echo "==> Rebooting device..."
fastboot continue || fastboot reboot
fi
echo
done