-
Notifications
You must be signed in to change notification settings - Fork 1
/
create_images.sh
78 lines (63 loc) · 2.87 KB
/
create_images.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
#! /usr/bin/bash
# See PLATFORM_SECURITY_PATCH in $ANDROID_ROOT/build/make/core/version_defaults.mk
if _os_patch_level=$(grep -Po 'PLATFORM_SECURITY_PATCH\s+:=\s+\K([0-9]{4}(-[0-9]{2}){2})' "$ANDROID_ROOT/build/make/core/version_defaults.mk"); then
echo "Using SPL $_os_patch_level from Android tree"
else
_os_patch_level='2020-06-05'
echo "WARNING: Patch level not found in Android tree. Using $_os_patch_level"
fi
_os_version=10
echo "==> Generating images for patch level $_os_patch_level"
# True by default, analogous to BOARD_USES_RECOVERY_AS_BOOT:
[ "$_recovery_ramdisk" = "false" ] && _ramdisk=ramdisk.img || _ramdisk=ramdisk-recovery.img
_ramdisk=$ANDROID_ROOT/out/target/product/$_device/$_ramdisk
[ ! -f "$_ramdisk" ] && echo "WARNING: $_ramdisk does not exist!"
# mkdir -p $(dirname $_boot_out)
if [[ "$_has_dtbo" == "true" ]]; then
_dts_folder="$_out/arch/arm64/boot/dts"
_files=$(find "$_dts_folder" -iname "*.dtbo")
echo "==> Creating dtboimg from $_files"
_mkdtboimg="$_kernel_path/scripts/mkdtboimg.py"
[[ ! -f "$_mkdtboimg" ]] && _mkdtboimg="$ANDROID_ROOT/prebuilts/misc/linux-x86/libufdt/mkdtimg"
[[ ! -f "$_mkdtboimg" ]] && _mkdtboimg="$ANDROID_ROOT/system/libufdt/utils/src/mkdtboimg.py"
[[ ! -f "$_mkdtboimg" ]] && (echo "No mkdtbo script/executable found"; exit 1)
echo "==> Using mkdtbo at $_mkdtboimg"
# --page_size="$BOARD_KERNEL_PAGESIZE"
# _files requires word splitting (Tama has multiple dtbo files)
# shellcheck disable=SC2086
"$_mkdtboimg" create "$_device-dtbo.img" $_files
fi
if [[ "$_has_vendor_boot" == "true" ]]; then
echo "TODO: Create and flash vendor_boot"; exit 1
fi
if [[ "${_permissive:-false}" == "true" ]]; then
echo "==> Adding permissive to cmdline"
BOARD_KERNEL_CMDLINE+=" androidboot.selinux=permissive"
# enforcing=0 selinux=0
fi
# TODO MOVE IT ALL HERE
# BOARD_KERNEL_CMDLINE += androidboot.selinux=permissive
#BOARD_KERNEL_CMDLINE+=" console=ttyMSM0,115200,n8 androidboot.console=ttyMSM0"
BOARD_KERNEL_CMDLINE+=" androidboot.memcg=1"
BOARD_KERNEL_CMDLINE+=" msm_rtb.filter=0x3F ehci-hcd.park=3"
BOARD_KERNEL_CMDLINE+=" coherent_pool=8M"
BOARD_KERNEL_CMDLINE+=" sched_enable_power_aware=1 user_debug=31"
BOARD_KERNEL_CMDLINE+=" printk.devkmsg=on"
BOARD_KERNEL_CMDLINE+=" loop.max_part=16"
BOARD_KERNEL_CMDLINE+=" kpti=0"
echo "$BOARD_KERNEL_CMDLINE"
echo "==> Creating $_boot_out..."
"$ANDROID_ROOT/out/host/linux-x86/bin/mkbootimg" \
--kernel "$_kernel" \
--ramdisk "$_ramdisk" \
--cmdline "$BOARD_KERNEL_CMDLINE" \
--base "$BOARD_KERNEL_BASE" \
--pagesize "$BOARD_KERNEL_PAGESIZE" \
--os_version "$_os_version" \
--os_patch_level "$_os_patch_level" \
--ramdisk_offset "$BOARD_RAMDISK_OFFSET" \
--tags_offset "$BOARD_KERNEL_TAGS_OFFSET" \
"${_mkbootimg_args[@]}" \
--output "$_boot_out" \
--id
echo "==> mkbootimg successful, created $_boot_out"