为 Pixel 3 构建自定义内核的 Android 11
My Environment
OS:
Debian 11
Mobile Device:
Google Pixel 3
AOSP Tag:
android-11.0.0_r1
AOSP Build ID:
RP1A.200720.009
Prepare Building Environment
Make sure you have installed adb
and
fastboot
, if not
Download from Google (recommended!!)
or
1 | sudo apt install android-tools-adb |
Install some tools
1 | sudo apt-get install git-core gnupg flex bison build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 libncurses5-dev lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig |
Install repo
1 | mkdir ~/.bin |
Build Kernel
Get the source code, it will take about 30GB of disk space after
building. 1
2
3mkdir kernel && cd kernel
repo init -u https://android.googlesource.com/kernel/manifest -b android-msm-crosshatch-4.9-android11-qpr2
repo sync1
2
3
4cd prebuilts
git clone https://android.googlesource.com/kernel/prebuilts/build-tools
mv build-tools kernel-build-tools
export PATH=${WORK_DIR}/kernel/prebuilts/kernel-build-tools/linux-x86/bin:$PATHandroid-11.0.0_r1
, checkout msm
to
commit 5bded8e40b62
. You can get this commit id in
${WORK_DIR}/android11/device/google/crosshatch-kernel/Image.lz4
after downloading the Android source. 1
2cd ${WORK_DIR}/kernel/private/msm-google
git checkout 5bded8e40b621
2cd ${WORK_DIR}/kernel
. build/build.sh
Build Android
Get the source, it will take about 200GB of disk space after
building. 1
2
3mkdir android11 && cd android11
repo init --depth 1 -u https://android.googlesource.com/platform/manifest -b android-11.0.0_r1
repo sync -c -j81
2
3
4wget https://dl.google.com/dl/android/aosp/google_devices-blueline-rp1a.200720.009-6cd41940.tgz
wget https://dl.google.com/dl/android/aosp/qcom-blueline-rp1a.200720.009-f772c38c.tgz
tar -xf google_devices-blueline-rp1a.200720.009-6cd41940.tgz && tar -xf qcom-blueline-rp1a.200720.009-f772c38c.tgz
./extract-google_devices-blueline.sh && ./extract-qcom-blueline.sh1
2
3
4cp ${WORK_DIR}/kernel/out/android-msm-pixel-4.9/dist/Image.lz4 ${WORK_DIR}/android11/device/google/crosshatch-kernel/Image.lz4
. build/envsetup.sh
lunch aosp_blueline-userdebug
make -j12
Flash Device
After getting the building output, let's flash them to the device.
Since $ANDROID_PRODUCT_OUT
will be set automatically, we
can just use command flashall
. If not, set it to
${WORK_DIR}/android11/out/target/product/blueline
.
1
2adb reboot bootloader
fastboot flashall -w
Update Drivers
Actually now your device can work well via adb. But due to driver
mismatching, you may not be able to use the touchscreen, wlan etc. To
fix this problem 1
2
3adb root
adb remount -R
adb push ${WORK_DIR}/kernel/out/android-msm-pixel-4.9/dist/*.ko /vendor/lib/modules/
Result
References
mkbootfs command not found while trying to build aosp kernel
Built kernel from scratch, touchscreen doesn't work?
Touchscreen not working after building and flashing clean msm kernel for the Google Pixel blueline
Pixel 3 Aosp 自编译内核如何正确的驱动设备正常运行