[Xperia Z5 Compact General] fafoudef:
Additional information for Nougat 7.1, TWRP and Xposed

Hello,

I followed the guide given in the first page of this topic. But in order I root an Xperia Z5 Compact with Nougat 7.1.1 and install the latest TWRP and Xposed modules, I had to change a few things.

My Sony Z5 Compact 5803 was initially running Nougat 7.1.1 and I used a Dell laptop E7270 with Windows 10 for all the tasks involving a computer.

First comment:

For all the flashboot operations with flashtool, it may not work with USB 3.0 ports on some computers.

On my Dell laptop (E7270) it did not and as I do not have any USB 2 ports, I used a Dell docking station which has USB 2 ports, and it did the trick.​

Step 0 - Backup your phone (optional)

Nothing to add.​

Step 1 - Backup the TA partition

Nothing to add.​

Step 2 - Unlock the boot loader

Some additional info about the instructions from Sony website.

To be able to unlock your Xperia Z5 Compact, prepare it by following these steps:​

Go into Settings > About phone and tap seven times on Build number to enable developer options.

From Settings, go into Developer options and enable OEM unlocking and USB debugging.

After they send you the unlock code by Email, you have to install Android SDK and its drivers:

The SDK Manager is included in Android Studio, but you don’t need to install more than the basic Android command line tools. These can be found at the bottom of this page.

When completing the installation, open the Android SDK Manager and, in the Packages window, scroll down, and in the Extras folder tick the box in front of Google USB driver and install it.

Download and install an updated Fastboot driver .

This is the standardandroid_winusb.inf-file, with a few lines of code added to enable Fastboot to support Sony devices.

Replace the original android_winusb.inf-file with the downloaded file in C:\ > Progran Files (x86) > Android > sdk > extras > google > usb_driver folder on your computer.

Turn off your Xperia Z5 Compact.

Connect a USB-cable to your computer.

On your Xperia™ Z5 Compact, press the Volume up button at the same time as you connect the other end of the USB-cable.

Original instruction (which did not work for me, maybe because I have Windows 10) : When asked for a driver (on your computer) to recognize the phone, open the Devices and Printers directory, click on the fastboot driver and press Update. Browse and point towards the location of the new android_winbus.inf file.

What worked for me

: When asked for a driver (on your computer) to recognize the phone, go to Device Manager (I usually just type device manager in the search bar, I don't know where Windows has hidden it), and under "Other devices", you may see your device with a yellow triangle "problem" icon.

To install the driver, right click on your device, select "update driver", "browse my computer for driver software", "let me pick from a list of available drivers on my computer", then select "show all devices" at the top of the list, click next, then "have disk".

Finally you can go select the path to the Google USB driver, usually there (C:\Program Files (x86)\Android\android-sdk\extras\google\usb_driver) and install the driver!

This guide was found here.

After that you can continue to follow the steps from Sony website.

Step 3 - Download stock firmware

If the firmware list is empty and the software cannot find any firmware for any models, it probably means that you do not have the latest version of XperiFirm.

Download it from here.​

Step 4 - Create a FTF file from the firmware

If the device name doesn't appear in Flashtool, it means that you have to double click in the Device field to select the name of your device.

Nothing else to add.

Step 5 - Flash the FTF file

Nothing to add.​

Step 6 - Patch the kernel

The procedure is a bit different in order to work with Nougat 7.1.1, TWRP and Xposed (for Nougat 7.1.1).

At first, let's follow the original method (I only tried with phh superuser):​

Download rootkernel tool, unzip to desired location.

Extract the kernel image file kernel.sin from the FTF file (you created in step 4) using any file compression program such as 7zip, WinZip, WinRAR, etc.

Open Flashtool > Tools > Sin Editor > Sin file > Locate the kernel you just extracted > Click Extract data. You should now have a file named kernel.elf in the same folder

Copy kernel.elf to the rootkernel folder.

Download the latest stable version of the phh's superuser.

Open command prompt and navigate to the rootkernel directory

Enter the following command: <rootkernel kernel.elf boot.img>

You will be prompted to make a series of choices, including whether you want to install phh superuser and Xposed. Type Y for all of them.

If you didn't see the prompt for phh (required) or Xposed (optional), check the filename of the ZIP files. Remember they're case sensitive.

You should now have a boot.img file in the rootkernel folder, that is your rooted kernel.

However, for Nougat 7.1.1, this method might return you: "Skiping TWRP recovery. No kernel modules for 3.10.84-perf-xxxxxxx available" when you create the boot.img file.

And you will probably not have any proposition of installing Xposed. The boot.img file will work, but you won't have TWRP nor Xposed.​

Including TWRP: ​

To include TWRP in the boot.img file the solution is to follow this guide.

Extract the file system.sin from the FTF file (you created in step 4) using any file compression program such as 7zip, WinZip, WinRAR, etc.

Open Flashtool > Tools > Sin Editor > Sin file > Locate the system.sin file you just extracted > Click Extract data. You should now have a file named system.ext4 in the same folder (5.2GB or bigger)

Use Ext2Read to open the system.ext4 file.

Find the folder: "/lib/modules", and save it on your desktop

Create a folder named "3.10.84-perf-xxxxxxxx" into rootkernel_v5.23_Windows_Linux/Android/twrp_common_kmodules (replace xxxxxxxxx by the number given in the error warning by rootkernel)

Copy the following files from "/lib/modules" into this new folder:

core_ctl.ko

ecryptfs.ko

kscl.ko

mhl_sii8620_8061_drv.ko

texfat.ko​

Then if you re-run: rootkernel kernel.elf boot.img

You should now have a message telling you that TWRP was included successfully.

Including Xposed:​

At time of this edit (2018/1/27), Xposed does now support Android 7.0, 7.1.1 (Nougat) and 8.0, 8.1 (Oreo).

However, I didn't manage to include it into the rooted kernel. But I managed to install it afterwards.

Step 7 - Flash the DRM keys (one-time procedure)

Nothing to add except that in Flashtool, if the Device filter field is empty, you will probably have to double click to select Sony Xperia Z5 compact.​

Step 8 - Flash the kernel

Nothing to add.​

Step 9 - Finish installation of Xposed framework with TWRP

TWRP is a very useful module as it allows you to backup your system and also flash/install (not sure of the correct term) modules like Xposed framework.​

First, how to start TWRP?	​

You have to reboot your phone, then, press the VOL UP button repeatedly while it is starting. In many tutorials I read to press continuously the VOL UP or VOL DOWN button during startup. I am sure it works on other phones, but with the Sony Xperia Z5 Compact, only pressing VOL UP repeatedly was able to prompt the TWRP main menu (and it took me some time to figure out!).

You can then backup your system from there. And you can also flash the Xposed framework:

Xposed:​

Download the latest Xposed framework ZIP file from here.

Select the link to download the framework and chose the good version (I would recommend the latest stable one (non beta)) according to your processor (arm, arm64, x86).

If you don't know, you can easily check by installing droid hardware info from the Play store, as explained here.

You can also download the uninstaller, just in case. And you will also need to download Xposed installer .apk file (this file will be installed later).

Put these 3 files somewhere on the phone (in a folder you will find easily).

Also, go to Settings > Lock screen & Security > Unknown sources > Toggle ON

Also, install phh's superuser app (from Play Store for example), so you can grant root access to applications that need it (which is the main point of being root!).

Now, restart your phone and start TWRP. Then select Install and navigate to the Xposed framework zipfile you downloaded (not the apk), and flash it.

You can now restart and install the Xposed apk installer (maybe you can do it before installing the framework, I don't know if one order is better).

As you have enabled "unknown sources" it should be easy to install it just by clicking on it.

Step 10 - Tadaaa

If every thing worked well, you now have your Sony Xperia Z5 compact rooted with phh superuser, coming with the latest TWRP and Xposed modules.

If it didn't work well, maybe I forgot a step somewhere, I tried so many solutions to make it work, that remembering only the good steps and in the right order wasn't really easy.​

Battery drain and epilog:

Finally, you must know that I did all of it because my Z5C had an abnormal battery drain and I have tried everything else before, to solve it, with no success.

So, rooting it to use Amplify was the ultimate resort. And it... didn't work, still an empty battery in 18h with wifi and data off.

But, just when I was ready to burn it in a fire of despair I finally found the truth!

It was automatically trying to connect to one network, failing, trying again, failing, etc.

(when being in a place with no network at all, instead of draining more power (as expected), it was draining a lot less, probably because it wasn't seeing the network it was desperately trying to connect to (TPO))

Anyway, in Settings > More > Mobile networks > Service providers, I selected Manual search mode, selected the good network, and now my Z5C lasts 4 days (with wifi and data on) instead of 18h with wifi and data off!!!!!

I know this information should belong to another post, but since it was the only reason why I did all of it, I think it is a good conclusion!​