配置
- 操作系统 :虚拟机 ubuntu 16.04
- 内存 :8G
- 硬盘 :150G
- CPU :4核
编译过程
注: 编译环境见pixel XL源码编译
1. 源码分支获取
根据手机型号选择分支名称
1
| https://source.android.google.cn/setup/build/building-kernels?hl=zh-cn
|
Pixel XL的分支名称为android-msm-marlin-3.18-pie-qpr2
2. 下载源码
1 2 3 4 5
| mkdir android-kernel && cd android-kernel
repo init -u https://android.googlesource.com/kernel/manifest -b android-msm-marlin-3.18-pie-qpr2 repo sync
|
3. 构建
1 2
| ./build/build.sh BUILD_CONFIG=common/build.config.gki.aarch64
|
注:此处可能会报错
1
| build/buildinfo/buildinfo.py not found
|
编辑build.config,将EXTRA_CMDS=’python build/buildinfo/buildinfo.py’ 删除,实测可以编译成功
1 2 3 4 5
| KERNEL_DIR=private/msm-google . ${ROOT_DIR}/${KERNEL_DIR}/build.config.common POST_DEFCONFIG_CMDS="check_defconfig && compression_tool_and_files lz4" EXTRA_CMDS='python build/buildinfo/buildinfo.py' STOP_SHIP_TRACEPRINTK=1
|
编译成功后内核二进制文件、模块和相应的映像位于 out/android-msm-marlinxxxxx/dist 目录下。
4. 刷机
4.1 临时刷入
1 2 3 4 5
|
adb reboot bootloader fastboot boot Image.lz4-dtb
|
4.2 永久刷入
4.2.1 拷贝内核文件到AOSP项目下
将out/xxx/Image.lz4-dtb
拷贝到 device/google/marlin-kernel
下(以防万一拷贝之前备份device/google/marlin-kernel/Image.lz4-dtb
)
4.2.2 编译aosp
1 2 3
| source build/envsetup.sh lunch 15 make bootimage
|
4.2.3 编译完成刷入系统
刷入/out/target/product/marlin/boot.img
1
| fastboot flash boot boot.img
|