简介
AOSP(Android Open Source Project)是Android系统的开源版本,任何人都可以下载、编译和修改。手头上有一台Pixel 4XL,尝试编译AOSP并将其烧录到的设备上。
准备工作
在开始之前,您需要确保您的电脑满足以下条件:
- 足够的存储空间:编译AOSP需要大量的存储空间,建议至少预留200GB的空间。
- 足够的RAM:编译AOSP也需要大量的RAM,建议至少16GB的RAM。
- 一台运行Linux或macOS的电脑:Windows系统不适用于编译AOSP。
- TYPEC线一条,
- 一部快废了的pixel手机
救砖: 烧录变砖的风险很高.
https://developers.google.cn/android/images这里下载对应版本的固件,并进行解压
虽然找得到固件, 但是并不能正常下载下来
We’re sorry…
… but your computer or network may be sending automated queries. To protect our users, we can’t process your request right now.See Google Help for more information.
进入引导程序界面,连接电脑,直接打开**flach-all.bat**,等待完成后你的手机就能开机
pixel4XL进入引导界面的步骤:
1. 首先,确保您的设备已关闭。(按住 Pixel 4 XL 的电源按钮约 30 秒钟来强制关机)
2. 按住音量下按钮和电源按钮同时长达30秒钟,直到设备重新启动。
3. 在Pixel徽标出现时松开电源按钮,但继续按住音量下按钮,直到您看到“启动器锁定状态”选项。
4. 使用音量按钮导航到“启动器锁定状态”,然后按电源按钮确认。
https://flash.android.com/release/13.0.0 界面如下
后续确认并下载固件:
下载完后, 会自动烧录到手机中, 等待烧录完成即可!
小插曲: 由于前面已经解锁过bootloader, 烧录的最后会提示重新锁定.
为PIXEL4XL编译AOSP[使用清华镜像]
AOSP的下载和编译过程可参考:Ubuntu 20.04编译AOSP 并启动模拟器
1. 编译Pixel4XL的固件, 还需要获取对应失败的驱动程序二进制文件
Nexus 和 Pixel 设备的驱动程序二进制文件
很明显, Pixel4XL 最新支持到 Android 13.0.0
下载下来的两个文件, 放到AOSP源码的目录下执行后再编译系统, 执行过程会提示一些LICENCE之类的问题, 同意即可
2. 确定Pixel4XL支持的系统版本并切换到制定分支
//https://blog.csdn.net/weixue9/article/details/100572970
# 查看所有分支
aosp/.repo/manifests$ git branch -a | cut -d / -f 3 | grep android-13
# 切换分支
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-13.0.0_r31
repo sync
如果没有切换到对应的分支, 根本找不到对应的Pixel 4XL 的项目配置
3. 编译
source build/envsetup.sh
lunch aosp_coral-userdebug
make -j12
可能编译失败: 内存问题, 增加虚拟内存解决
make
20:43:39 ************************************************************
20:43:39 You are building on a machine with 15.4GB of RAM
20:43:39
20:43:39 The minimum required amount of free memory is around 16GB,
20:43:39 and even with that, some configurations may not work.
20:43:39
20:43:39 If you run into segfaults or other errors, try reducing your
20:43:39 -j value.
20:43:39 ************************************************************
build/make/core/soong_config.mk:209: warning: BOARD_PLAT_PUBLIC_SEPOLICY_DIR has been deprecated
. Use SYSTEM_EXT_PUBLIC_SEPOLICY_DIRS instead.
build/make/core/soong_config.mk:210: warning: BOARD_PLAT_PRIVATE_SEPOLICY_DIR has been deprecate
d. Use SYSTEM_EXT_PRIVATE_SEPOLICY_DIRS instead.
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=13
TARGET_PRODUCT=aosp_coral
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm64
TARGET_ARCH_VARIANT=armv8-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=arm
TARGET_2ND_ARCH_VARIANT=armv8-a
TARGET_2ND_CPU_VARIANT=generic
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-6.5.0-27-generic-x86_64-Ubuntu-22.04.4-LTS
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=TP1A.221005.002.B2
OUT_DIR=out
PRODUCT_SOONG_NAMESPACES=hardware/google/av hardware/google/camera hardware/google/interfaces ha
rdware/google/pixel device/google/coral hardware/qcom/sm8150/display hardware/qcom/sm8150/data/i
pacfg-mgr hardware/qcom/sm8150/gps vendor/google/airbrush/floral vendor/google/biometrics/face/f
lorence vendor/google/camera vendor/google/darwinn vendor/google_devices/common/proprietary/conf
irmatioui_hal vendor/google_nos/host/android vendor/qcom/sm8150 vendor/qcom/sm8150/proprietary/c
ommonsys/telephony-apps/DataStatusNotification vendor/qcom/sm8150/proprietary/gps vendor/qcom/sm
8150/proprietary/qmi vendor/qcom/sm8150/codeaurora/location vendor/google/interfaces vendor/goog
le_nos/test/system-test-harness vendor/qcom/sensors vendor/google/tools/sensors vendor/qcom/sm72
50/codeaurora/commonsys/telephony/ims/ims-ext-common vendor/qcom/sm7250/codeaurora/dataservices/
rmnetctl vendor/qcom/sm7250/proprietary/commonsys/qcrilOemHook vendor/qcom/sm7250/proprietary/co
mmonsys/telephony-apps/ims vendor/qcom/sm7250/proprietary/commonsys/telephony-apps/QtiTelephonyS
ervice vendor/qcom/sm7250/proprietary/commonsys/telephony-apps/xdivert vendor/qcom/sm7250/propri
etary/qcril-data-hal vendor/qcom/sm7250/proprietary/qcril-hal vendor/qcom/sm7250/proprietary/dat
a vendor/qcom/proprietary/bluetooth/hidl_client vendor/qcom/coral/proprietary
============================================
[100% 1/1] analyzing Android.bp files and generating ninja file at out/soong/build.ninja
FAILED: out/soong/build.ninja
cd "$(dirname "out/host/linux-x86/bin/soong_build")" && BUILDER="$PWD/$(basename "out/host/linux
-x86/bin/soong_build")" && cd / && env -i "$BUILDER" --top "$TOP" --soong_out "out/soon
g" --out "out" -o out/soong/build.ninja --globListDir build --globFile out/soong/globs-b
uild.ninja -t -l out/.module_paths/Android.bp.list --available_env out/soong/soong.environment.a
vailable --used_env out/soong/soong.environment.used.build Android.bp
Killed
20:45:07 soong bootstrap failed with: exit status 1
ninja: build stopped: subcommand failed.
#### failed to build some targets (01:31 (mm:ss)) ####
烧录
- 打开两个调试开关
“Settings”/”System”/”Advanced”/”Developer options”/”USB debugging”
“Settings”/”System”/”Advanced”/”Developer options”/”OEM unlocking” - 开始烧录
cd out/target/product/coral/
adb reboot bootloader
fastboot flashing unlock
fastboot flashall -w
注意
如果是bootloader未解锁, 需要通过配合音量键和电源键解锁, 解锁后可以进入fastbootd模式
烧录过程会重启几次
android@MR26:/aosp/out/target/product/coral$ fastboot flashall -w
< waiting for any device >
--------------------------------------------
Bootloader Version...: c2f2-0.5-8906123
Baseband Version.....: g8150-00123-220708-B-8810441
Serial Number........: 9B051FFBA00E7C
--------------------------------------------
Checking 'product' OKAY [ 0.070s]
Setting current slot to 'b' OKAY [ 0.079s]
Sending 'boot_b' (65536 KB) OKAY [ 2.350s]
Writing 'boot_b' OKAY [ 0.425s]
Sending 'dtbo_b' (8192 KB) OKAY [ 0.410s]
Writing 'dtbo_b' OKAY [ 0.124s]
Sending 'vbmeta_b' (4 KB) OKAY [ 0.140s]
Writing 'vbmeta_b' OKAY [ 0.078s]
Sending 'vbmeta_system_b' (4 KB) OKAY [ 0.140s]
Writing 'vbmeta_system_b' OKAY [ 0.077s]
Rebooting into fastboot OKAY [ 0.070s]
< waiting for any device >
Sending 'super' (4 KB) OKAY [ 0.045s]
Updating super partition OKAY [ 1.015s]
Resizing 'product_b' OKAY [ 0.005s]
Resizing 'system_b' OKAY [ 0.005s]
Resizing 'system_ext_b' OKAY [ 0.005s]
Resizing 'system_a' OKAY [ 0.006s]
Resizing 'vendor_b' OKAY [ 0.005s]
Resizing 'vendor_a' OKAY [ 0.006s]
Invalid sparse file format at header magic
Resizing 'product_b' OKAY [ 0.006s]
Sending sparse 'product_b' 1/2 (262140 KB) OKAY [ 8.997s]
Writing 'product_b' OKAY [ 2.498s]
Sending sparse 'product_b' 2/2 (19320 KB) OKAY [ 0.753s]
Writing 'product_b' OKAY [ 0.147s]
Invalid sparse file format at header magic
Resizing 'system_b' OKAY [ 0.006s]
Sending sparse 'system_b' 1/4 (262116 KB) OKAY [ 9.101s]
Writing 'system_b' OKAY [ 2.500s]
Sending sparse 'system_b' 2/4 (262116 KB) OKAY [ 9.269s]
Writing 'system_b' OKAY [ 1.459s]
Sending sparse 'system_b' 3/4 (262140 KB) OKAY [ 9.488s]
Writing 'system_b' OKAY [ 1.471s]
Sending sparse 'system_b' 4/4 (70868 KB) OKAY [ 2.458s]
Writing 'system_b' OKAY [ 0.442s]
Resizing 'system_ext_b' OKAY [ 0.005s]
Sending 'system_ext_b' (163524 KB) OKAY [ 5.689s]
Writing 'system_ext_b' OKAY [ 1.936s]
Resizing 'system_a' OKAY [ 0.008s]
Sending 'system_a' (24708 KB) OKAY [ 0.996s]
Writing 'system_a' OKAY [ 0.199s]
Invalid sparse file format at header magic
Resizing 'vendor_b' OKAY [ 0.010s]
Sending sparse 'vendor_b' 1/4 (262116 KB) OKAY [ 8.423s]
Writing 'vendor_b' OKAY [ 2.476s]
Sending sparse 'vendor_b' 2/4 (262096 KB) OKAY [ 8.982s]
Writing 'vendor_b' OKAY [ 1.549s]
Sending sparse 'vendor_b' 3/4 (262140 KB) OKAY [ 9.284s]
Writing 'vendor_b' OKAY [ 1.436s]
Sending sparse 'vendor_b' 4/4 (67856 KB) OKAY [ 2.437s]
Writing 'vendor_b' OKAY [ 0.430s]
Erasing 'userdata' OKAY [ 4.547s]
Erase successful, but not automatically formatting.
File system type raw not supported.
Erasing 'metadata' OKAY [ 0.004s]
Erase successful, but not automatically formatting.
File system type raw not supported.
Rebooting OKAY [ 0.000s]
Finished. Total time: 123.496s
参考
Android 12源码编译报错:FAILED: out/soong/build.ninja
使用Google Pixel5手机调试AOSP(代码下载、编译、刷机、调试)详细攻略
aosp-刷入到pixel4XL设备
Build, Flash and Un-Flash AOSP Image on Pixel Phones