[Xperia Z General] Cookie Ninja:
ROOT JB (101) AND KITKAT (230) FIRMWARE WITH LOCKED BOOTLOADER

This thread is now officially obsolete. There is a new, simple and efficient ROOT method created by [MENTION=3280118]geohot[/MENTION], based on the asec exploit. This method is valid for all versions of android with kernel dates older(earlier) than 04 June. The method probably works on any phone / tablet device EXCEPT the HTC M8, Moto G & E, and devices with Intel chipsets. Go to this thread for details:

http://xdaforums.com/showthread.php?t=2783863

The guide below is obsolete and remains only for info. Please do not follow?.

DISCLAIMER

: The steps WILL INVOLVE OBTAINING BOOTLOADER UNLOCK CODE FROM SONY, However, after unlocking, you will be guided to re-lock bootloader so that the end result will be a phone with Marlin Keys, Bravia Engine2 and Bootloader INTACT (LOCKED).

Starting Assumptions

:

1. You have a Sony Xperia Z (C66XX) L-39H (Duh! Obvious!)

2. You have some knowledge of Root, SUPERUSER and enabling developer options, enabling USB Debugging mode, switching off and connecting your phone to USB & Computer with vol Up / Down Pressed to enable Fastboot mode or Flash Mode. If not, then go slowly and patiently, read every screen that flashes in front of you on your PC/Laptop and choose dilligently.

3. The bootloader status of your phone is

BOOTLOADER UNLOCK ALLOWED--YES

. This is the general case if you are on a no-contract plan with your service provider, or you have brought the phone at a full premium price (No discounted price by your wireless service provider). US / Canadian users, please obtain your unlock codes before you proceed further, all your phone's bootloaders ARE LOCKED. If you have bought the phone second-hand or from a dubious source check the bootloader lock status by opening the dialler and entering *#*#7378423#*#* (star-hash-star-hash S E R V I C E hash-star-hash-star). You will see four options 1. Service Info, 2. Service Tests, 3. Calibrations and 4. Customisation Settings. To check the bootloader status tap on Service Info>(next page)>tap on configuration>(next page) the last item is your bootloader status. It must read bootloader unlock allowed-YES If it reads "bootloader unlock allowed-NO" then you need unlock codes from your wireless service provider. If it reads "bootloader-UNLOCKED", then you have lost your Marlin keys and bootloader (This also means you cannot flash Sony updates, but you have a wide open field to flash any ROM and kernel of your choice!).

4. Loads of Patience....

5. Some coffee / favourite non-alcoholic brew at hand for sustenance (alcoholic beverages can be for later, till you're done with the process / you are past the legal age. Until then go easy....)

6. It is assumed that you have a Windows PC / Laptop (Win32/64) with all necessary drivers loaded. If not just download and install PC Companion, it will install the necessary Sony drivers.

Step-1

Locked bootloader with 4.2.2 (67 or lower firmware) ROOT status idoesn't matter.

Locked Bootloader with 4.3 (.569 / Commercial & Journalist's firmware) rooted / unrooted.

If on 4.2 firmware

, then ROOT your device using BINARY's Method or cubeundcube's method (DOOMLORD's method works below 67 firmware, but I may be wrong) Links:

Binary's Thread: http://xdaforums.com/showthread.php?t=1886460

cubeundcube nethod: http://xdaforums.com/showthread.php?t=2559009

DOOMLORD's thread: http://xdaforums.com/showthread.php?t=2327472

If on 4.3 firmware and not rooted

, then downgrade to 4.2.2 (67 firmware) by flashing a ftf file of your region. Links for flashtool thread is given below. Use thread search to find ftf file for your region and download it.

If you are already rooted on 4.3, 569 firmware AND have a locked bootloader, then start from this point.

Make a backup of your Trim Area (TA) by using the tool created by DevShaft at this thread: http://xdaforums.com/showthread.php?t=2292598 This Step is VERY IMPORTANT!!!!!

Step-2

You now have a rooted phone on 4.2.2 (67 firmware) or 4.3 (569 firmware), AND you have made a backup of yourphone's TA.

Now, upgrade to 4.3 (101 firmware) by connecting your phone to the PC (USB cable) using PC Companion or by using SUS. Use the UPGRADE option and not the CLEAN INSTALL option to retain data. On the first boot after upgrade you will realize that you've lost ROOT and any recovery that you had earlier installed.

Make a FTF file of the upgraded ROM by following the instructions from this thread by deadmask (http://xdaforums.com/xperia-u/general/guide-how-make-ftf-stock-firmware-sus-t2075736) or from Stage-3 of this thread by VipeR (http://xdaforums.com/showthread.php?t=2188129)

Step-3

You now have a phone on the latest firmware (without root) AND you have a backup of TA from 4.2 firmware, AND ALSO have a FTF file for the latest firmware.

Obtain the unlock code for your bootloader from the Sony website. Link: http://unlockbootloader.sonymobile.com/

enter your phone's IMEI number and your email to recieve the unlock code. Legal eagles, obtaining an unlock code DOES NOT MEAN THAT you have actually used it!!! Open your e-mail inbox and check for mail from SONY containing your unlock code.

Custom Kernel Download First download a custom kernel by DOOMLORD (with CWM) recovery for use immediately after unlocking the bootloader from this thread by DOOMLORD: http://xdaforums.com/showthread.php?t=2167381 . Download the custom kernel and place it on your computer's desktop/folder of your choice. Extract the contents of the zip file and we'll come back to it later.

ADB+Fastboot Tools Download a set of ADB and fastboot tools made by anonymous and hosted at the Dev-host site Download link : http://d-h.st/I8l

After the zip file has downloaded extract it to get a folder fastboot+ADB Now take out the boot.img file from the zip file containing DOOMLORD's kernel above, and copy it to the win32subfolder inside the fastboot+ADB folder. Make a note of the location (Drive/folder) where this folder has been saved. (preferred storage on the desktop)

CWM Flashable SuperSU Download Download the latest flashable Super SU by Chainfire from the OP of this thread: http://xdaforums.com/showthread.php?t=1538053 . Download the latest cwm flashable superSU.zip and place it in your phone's external SD Card

Use Androxyde's Flashtool (thread link:http://xdaforums.com/showthread.php?t=920746) to unlock your bootloader It is a painless one-click procedure using the BL button. follow the instructions in the flashtool and let the phone reboot (after unplugging USB) Now recheck if ADB debigging mode and Unknown sources are enabled in phone settings.

Now click START on your PC and enter 'cmd' in the search box. Right click on the command prompt / DOS box (cmd.exe) and choose "run as administrator". Enter the administrator password if prompted by the PC. In the command prompt window type the following commands:

Hold the phone in your hand and do the reboot command. As soon as the blue light goes off and the SONY logo appears wait for the phone LED to turn violet. Press Vol UP button on seeing the violet LED and release-press-release-press two to three times for good measure (Sometimes a constant press also works) till the LED goes off and the phone boots into CWM. In the CWM menu use the Vol up/down to tab move between the options and use the power button to select. There is also a touch-swipe down/up to tab-move and swipe right to select or swipe left to go back, use this method only if you are confident/familiar with the touch-select method. Select flash a Zip from external SD card and navigate to the folder where you stored the update-superSU-1.93.zip and select it. confirm by moving down to select Yes, Flash update-supersu1.93.zip and let CWM finish flasing the SU. go back to the main page and reboot to system from CWM.

After the phone reboots check Super SU is loaded on your phone in /System/app/ and check full root access on your phone....

Step-4

You now have a rooted phone on the Latest 101 firmware, with unlocked bootloader, AND you have a backup of your phone's TA and also have a ftf file of the latest firmware.

Now you have one last step to go back to stock kernel for locking your bootloader. Start Flashtool and select the flash (lightning) button select flash mode. Now select the latest firmware, which you had converted to FTF and on the right side top, (wipe options) untick all wipe options. On the right bottom (exclude), tick mark to exclude everything EXCEPT kernel and fotakernel. See that the centre window (flash content) shows only kernel.sin, fotakernel.sin and loader.sin. (Check Screenshot for reference) Now hit the flash button and put the phone into flash mode.Unplug and Reboot

Step-5

Now you have a rooted phone with the latest firmware on stock kernel (no CWM) AND you have a backup of the TA from your phone.

Now's the time to flash the TA. Do you remember the steps of making backup/restoring TA. check DevShaft's thread again, and remember it is better to do a dry run for restoring TA, before the final restore. DO IT.

Finally, you have rooted the phone with the latest firmware, and relocked your bootloader, and all with a ROM/Kernel and customisation of your region/choice.

Future Steps:

Flash a recovery. [NUT]'s dual recovery for locked bootloader is the best. Thread link : http://xdaforums.com/showthread.php?t=2261606

Acknowledgements:

All DEVs and OPs whose threads, posts, tools and files as mentioned in this post. I have only placed them in one order. You may thank each thread OP &/or Dev for their tools, files and guides.