下载内核源码
1.查看内核版本
首先需要看一下内核的版本,可以在手机中看到内核版本
2.下载该内核版本对应的源码
cd ~/mount/project/androidq
git clone https://aosp.tuna.tsinghua.edu.cn/android/kernel/msm.git
cd msm
git checkout 4fecde07e68d
执行结果如下:
longzhiye@longzhiye-laptop:~/mount/project/androidq$ git clone https://aosp.tuna.tsinghua.edu.cn/android/kernel/msm.git
正克隆到 'msm'...
warning: 重定向到 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
接收对象中: 100% (11825131/11825131), 2.98 GiB | 16.48 MiB/s, 完成.
处理 delta 中: 100% (9920545/9920545), 完成.
longzhiye@longzhiye-laptop:~/mount/project/androidq$ cd msm/
longzhiye@longzhiye-laptop:~/mount/project/androidq/msm$ git checkout 4fecde07e68d
正在检出文件: 100% (56480/56480), 完成.
注意:正在检出 '4fecde07e68d'。
您正处于分离头指针状态。您可以查看、做试验性的修改及提交,并且您可以通过另外
的检出分支操作丢弃在这个状态下所做的任何提交。
如果您想要通过创建分支来保留在此状态下所做的提交,您可以通过在检出命令添加
参数 -b 来实现(现在或稍后)。例如:
git checkout -b <新分支名>
HEAD 目前位于 4fecde07e68d Merge android-msm-wahoo-4.4-qt-qpr2 into android-msm-wahoo-4.4-qt-qpr3
这里的分支"4fecde07e68d"就是上面的手机截图中内核版本里g后面的数字
编译
3.安装libssl(不装编译的时候会报错)
sudo apt install libssl-dev
执行结果如下:
longzhiye@longzhiye-laptop:~/mount/project/androidq/msm$ sudo apt install libssl-dev
[sudo] longzhiye 的密码:
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
下列软件包是自动安装的并且现在不需要了:
gir1.2-goa-1.0 gir1.2-snapd-1
使用'sudo apt autoremove'来卸载它(它们)。
将会同时安装下列软件:
libssl1.1
建议安装:
libssl-doc
下列【新】软件包将被安装:
libssl-dev
下列软件包将被升级:
libssl1.1
升级了 1 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 71 个软件包未被升级。
需要下载 2,870 kB 的归档。
解压缩后会消耗 7,850 kB 的额外空间。
您希望继续执行吗? [Y/n] y
获取:1 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libssl1.1 amd64 1.1.1-1ubuntu2.1~18.04.23 [1,303 kB]
获取:2 http://security.ubuntu.com/ubuntu bionic-security/main amd64 libssl-dev amd64 1.1.1-1ubuntu2.1~18.04.23 [1,568 kB]
已下载 2,870 kB,耗时 5秒 (553 kB/s)
正在预设定软件包 ...
(正在读取数据库 ... 系统当前共安装有 204375 个文件和目录。)
正准备解包 .../libssl1.1_1.1.1-1ubuntu2.1~18.04.23_amd64.deb ...
正在将 libssl1.1:amd64 (1.1.1-1ubuntu2.1~18.04.23) 解包到 (1.1.1-1ubuntu2.1~18.04.22) 上 ...
正在选中未选择的软件包 libssl-dev:amd64。
正准备解包 .../libssl-dev_1.1.1-1ubuntu2.1~18.04.23_amd64.deb ...
正在解包 libssl-dev:amd64 (1.1.1-1ubuntu2.1~18.04.23) ...
正在设置 libssl1.1:amd64 (1.1.1-1ubuntu2.1~18.04.23) ...
正在设置 libssl-dev:amd64 (1.1.1-1ubuntu2.1~18.04.23) ...
正在处理用于 libc-bin (2.27-3ubuntu1.6) 的触发器 ...
4.去掉内核校验(不然重刷内核后触屏没有反应)
$aosp\msm\arch\arm64\configs\wahoo_defconfig
CONFIG_MODVERSIONS=y
CONFIG_MODULE_SRCVERSION_ALL=y
修改为
# CONFIG_MODVERSIONS=y
# CONFIG_MODULE_SRCVERSION_ALL=y
$aosp\msm\kernel\module.c
return -ENOEXEC;
修改为
// return -ENOEXEC;
5.将编译工具链加入到环境变量中并编译
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
make wahoo_defconfig
make -j4
运行结果如下:
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]: *** 正在等待未完成的任务....
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
报错信息
drivers/thermal/thermal_core.c:43:26: fatal error: ../base/base.h: No such file or directory
#include <../base/base.h>
修改"drivers/thermal/thermal_core.c"文件
$aosp\msm\drivers\thermal\thermal_core.c
#include "<../base/base.h>"
修改为
#include "../base/base.h"
继续编译
make -j4
编译成功会有如下提示:
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) ####
打包并刷入手机
6.打包
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
运行结果如下:
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.刷入手机
手机进入fastboot模式
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
成功刷入手机,开机后进入查看内核界面,"Kernel verion"已经发生变化文章来源:https://www.toymoban.com/news/detail-717103.html
文章来源地址https://www.toymoban.com/news/detail-717103.html
到了这里,关于android10.0(Q)编译安卓内核(pixel 2)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!