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!