Download the kernel source code
1. Check the kernel version
First, you need to check the kernel version. You can see the kernel version on your phone.
2. Download the source code corresponding to the kernel version
cd ~/mount/project/androidq git clone https://aosp.tuna.tsinghua.edu.cn/android/kernel/msm.git cd msm git checkout 4fecde07e68d
The execution results are as follows:
longzhiye@longzhiye-laptop:~/mount/project/androidq$ git clone https://aosp.tuna.tsinghua.edu.cn/android/kernel/msm.git Cloning to 'msm'... warning: Redirect to https://aosp.tuna.tsinghua.edu.cn/kernel/msm.git/ remote: Enumerating objects: 2324949, done. remote: Counting objects: 100% (2324949/2324949), done. remote: Compressing objects: 100% (521905/521905), done. remote: Total 11825131 (delta 1865339), reused 2217253 (delta 1796210), pack-reused 9500182 Received: 100% (11825131/11825131), 2.98 GiB | 16.48 MiB/s, completed. Processing delta medium: 100% (9920545/9920545), completed. longzhiye@longzhiye-laptop:~/mount/project/androidq$ cd msm/ longzhiye@longzhiye-laptop:~/mount/project/androidq/msm$ git checkout 4fecde07e68d Checking out files: 100% (56480/56480), complete. NOTE: Checking out '4fecde07e68d'. You are detaching the head pointer. You can review, make experimental changes, and commit, and you can do so via another The checkout branch operation discards any commits made in this state. If you want to keep the commits made in this state by creating a branch, you can do so by adding in the checkout command Parameter -b to achieve (now or later). For example: git checkout -b <new branch name> HEAD is currently at 4fecde07e68d Merge android-msm-wahoo-4.4-qt-qpr2 into android-msm-wahoo-4.4-qt-qpr3
The branch “4fecde07e68d” here is the number after g in the kernel version in the mobile phone screenshot above
Compile
3. Install libssl (an error will be reported when compiling without installation)
sudo apt install libssl-dev
The execution results are as follows:
longzhiye@longzhiye-laptop:~/mount/project/androidq/msm$ sudo apt install libssl-dev [sudo] longzhiye's password: Reading package list... Done Analyzing a package's dependency tree Reading status information... Complete The following packages were installed automatically and are no longer needed: gir1.2-goa-1.0 gir1.2-snapd-1 Use 'sudo apt autoremove' to uninstall it(them). The following software will also be installed: libssl1.1 Recommended installation: libssl-doc The following [new] packages will be installed: libssl-dev The following packages will be upgraded: libssl1.1 1 package upgraded, 1 newly installed, 0 packages to uninstall, and 71 packages have not been upgraded. Requires download of 2,870 kB archive. Decompression consumes an additional 7,850 kB of space. Do you wish to proceed? [Y/n] y Get: 1 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libssl1.1 amd64 1.1.1-1ubuntu2.1~18.04.23 [1,303 kB] Get: 2 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libssl-dev amd64 1.1.1-1ubuntu2.1~18.04.23 [1,568 kB] Downloaded 2,870 kB, took 5 seconds (553 kB/s) Preconfiguring packages... (Reading database... The system currently has a total of 204375 files and directories installed.) Preparing to unpack.../libssl1.1_1.1.1-1ubuntu2.1~18.04.23_amd64.deb... Unpacking libssl1.1:amd64 (1.1.1-1ubuntu2.1~18.04.23) onto (1.1.1-1ubuntu2.1~18.04.22)... Selecting unselected package libssl-dev:amd64. Preparing to unpack.../libssl-dev_1.1.1-1ubuntu2.1~18.04.23_amd64.deb... Unpacking libssl-dev:amd64 (1.1.1-1ubuntu2.1~18.04.23) ... Setting up libssl1.1:amd64 (1.1.1-1ubuntu2.1~18.04.23) ... Setting up libssl-dev:amd64 (1.1.1-1ubuntu2.1~18.04.23) ... Processing triggers for libc-bin (2.27-3ubuntu1.6)...
4. Remove the kernel verification (otherwise the touch screen will not respond after reflashing the kernel)
$aosp\msm\arch\arm64\configs\wahoo_defconfig
CONFIG_MODVERSIONS=y CONFIG_MODULE_SRCVERSION_ALL=y change into # CONFIG_MODVERSIONS=y # CONFIG_MODULE_SRCVERSION_ALL=y
$aosp\msm\kernel\module.c
return -ENOEXEC; change into // return -ENOEXEC;
5. Add the compilation tool chain to the environment variables and compile
cd msm export PATH=$PATH:/home/longzhiye/mount/project/androidq/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin export PATH=$PATH:/home/longzhiye/mount/project/androidq/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin export PATH=$PATH:/home/longzhiye/mount/project/androidq/prebuilts/misc/linux-x86/dtc export PATH=$PATH:/home/longzhiye/mount/project/androidq/prebuilts/misc/linux-x86/libufdt export PATH=$PATH:/home/longzhiye/mount/project/androidq/prebuilts/misc/linux-x86/lz4 export ARCH=arm64 export CROSS_COMPILE=/home/longzhiye/mount/project/androidq/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android- export CROSS_COMPILE_ARM32=/home/longzhiye/mount/project/androidq/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androideabi- export CC=/home/longzhiye/mount/project/androidq/prebuilts/clang/host/linux-x86/clang-3289846/bin/clang makewahoo_defconfig make -j4
The running results are as follows:
longzhiye@longzhiye-laptop:~/mount/project/androidq$ cd msm/ longzhiye@longzhiye-laptop:~/mount/project/androidq/msm$ export PATH=$PATH:/home/longzhiye/mount/project/androidq/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9 /bin longzhiye@longzhiye-laptop:~/mount/project/androidq/msm$ export PATH=$PATH:/home/longzhiye/mount/project/androidq/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9 /bin longzhiye@longzhiye-laptop:~/mount/project/androidq/msm$ export PATH=$PATH:/home/longzhiye/mount/project/androidq/prebuilts/misc/linux-x86/dtc longzhiye@longzhiye-laptop:~/mount/project/androidq/msm$ export PATH=$PATH:/home/longzhiye/mount/project/androidq/prebuilts/misc/linux-x86/libufdt longzhiye@longzhiye-laptop:~/mount/project/androidq/msm$ export PATH=$PATH:/home/longzhiye/mount/project/androidq/prebuilts/misc/linux-x86/lz4 longzhiye@longzhiye-laptop:~/mount/project/androidq/msm$ export ARCH=arm64 longzhiye@longzhiye-laptop:~/mount/project/androidq/msm$ export CROSS_COMPILE=/home/longzhiye/mount/project/androidq/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/ aarch64-linux-android- longzhiye@longzhiye-laptop:~/mount/project/androidq/msm$ export CROSS_COMPILE_ARM32=/home/longzhiye/mount/project/androidq/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/ arm-linux-androideabi- longzhiye@longzhiye-laptop:~/mount/project/androidq/msm$ export CC=/home/longzhiye/mount/project/androidq/prebuilts/clang/host/linux-x86/clang-3289846/bin/clang longzhiye@longzhiye-laptop:~/mount/project/androidq/msm$ make wahoo_defconfig # # configuration written to .config # #### build completed successfully (2 seconds) #### longzhiye@longzhiye-laptop:~/mount/project/androidq/msm$ make -j4 Android GCC has been deprecated in favor of Clang, and will be removed from Android in 2020-01 as per the deprecation plan in: https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/ + /master/GCC_4_9_DEPRECATION.md ... drivers/thermal/thermal_core.c:43:26: fatal error: ../base/base.h: No such file or directory #include <../base/base.h> ^ compilation terminated. scripts/Makefile.build:276: recipe for target 'drivers/thermal/thermal_core.o' failed make[2]: *** [drivers/thermal/thermal_core.o] Error 1 scripts/Makefile.build:483: recipe for target 'drivers/thermal' failed make[1]: *** [drivers/thermal] Error 2 make[1]: *** Waiting for unfinished tasks.... CC drivers/soc/qcom/wlan_firmware_service_v01.o Android GCC has been deprecated in favor of Clang, and will be removed from Android in 2020-01 as per the deprecation plan in: https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/ + /master/GCC_4_9_DEPRECATION.md
Error message
drivers/thermal/thermal_core.c:43:26: fatal error: ../base/base.h: No such file or directory #include <../base/base.h>
Modify the “drivers/thermal/thermal_core.c” file
$aosp\msm\drivers\thermal\thermal_core.c
#include "<../base/base.h>" change into #include "../base/base.h"
Continue compiling
make -j4
If the compilation is successful, the following prompt will appear:
Building modules, stage 2. DTC arch/arm64/boot/dts/qcom/msm8998-v2.1-soc.dtb MODPOST 9 modules Android GCC has been deprecated in favor of Clang, and will be removed from Android in 2020-01 as per the deprecation plan in: https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/ + /master/GCC_4_9_DEPRECATION.md CAT arch/arm64/boot/Image.lz4-dtb #### build completed successfully (9 seconds) ####
Package and flash into mobile phone
6. Packaging
cd .. export TARGET_PREBUILT_KERNEL=/home/longzhiye/mount/project/androidq/msm/arch/arm64/boot/Image.lz4-dtb source build/envsetup.sh lunch aosp_walleye-userdebug time make bootimage
The running results are as follows:
longzhiye@longzhiye-laptop:~/mount/project/androidq/msm$ cd .. longzhiye@longzhiye-laptop:~/mount/project/androidq$ export TARGET_PREBUILT_KERNEL=/home/longzhiye/mount/project/androidq/msm/arch/arm64/boot/Image.lz4-dtb longzhiye@longzhiye-laptop:~/mount/project/androidq$ source build/envsetup.sh longzhiye@longzhiye-laptop:~/mount/project/androidq$ lunch aosp_walleye-userdebug ============================================ PLATFORM_VERSION_CODENAME=REL PLATFORM_VERSION=10 TARGET_PRODUCT=aosp_walleye TARGET_BUILD_VARIANT=userdebug ... OUT_DIR=out PRODUCT_SOONG_NAMESPACES=device/google/wahoo vendor/google/camera hardware/google/pixel ============================================ 20:31:39 Disallowed PATH tool "locale" used: []string{<!-- -->"locale", "-a"} 20:31:39 See https://android.googlesource.com/platform/build/ + /master/Changes.md#PATH_Tools for more information. 20:31:43 Disallowed PATH tool "locale" used: []string{<!-- -->"locale", "-a"} 20:31:43 See https://android.googlesource.com/platform/build/ + /master/Changes.md#PATH_Tools for more information. [100% 2/2] Target boot image from recovery: out/target/product/walleye/boot.img #### build completed successfully (18 seconds) #### real 0m18.171s user 0m21.882s sys 0m7.009s
7. Flash into the phone
The phone enters fastboot mode
cd ~/mount/project/androidq source build/envsetup.sh lunch aosp_walleye-userdebug adb reboot bootloader cd out/target/product/walleye/ fastboot flash boot boot.img fastboot reboot
Successfully flashed the phone and entered the kernel view interface after booting. “Kernel version” has changed.