[Sony Cross-Device General] panyan:
A Comprehensive guide to Rooting And Custom Recovery with a Non-Functioning USB Port​

This is for those of us who have a broken USB port on our Xperia devices and still want to flash! If it is too difficult/expensive to get your device repaired, this method may still get you root and custom recovery.

Requirements:

As we always say with suggestions from XDA, DO THIS AT YOUR OWN RISK. I take no responsibility for you or your device.

This procedure was carried out on a Z3 Compact with stock firmware 23.4.A.1.264.

1. Xperia device with stock firmware - what I had: 23.4.A.1.264

2. KingRoot - what I had: 4.8.1

3. [NUT]'s XZDualRecovery - what I had: Z3C-lockeddualrecovery2.8.26-RELEASE.combined.zip

4. Android file exporer with root capcibility - what I had: ES File Explorer File Manager

5. Android terminal with root capability - what I had: Terminal Emulator for Android

6. Root Checker - what I had: Root Checker

STEP 1:

Use Kingroot to root the device. The version I had at the time said that there was no root method specifically available but there was a generic method which worked. If this doesnt work - try rebooting and try it. It worked for me on my second attempt.

STEP 2:

Use Root Checker to make sure the device is rooted - a dialog box should open from Kingroot asking if you want to grant it root access, press yes!

STEP 3:

Download XZDualRecovery twice - one for flashing and one for extracting (I found this easier on a PC).

STEP 4:

In the extracted version, open the install.bat in a text editor so you can read the code

STEP 5:

Search for the bit where the bat file makes the directory and transfers the necessary files

echo =============================================
echo Step2 : Sending the recovery files.
echo =============================================
adb shell "mkdir /data/local/tmp/recovery"
adb push ..\tmp\dr.prop /data/local/tmp/recovery/dr.prop
adb push ..\system\bin\chargemon /data/local/tmp/recovery/chargemon
adb push ..\system\bin\mr /data/local/tmp/recovery/mr
adb push ..\system\.XZDualRecovery\xbin\dualrecovery.sh /data/local/tmp/recovery/dualrecovery.sh
adb push ..\tmp\NDRUtils.apk /data/local/tmp/recovery/NDRUtils.apk
adb push ..\system\.XZDualRecovery\xbin\rickiller.sh /data/local/tmp/recovery/rickiller.sh
adb push ..\tmp\byeselinux.ko /data/local/tmp/recovery/byeselinux.ko
adb push byeselinux\byeselinux.sh /data/local/tmp/recovery/byeselinux.sh
adb push ..\tmp\wp_mod.ko /data/local/tmp/recovery/wp_mod.ko
adb push byeselinux\sysrw.sh /data/local/tmp/recovery/sysrw.sh
adb push ..\tmp\modulecrcpatch /data/local/tmp/recovery/modulecrcpatch
adb push ..\system\.XZDualRecovery\xbin\busybox /data/local/tmp/recovery/busybox
adb push ..\system\.XZDualRecovery\xbin\recovery.twrp.cpio.lzma /data/local/tmp/recovery/recovery.twrp.cpio.lzma
adb push ..\system\.XZDualRecovery\xbin\recovery.philz.cpio.lzma /data/local/tmp/recovery/recovery.philz.cpio.lzma
if exist {..\system\.XZDualRecovery\xbin\ramdisk.stock.cpio.lzma} (
adb push ..\system\.XZDualRecovery\xbin\ramdisk.stock.cpio.lzma /data/local/tmp/recovery/ramdisk.stock.cpio.lzma
)
adb push ..\tmp\installrecovery.sh /data/local/tmp/recovery/install.sh

STEP 6:

Make the corresponding directory /data/local/tmp/recovery with your file explorer

STEP 7:

Copy the files mentioned in the bat from the extracted version to the folder location. All the files go into one folder with the same file name apart from the last one which is renamed installrecovery.sh to install.sh.

STEP 8:

Double check everything that it mentioned in the bat file is in the correct directory on the device.

STEP 9:

Open terminal emulator and type "su" - a dialog box should open from Kingroot asking if you want to grant it root access, press yes!

STEP 10:

Use "pwd" and "cd" to see where you are and to change directory. You are trying to get to /data/local/tmp/recovery.

STEP 11:

Once your there type in "./install.sh" to start [NUT]'s recovery installer. A whole bunch of stuff should come up in the window explaining the status of the installer.

STEP 12:

If all went well - your device should reboot and go straight into TWRP. MAKE A BACKUP!!!

STEP 13:

From here I directly wiped the device and installed a new ROM. Click the thanks button if this worked for you - Happy Flashing!

Credits

[MENTION=4904057][NUT][/MENTION] for his custom recovery and support.

[MENTION=4708091]istux[/MENTION] for his research, suggestions and perseverance.