Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,813,836 Members 41,385 Now Online
XDA Developers Android and Mobile Development Forum

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

Tip us?
 
raitchison
Old
(Last edited by raitchison; 6th January 2011 at 08:25 PM.)
#1  
raitchison's Avatar
Senior Member - OP
Thanks Meter 48
Posts: 251
Join Date: Mar 2009
Location: West Hills, CA US

 
DONATE TO ME
Default [GUIDE] Flash any recovery easily on the phone using flash_image

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:
Quote:
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:
Quote:
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.
Attached Files
File Type: zip flash_image.zip - [Click for QR Code] (8.8 KB, 9255 views)
The Following 14 Users Say Thank You to raitchison For This Useful Post: [ Click to Expand ]
 
steviewevie
Old
(Last edited by steviewevie; 6th January 2011 at 04:09 PM.)
#2  
steviewevie's Avatar
Retired Forum Moderator
Thanks Meter 615
Posts: 5,319
Join Date: Oct 2009
Location: 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 ?
 
dhkr123
Old
#3  
Senior Member
Thanks Meter 15
Posts: 290
Join Date: Nov 2010
"dd" will do exactly the same, but no need to install extra stuff since its already there.
 
steviewevie
Old
#4  
steviewevie's Avatar
Retired Forum Moderator
Thanks Meter 615
Posts: 5,319
Join Date: Oct 2009
Location: UK
Quote:
Originally Posted by dhkr123 View Post
"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 ?
 
Bronz_Most
Old
#5  
Member
Thanks Meter 4
Posts: 87
Join Date: Dec 2010
Location: Brussels
Excellent, worked for me, flashed CW 3.0 without fastboot
Phone: HTC ENDEAVORU (One X)
Status: Rooted, S-ON
Recovery Image: Clockworkmod
Helped? Say thanks!
 
raitchison
Old
#6  
raitchison's Avatar
Senior Member - OP
Thanks Meter 48
Posts: 251
Join Date: Mar 2009
Location: West Hills, CA US

 
DONATE TO ME
Quote:
Originally Posted by steviewevie View Post
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
Old
#7  
Senior Member
Thanks Meter 15
Posts: 290
Join Date: Nov 2010
Quote:
Originally Posted by steviewevie View Post
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
Old
#8  
Senior Member
Thanks Meter 15
Posts: 290
Join Date: Nov 2010
Quote:
Originally Posted by raitchison View Post
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
Old
#9  
steviewevie's Avatar
Retired Forum Moderator
Thanks Meter 615
Posts: 5,319
Join Date: Oct 2009
Location: UK
Quote:
Originally Posted by raitchison View Post
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 ?
 
raitchison
Old
(Last edited by raitchison; 6th January 2011 at 08:24 PM.)
#10  
raitchison's Avatar
Senior Member - OP
Thanks Meter 48
Posts: 251
Join Date: Mar 2009
Location: West Hills, CA US

 
DONATE TO ME
Quote:
Originally Posted by steviewevie View Post
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.

Tags
flash_image, guide, recovery
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes