感謝依古比古、要有光、希特勒🍰對我的幫助(排名不分先後)
刷入系統#
使用 Google 提供的 Factory Images 中,pixel 1 的最後一個版本 10.0.0 (QP1A.191005.007.A3, Dec 2019)
https://developers.google.com/android/images#sailfish
提示:自己編譯的也可
確定內核版本#
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
兩個。
提示:在 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
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"
編譯成功#
等等!
為什麼內核版本號末尾有-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 也放到這個目錄。
在 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
參考