[KOT49H 4.4.2 KitKat] *Custom recovery flashable zips to return N4 to stock*

someguy01234

Well-known member
Nov 9, 2011
1,813
2
0
Visit site
Warning: This process is recommended for those who are familar with flashing using custom recoveries, proceed at your own risk. Make a backup of your device before proceeding. You take your own risk and I'm not responsible for any damages to your phone. If you are not familar at using custom recoveries and do not know how to use fastboot to return your Nexus to stock, stop here.

WHAT IS IT

These are flashable zip packages compatible with custom recoveries (CWM and TWRP) that will install factory stock image files to the Nexus 4 and returning it to factory state. The image files being flashed are unmodified stock image (*.img) files. The purpose I made these packages is to make it easy to return to factory stock for those who have rooted. The flashable packages will check to make sure if the device is a Nexus 4 before flashing.


INSTRUCTIONS

0. Backup
Make a nandriod backup of your current working rom and copy the backup to your PC incase you need to restore it.

This is not necessary, but if you previously re-locked your bootloader, make sure your bootloader is unlocked (use this app to unlock bootloader without wiping data) so in case things goes wrong you can install custom recovery and retrieve your data.

1. Download the flashable zip packages and flash them using custom recoveries
The full firmware is split up into 5 packages so you can flash each "partition" individually, or retain certain ones you want to keep. Images available for flashing:

[bootloader, boot (kernel), radio (baseband), recovery, system (the main OS)]
(download links in bottom of post)

It is recommended to wipe "system" partition first if you'll be flashing over it.


Notice: The "userdata.img" is not included for flashing, which mean your user installed apps, settings and internal storage files will not be erased. (This do not pertain to system installed apps (apps located in /system/app) and their settings, as well as root. These will be erased when you flash the "system" package.)

2. If you flashed the "system" zip package, it is not required, though highly recommended do a "factory reset" wipe or "fix permissions" to prevent system errors
If you have flashed the "system" package, which contain the main OS files, I recommend two things before rebooting:

A. Factory reset
Factory reset using custom recoveries will erase your apps and settings, but leave your internal storage files alone. This will ensure you don't have any bugs when switching between different Android version or roms.
Do not use the factory reset option in stock android or stock recovery unless you must, unlike with custom recoveries they will wipe your internal storage (this is where all your photos, music and downloaded files are located). Custom recoveries leave them alone unless you specifically wipe internal storage (also known as "/data/media").

B. If you want to keep your apps, settings and not do a factory reset
Do a "Fix Permissions" in your custom recovery.

Due to potential mismatching of settings between your previously installed rom and the newly installed stock rom, it may cause serious errors. This will not likely be an issue if you go from an older stock Android version to a new one. No guarantee however.

However, when the user migrate from between different custom roms or going from a custom rom back to stock while retaining apps data, issues can and will arise. You may receive a "System UIDs inconsistent" error. If you do, boot into custom recovery and apply "Fix Permissions". This may not resolve all errors, in which case the only remedy is to do a factory reset. The results will vary depending on the rom you used previously and your specific settings.

Hints:
The CWM version I'm using for the Nexus 4 doesn't include a 'fix permissions' option, you might want to use TWRP instead.


Reboot and cross your fingers.


DOWNLOAD



MD5 sums
Code:
ba9dce78e97defdbdfd7fd8e4dba4acf  stock_occam_bootloader_makoz30d.zip
f74abac18d620267c15c48b622525f6a  stock_occam_kot49h_boot_3.4.0-perf-g2cae413.zip
0a82fee97cd2629d77d6fc103947a6aa  stock_occam_kot49h_radio_m9615a-cefwmazm-2.0.1700.98.zip
2e139b2851049093c0c063ab0999a7d2  stock_occam_kot49h_recovery.zip
aa851415a7b1502def8e6cb239ff64ec  stock_occam_kot49h_system_4.4.2.zip

How these packages are made:
-The bootloader files are taken from official Google OTA update package.
-The boot, radio and recovery img are taken from official Google factory image.
-The original system.img is 'sparse' and had to be unsparse to be compatible with custom recoveries, however all files within are unmodified. For more info, see here.
-The script file for each flash package is called "updater-script", which is located in the folder "/meta-inf/com/google/android/" in each zip files. Don't edit it if you don't know what you're doing though.
 
Last edited:

anon5664829

Banned
Feb 6, 2013
2,322
0
0
Visit site
Re: Interest check: flashable zip to flash stock img files using custom recoveries.

I am putting together a flashable zip file that will flash factory stock img files to the phone using custom recovery (CWM or TWRP). Basically flashing the zip will put all of these on your phone back to 100% original:
bootloader
boot (kernel)
radio (baseband)
recovery
system (the main OS)

This is because it will use unmodified stock img files. This is the easiest way to not lose your data in the process as well since I excluded the "userdata" partition, so all apps data and internal storage are left alone. So it's a good way to update to KitKat or going back to stock without losing your data. You can flash this package even if your bootloader is locked (as long as you have custom recovery already installed).

However, it's not full proof because you can get the error "System UIDs inconsistent", you get it when you go from a custom rom back to stock and your apps data don't match up, so you still have to clear your apps data or use "fix permissions" in custom recovery to fix this issue.

Not sure if anyone is interested in this since I guess once you know how to install custom recoveries, you probably already know how to return your device to stock easily with fastboot. And sure you can flash "stock roms", but really they are modified and not 100% original.

Code:
assert(getprop("ro.product.device") == "mako" || getprop("ro.build.product") == "mako");
mount("ext4", "EMMC", "/dev/block/platform/msm_sdcc.1/by-name/system", "/system");

ui_print("Flashing bootloader....");
package_extract_file("bootloader-flag.txt", "/dev/block/platform/msm_sdcc.1/by-name/misc");
package_extract_file("bootloader.sbl2.img", "/dev/block/platform/msm_sdcc.1/by-name/sbl2");
package_extract_file("bootloader.sbl3.img", "/dev/block/platform/msm_sdcc.1/by-name/sbl3");
package_extract_file("bootloader.tz.img", "/dev/block/platform/msm_sdcc.1/by-name/tz");
package_extract_file("bootloader.rpm.img", "/dev/block/platform/msm_sdcc.1/by-name/rpm");
package_extract_file("bootloader.aboot.img", "/dev/block/platform/msm_sdcc.1/by-name/aboot");
package_extract_file("bootloader-flag-clear.txt", "/dev/block/platform/msm_sdcc.1/by-name/misc");

ui_print("Flashing baseband...");
package_extract_file("radio.img", "/dev/block/platform/msm_sdcc.1/by-name/modem");

ui_print("Flashing kernel...");
package_extract_file("boot.img", "/dev/block/platform/msm_sdcc.1/by-name/boot");

ui_print("Flashing recovery...");
package_extract_file("recovery.img", "/dev/block/platform/msm_sdcc.1/by-name/recovery");

ui_print("Flashing system...");
package_extract_file("system.img", "/dev/block/platform/msm_sdcc.1/by-name/system");

ui_print("Finished...");

You can reuse this script to make your own flash package if you like. It is pretty straight forward, the bootloader part is taken exactly from the OTA update packages. The command to flash other partitions are the standard way used by custom roms. I could upload the flash package barebone, but it won't be too useful for non advance users, since you still need to decrypt the system.img file (using simg2img in linux), since custom recoveries will not be able to flash it in it's original form.

If anyone is interested, I can make one package that flash all of them, or individual packages that flash each img seperately, since some might not like to lose their custom recovery or lte radio. Pretty sure something like this is available at XDA in some form.

I'm rather interested in this.

Posted via Android Central App
 

someguy01234

Well-known member
Nov 9, 2011
1,813
2
0
Visit site
Re: Interest check: flashable zip to flash stock img files using custom recoveries.

I'm rather interested in this.

Posted via Android Central App
That took a long time to write, I need a break.

I got lots of error going from PSX rom back to stock while keeping the apps data. No issues with CyanogenMod to stock though.
 
Last edited:

anon5664829

Banned
Feb 6, 2013
2,322
0
0
Visit site
Re: Interest check: flashable zip to flash stock img files using custom recoveries.

That took a long time to write, I need a break.

I got lots of error going from PSX rom back to stock while keeping the apps data. No issues with CyanogenMod to stock though.

Thanks for this regardless.

Posted via Android Central App
 

someguy01234

Well-known member
Nov 9, 2011
1,813
2
0
Visit site
Re: Interest check: flashable zip to flash stock img files using custom recoveries.

Well it is expected as I describe in the steps, but some roms are more compatible with stock than other.
 

DeadpoolJunior

Well-known member
Nov 27, 2012
282
0
0
Visit site
Re: *Flashable zips to return Nexus 4 to stock using CWM or TWRP* [KRT16S 4.4 KitKat]

So just to clarify, for someone who has flashed the LTE zip package for the N4, I would only have to flash the radio to return to stock right? I have a custom recovery but no custom kernel. Everything is the same except I'm rooted and flashed the LTE zip. I'm still on KRT16O.

Sent from my Nexus 4 using Tapatalk
 

someguy01234

Well-known member
Nov 9, 2011
1,813
2
0
Visit site
Re: *Flashable zips to return Nexus 4 to stock using CWM or TWRP* [KRT16S 4.4 KitKat]

If you didn't flash the zip that modified the build.prop as well, if the build.prop is changed it will also failed. But I assume you didn't.

There is no KRT16O to KOT49E OTA package, you'll have to update it to KRT16S first. occam-KRT16S-from-KRT16O
 

DeadpoolJunior

Well-known member
Nov 27, 2012
282
0
0
Visit site
Re: *Flashable zips to return Nexus 4 to stock using CWM or TWRP* [KRT16S 4.4 KitKat]

Yeah I know I have to move to KRT16S first, it's just that the update keeps failing because the build prop has unexpected colleges or something. I'll go ahead and just flash the stock radio and see if it works.

EDIT: Flashing just the radio didn't do the trick. Flashed the stock system zip and I was good to go. Jumped to KRT16S and then KOT49E in a matter of minutes. Thanks.
Sent from my Nexus 4 using Tapatalk
 
Last edited:

Waterdroid

Well-known member
Nov 6, 2013
111
0
0
Visit site
Re: *Flashable zips to return Nexus 4 to stock using CWM or TWRP* [KRT16S 4.4 KitKat]

Flashed the radio with TWRP, thanks!

Sent from my Nexus 4 using AC Forums mobile app
 

Junior Milovale

New member
Dec 10, 2013
1
0
0
Visit site
Re: Interest check: flashable zip to flash stock img files using custom recoveries.

Hi im interested in the file u are talkn about as im tryn to update my nexus 4 to 4.4.2 but always aborts so im kind of lost lol
 

DeadpoolJunior

Well-known member
Nov 27, 2012
282
0
0
Visit site
Re: Interest check: flashable zip to flash stock img files using custom recoveries.

Hi im interested in the file u are talkn about as im tryn to update my nexus 4 to 4.4.2 but always aborts so im kind of lost lol

He has all the files on his drive. Just download and flash the system one, and then flash the 4.4.2 update zip. Should work although I'm not sure the nature of your issues.

By the way, are you gonna update the post with the 4.4.1 files? Or will flashing the zips you have now work? Freakin Google puts out another update as soon as I get to 4.4.1.

Sent from my Nexus 4 using Tapatalk
 

someguy01234

Well-known member
Nov 9, 2011
1,813
2
0
Visit site
Re: Interest check: flashable zip to flash stock img files using custom recoveries.

By the way, are you gonna update the post with the 4.4.1 files? Or will flashing the zips you have now work? Freakin Google puts out another update as soon as I get to 4.4.1.

Sent from my Nexus 4 using Tapatalk

4.4.2 is up. Same bootloader and recovery, kernel and radio are new.
 

DeadpoolJunior

Well-known member
Nov 27, 2012
282
0
0
Visit site
Re: Interest check: flashable zip to flash stock img files using custom recoveries.

4.4.2 is up. Same bootloader and recovery, kernel and radio are new.

What I'm saying is, I could flash that system image that you have for 442 on my 441 right? Because I'm trying to go from 441 to 442 but I flashed the 4g zip again so I'm sure the system thing will fail again.

Sent from my Nexus 4 using Tapatalk
 

someguy01234

Well-known member
Nov 9, 2011
1,813
2
0
Visit site
Re: Interest check: flashable zip to flash stock img files using custom recoveries.

What I'm saying is, I could flash that system image that you have for 442 on my 441 right? Because I'm trying to go from 441 to 442 but I flashed the 4g zip again so I'm sure the system thing will fail again.

Sent from my Nexus 4 using Tapatalk
Yes, it should work, back up first though.
 

bigandyb

New member
Jan 18, 2014
1
0
0
Visit site
Re: Interest check: flashable zip to flash stock img files using custom recoveries.

You Legend.

Solved my problems after days.

Worked from CM11.2 don't forget to flash the boot (kernel) as my phone had glitched graphics.

Thanks Again, Fantastic work
 

ksheth94

New member
May 7, 2014
1
0
0
Visit site
Re: Interest check: flashable zip to flash stock img files using custom recoveries.

Thanks you!
Btw, is it possible to flash "stock recovery" using TWRP?
My USB is dead, so.
Thanks again!