好多年不关注这些了,搜索发现多了ab分区、卡刷/OTA包payload.bin等变化。现在再看源码、搜资料自己解包payload.bin等是来不及了。所以还是先看看网上的一些教程吧。
python3 payload_dumper.py payload.bin
Traceback (most recent call last):
File "payload_dumper.py", line 7, in
import bsdiff4
ModuleNotFoundError: No module named 'bsdiff4'
缺少库,根据requirements.txt安装
pip3 install bsdiff4>=1.1.5
安装protobuf报错。
python3 payload_dumper.py payload.bin
Traceback (most recent call last):
File "payload_dumper.py", line 15, in
import update_metadata_pb2 as um
File "/mnt/d/payload_dumper/update_metadata_pb2.py", line 6, in
from google.protobuf import descriptor as _descriptor
ModuleNotFoundError: No module named 'google'
pip3 install protobuf>=3.19.3
protobuf requires Python '>=3.7' but the running Python is 3.6.9
直接读取requirements.txt安装也是报错:protobuf requires Python ‘>=3.7’ but the running Python is 3.6.9。不想升级python。
pip3 install -r requirements.txt
Collecting protobuf>=3.19.3 (from -r requirements.txt (line 1))
Using cached https://files.pythonhosted.org/packages/6c/be/4e32d02bf08b8f76bf6e59f2a531690c1e4264530404501f3489ca975d9a/protobuf-4.21.0-py2.py3-none-any.whl
protobuf requires Python '>=3.7' but the running Python is 3.6.9
因为不了解python,仔细看是大于等于的关系,安装的是protobuf-4.21.0版本,尝试安装protobuf-3.19.3版本成功:(six>=1.16.0通过requirements.txt安装了)
pip3 install protobuf==3.19.3
Collecting protobuf==3.19.3
Installing collected packages: protobuf
Successfully installed protobuf-3.19.3
python3 payload_dumper.py payload.bin
Processing apusys partitionSOURCE_COPY supported only for differential OTA
看其python代码没有使用其他文件,但是为了测试还是把OTA包整个解压到这里,再次测试还是报同样错误。在output目录生成空文件apusys.img。
payload_dumper.exe
Traceback (most recent call last):
File "payload_dumper.py", line 89, in
AssertionError: unsupported op
[15820] Failed to execute script payload_dumper
unota_windows_amd64.exe -i payload_input\payload.bin
2022/09/30 14:57:42 extract apusys to payload_extract\apusys.img ....
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0xbe59dc]
goroutine 1 [running]:
main.extractPartition(0xc000025450, {0xc00080f7e0?, 0xc00006fd30?}, {0xd0b500, 0xc00000a168}, 0x6165d)
./unota.go:154 +0x15c
main.extractPartitions({0xc0001cae00, 0x1d, 0x6153a?}, {0xd0b500, 0xc00000a168}, 0xc00000e488?)
./unota.go:216 +0x352
main.payload({0xd0b500, 0xc00000a168})
./unota.go:143 +0x2b1
main.main()
./unota.go:91 +0x4a5
unota_windows_amd64.exe -i payload_input\payload.bin -s boot
2022/09/30 15:04:04 extract boot to payload_extract\boot.img ....
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0xbe59dc]
goroutine 1 [running]:
main.extractPartition(0xc000025860, {0xc0000120f0?, 0xc00006dd30?}, {0xd0b500, 0xc00000a168}, 0x6165d)
./unota.go:154 +0x15c
main.extractPartitions({0xc0001c8e00, 0x1d, 0x6153a?}, {0xd0b500, 0xc00000a168}, 0xc00000e4a8?)
./unota.go:216 +0x352
main.payload({0xd0b500, 0xc00000a168})
./unota.go:143 +0x2b1
main.main()
./unota.go:91 +0x4a5
绑定账号过了7天了,忘了是否必须开启oem解锁,为了保险是开启的:但是好像小米的官方以及一些推荐帖子并没有提开启oem解锁这个选项。
备份好数据后,执行reboot bootloader,进入fastboot界面。额,我记得上次好像还是经典的兔子界面,这次是只有一行橘红色的fastboot大写的黑色背景界面,是不是OTA更新改了?fastboot devices还是能识别设备的。我也不是很确定之前到底是不是兔子界面,如果不是很可能这个bootloader不是使用的高通的lk,如果是uboot可能还好,如果是个我完全不知道的,那么后面还想做双、多系统共存就麻烦了。
使用当时最新的miflash_unlock-6.5.406.31,登录手机绑定的小米账号。
解锁成功后自动重启了。卡了很久银色大MIUI界面,还以为出问题了,过了4、5分钟终于进入了MIUI13引导界面,说明是删除所有数据后启动在做dex2oat之类的优化。并没有验证小米账号的步骤,选择不联网、不登录账号进入了系统,也可能是因为我之前没有开启查找设备的功能。
进入开发者选项看到oem解锁选项是勾选灰色状态,无法设置了。设备解锁状态是已解锁。糟糕,忘了记录属性了,还说对比下解锁后改变了那些属性值。
我记得最开始应该是使用的a分区,OTA更新后使用的应该是b分区,执行:
xaga:/ $ mount|grep /dev/block/sd
/dev/block/sdc20 on /metadata type ext4 (rw,seclabel,nosuid,nodev,noatime,discard)
/dev/block/sdc3 on /mnt/vendor/protect_f type ext4 (rw,seclabel,nosuid,nodev,noatime,nodelalloc,noauto_da_alloc,commit=1)
/dev/block/sdc4 on /mnt/vendor/protect_s type ext4 (rw,seclabel,nosuid,nodev,noatime,nodelalloc,noauto_da_alloc,commit=1)
/dev/block/sdc13 on /mnt/vendor/nvdata type ext4 (rw,seclabel,nosuid,nodev,noatime,nodelalloc,noauto_da_alloc,commit=1)
/dev/block/sdc7 on /mnt/vendor/nvcfg type ext4 (rw,seclabel,nosuid,nodev,noatime,nodelalloc,noauto_da_alloc,commit=1)
/dev/block/sdc8 on /mnt/vendor/persist type ext4 (rw,seclabel,nosuid,nodev,noatime,nodelalloc,noauto_da_alloc,commit=1)
/dev/block/sdc84 on /mnt/rescue type ext4 (rw,seclabel,noatime)
/dev/block/sdc83 on /cust type ext4 (ro,seclabel,nosuid,nodev,noatime)
/dev/block/sdc55 on /mnt/vendor/mdota type ext4 (ro,seclabel,noatime)
xaga:/ $ ls -la /dev/block/by-name/|grep sdc55
lrwxrwxrwx 1 root root 16 2022-09-30 16:26 mcf_ota_b -> /dev/block/sdc55
应该还是b分区,所以boot.img输入b分区应该是没错的,不过为了更安全,我决定还是不刷入分区,而是使用临时启动模式。因为我不确定修补的boot.img是否没有问题。中间想安装个apk,但是暂时不想登录小米账号开启usb安装,所以把启用miui优化选项关闭,这样就可以adb install安装apk了。
Sending 'boot.img' (65536 KB) OKAY [ 1.413s]
Booting FAILED (remote: 'unknown command')
fastboot: error: Command failed
难道现在不支持这样启动了?
fastboot flash boot_b boot.img
Sending 'boot_b' (65536 KB) OKAY [ 1.476s]
Writing 'boot_b' OKAY [ 0.177s]
Finished. Total time: 1.715s