快速编译kernel

1.配置编译环境

source build/envsetup.sh

lunch xx

2.开始编译

make showcommands bootimage  >build.log

通过参数showcommands 将编译的命令显示出来,

比如原来编译命令是make -j4 但是编译的细节没看到,如果要显示编译的命令可以用参数showcommands

3.创建编译脚本

a.touch buld_kernel.sh

b.复制第二步编译的build.log中 bin/bash -c 开始的每一段到buld_kernel.sh里

c.在脚本之前加上 source 和 lunch 就可以了

d.增加可执行全限

chmod +x buld_kernel.sh

4.运行编译脚本

./build_kernel.sh

注:以后每次编译使用这个脚本就可以了

 

5.高通平台sdm450例子

下面是制作的脚本

source build/envsetup.sh
lunch 19

/bin/bash -c "(if [ ! -z \"hq_sdm450_defconfig\" ]; then            rm -f ../../out/target/product/hq_sdm450/obj/kernel/msm-4.9/.config;            make -j2 -C kernel/msm-4.9 O=../../out/target/product/hq_sdm450/obj/kernel/msm-4.9 DTC_EXT=dtc CONFIG_BUILD_ARM64_DT_OVERLAY=y ARCH=arm64 CROSS_COMPILE=aarch64-linux-android- hq_sdm450_defconfig;             make -j2 -C kernel/msm-4.9 O=../../out/target/product/hq_sdm450/obj/kernel/msm-4.9 DTC_EXT=dtc CONFIG_BUILD_ARM64_DT_OVERLAY=y ARCH=arm64 CROSS_COMPILE=aarch64-linux-android- headers_install;         if [ -d \"out/target/product/hq_sdm450/obj/kernel/msm-4.9/usr/include/bringup_headers\" ]; then                 cp -Rf  out/target/product/hq_sdm450/obj/kernel/msm-4.9/usr/include/bringup_headers/* out/target/product/hq_sdm450/obj/kernel/msm-4.9/usr/include/ ;            fi ;            fi ) && (if [ \"hq_sdm450_defconfig\" != \"hq_sdm450_defconfig\" ]; then            echo \"Used a different defconfig for header generation\";          rm -f ../../out/target/product/hq_sdm450/obj/kernel/msm-4.9/.config;            make -j2 -C kernel/msm-4.9 O=../../out/target/product/hq_sdm450/obj/kernel/msm-4.9 DTC_EXT=dtc CONFIG_BUILD_ARM64_DT_OVERLAY=y ARCH=arm64 CROSS_COMPILE=aarch64-linux-android- hq_sdm450_defconfig; fi ) && (if [ ! -z \"\" ]; then             echo \"Overriding kernel config with ''\";          echo  >> out/target/product/hq_sdm450/obj/kernel/msm-4.9/.config;           make -j2 -C kernel/msm-4.9 O=../../out/target/product/hq_sdm450/obj/kernel/msm-4.9 DTC_EXT=dtc CONFIG_BUILD_ARM64_DT_OVERLAY=y ARCH=arm64 CROSS_COMPILE=aarch64-linux-android- oldconfig; fi )"
/bin/bash -c "(rm -rf out/target/product/hq_sdm450/obj/KERNEL_OBJ ) && (ln -s kernel/msm-4.9 out/target/product/hq_sdm450/obj/KERNEL_OBJ )"
/bin/bash -c "(rm -rf out/target/product/hq_sdm450/obj/kernel/msm-4.9/arch/arm64/boot/dts ) && (make -j2 -C kernel/msm-4.9 O=../../out/target/product/hq_sdm450/obj/kernel/msm-4.9 DTC_EXT=dtc CONFIG_BUILD_ARM64_DT_OVERLAY=y ARCH=arm64 CROSS_COMPILE=aarch64-linux-android- KCFLAGS=-mno-android ) && (make -j2 -C kernel/msm-4.9 O=../../out/target/product/hq_sdm450/obj/kernel/msm-4.9 DTC_EXT=dtc CONFIG_BUILD_ARM64_DT_OVERLAY=y ARCH=arm64 CROSS_COMPILE=aarch64-linux-android- KCFLAGS=-mno-android modules ) && (make -j2 -C kernel/msm-4.9 O=../../out/target/product/hq_sdm450/obj/kernel/msm-4.9 INSTALL_MOD_PATH=../../../dlkm INSTALL_MOD_STRIP=1 DTC_EXT=dtc CONFIG_BUILD_ARM64_DT_OVERLAY=y ARCH=arm64 CROSS_COMPILE=aarch64-linux-android- modules_install ) && (mdpath=\`find out/target/product/hq_sdm450/dlkm/lib/modules -type f -name modules.dep\`; if [ \"\$mdpath\" != \"\" ];then mpath=\`dirname \$mdpath\`; ko=\`find \$mpath/kernel -type f -name *.ko\`; for i in \$ko; do mv \$i out/target/product/hq_sdm450/dlkm/lib/modules/; done; fi ) && (mdpath=\`find out/target/product/hq_sdm450/dlkm/lib/modules -type f -name modules.dep\`; if [ \"\$mdpath\" != \"\" ];then mpath=\`dirname \$mdpath\`; rm -rf \$mpath; fi )"
/bin/bash -c "(rm -f out/target/product/hq_sdm450/kernel ) && (cp \"out/target/product/hq_sdm450/obj/kernel/msm-4.9/arch/arm64/boot/Image.gz-dtb\" \"out/target/product/hq_sdm450/kernel\" )"
/bin/bash -c "(out/host/linux-x86/bin/mkbootimg  --kernel out/target/product/hq_sdm450/kernel --base 0x80000000 --pagesize 2048 --cmdline \"console=ttyMSM0,115200,n8 androidboot.console=ttyMSM0 androidboot.hardware=qcom msm_rtb.filter=0x237 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 androidboot.bootdevice=7824900.sdhci earlycon=msm_serial_dm,0x78af000 firmware_class.path=/vendor/firmware_mnt/image androidboot.usbconfigfs=true loop.max_part=7 buildvariant=userdebug\" --os_version 9 --os_patch_level 2018-10-05 --header_version 1 --output out/target/product/hq_sdm450/boot.img ) && (size=\$(for i in out/target/product/hq_sdm450/boot.img; do stat --format \"%s\" \"\$i\" | tr -d '\\n'; echo +; done; echo 0); total=\$(( \$( echo \"\$size\" ) )); printname=\$(echo -n \"out/target/product/hq_sdm450/boot.img\" | tr \" \" +); maxsize=\$((   0x04000000-69632)); if [ \"\$total\" -gt \"\$maxsize\" ]; then echo \"error: \$printname too large (\$total > \$maxsize)\"; false; elif [ \"\$total\" -gt \$((maxsize - 32768)) ]; then echo \"WARNING: \$printname approaching size limit (\$total now; limit \$maxsize)\"; fi ) && (out/host/linux-x86/bin/avbtool add_hash_footer       --image out/target/product/hq_sdm450/boot.img       --partition_size 0x04000000     --partition_name boot )"

 

你可能感兴趣的:(快速编译kernel)