相关文章:【android Framework 探究】android 13 aosp编译全记录
写在开始
书接上文,编译完后,在二手平台挑挑拣拣最终下手piexl 5,这就开始迫不及待的烧录。
一,解锁bootloader
如果之前已经解锁可以跳过这步
- adb reboot bootloader
- fastboot devices (查看设备是否就绪)
查看 Device States为“lock”再进行如下解锁操作,如果已经是“unlock”,说明已经解锁解锁,直接开始烧录即可。
- fastboot flashing unlock
使用手机音量键切换,Unlock the bootloader,按电源键确认,解锁后,Device States为“unlock”
二,烧录
- 设置环境变量
/home/{usr name}/{build directory}/out/target/product/{taget}
如上格式设置环境变量。我的如下:
export ANDROID_PRODUCT_OUT=“/home/wu/GitProjects/aosp/out/target/product/redfin”
- fastboot -w flashall
烧录过程中重启属于正常现象,如下输出说明烧录成功。
--------------------------------------------
Bootloader Version...: r3-0.4-8351081
Baseband Version.....: g7250-00202-220422-B-8489468
Serial Number........: XXXXXXXXXX
--------------------------------------------
Checking 'product' OKAY [ 0.015s]
Setting current slot to 'b' OKAY [ 0.586s]
Sending 'boot_b' (98304 KB) OKAY [ 3.214s]
Writing 'boot_b' OKAY [ 2.063s]
Sending 'dtbo_b' (16384 KB) OKAY [ 0.620s]
Writing 'dtbo_b' OKAY [ 0.462s]
Sending 'vbmeta_b' (8 KB) OKAY [ 0.140s]
Writing 'vbmeta_b' OKAY [ 0.079s]
Sending 'vbmeta_system_b' (4 KB) OKAY [ 0.140s]
Writing 'vbmeta_system_b' OKAY [ 0.079s]
Sending 'vendor_boot_b' (98304 KB) OKAY [ 3.300s]
Writing 'vendor_boot_b' OKAY [ 2.084s]
Rebooting into fastboot OKAY [ 0.061s]
< waiting for any device >
Sending 'super' (4 KB) OKAY [ 0.006s]
Updating super partition OKAY [ 0.036s]
Resizing 'product_b' OKAY [ 0.005s]
Resizing 'system_b' OKAY [ 0.005s]
Resizing 'system_ext_b' OKAY [ 0.005s]
Resizing 'system_a' OKAY [ 0.005s]
Resizing 'vendor_b' OKAY [ 0.005s]
Resizing 'vendor_a' OKAY [ 0.005s]
Invalid sparse file format at header magic
Resizing 'product_b' OKAY [ 0.005s]
Sending sparse 'product_b' 1/2 (262140 KB) OKAY [ 8.251s]
Writing 'product_b' OKAY [ 1.423s]
Sending sparse 'product_b' 2/2 (19152 KB) OKAY [ 0.606s]
Writing 'product_b' OKAY [ 0.140s]
Invalid sparse file format at header magic
Resizing 'system_b' OKAY [ 0.006s]
Sending sparse 'system_b' 1/4 (262116 KB) OKAY [ 8.318s]
Writing 'system_b' OKAY [ 1.440s]
Sending sparse 'system_b' 2/4 (262120 KB) OKAY [ 8.618s]
Writing 'system_b' OKAY [ 1.385s]
Sending sparse 'system_b' 3/4 (262140 KB) OKAY [ 8.746s]
Writing 'system_b' OKAY [ 1.463s]
Sending sparse 'system_b' 4/4 (70884 KB) OKAY [ 2.347s]
Writing 'system_b' OKAY [ 0.409s]
Resizing 'system_ext_b' OKAY [ 0.006s]
Sending 'system_ext_b' (176388 KB) OKAY [ 5.924s]
Writing 'system_ext_b' OKAY [ 0.972s]
Resizing 'system_a' OKAY [ 0.006s]
Sending 'system_a' (24712 KB) OKAY [ 0.769s]
Writing 'system_a' OKAY [ 0.166s]
Invalid sparse file format at header magic
Resizing 'vendor_b' OKAY [ 0.005s]
Sending sparse 'vendor_b' 1/3 (262092 KB) OKAY [ 8.368s]
Writing 'vendor_b' OKAY [ 1.445s]
Sending sparse 'vendor_b' 2/3 (262116 KB) OKAY [ 8.597s]
Writing 'vendor_b' OKAY [ 1.436s]
Sending sparse 'vendor_b' 3/3 (238108 KB) OKAY [ 7.673s]
Writing 'vendor_b' OKAY [ 1.289s]
Erasing 'userdata' OKAY [ 6.581s]
Erase successful, but not automatically formatting.
File system type raw not supported.
Erasing 'metadata' OKAY [ 0.045s]
Erase successful, but not automatically formatting.
File system type raw not supported.
Rebooting OKAY [ 0.000s]
Finished. Total time: 123.361s
遇到的问题
fastboot -w flashall 报错
fastboot: error: could not read android-info.txt
解决方法
export ANDROID_PRODUCT_OUT ,请设置绝对路径,发现我出错时用的
~/来代替/home/{usr name}
三,刷原厂镜像包
按照上面的方法刷完之后,你会发现原生UI实在是太丑了。也为了防止刷机出现意外情况,需要恢复系统,你可以提前准备好google原厂系统镜像包,在需要的时候刷回去。
下载原厂镜像包
解压后,执行./flash-all.sh即可,出现如下提示:
< waiting for any device >
新打开一个命令框执行adb reboot bootloader,等待重启后,就自动执行刷机操作了。
最后
连接wifi提示网络受限解决:
adb shell settings put global captive_portal_http_url http://connect.rom.miui.com/generate_204
adb shell settings put global captive_portal_https_url https://connect.rom.miui.com/generate_204
执行完,切为飞行模式,再切换回来。