感谢依古比古、要有光、希特勒🍰对我的帮助(排名不分先后)
刷入系统
使用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_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
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
参考
3 条评论
6666666666
太厉害啦~
🍑ヾ(≧∇≦*)ゝ