[Xperia Z5 Compact General] mhaha:
Restore DRM (unroot + relock bootloader)

OP here, I've recently upgraded to the XZ1 Compact, so I'm no longer in possession of a Z5 Compact, therefore generally will not be able to provide any further updates or assistance to this thread.

A principle of mine is to only write about what I have personally experimented (and had success) with.

This is largely the reason why I did not include any information about unrooting or restoring the DRM to factory state, I simply had not done it myself.

Of course, it was also somewhat "off-topic" since we're focusing on how to root the phone here, but then again, it's perfectly logical to expect instructions on how to "undo" things.

So, now that I have had the chance to actually restore my Z5 Compact to factory state with DRM keys properly restored as if the bootloader has never been unlocked, here's the step-by-step for doing the same.

Here it is assumed that you've rooted your phone using my guide.

Step 0

- As always, remember to backup all your data before trying anything.

Since you're already rooted, it's highly recommended to make a nandroid backup in TWRP in addition to regular backups.

Step 1

- Prepare the necessary tools

Download Backup TA v9.11 by DevShaft

Don't worry about the unmaintained status or the compatibility list, it's compatible, it works

Make a duplicate copy of your TA_E5823.img file from Step 1 in the root guide and rename it to TA.img - exact letters

Step 2

- Prepare your phone

Enable USB Debugging

Settings > About Phone > Tap Build Number multiple times to unlock Developer Options > Return to Settings > Developer Options > USB Debugging

Navigate to the folder where you unzipped the Backup-TA-9.11 tool

Run Backup-TA.bat

Read disclaimer (or don't), press ENTER

The prompt will say "Waiting for USB Debugging..."

Plug in the USB cable from your computer to the phone

A prompt will show on your phone titled "Allow USB Debugging?", check "Always allow from this computer" and tap OK

SuperSU (or whatever superuser manager you're using) will also prompt for permission for ADB Shell, grant it

Step 3

- Convert your TA backup

In the Backup-TA tool command console, type 4 to select Convert TA.img

Check that the message is "CONVERT TA.IMG", type Y

Copy the file TA.img from Step 1 to the sub-folder "\convert-this" within the "\Backup-TA-9.11" folder

Type Y

Confirm success message on screen, then press ENTER and move on to the next step.

Step 4

- Simulation run (optional but highly recommended)

Type 3 to select Restore dry-run

Type Y

Type 1, press ENTER

Type Y

Check the on screen log, if you see *** Restore successful *** type N then proceed to next step.

Step 5

- Restore your DRM

Type 2 to select Restore

Type Y

Type 1, press ENTER

Type Y

Check the on screen log, you should see *** Restore successful *** indicating success. Type Y to restart your phone.

That's it!

PS. You might need to flash a pure stock firmware afterwards. My phone got into a soft brick after the last step, but since I was going to reflash a clean image anyway, the reflash fixed the soft brick for me.

If you run into any problems, please check the Backup TA tool thread, chances are your questions have already been answered. If not, post a reply there.

For example, it seems there's a slight problem with the tool under Windows 10, but easily fixed, just search the thread. I'm using Windows 7, no issues for me.

Please refrain from asking unroot/restore/relock etc. questions in this thread. Thanks!