[Nexus S Android Development] cpaixao:
Error-Proof Flashing Ritual

All my trial on testing roms, kernels and more, i've seen and noticed that most part of after flashing issues (reboots and FC) is related to flashing procedure. People just dont "know" how to flash a kernel or rom properly. In order to minimize questions directed to dev about "hey, why my phone is reboot about 10 sec after booting" or "hey dev, why everything is FCing for me!?", i think everyone should make sure they're really flashing kernel in the right way. So, i decided to bring here my....

Error-Proof Flashing Ritual​

:D

Before begin, let me clear something to you: Flashing is a very crucial process, when it writes one-time data directly on module. I'll try to make it in didactic way...

"What happens when I flash a new kernel?"

Well, when you flash a new kernel you overwrite the module previously data. What does is that "Overwrite" has never been a good idea in anywhere. Specially when we're talking about one-time modules, data **should** be there for life. So, when you overwrite that data, you'll always about to get something wrong, as its a different data.

"Why wipe the cache and davilk-cache?"

Kernel makes relations when its get evolved along the system and it saves that "knowledge" to save time next turn it need to redo that. Changing kernel results that knowledge becomes invalid. We need a 0-point cache to start from the begin with new kernel, in order to avoid mistaken answers by cache. We need to Wipe this out!

"Why the He*L i should i need to wipe everything x2 (at least)??"

Unfortunately, CWM recovery doesnt accomplish the task as it should do. There's no another reason to wipe 2x or more the cache or whatever task in CMW recovery but to make **sure** it really proceeded as we believed.

Well, I talk way too much... So, lets begin!

1 - With the kernel in the root of sdcard, boot on CWM recovery;

2 - chose "wipe cache partition" and confirm

3 - chose "wipe cache partition" and confirm (again, c'mon guy)

4 - go to "advanced" and chose wipe davilk-cache and confirm

5 - chose wipe davilk-cache and confirm once more.

6 - roll back to main menu, chose flash package from sd card and chose the kernel zip and confirm

7 - do it again;

8 - Power off the phone (plz, dont reboot)

9 - Now, boot the phone.

"I still get reboots and FC, your, bastard!"

Ok, no problem. Lets add one more security layer to the process (i do it everytime on my phone, actually). With this, we FORCE ERASE the boot partition (where kernel lives), and it flashing new data on that becomes easier for CWM recovery. You will need the android-sdk tools and a .img kernel package, as this one (its the stock 4.0.3 kernel) http://dl.dropbox.com/u/20001234/boot.img copy that to your /platform-tools

1 - connect usb and boot into fastboot mode

2 - Open CMD, browse to your platform-tools on your pc and type "fastboot erase boot" and enter.

3 - type "fastboot erase boot" and enter, (notice that the time to finish that task is different now because boot partition is empty this time)

4 - power off the phone

5 - boot the phone into fastboot mode again and type "fastboot flash boot boot.img"

6 - type your keyboard up arrow and enter again.

7 - Power off

8 - Now boot at CWM again and redo the wipe and flash process.

Done!

It may look hard but it isnt. I see it as necessary method to make sure you're helping the dev avoid questions you shoulndt if you were followed this, and you'll get the best performance for kernel at the same time!