|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | + |
| 4 | +usage() |
| 5 | +{ |
| 6 | + echo "usage: [-s] -v=[4.4|4.9|4.14|v4.19] -a={AOSP|P} -t=clang-r349610" |
| 7 | + echo "-s = skip download" |
| 8 | + echo "-v = kernel version" |
| 9 | + echo "-a = android version" |
| 10 | + echo "-t = toolchain to use from prebuilts" |
| 11 | + echo "-m = mirror build, use premerge mirror" |
| 12 | + echo "-c = continue build, no download, no reconfig, just build" |
| 13 | +} |
| 14 | + |
| 15 | + |
| 16 | +set -ex |
| 17 | + |
| 18 | +# export TOOLCHAIN="clang-4679922" |
| 19 | +export TOOLCHAIN="clang-r349610" |
| 20 | +export nproc=9 |
| 21 | +export ANDROID_VERSION="P" |
| 22 | +export PASTRY_BUILD=1 |
| 23 | +export REFERENCE_BUILD_URL="http://testdata.linaro.org/lkft/aosp-stable/android-8.1.0_r29/" |
| 24 | +export KERNEL_DIR="hikey-linaro" |
| 25 | +export C_COMPILER="clang" |
| 26 | +export usegcc="0" |
| 27 | +# Some works about trees |
| 28 | +# android-hikey-linaro-4.4 android-hikey-linaro-4.9 android-hikey-linaro-4.14 android-hikey-linaro-4.19 |
| 29 | +# These are the blend of Common (aosp-mainline) + LTS for booting mainline + hikey support |
| 30 | +# android-4.4-p, android-4.9-p, android-4.14-p represent the blend of Common for P and LTS but no hikey support |
| 31 | +# android-4.4-p-hikey, android-4.9-p-hikey, android-4.14-p-hikey represent the blend of Common for P, LTS and hikey support |
| 32 | +# checkout -b android-hikey-linaro-4.9 origin/android-hikey-linaro-4.9 |
| 33 | + |
| 34 | +while [ "$1" != "" ]; do |
| 35 | + case $1 in |
| 36 | + -v | --version ) shift |
| 37 | + export VERSION=$1 |
| 38 | + ;; |
| 39 | + -a | --android ) shift |
| 40 | + export ANDROID_VERSION=$1 |
| 41 | + ;; |
| 42 | + -t | --toolchain ) shift |
| 43 | + toolchain=$1 |
| 44 | + ;; |
| 45 | + -s | --skipdownloads ) skipdownloads=1 |
| 46 | + ;; |
| 47 | + -m | --mirror-build ) mirrorbuild=1 |
| 48 | + ;; |
| 49 | + -g | --gcc ) usegcc=1 |
| 50 | + ;; |
| 51 | + -c | --continue ) cont=1 |
| 52 | + skipdownloads=1 |
| 53 | + ;; |
| 54 | + -h | --help ) usage |
| 55 | + exit |
| 56 | + ;; |
| 57 | + * ) usage |
| 58 | + exit 1 |
| 59 | + esac |
| 60 | + shift |
| 61 | +done |
| 62 | + |
| 63 | +if [ "$VERSION" = "4.9" ]; then |
| 64 | + if [ "$ANDROID_VERSION" = "AOSP" ]; then |
| 65 | + export KERNEL_BRANCH=android-hikey-linaro-4.9 |
| 66 | + else |
| 67 | + export KERNEL_BRANCH=android-4.9 |
| 68 | + fi |
| 69 | + export ANDROID_KERNEL_CONFIG_DIR="android-4.9" |
| 70 | + if [ "$mirrorbuild" == "1" ]; then |
| 71 | + export UPSTREAM_KERNEL_BRANCH=mirror-android-4.9 |
| 72 | + fi |
| 73 | +elif [ "$VERSION" = "4.14" ]; then |
| 74 | + if [ "$ANDROID_VERSION" = "AOSP" ]; then |
| 75 | + export KERNEL_BRANCH=android-hikey-linaro-4.14 |
| 76 | + else |
| 77 | + export KERNEL_BRANCH=android-4.14 |
| 78 | + fi |
| 79 | + export ANDROID_KERNEL_CONFIG_DIR="android-4.14" |
| 80 | + if [ "$mirrorbuild" == "1" ]; then |
| 81 | + export UPSTREAM_KERNEL_BRANCH=mirror-android-4.14 |
| 82 | + fi |
| 83 | +elif [ "$VERSION" = "4.19" ]; then |
| 84 | + # 4.19 for now is not associated with any pastry |
| 85 | + export KERNEL_BRANCH=android-hikey-linaro-4.19 |
| 86 | + export ANDROID_KERNEL_CONFIG_DIR="android-4.19" |
| 87 | + export PASTRY_BUILD=0 |
| 88 | + if [ "$mirrorbuild" == "1" ]; then |
| 89 | + export UPSTREAM_KERNEL_BRANCH=mirror-android-4.19 |
| 90 | + fi |
| 91 | +elif [ "$VERSION" = "4.4" ]; then |
| 92 | + if [ "$ANDROID_VERSION" = "AOSP" ]; then |
| 93 | + export KERNEL_BRANCH=android-hikey-linaro-4.4 |
| 94 | + else |
| 95 | + export KERNEL_BRANCH=android-4.4 |
| 96 | + fi |
| 97 | + export ANDROID_KERNEL_CONFIG_DIR="android-4.4" |
| 98 | + if [ "$mirrorbuild" == "1" ]; then |
| 99 | + export UPSTREAM_KERNEL_BRANCH=mirror-android-4.4 |
| 100 | + fi |
| 101 | +fi |
| 102 | + |
| 103 | +# android-4.14 android-4.4 android-4.9 p |
| 104 | + |
| 105 | +if [ "$ANDROID_VERSION" = "P" ]; then |
| 106 | + export CONFIG_FRAGMENTS_PATH="p" |
| 107 | +fi |
| 108 | + |
| 109 | +if [ "$ANDROID_VERSION" = "O-MR1" ]; then |
| 110 | + export REFERENCE_BUILD_URL="http://testdata.linaro.org/lkft/aosp-stable/android-8.1.0_r29/" |
| 111 | +elif [ "$ANDROID_VERSION" = "P" ]; then |
| 112 | +# export REFERENCE_BUILD_URL="https://snapshots.linaro.org/android/android-lcr-reference-hikey-p/latest?dl=/android/android-lcr-reference-hikey-p/latest/" |
| 113 | + export REFERENCE_BUILD_URL="http://people.linaro.org/~yongqin.liu/images/hikey/pie/" |
| 114 | +else |
| 115 | + echo "need AOSP master ref" |
| 116 | + export PASTRY_BUILD=0 |
| 117 | +fi |
| 118 | + |
| 119 | + |
| 120 | +echo "git checkout -b "$KERNEL_BRANCH"-"${ANDROID_VERSION,,}"-hikey origin/"$KERNEL_BRANCH"-"${ANDROID_VERSION,,}"-hikey " |
| 121 | + |
| 122 | +if [ "$skipdownloads" != "1" ]; then |
| 123 | + git clone --depth=1 https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9 |
| 124 | + git clone --depth=1 https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86 |
| 125 | +fi |
| 126 | + |
| 127 | +export PATH=${PWD}/aarch64-linux-android-4.9/bin/:${PWD}/linux-x86/${TOOLCHAIN}/bin/:${PATH} |
| 128 | + |
| 129 | +if [ "$skipdownloads" != "1" ]; then |
| 130 | + mkdir patches |
| 131 | + cd patches |
| 132 | + wget -r -np -nH -R index.html --cut-dirs=2 http://people.linaro.org/~tom.gall/patches/ |
| 133 | + cd .. |
| 134 | +fi |
| 135 | + |
| 136 | +#if [ "$skipdownloads" = "1" ]; then |
| 137 | +# cd configs |
| 138 | +# git pull |
| 139 | +# cd .. |
| 140 | +#else |
| 141 | +# git clone --depth=1 https://android.googlesource.com/kernel/configs |
| 142 | +# |
| 143 | +# if [ "$ANDROID_VERSION" = "O-MR1" ]; then |
| 144 | +# cd configs |
| 145 | +# patch -p1 < ../patches/ConfigsTurnOnQTA.patch |
| 146 | +# cd .. |
| 147 | +# fi |
| 148 | + |
| 149 | + |
| 150 | +if [ "$skipdownloads" != "1" ]; then |
| 151 | + git clone https://github.com/tom-gall/LinaroAndroidKernelConfigs.git |
| 152 | +fi |
| 153 | + |
| 154 | +if echo "$ANDROID_VERSION" | grep -i aosp ; then |
| 155 | + CMD="androidboot.console=ttyFIQ0 androidboot.hardware=hikey firmware_class.path=/vendor/firmware efi=noruntime printk.devkmsg=on buildvariant=userdebug overlay_mgr.overlay_dt_entry=hardware_cfg_enable_android_fstab video=HDMI-A-1:1280x720@60" |
| 156 | +elif [ "$VERSION" = "4.19" ]; then |
| 157 | + CMD="console=ttyAMA3,115200 androidboot.console=ttyAMA3 androidboot.hardware=hikey firmware_class.path=/vendor/firmware efi=noruntime printk.devkmsg=on buildvariant=userdebug overlay_mgr.overlay_dt_entry=hardware_cfg_enable_android_fstab initrd=0x11000000,0x17E28A" |
| 158 | + # this one works CMD="console=ttyAMA3 androidboot.console=ttyAMA3 androidboot.hardware=hikey firmware_class.path=/vendor/firmware efi=noruntime printk.devkmsg=on buildvariant=userdebug" |
| 159 | + # CMD="console=ttyAMA3,115200 androidboot.console=ttyAMA3 androidboot.hardware=hikey firmware_class.path=/vendor/firmware efi=noruntime printk.devkmsg=on buildvariant=userdebug overlay_mgr.overlay_dt_entry=hardware_cfg_enable_android_fstab initrd=0x11000000,0x17E28A" |
| 160 | + |
| 161 | + # console=ttyAMA3,115200 androidboot.console=ttyAMA3 androidboot.hardware=hikey firmware_class.path=/vendor/firmware efi=noruntime printk.devkmsg=on buildvariant=userdebug |
| 162 | + |
| 163 | + |
| 164 | +elif [ "$ANDROID_VERSION" = "O-MR1" ]; then |
| 165 | + CMD="androidboot.console=ttyFIQ0 androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noruntime printk.devkmsg=on buildvariant=userdebug" |
| 166 | +# CMD="androidboot.console=ttyFIQ0 androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noruntime printk.devkmsg=on buildvariant=userdebug video=HDMI-A-1:1280x720@60" |
| 167 | + |
| 168 | +elif [ "$ANDROID_VERSION" = "P" ]; then |
| 169 | + CMD="console=ttyAMA3,115200 androidboot.console=ttyAMA3 androidboot.hardware=hikey firmware_class.path=/vendor/firmware efi=noruntime printk.devkmsg=on buildvariant=userdebug overlay_mgr.overlay_dt_entry=hardware_cfg_enable_android_fstab initrd=0x11000000,0x17E28A" |
| 170 | + |
| 171 | +else |
| 172 | + echo "What Andoid Version are you planning to run?" |
| 173 | +fi |
| 174 | + |
| 175 | +if [ "$skipdownloads" = "1" ]; then |
| 176 | + cd "$KERNEL_DIR" |
| 177 | + if [ "$cont" = "1" ]; then |
| 178 | + # nothing to do |
| 179 | + echo "nothing to do" |
| 180 | + else |
| 181 | + if [ "$mirrorbuild" == "1" ]; then |
| 182 | + git merge --no-edit remotes/origin/${UPSTREAM_KERNEL_BRANCH} |
| 183 | + fi |
| 184 | + make mrproper |
| 185 | + fi |
| 186 | +# git checkout master |
| 187 | +# git clean -fd |
| 188 | +# git pull |
| 189 | +# git checkout "$KERNEL_BRANCH" |
| 190 | +# git pull |
| 191 | + |
| 192 | +else |
| 193 | + |
| 194 | + if [ "$PASTRY_BUILD" = "1" ]; then |
| 195 | + if [ "$VERSION" = "4.19" ]; then |
| 196 | + git clone https://android.googlesource.com/kernel/hikey-linaro |
| 197 | + else |
| 198 | + git clone https://github.com/tom-gall/hikey-linaro.git |
| 199 | + fi |
| 200 | + else |
| 201 | + git clone https://android.googlesource.com/kernel/hikey-linaro |
| 202 | + fi |
| 203 | + |
| 204 | + cd "$KERNEL_DIR" |
| 205 | + if [ "$PASTRY_BUILD" = "1" ]; then |
| 206 | + if [ "$VERSION" = "4.19" ]; then |
| 207 | + git checkout -b "$KERNEL_BRANCH" origin/"$KERNEL_BRANCH" |
| 208 | + else |
| 209 | + git checkout -b "$KERNEL_BRANCH"-"${ANDROID_VERSION,,}"-hikey origin/"$KERNEL_BRANCH"-"${ANDROID_VERSION,,}"-hikey |
| 210 | + fi |
| 211 | + else |
| 212 | + git checkout -b "$KERNEL_BRANCH" origin/"$KERNEL_BRANCH" |
| 213 | + fi |
| 214 | + |
| 215 | + if [ "$mirrorbuild" == "1" ]; then |
| 216 | + cp arch/arm64/configs/hikey_defconfig ../. |
| 217 | + fi |
| 218 | + |
| 219 | + if [ "$mirrorbuild" == "1" ]; then |
| 220 | + git merge --no-edit remotes/origin/${UPSTREAM_KERNEL_BRANCH} |
| 221 | + cp ../hikey_defconfig arch/arm64/configs/. |
| 222 | + #patch -p1 < ~/ee7ead2.diff |
| 223 | + fi |
| 224 | + |
| 225 | + if [ "$VERSION" = "4.9" ]; then |
| 226 | + if [ "$ANDROID_VERSION" = "O-MR1" ]; then |
| 227 | + git revert --no-edit bbab5cb8a5bd598af247d9eaf5a3033e7d12104e |
| 228 | + fi |
| 229 | + fi |
| 230 | + if [ "$VERSION" = "4.14" ]; then |
| 231 | + if [ "$ANDROID_VERSION" = "O-MR1" ]; then |
| 232 | + git revert --no-edit 20ebc74d51a1542e4290abf5ac9e32b524f891d1 |
| 233 | + git revert --no-edit d0455063e17c07841eb40b8e755f4c9241506de5 |
| 234 | + fi |
| 235 | + fi |
| 236 | +fi |
| 237 | +cd .. |
| 238 | + |
| 239 | + |
| 240 | +export CLANG_TRIPLE=aarch64-linux-gnu- |
| 241 | +export CROSS_COMPILE=aarch64-linux-android- |
| 242 | + |
| 243 | +cd "$KERNEL_DIR" |
| 244 | + |
| 245 | +if [ "$cont" != "1" ]; then |
| 246 | + # copy kernel config for any version besides AOSP |
| 247 | + if [ "$ANDROID_VERSION" = "O-MR1" ]; then |
| 248 | + cp ../LinaroAndroidKernelConfigs/${ANDROID_VERSION}/${VERSION}/hikey_defconfig .config |
| 249 | + elif [ "$VERSION" = "4.19" ]; then |
| 250 | + ARCH=arm64 scripts/kconfig/merge_config.sh arch/arm64/configs/hikey_defconfig ../configs/${CONFIG_FRAGMENTS_PATH}/${ANDROID_KERNEL_CONFIG_DIR}/android-base.config ../configs/${CONFIG_FRAGMENTS_PATH}/${ANDROID_KERNEL_CONFIG_DIR}/android-recommended-arm64.config |
| 251 | + elif [ "$ANDROID_VERSION" = "P" ]; then |
| 252 | + cp ../LinaroAndroidKernelConfigs/${ANDROID_VERSION}/${VERSION}/hikey_defconfig .config |
| 253 | + else # AOSP BUILD |
| 254 | + ARCH=arm64 scripts/kconfig/merge_config.sh arch/arm64/configs/hikey_defconfig ../configs/${CONFIG_FRAGMENTS_PATH}/${ANDROID_KERNEL_CONFIG_DIR}/android-base.config ../configs/${CONFIG_FRAGMENTS_PATH}/${ANDROID_KERNEL_CONFIG_DIR}/android-recommended-arm64.config |
| 255 | + fi |
| 256 | +fi |
| 257 | + |
| 258 | +cp .config ../defconfig |
| 259 | + |
| 260 | + |
| 261 | +if [ "$usegcc" = "1" ]; then |
| 262 | + export C_COMPILER=gcc |
| 263 | +fi |
| 264 | + |
| 265 | +if [ "$VERSION" = "4.19" ]; then |
| 266 | + make ARCH=arm64 CC="${C_COMPILER}" HOSTCC="${C_COMPILER}" -j$(nproc) Image |
| 267 | + make ARCH=arm64 CC="${C_COMPILER}" HOSTCC="${C_COMPILER}" -j$(nproc) dtbs |
| 268 | + # make ARCH=arm64 CC=clang HOSTCC=clang -j$(nproc) Image |
| 269 | + # make ARCH=arm64 CC=clang HOSTCC=clang -j$(nproc) dtbs |
| 270 | + cat arch/arm64/boot/Image arch/arm64/boot/dts/hisilicon/hi6220-hikey.dtb > arch/arm64/boot/Image-dtb |
| 271 | +else |
| 272 | + make ARCH=arm64 CC=clang HOSTCC=clang -j$(nproc) Image-dtb |
| 273 | +fi |
| 274 | + |
| 275 | +cd .. |
| 276 | +if [ "$skipdownloads" != "1" ]; then |
| 277 | + wget -q https://android-git.linaro.org/platform/system/core.git/plain/mkbootimg/mkbootimg.py -O mkbootimg |
| 278 | + wget -q ${REFERENCE_BUILD_URL}/ramdisk.img -O ramdisk.img |
| 279 | +fi |
| 280 | + |
| 281 | + |
| 282 | + |
| 283 | +if [ "$ANDROID_VERSION" = "O-MR1" ]; then |
| 284 | + python mkbootimg --kernel ${PWD}/"$KERNEL_DIR"/arch/arm64/boot/Image-dtb --cmdline "${CMD}" --os_version O --os_patch_level 2016-11-05 --ramdisk ./ramdisk.img --output boot.img |
| 285 | +else |
| 286 | + python mkbootimg --kernel ${PWD}/"$KERNEL_DIR"/arch/arm64/boot/Image-dtb --cmdline "${CMD}" --os_version P --os_patch_level 2018-09-01 --ramdisk ./ramdisk.img --output boot.img |
| 287 | +fi |
| 288 | +# |
0 commit comments