banner
Silas

REAO

Be a better man
github

pixel1-android10内核编译

感谢依古比古、要有光、希特勒🍰对我的帮助(排名不分先后)

刷入系统#

使用 Google 提供的 Factory Images 中,pixel 1 的最后一个版本 10.0.0 (QP1A.191005.007.A3, Dec 2019)

https://developers.google.com/android/images#sailfish

tips:自己编译的也可

确定内核版本#

adb shell "cat /proc/version"
------------------------------------------------
Linux version 3.18.137-g72a7a64494e (android-build@wphn3.hot.corp.google.com) (gcc version 4.9.x 20150123 (prerelease) (GCC) ) #1 SMP PREEMPT Fri Sep 27 18:40:34 UTC 2019

commit 为 72a7a64494e

下载内核源码#

## 下载源码
git clone https://android.googlesource.com/kernel/msm

## 切换commit到系统对应
git checkout 72a7a64494e

环境配置#

因为某些奇怪问题找不到目录,把toolchain从 aosp 源码 (android-10.0.0_r17) 里拷出来了,放在了 /opt 下:

sudo cp -r ~/BUILD/android-10.0.0_r17_pixel/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9 /opt
sudo cp -r ~/BUILD/android-10.0.0_r17_pixel/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9 /opt

依然要配置CROSS_COMPILE_ARM32CROSS_COMPILE两个。

tips:在 zsh 下操作的

export PATH=$PATH:/opt/arm-linux-androideabi-4.9/bin:/opt/aarch64-linux-android-4.9/bin

export ARCH="arm64"
export CROSS_COMPILE="aarch64-linux-android-"
export CROSS_COMPILE_ARM32="arm-linux-androideabi-"

在此处找到 pixel 1 对应的编译配置marlin_defconfighttps://source.android.com/source/building-kernels.html

sudo apt-get install liblz4-tool

make clean
make mrproper
make marlin_defconfig
make -j8

问题#

找不到相对路径头文件

https://github.com/flar2/wahoo/commit/fb5195f801ba5dc49b70cf12ee7da6108f1de949

相对路径找不到的话,把 <header_name>改为"header_name"

编译成功#

image

image


等等!

为什么内核版本号末尾有-dirty这个东西?

If kernel images are being built with -dirty on the end of the version string, this means that there are modifications in the source directory that have not been committed.

如果在构建内核镜像时,在版本字符串的末尾加上了 - dirty,这意味着在源代码目录中存在着尚未提交的修改。

来源:Working with -dirty Kernel Strings - https://docs.windriver.com/bundle/Wind_River_Linux_Kernel_Development_LTS_18_1/page/mmo1403548840403.html)


刷入#

临时刷入#

adb reboot bootloader
fastboot boot Image.lz4-dtb

永久刷入#

1、repack boot.img

把原廠的 boot.img 解開之後把我們做的 kernel 塞進去
https://forum.xda-developers.com/t/tool-android-image-kitchen-unpack-repack-kernel-ramdisk-win-android-linux-mac.2073775/下載 Linux 版 AIK (點選文中的 AIK-Linux-v3.8-ALL.tar.gz 附件),解壓縮。
把這個原廠的 stockboot.img 檔案傳輸到電腦,放到 AIK 的工作目錄,並將剛剛編譯的 Image.gz-dtb 也放到這個目錄。
image
在 AIK 目錄開啟終端機,使用指令解開 stockboot.img (需要 sudo)
./unpackimg.sh stockboot.img
進入目錄 split_img,把 stockboot.img-kernel 檔案替換成我們編譯好的 Image.gz-dtb (檔名要改成 stockboot.img-kernel)。
回到 AIK 目錄,重新打包,應該會得到一個 image-new.img 的檔案。
./repackimg.sh
image

fastboot flash boot image-new.img

2、重新编译 aosp

image

image


参考

  1. [编译 Android kernel] -https://note.youdao.com/ynoteshare/index.html?id=a9744e4ccc57edf79958a279ca5ba82a&type=note&_time=1648045688213
  2. [如何編譯修改 Android Kernel (內核)] -https://ivon852.github.io/2021/12/26/%E5%A6%82%E4%BD%95%E7%B7%A8%E8%AD%AF%E4%BF%AE%E6%94%B9Android-Kernel-%E5%85%A7%E6%A0%B8/
加载中...
此文章数据所有权由区块链加密技术和智能合约保障仅归创作者所有。