Loading... > 感谢依古比古、要有光、希特勒🍰对我的帮助(排名不分先后) ## **刷入系统** 使用Google 提供的Factory Images中,pixel 1的最后一个版本 `10.0.0 (QP1A.191005.007.A3, Dec 2019)` [https://developers.google.com/android/images#sailfish](https://developers.google.com/android/images#sailfish) tips:自己编译的也可 ## **确定内核版本** ```bash 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_ARM32`、 `CROSS_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_defconfig`:[https://source.android.com/source/building-kernels.html](https://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](https://github.com/flar2/wahoo/commit/fb5195f801ba5dc49b70cf12ee7da6108f1de949) 相对路径找不到的话,把 `<header_name>`改为`"header_name"` ## **编译成功**   --- **等等!** **为什么内核版本号末尾有`-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/](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也放到這個目錄。 >  > 在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 >  ``` fastboot flash boot image-new.img ``` **2、重新编译aosp**   --- **参考** 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/ 最后修改:2022 年 03 月 27 日 © 允许规范转载 赞 4 如果觉得我的文章对你有用,请随意赞赏
3 条评论
6666666666
太厉害啦~
🍑ヾ(≧∇≦*)ゝ