Manually Flashing Any Android ROM
With Fastboot and payload_dumper, we can flash any ROM we need at any time.
In this article, Iโll share my experience successfully flashing third-party ROMs (like crDroid OS) on Redmi K40 via Fastboot. After referencing some threads on XDA forums, I found a simple method to avoid errors during flashing.
Recently, during an update, I encountered the error:
"Error applying update: 7 (ErrorCode:: kInstallDeviceOpenError )Updater process ended with ERROR: 1 Error installing zip file"Considering OTA packages for A/B partitions donโt contain updater-script files at all, referring to Googleโs โBuilding OTA Packagesโ documentation, you could modify
pre-device,pre-build-incremental,pre-build, etc. But trust me, itโs completely useless.
Through research, I found this article: Flash fastboot rom / unbrick any xiaomi phone without any flashtool.
Preparation
- Ensure ADB drivers are installed, available here.
- Unlock Bootloader.
- Download Recovery suitable for your device.
- Download ROM suitable for your device.
- Download payload_dumper tool.
Extracting ROM
- Extract the ROM to get these files:
.
โโโ apex_info.pb
โโโ boot.img
โโโ care_map.pb
โโโ META-INF
โ โโโ com
โ โโโ android
โ โโโ metadata
โ โโโ metadata.pb
โ โโโ otacert
โโโ payload.bin
โโโ payload_properties.txt
4 directories, 8 files
- Decoding Android OTA payload
- Refer to payload_dumper README, run command:
podman run --rm -v $PWD:/data -it vm03/payload_dumper /data/payload.bin --out /data/output
- Get these files in output folder (may vary by ROM/version):
.
โโโ boot.img
โโโ dtbo.img
โโโ odm.img
โโโ product.img
โโโ system_ext.img
โโโ system.img
โโโ vbmeta.img
โโโ vbmeta_system.img
โโโ vendor_boot.img
โโโ vendor.img
1 directory, 10 files
Flashing ROM
-
Connect phone to computer, boot into TWRP or OrangeFox
-
Execute
adb reboot fastbootto enter fastbootd mode (not bootloader mode, differences explained here).
fastboot devices
- Use fastboot commands to flash .img files one by one (filenames correspond to partition names). Mainly includes: boot.img, system.img and system_ext.img.
fastboot flash boot boot.img
fastboot flash dtbo dtbo.img
fastboot flash odm odm.img
fastboot flash product product.img
fastboot flash system system.img
fastboot flash system_ext system_ext.img
fastboot flash vbmeta vbmeta.img
fastboot flash vendor vendor.img
Or a simplified one-liner (fish bash syntax, translate for others):
for img in (ls *.img)
set img_name (basename $img .img)
fastboot flash $img_name $img
end
-
After flashing completes, execute fastboot reboot to restart device
-
If needed, you can reboot into TWRP and normally flash the complete ROM (usually works fine), or manually flash other files (like vendor.img, vbmeta.img, etc.) if necessary.
Conclusion
Flashing/updating devices is risky. Use regular Android backups like NeoBackup with automatic cloud uploads to maintain good backup habits.
Good luck and have fun!