[Sony Xperia M5] loureirorg:
Just to clarify, there are 3 steps:

1. Unlock the bootloader on the Sony website;

2. Install a custom recovery (like TWRP);

3. Install a custom kernel with sudo support (use your custom recovery for this);

Note about DRM Keys:

Some tutorials recommend you to save the DRM keys before unlocking your boodloader. They say that without these DRM keys, all DRM based software (like Netflix, Spotify and the bravia engine) won't work. I say this is BS. Everything works fine: Netflix, Spotify, the Bravia engine. These Sony DRM keys are not the same DRM keys used by Android software.

----

Detailed steps:

1. Unlock bootloader:

* Note: this will wipe your data, so do a backup before;

* Note II: see "Note about DRM Keys" above;

* Go to: https://developer.sonymobile.com/unlockbootloader/unlock-yourboot-loader/

* Select “Xperia M” (there's no M5), put your email and your phone's IMEI

* Confirm your email, get the fastboot command

* On phone, enter in fastboot mode (vol up + put cable, keep pressing vol-up until: vibration and a black screen);

* Run the 2 fastboot commands you received on email (fastboot devices, fastboot ...);

* Reboot with a “fastboot reboot”

2. TWRP Custom Recovery:

* Download: https://mega.nz/#!NZIlBL5Y!xSHX-Gn0Dk9omRG-RJY3QOzr7MQD_uuzCrtv7CMPBTc

* Run: fastboot flash recovery recovery.img

* Tutorial: https://developer.sonymobile.com/20...for-a-range-of-unlocked-xperia-devices-video/

3. Kernel with Sudo:

* Follow instructions here: https://xdaforums.com/xperia-m5/development/kernel-stock-marshmallow-kernel-root-t3453072

* If your kernel version is different, you can install a stock ROM with the right kernel version.

* Other methods won't work:

__* I tried Kingoroot, one click root, etc. None worked.

__* Sudo.apk on custom recovery: DO NOT try to install sudo.apk through the custom recovery. If you do that, you will soft brick your phone - your screen will be freeze on the Sony logo (no panic, it's possible to revert this brick by installing the stock rom).

--

Custom ROMs:

There are some on this forum, all from the "TRXteam" user, but DO NOT install them. They don't have support for camera, phone calls, etc. TRXteam is not working on these ROMs anymore. If you install them, you will need to revert to the stock ROM.

---

Shortcuts:

* Forced shutdown: vol up + power = keep pressing (it takes about 10 seconds) until a small vibration and keep going until a three-vibration.

* Fastboot mode: turn your phone off, then press vol up + put cable, keep pressing until vibrates+black screen. Run a "fastboot devices" command on your pc to test if it worked.

* Recovery mode: turn your phone off, then press vol down + power, then on logo, release the power button but keep pressing the down button until the recovery screen

--

Stock ROM (works on linux, windows, mac):

Usually, a Stock ROM is only necessary if you screwed up your phone.

You don't need this step when rooting your phone (unless you need a specific kernel version or if you soft bricked it).

This reverts your phone to the factory software, like a brand new phone and ALL your data will be wiped.

Step 1: Creating a TRT image

* You can use this tutorial instead: http://www.xperiablog.net/2014/08/1...re-files-using-xperifirm-and-flashtool-guide/

* Download Flashtool: http://www.flashtool.net/downloads.php

* Patch Flashtool: download "x10flasher.jar" from the above website, then copy this file to the Flashtool root folder (if you don't do it, you will get a "unresponsive app" while flashing);

* Download XperiFirm: https://mega.nz/#!0MohiK5A!m6zJs359UxbRgS3fP8a1Qyf0Jcr_I1sGFladNAZODDo

* Open XperiFirm and download stock ROM:

__* Settings > Uncheck “Unpack firmware automatically”

__* Xperia M5 (Holly) > E5663 Dual > Service Exchange Unit > Click on the “Available Firmware” item > Download

* Open the downloaded folder (ex. “E5653_Customized AU_1297-5795_30.2.A.1.21_R4B”)

__* Manually delete this file: “fwinfo.xml” (if it is there)

__* If you don’t delete it, the firmware WILL corrupt and BRICK your phone!!!!

__* Check if is there any FILE_* files. It should have. If there's none, it's because you didn't uncheck “Unpack firmware automatically” option on settings. Uncheck, remove this folder and download again.

* Open Flashtool, select “Xperia M5”

* Click Tools > Bundles > FILESET Decrypt > Chose ROM folder (with FILES_* files)

* Select all files (around 4) > Right arrow (to move) > Convert

* Once it finishes, it will open a new pop up (Bundler)

* Click “Device” field twice > Xperia M5 > E5663

* Branding (it’s just a text field, it doesn’t matter what you put actually): International

* Version (also just a text field): Put the firmware version you downloaded (is in the folder name). Ex.: “30.0.B.1.23_R1A”

* Move all items from left to right, except the “.ta” files (usually 2: cust-reset.ta and simlock.ta)

* Click “Convert”

* “A FSC script was found. Do you want to include it?”: Choose YES!!!! If you choose no, it will HARD F* BRICK your phone. A HARD BRICK can't be undone (not that I know).

* Step 2: Flashing

* Tutorial: http://www.xperiablog.net/2014/06/01/debrand-your-xperia-z2-tutorial/