3

For a non-rooted device, almost all articles/forum posts I've read say that in order to flash a custom ROM you first need to flash (or boot) a custom recovery image like TWRP.

I'm not sure I understand why. If the bootloader is unlocked, shouldn't it be possible to manually flash images that make up the custom ROM to the required partitions with fastboot flash <partition> [ <xxxx.img> ], and leave the stock recovery untouched.

I realize that this may be difficult and that there is no benefit in doing it this way, but I'm curious to know whether or not it is possible, and if not, why?

2
  • 1
    If you can make a fastboot compatible image for your custom ROM or can find one on the internet, than you can flash it via fastboot too. It is a matter of availability of images only. Recovery flashable images are convenient and more flexible though.
    – Firelord
    Commented Feb 1, 2019 at 8:31
  • Note: fastboot has size limit. depending on ROM and fastboot version one must split system.img into system.img_sparsechunk.0 files manually or via argument
    – alecxs
    Commented Jan 14, 2021 at 19:00

2 Answers 2

3

This question isn't as straightforward as it seems. The answer really depends on the contents of the custom ROM zip (assuming it comes in zip format) that you're trying to flash.

Most custom ROMs are not provided as image files. While almost all custom ROM zips include a boot.img which includes the kernel and is fastboot flashable, the system portion is where you run into an issue without a custom recovery. Stock-based custom ROMs typically include system files in a folder, which a custom recovery (like TWRP) will then extract to the system partition of the device. There is no way to complete that operation via fastboot. In order to flash such a system using fastboot, you would have to create an empty image based on the size of your system partition, format it using the expected filesystem for your device, loop mount it to a folder (if using a Linux system - in Windows you may have trouble finding a tool to do this, though OSFMount may work), and then copy the contents to that folder, so that they are included in the image. Once you unmount the image, you'll have a raw system image of the custom ROM that is flashable via fastboot. See an example of this process described here.

For AOSP-based custom ROMs, system files are typically included as a block-based full OTA dat (or dat.br) file. These can also be converted into an image file, using a tool like sdat2img for a dat file, and the same tool for a dat.br file, after using the Brotli tool to decompress it.

As you can see, while it is possible to flash a custom ROM without a custom recovery, it's certainly simpler to use one, especially since most custom ROM zips are built with the expectation that a custom recovery is how it will be installed.

3

Yes it is possible to flash images via Fastboot ?

With an unlocked bootloader you should be able to flash some partitions without overwriting the stock recovery, however each system usually requires a unique recovery to handle factory resets etc..

I have had issue's in the past with Maximum flash size, it wouldn't let me use Fastboot because my system.IMG file was too large to send via Fastboot.. That then required splitting the image into smaller files and flashing the smaller files.

You don't specifically need a custom recovery, however it makes everything a lot easier... For example, most custom firmware requires you to do a full backup of your device prior to installing, you need a custom recovery or rooted device to be able to make a full backup...

Why do they say " Use a custom recovery " ... Well this is probably determined by the firmware creator, they've most likely built everything into a single Flashable Zip file, using Fastboot won't work because the zip file contains more than just .IMG files, usually a ZIP firmware will have a folder called system, the system folder is copied to your device by the recovery, not flashed .. each firmware usually contains 3 parts ( boot.IMG, System folder, additional files)... However some firmware's contain a complete system.IMG file instead of a folder.. These files can be pulled from the firmware and flashed via Fastboot, however Fastboot can not flash folders ( only a custom recovery can do that )

... I'm starting to get lost here...

2
  • Very helpful. However I'm kind of confused about this part "For example, most custom firmware requires you to do a full backup of your device prior to installing". Are you saying that you actually do need to first install a custom recovery to install these custom firmwares? Or does using fastboot allow you to bypass this requirement?
    – catanman
    Commented Feb 6, 2019 at 4:12
  • You do need a custom recovery for some firmware's to install. Commented Feb 6, 2019 at 8:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .