[Nexus 4 Android Development] Michaelmania:
All partitions wiped but &quot;System&quot; yet OS doesn't display desktop

This is in no way a fault with our beloved Chroma ROM but since i had this scary experience, i felt sharing with my Chroma-iites first

Here goes: I had this niggling problem where i had downloaded TK Gapps to my "downloads" folder and flashed the file using TWRP recovery from that folder itself. Now whenever TK Gapps is flashed you will notice two log files created in that folder. Normally if you delete them they are gone. But queerily, since i had done the operation from "downloads" folder they kept coming back inspite of me deleting them. (PS: experts may know better).

Next, i was (and maybe still will) also facing "sleep-of-death" events. The screen wouldn't come on but internally phone would continue to run. This was evident when i made phone calls, sent texts, etc.

So to fix these issues, I thought i would do a clean flash. But this time also wipe the "internal storage" for good measure. Needless to say, i already had done my separate app backups with data. Also had a nandroid backup. Since i would wipe my sdcard, i didn't transfer any zip files to be flashed. Thought i would do it after wiping.

My idea was that, after the OS boots i would again get a clean start and then i would transfer the necessary files via cable using "computer" on a windows pc. Else if it fails, i would try to mount partitions through TWRP and again do so via computer (oh! how i knew so little). Worst case, i would try the ADB sideload feature which i had heard of but never tried.

Then it all went haywire. OS did a proper boot, but right after boot animation, it was black. If the power key was pressed the screen turns off. And if it is pressed again, you could see the lcd backlight coming on but still a black screen. However if power key was pressed, you would get standard Chroma options of "power off" and "reboot". So i rebooted into TWRP recovery. I wiped the following partitions: Dalvik Cache, Cache, Data, System.

Using the nandroid backup I restored the "boot" and "system" partitions. The result was the same.

Now the solution that worked:

1) Downloaded Nexus 4 factory image from https://developers.google.com/android/nexus/images. It comes as a .tgz file

2) Went to the "platform tools" folder. This usually comes with android sdk. However, i had found just this folder with the essential files by reading this and this.

3a) Now i was set to flash a Nexus 4 factory image (the latest) via fastboot mode

3b) Hours had passed and i was juggling with ADB and Fastboot commands and trying to know the difference between the two

3c) This came in handy

4) Finally by following this tutorial i successfully flashed the factory image. I now had a fully stock Nexus 4. The only difference being the bootloader was unlocked.

5) Again I followed the steps required to install Chroma and TK Gapps from scratch. This includes flashing TWRP recovery first.

I now have my Mako back running Chroma in all its glory. No aforementioned glitches thus far.

I had gone through several other steps in search of finding the solution. Refraining from mentioning them so as no to bloat this post. Everything was necessary to come to this. I am no developer nor a guy associated with this realm. I simply read a lot and searched and searched and searched. If i could do it, anybody can. Hope this helps someone in need.