Manually Flashing Any Android ROM


๐Ÿค–This article was translated by AI (LLM). There may be errors or inaccuracies. For the original content, please refer to the original version.

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
  1. Refer to payload_dumper README, run command:
podman run --rm -v $PWD:/data -it vm03/payload_dumper /data/payload.bin --out /data/output
  1. 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

  1. Connect phone to computer, boot into TWRP or OrangeFox

  2. Execute adb reboot fastboot to enter fastbootd mode (not bootloader mode, differences explained here).

fastboot devices
  1. 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
  1. After flashing completes, execute fastboot reboot to restart device

  2. 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!