[GUIDE] Flash any recovery easily on the phone using flash_image

Search This thread
Background

To update (flash) a recovery image onto your phone allows you to update or replace your recovery environment on your phone. There are a number of ways to flash a new recovery image, some of the more commonly used methods are using a tool such as ROM Manager or using development tools such as Fastboot. There is also a third method using a standalone utility "flash_image" which allows the flashing of recovery using the terminal emulator on the phone.

flash_image is not a new tool, it has been used on Android since the beginning, many custom ROMs include the utility as part of the ROM itself though not all stock ROMs (including the stock ROM on the G2) include it.

Requirements

1. A permanently rooted (with S-OFF) phone
2. The flash_image binary
3, A recovery image that is compatible with your phone and ROM
3. A terminal emulator application on the phone or use of an ADB shell

Overview:
1. Get the flash_image binary and recovery image onto your phone
2. Copy or move the flash image binary to your system and make executable
3. Use flash_image to update your recovery environment

Stage 1: Get flash_image and recovery image on your phone

1. Download the flash_image binary (not needed if you are running a custom ROM that includes this binary)
2. Download the recovery image you wish to use

You can either directly download the files onto your phone or onto your PC and transfer to your phone. Probably the easiest way to do this is to connect your phone to your computer via USB and mount USB storage, then copy the files to your SD Card. Alternatively you can use ADB Push, bluetooth file transfer or several other methods.

Stage 2: Copy or move the flash image binary to your system and make executable

In terminal emulator:
su
mount -o remount, rw /system
cd /sdcard (or wherever you downloaded/copied the file)
cp flash_image /system/bin
cd /system/bin
chmod 777 flash_image

Stage 3: use flash_image to update your recovery environment

In terminal emulator:
su (not needed if using the same terminal session used in the steps above)
cd /sdcard (or wherever you downloaded/copied the recovery image)
flash_image recovery recovery.img (use the appropriate file name for the image file you are flashing)

Reboot into recovery and verify that the correct recovery environment is installed

Notes

Any of the commands that call for using a terminal emulator on the phone should work fine using an ADB shell if you prefer.

This was tested on G2 but I can't think of why it would not work on Desire Z or any other phone for which this version of flash_image works. Obviously different phones have different compatible recovery images.

I've attached a zip file containing the flash_image binary that I extracted from the CM 6.1 update zip. I suspect most custom ROMs already have flash_image.

If you are wondering "Why should I use this method over using ROM Manager?" you could be using a recovery image that ROM manager doesn't support, for example ClockWorkMod Recovery 3.x which is required for some experimental ROMs.

If you are wondering "Why should I use this method over using fastboot?" The two main reasons are you can't use fastboot if you are not with a computer with working ADB and using fastboot requires that you have previously flashed the engineering HBOOT.

This is my first guide so I'm open to suggestions or feedback.
 

Attachments

  • flash_image.zip
    8.8 KB · Views: 22,694
Last edited:

steviewevie

Retired Forum Moderator
Oct 28, 2009
5,333
616
UK
Nice one :)

Though I would suggest that

Code:
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system

could be simplified to :

Code:
mount -o remount,rw /system

Edit - actually /system isn't even on /dev/block/mtdblock3, and it's not a yaffs2 file system, I suspect that's come from another phone model ?
 
Last edited:

dhkr123

Senior Member
Nov 8, 2010
290
15
"dd" will do exactly the same, but no need to install extra stuff since its already there.
 

steviewevie

Retired Forum Moderator
Oct 28, 2009
5,333
616
UK
"dd" will do exactly the same, but no need to install extra stuff since its already there.

I wouldn't have a problem using dd myself. But I would have thought it was much more risky, since instead of typing something relatively user-friendly like "recovery", you're typing in /dev/xyz/abc or similar, which if you get it slightly wrong could be disastrous ?
 
Nice one :)

Though I would suggest that

Code:
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system

could be simplified to :

Code:
mount -o remount,rw /system

Edit - actually /system isn't even on /dev/block/mtdblock3, and it's not a yaffs2 file system, I suspect that's come from another phone model ?

Interesting, I've been using that command since forever (since I first rooted my G1 in early 2009) and it definitely does work on my G2 as well as my wife's MT4G.

I just tried "mount -o remount,rw /system" on my phone and it does not work, mount gives me the "Usage:" messages which seems to mean it wants more parameters.
 

dhkr123

Senior Member
Nov 8, 2010
290
15
I wouldn't have a problem using dd myself. But I would have thought it was much more risky, since instead of typing something relatively user-friendly like "recovery", you're typing in /dev/xyz/abc or similar, which if you get it slightly wrong could be disastrous ?

Unless you run wpthis before dd, you're perfectly safe. The radio partitions are all protected by the power-on write protect feature of the eMMC AS WELL as the linux kernel write protect on low addresses. Worst you can do is blow away your system, data, cache, misc, boot, or recovery partitions, and these are trivial to recover from.
 

dhkr123

Senior Member
Nov 8, 2010
290
15
Interesting, I've been using that command since forever (since I first rooted my G1 in early 2009) and it definitely does work on my G2 as well as my wife's MT4G.

I just tried "mount -o remount,rw /system" on my phone and it does not work, mount gives me the "Usage:" messages which seems to mean it wants more parameters.

Depends on whether or not the mount command can tell the associations between the devices and mount points, which is determined by either system configuration, or what mount command you are using (i.e. android's mount or busybox mount).
 

steviewevie

Retired Forum Moderator
Oct 28, 2009
5,333
616
UK
Interesting, I've been using that command since forever (since I first rooted my G1 in early 2009) and it definitely does work on my G2 as well as my wife's MT4G.

I just tried "mount -o remount,rw /system" on my phone and it does not work, mount gives me the "Usage:" messages which seems to mean it wants more parameters.

Sorry, there should have been an extra space, this works on my phone :

Code:
mount -o remount, rw /system

I don't have a "/dev/block/mtdblock3" on my system. My system partition is mounted on /dev/block/mmcblk0p25, and it is ext3 not yaffs2.

What ROM are you running ? I am running the stock DZ 1.34 ROM. I wonder if you are running Gingerbread ?
 
Sorry, there should have been an extra space, this works on my phone :

Code:
mount -o remount, rw /system

I don't have a "/dev/block/mtdblock3" on my system. My system partition is mounted on /dev/block/mmcblk0p25, and it is ext3 not yaffs2.

What ROM are you running ? I am running the stock DZ 1.34 ROM. I wonder if you are running Gingerbread ?

I'm running the Stock G2 T-Mobile post-OTA ROM, definitely not Gingerbread.

Edit: I just tried your method and it works, I will update the guide because your way is simpler and sounds like a safer choice.
 
Last edited:
Not sure that's actually quicker, at least I don't think it would be for me, especially if you are changing recoveries with any frequency (like if tying out Gingerbread ROMs then going back to a 2.2 ROM) because you'd need to constantly rename your recovery images. With my method you would only need to leave the two files named as they are, or for expediency you could rename to recovery.img and recovery3.img then when you wanted to switch you could just execute:

flash_image recovery recovery.img

or

flash_image recovery recovery3.img

Depending on which recovery you wanted at that point & time.

As I said in the guide, there are already a number of options available, using ROM Manager and fastboot are the most commonly seen in guides but your method and mine are other options for people for whom they work better. :)
 
  • Like
Reactions: thatruth132

sanjivp2000

New member
Jan 5, 2011
1
0
Great description, but file did not work for me

It's a very good description that a novice like me can follow. And, I am sure the provided file works for many of you, since many of you reported it to work. After following this guide, and not getting it to work (Stopping Signal error), I decided to find another binary file for flash_image, and the other flash_image file worked for me on my Sprint CDMA Hero. My phone currently has aospMod v0.9.9.2 | AOSP 2.2.1(12/10/2010), if it matters.
One can download a flash_image from here http://cyanogen-files.carneeki.net/flash_image.zip
Then unzip and place on sdcard - follow all the steps in the original post of this thread.

It is my understanding that this file is not unique for different android phones, but if I am incorrect, someone please reply to this thread to correct me.

Again, great job in summarizing the steps.

Regards,

Sanjiv
 

acritec

Senior Member
Sep 3, 2008
60
17
Lier
Also usable for splash screen ??

Just curious,

Anybody tried to use flash_image to flash a custom splash screen ?
Something like :
flash_image splash1 customsplash.img
 

jaoyina

Member
Jan 30, 2011
44
0
very good post for a newbie like me, just want to make sure, do i need to do the stage 2 every time I flash the recovery?
 

pokemontrainer4life

Senior Member
Oct 7, 2010
78
7
Is there a way I can reflash a recovery without access to the ROM?
I'm stuck at the HTC splash screen, so I'm basically stuck in my current (broken) recovery.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 16
    Background

    To update (flash) a recovery image onto your phone allows you to update or replace your recovery environment on your phone. There are a number of ways to flash a new recovery image, some of the more commonly used methods are using a tool such as ROM Manager or using development tools such as Fastboot. There is also a third method using a standalone utility "flash_image" which allows the flashing of recovery using the terminal emulator on the phone.

    flash_image is not a new tool, it has been used on Android since the beginning, many custom ROMs include the utility as part of the ROM itself though not all stock ROMs (including the stock ROM on the G2) include it.

    Requirements

    1. A permanently rooted (with S-OFF) phone
    2. The flash_image binary
    3, A recovery image that is compatible with your phone and ROM
    3. A terminal emulator application on the phone or use of an ADB shell

    Overview:
    1. Get the flash_image binary and recovery image onto your phone
    2. Copy or move the flash image binary to your system and make executable
    3. Use flash_image to update your recovery environment

    Stage 1: Get flash_image and recovery image on your phone

    1. Download the flash_image binary (not needed if you are running a custom ROM that includes this binary)
    2. Download the recovery image you wish to use

    You can either directly download the files onto your phone or onto your PC and transfer to your phone. Probably the easiest way to do this is to connect your phone to your computer via USB and mount USB storage, then copy the files to your SD Card. Alternatively you can use ADB Push, bluetooth file transfer or several other methods.

    Stage 2: Copy or move the flash image binary to your system and make executable

    In terminal emulator:
    su
    mount -o remount, rw /system
    cd /sdcard (or wherever you downloaded/copied the file)
    cp flash_image /system/bin
    cd /system/bin
    chmod 777 flash_image

    Stage 3: use flash_image to update your recovery environment

    In terminal emulator:
    su (not needed if using the same terminal session used in the steps above)
    cd /sdcard (or wherever you downloaded/copied the recovery image)
    flash_image recovery recovery.img (use the appropriate file name for the image file you are flashing)

    Reboot into recovery and verify that the correct recovery environment is installed

    Notes

    Any of the commands that call for using a terminal emulator on the phone should work fine using an ADB shell if you prefer.

    This was tested on G2 but I can't think of why it would not work on Desire Z or any other phone for which this version of flash_image works. Obviously different phones have different compatible recovery images.

    I've attached a zip file containing the flash_image binary that I extracted from the CM 6.1 update zip. I suspect most custom ROMs already have flash_image.

    If you are wondering "Why should I use this method over using ROM Manager?" you could be using a recovery image that ROM manager doesn't support, for example ClockWorkMod Recovery 3.x which is required for some experimental ROMs.

    If you are wondering "Why should I use this method over using fastboot?" The two main reasons are you can't use fastboot if you are not with a computer with working ADB and using fastboot requires that you have previously flashed the engineering HBOOT.

    This is my first guide so I'm open to suggestions or feedback.
    1
    Not sure that's actually quicker, at least I don't think it would be for me, especially if you are changing recoveries with any frequency (like if tying out Gingerbread ROMs then going back to a 2.2 ROM) because you'd need to constantly rename your recovery images. With my method you would only need to leave the two files named as they are, or for expediency you could rename to recovery.img and recovery3.img then when you wanted to switch you could just execute:

    flash_image recovery recovery.img

    or

    flash_image recovery recovery3.img

    Depending on which recovery you wanted at that point & time.

    As I said in the guide, there are already a number of options available, using ROM Manager and fastboot are the most commonly seen in guides but your method and mine are other options for people for whom they work better. :)