[GUIDE] Update stock rooted/modified rom to last 6.0 Marshmallow w/o losing your data

Search This thread

c3k

Senior Member
Sep 13, 2009
622
520
Requirements:
  • you need to have a pc with adb working
  • a stock firmware on your device (any)
  • unlocked bootloader
  • a working backup just in case

Pro:
  • you will not lose your data / application

Cons:
  • you will lose all system modification (root, busybox, custom kernel...)
  • you'll take all the risk of operation (I've tested on my device)

Guide:
some file names changes depending on version so please complete the {version_here} placeholder with the file you download
* prepend "sudo" on command line if you are on a Linux machine
  1. download last version for your device here (if you want to root download the zip file in the section below to speed up the operations)
  2. extract
  3. extract image-{device_here}-{version_here}.zip in the same folder (no subdir)
  4. command line* (or reboot device with vol down pressed):
    Code:
    adb reboot bootloader
  5. command line*:
    Code:
    cd {your_path_here}
  6. command line*:
    Code:
    fastboot flash bootloader bootloader-{device_here}-{version_here}.img
  7. command line*:
    Code:
    fastboot reboot-bootloader
  8. command line*:
    Code:
    fastboot flash radio radio-{device_here}-{version_here}.img
  9. command line*:
    Code:
    fastboot flash system system.img
  10. command line*:
    Code:
    fastboot flash boot boot.img
  11. ONLY IF YOU FOUND A VENDOR.IMG IN THE ZIP command line*:
    Code:
    fastboot flash vendor vendor.img
  12. command line*:
    Code:
    fastboot flash cache cache.img
  13. command line*:
    Code:
    fastboot reboot

Now you have the lastest stock image and all your data.

Change recovery (TWRP) and root:
Note that we haven't flash the stock recovery, but during every boot of an unmodified system there's a script that do that (supersu usually deactive this behavior during install).
If you had TWRP installed and the SuperSU zip on your device, at the end of the above procedure you can boot directly from bootloader to recovery and go directly to last step:
 
Last edited:
C

cimbrum

Guest
Just tried with flash_all.bat. I'm getting the message "Can not generate image". How can I solve this, please?
 

Attachments

  • cannot_generate_image.png
    cannot_generate_image.png
    57.8 KB · Views: 11,215

chikess

Senior Member
Mar 28, 2008
381
64
i've gone your way, but i tried also the flash-all.bat with the -w switch, didnt work.
 

Sp0KI

Member
Dec 18, 2011
22
3
Cant flash the system.img manually. All the other img are working. I get this error message :

Code:
target reported max download size of 1073741824 bytes
error: cannot load 'system.img'

The old system.img from lrx22c works also.
Someone know whats going on?
 

chikess

Senior Member
Mar 28, 2008
381
64
Cant flash the system.img manually. All the other img are working. I get this error message :

Code:
target reported max download size of 1073741824 bytes
error: cannot load 'system.img'

The old system.img from lrx22c works also.
Someone know whats going on?

I think that all who has flashed the developer preview got an broken filesystem or the partitions missmatch.

Before i used the preview the -w update flag worked well to rebuild the partitions, now it didnt work anymore, tried all factory images don to 4.4 :eek:
 
  • Like
Reactions: sradner

Sp0KI

Member
Dec 18, 2011
22
3
I think that all who has flashed the developer preview got an broken filesystem or the partitions missmatch.

Before i used the preview the -w update flag worked well to rebuild the partitions, now it didnt work anymore, tried all factory images don to 4.4 :eek:

I didn't flash the preview.
 

foosion

Senior Member
Jun 17, 2012
535
93
Doesn't this require an unlocked bootloader, and not necessarily root, or am I confused?
 

efrant

Retired Senior Moderator & Developers Relations
Feb 12, 2009
11,469
10,985
Montreal
Samsung Galaxy S20
Cant flash the system.img manually. All the other img are working. I get this error message :

Code:
target reported max download size of 1073741824 bytes
error: cannot load 'system.img'

The old system.img from lrx22c works also.
Someone know whats going on?
Are you using the latest version for the fastboot.exe file?
 

k1chy

Senior Member
Oct 9, 2011
181
80
OnePlus 7 Pro
Samsung Galaxy M30s
Doesn't this require an unlocked bootloader, and not necessarily root, or am I confused?

This requires an unlocked bootloader. But, there are users like us who have rooted the stock ROM.
This guide is meant for the users who has unlocked bootloader with rooted stock ROM.

This guide will also work for phones with unlocked bootloaders with STOCK ROM(rooted or un-rooted).

Are you using the latest version for the fastboot.exe file?

I had faced the same issue while flashing LRX22C. It got fixed by rebooting the phone and switching the cable to a different USB port. Might work for him too.
PS: I have flashed the images from Linux.
 
  • Like
Reactions: c3k
C

cimbrum

Guest
In my case I guess all the issues are from a previous attempt to flash OptiPop ROM. The flashing process it's a little tricky to understand (with that F2FS file system). I remember that after flashed OptiPop and the phone didn't boot, I tried to restore to stock ROM and it was a lot of errors until it worked fine again.
 

Sp0KI

Member
Dec 18, 2011
22
3
Are you using the latest version for the fastboot.exe file?

I'm using the newest Minimal ADB.
The strange thing is, that i can flash the LRX22C system.img and all other new lmy47d files but not the lmy47d system.img.
I guess i'll wait for the OTA update and hope it works then.
Tried rebooting and switching port and usb cabel..
 
Last edited:

SCFirefighter

Senior Member
Oct 14, 2012
610
124
You actually don't need to manually install supersu or root. Flash the 5.1 images and then (after the first full boot) flash twrp.

Once you boot into twrp and exit out of it, you will be promoted with a message that your phone is not rooted, and you're asked if you want to install supersu. It's built into twrp.
 
  • Like
Reactions: Your Pal Dave

Top Liked Posts

  • There are no posts matching your filters.
  • 185
    Requirements:
    • you need to have a pc with adb working
    • a stock firmware on your device (any)
    • unlocked bootloader
    • a working backup just in case

    Pro:
    • you will not lose your data / application

    Cons:
    • you will lose all system modification (root, busybox, custom kernel...)
    • you'll take all the risk of operation (I've tested on my device)

    Guide:
    some file names changes depending on version so please complete the {version_here} placeholder with the file you download
    * prepend "sudo" on command line if you are on a Linux machine
    1. download last version for your device here (if you want to root download the zip file in the section below to speed up the operations)
    2. extract
    3. extract image-{device_here}-{version_here}.zip in the same folder (no subdir)
    4. command line* (or reboot device with vol down pressed):
      Code:
      adb reboot bootloader
    5. command line*:
      Code:
      cd {your_path_here}
    6. command line*:
      Code:
      fastboot flash bootloader bootloader-{device_here}-{version_here}.img
    7. command line*:
      Code:
      fastboot reboot-bootloader
    8. command line*:
      Code:
      fastboot flash radio radio-{device_here}-{version_here}.img
    9. command line*:
      Code:
      fastboot flash system system.img
    10. command line*:
      Code:
      fastboot flash boot boot.img
    11. ONLY IF YOU FOUND A VENDOR.IMG IN THE ZIP command line*:
      Code:
      fastboot flash vendor vendor.img
    12. command line*:
      Code:
      fastboot flash cache cache.img
    13. command line*:
      Code:
      fastboot reboot

    Now you have the lastest stock image and all your data.

    Change recovery (TWRP) and root:
    Note that we haven't flash the stock recovery, but during every boot of an unmodified system there's a script that do that (supersu usually deactive this behavior during install).
    If you had TWRP installed and the SuperSU zip on your device, at the end of the above procedure you can boot directly from bootloader to recovery and go directly to last step:
    5
    I have got the system.img failing to load workaround here on attempting with a Nexus 5 and 5.1.0-lmy47i image, the trick was to use sparse file option of fastboost to a smaller value than 1GB like 512M, below is what I have done;

    1) got latest fastboot.exe and adb rev22 from Android Studio and up to date tools
    2) Using a helper rooting Software called Nexus Root Toolkit I have replaced copied newest fastboot files in \Nexus Root\data\
    3) In \Nexus Root\data\flashstock.bat change fastboot flash system %system_img% to fastboot -S 512M flash system %system_img%

    You should see this

    Code:
    Flash Stock + Unroot...
     ------------------------------------------------------------------
    
    
    target reported max download size of 1073741824 bytes
    sending 'bootloader' (2579 KB)...
    OKAY [  0.299s]
    writing 'bootloader'...
    OKAY [  0.503s]
    finished. total time: 0.802s
    rebooting into bootloader...
    OKAY [  0.003s]
    finished. total time: 0.003s
    
    target reported max download size of 1073741824 bytes
    sending 'radio' (45425 KB)...
    OKAY [  1.624s]
    writing 'radio'...
    OKAY [  3.125s]
    finished. total time: 4.750s
    rebooting into bootloader...
    OKAY [  0.002s]
    finished. total time: 0.003s
    
    target reported max download size of 1073741824 bytes
    sending 'boot' (8930 KB)...
    OKAY [  0.496s]
    writing 'boot'...
    OKAY [  0.758s]
    finished. total time: 1.256s
    rebooting into bootloader...
    OKAY [  0.002s]
    finished. total time: 0.002s
    
    target reported max download size of 1073741824 bytes
    erasing 'cache'...
    OKAY [  0.624s]
    sending 'cache' (13348 KB)...
    OKAY [  0.630s]
    writing 'cache'...
    OKAY [  1.084s]
    finished. total time: 2.339s
    rebooting into bootloader...
    OKAY [  0.001s]
    finished. total time: 0.002s
    
    target reported max download size of 1073741824 bytes
    sending 'recovery' (9648 KB)...
    OKAY [  0.516s]
    writing 'recovery'...
    OKAY [  0.801s]
    finished. total time: 1.318s
    rebooting into bootloader...
    OKAY [  0.002s]
    finished. total time: 0.003s
    
    erasing 'system'...
    OKAY [  1.086s]
    sending sparse 'system' (517642 KB)...
    OKAY [ 16.661s]
    writing 'system'...
    OKAY [ 34.579s]
    sending sparse 'system' (503978 KB)...
    OKAY [ 16.225s]
    writing 'system'...
    OKAY [ 34.701s]
    finished. total time: 103.255s
    rebooting into bootloader...
    OKAY [  0.002s]
    finished. total time: 0.003s
    
    target reported max download size of 1073741824 bytes
    erasing 'userdata'...
    OKAY [  8.373s]
    sending 'userdata' (137318 KB)...
    OKAY [  4.511s]
    writing 'userdata'...
    OKAY [  9.187s]
    finished. total time: 22.071s
    rebooting...
    
    finished. total time: 0.001s
    
    
    
    Booting up your freshly flashed stock device...
     ------------------------------------------------------------------
    
    Wait for your device to finish booting up...
    
            - It may appear to be boot looping; just wait...
    
            - It could take 5-10 minutes; please be patient...
    
    When its finally booted back up, please remember
    to re-enable USB debugging if you plan on using
    the toolkit to perform other operations.
    
    
    
    Press any key to exit...

    Attached are the latest fastboot files if you don't want to go thourgh all the hassle of downloading the whole android studio

    fastboot.exe - md5: d335a521b494edae60c131569126db82 - API 22
    adb.exe - md5: 9e6a80066408aaa565f61071e645450e - API 22
    AdbWinApi.dll - md5: 47a6ee3f186b2c2f5057028906bac0c6 - API 22
    AdbWinUsbApi.dll - md5: 5f23f2f936bdfac90bb0a4970ad365cf - API 22
    4
    thread updated
    4
    unROOT :
    1) Install adb + drivers (if you"re on Windows 10, adb may not working atm)
    2) Download the image factory of your current version (example : 5.1.1. LMY48B https://dl.google.com/dl/android/aosp/hammerhead-lmy48b-factory-596bb9c1.tgz )
    3) Extract boot.img, system.img & recovery.img
    4) In a command prompt from the adb directory use these commands :
    Code:
    fastboot flash boot boot.img
    fastboot flash system system.img
    fastboot flash recovery recovery.img

    If the OTA is knocking at your door :

    1) Just apply it and jump to the last part

    If you want to apply the update ASAP :
    (Get the latest OTA there : http://xdaforums.com/google-nexus-5/general/ref-nexus-5-stock-ota-urls-t2475327)

    1) Download the OTA.zip on your PC, rename the file update.zip, then place file in the same directory as adb.
    2) Make sure you have USB Debugging checking in the Developer Options, then connect your phone.
    3) Open the command prompt from the directory above on your PC and type the command: 'adb reboot recovery'
    4) When in recovery, you’ll see an android laying down. Press and hold POWER, and then press volume up and release. The menu will appear. Select “apply update from adb
    5) Using the command prompt type: 'adb sideload update.zip' The file will load and the update will begin. (if you"re on Windows 10, adb may not working atm)
    6) When completed, select reboot.

    Last part : back to the ROOT

    Go to
    http://xdaforums.com/google-nexus-5/orig-development/nexus-5-cf-auto-root-t2507211
    and follow instruction to root again.

    Voilà ! Your phone is up to date, rooted & you didn't loose any personal data. :)
    3
    if we already losing root and custom recovery, wouldn't it simply much easier to edit the flash-all.bat , remove the -W from that line at the end and simply run it as if we're running a clean install ? I mean all we have to do is to get into bootloader and run that edited flash-all.bat file .
    We won't lose the data either