[Xperia Z1 Android Development] Rekoil:
There are tools that do this automatically for you, but to date they only work on Windows and as a general rule of thumb it is a bad idea to blindly run scripts found on the internet on your computer, even if the author doesn't mean any harm, things can go wrong. Furthermore it is generally a good idea to actually learn how your device works rather than just using tools that do everything for you.

However if you do not feel up to the task, and are running Windows, you can use this automated tool instead if you want.

Fair warning: Flashing your TA partition is dangerous stuff, do this wrong and you can most certainly hard-brick your device. I will not take any responsibility at all for anything you deem might have (or might not have) been a result of these procedures, be it bricked devices, lost DRM-keys, your milk going sour, your computer exploding, your friends computer exploding, repetitive stress injury, the loss of any limbs and/or digits or literally anything else.

General requirements before getting started:

Android SDK platform-tools (namely ADB)

Rooted Sony Xperia Z1

For this guide I am going to assume you know how ADB works and that you know how to get access to ADB in your preferred operating system.

Backing up your TA partition

For this part you will need both a locked and rooted Xperia Z1. Ok, you don't actually

need

a locked device, but the most common reason for backing up this partition is to keep your DRM-keys intact, and this means your device needs to be locked.

Steps:

Open your favourite terminal emulator

Acquire a shell with your device (adb shell)

Acquire a root shell with your device (su)

cd /sdcard/

dd if=/dev/block/platform/msm_sdcc.1/by-name/TA of=TA.img

md5 /dev/block/platform/msm_sdcc.1/by-name/TA TA.img

Verify that the hashes match!

Leave root shell (exit)

Leave device shell (exit)

adb pull /sdcard/TA.img TA.img

Use your favourite tool to verify the hash hasn't changed after copying to your computer (openssl md5 TA.img)

Put this file (and the hash) in a safe place, this is your TA backup.

Restoring your TA partition

For this part you will need

your

TA partition backup and the matching rooted Xperia Z1 (literally the exact same device you got the backup from). You will also need to restore an unmodified stock boot partition (a boot partition from any ROM claiming to work on locked bootloaders will do fine) prior to restoring the TA partition backup, otherwise you will not be able to boot after restoring the TA partition. Also, do not attempt this with someone elses TA partition, I haven't personally tried it but I am told you will hard-brick your device! It sucks but if you've lost your DRM keys then you

will not

be able to recover them.

Steps:

Open your favourite terminal emulator

adb push TA.img /sdcard/TA.img

Acquire a shell with your device (adb shell)

Acquire a root shell with your device (su)

cd /sdcard/

If you have the hash you read during the backup procedure stored, now is a good time to verify that it still matches the backup

dd if=TA.img of=/dev/block/platform/msm_sdcc.1/by-name/TA

md5 /dev/block/platform/msm_sdcc.1/by-name/TA TA.img

Make absolutely certain that the hashes match!

If they don't

, DO NOT REBOOT YOUR DEVICE!

Leave root shell (exit)

Leave device shell (exit)

Done!

Good luck! If I have helped you, please click the thanks button! :)