We have moved to a new Sailfish OS Forum. Please start new discussions there.
45

Xperia X: backup TA partition before unlocking bootloader

asked 2017-10-10 00:19:34 +0300

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

updated 2018-06-10 17:39:01 +0300

olf gravatar image

When you unlock the bootloader of your Xperia all DRM keys are automatically deleted and you lose your warranty, see Sony Developer world website. In order to retain your warranty you should be able to reset your phone back to original factory conditions including the DRM keys.

The DRM keys are stored on the so-called TA partition. To backup this partition you need to make your phone run Android Marshmallow. Marshmallow is susceptible to Dirtycow vulnerability which makes it possible to create a backup of your TA partition.

In short the following steps are required to make a backup of the TA partition:

  • Downgrade to Android Marshmallow
    • Preparation
    • Download firmware
    • Generate FTF-file
    • Download FTF-file - Alternative
    • Flash Marshmallow firmware
  • Backup TA Partition
    • Back TA Partition with Flashtool - Alternative

!!Read all the instructions first before you start to follow this tutorial.

The origin for this wiki is based on the following sources: thefirmwarehub.com and sailfishmods.de and the websites these sources used as reference.

The procedure described below can be used both on windows and Linux


Downgrade to Android Marshmallow

Preparation

Note down your CDA code. This can be done as follows:

  • Open your phone app
  • type in: *#*#7378423#*#* (service menu should open now)
  • Go to Service Info > Software Info
  • Note down the code mentionned at Customization Version or Active Customization so you can usse it in case you want/have to reïnstall Android. (For me the CDA code was 1302-5683_R5D)

Download firmware

  • Download Xperifirm via this link
  • unzip the file you just downloaded
  • On the same website where you just downloaded Xperifirm you have to read the instructions how to use Xperifirm for the operating system you are using under "INSTRUCTIONS & REQUIREMENTS"
  • Run Xperifirm as administrator
    • linux: mono Xperifirm.exe
  • From the left side, choose your device model (Xperia X/F5121 or F5122). You must be sure that you select your phone model accordingly.
  • Click “Check All”. Wait until the list has been updated.
  • On the right, all available firmware are listed. Scroll down and select
    • F5121: 1301-2283 - Internal - Commerial and Journalists.
    • F5122: 1301-2282 - Internal - Commerial and Journalists.
  • Still further to the right sees under under "Aviable firmware" the appropriate Android 6.0.1 firmware (34.0.A.1.264 / R2A). Click once and a new window opens. There you see more information and also the size of 2.55GB. Click on Download. XperiFirm now downloads the appropriate firmware and converts it subsequently into an FTF file. this may take some time depending on the PC performance.
  • If Xperfirm indicates that it has found a FSC-file select yes.
  • Select the folder where you want to save the firmware, somewhere in your desktop where you can easily access it.

The download time depends in your network connection and stability, mostly it only takes 20 – 30 minutes. Once the firmware has been downloaded, you can now proceed to the next step.

Generate FTF-file

  • Download FlashTool and x10flasher.jar from flashtool.net under downloads for your operating system.

Installation under Windows and Linux differs, more information can be found on flashtool.net under FAQ. Especially, installation under Windows could differ from the instructions below

  • Install FlashTool
    • Windows:
      • lnstall FlashTool in the default directory: C:\Flashtool
      • Update Flashtool from version 9.23.1 to 9.23.2 by moving the file x10flasher.jar you've just downloaded into the folder c:\flashtool and thereby you overwrite the original x10flasher.jar file
      • Install your Sony device driver by navigating the folder inside Flash tool. The installer is located here C:\Flashtool\drivers\Flashtool-drivers.exe
        (For windows 8 and possibly also Windows 10 you have to take extra steps to install these drivers, see flashtool.net under FAQ )
      • Choose Flashmode Drivers, Fastboot Drivers
      • Now run, FlashTool, if you are using 64 bit operating system. Run the FlashTool64 else choose FlashTool and don’t forget to run it as Administrator
      • You will need to wait in the first startup
    • Linux:
      • Create udev rules as follows:sudo nano /etc/udev/rules.d/51-sony.rules and make the content equal to SUBSYSTEM=="usb", ACTION=="add", ATTRS{idVendor}=="0fce", ATTRS{idProduct}=="*", MODE="0777"
        more info about .rules files
      • Make sure that the udev rules file you just created has the following permissions: -rw-r–r– 1 root root
      • restart udev service or you reboot the system
      • Extract Flashtool using the following command: 7z x -so flashtool-0.9.23.1-linux.tar.7z |tar xf - -C .(you might have to install package "p7zip-full" to extract Flashtool using this command)
      • Update Flashtool from version 9.23.1 to 9.23.2 by moving the file x10flasher.jar you've just downloaded into the folder Flashtool which is created by extracting the file flashtool-0.9.23.1-linux.tar.7z and thereby overwriting the original x10flasher.jar file
      • go to the folder in which you just extracted the FlashTool and start FlashTool using the following command: ./FlashTool
      • After the tool is fully loaded close it again
      • sudo apt-get install mono-complete
      • sudo cert-sync /etc/ssl/certs/ca-certificates.crt
      • sudo certmgr -ssl -m https://software.sonymobile.com
      • Start FlashTool again
  • Now Click Tools > Bundles > Create.
  • Click the three dot icon and find the firmware that you recently downloaded.
  • Select all the items and click the “->” .
  • Under Device, double click the grey rectangle box on the right of Device to choose your phone model.
  • Under Branding, write down which network it belongs. For example Telstra AU for Australia.
  • Under version, write down the firmware version.
  • Hit the “Create” button, just Add the FSC script select “Yes” and wait the process to finish. This might take a while
  • your FTF file has been created!
  • Do not close the Sony Mobile Flasher (FlashTool) as you will need it in the following step.

Download an FTF file - Atlernative

If there isn't any official Sony firmware left at 34.0.A. xxx (Android 6.0.1 MashMallow) and all have been upgraded to more recent, you can still find one copy on this webpage the downloaded file calls it-self ".bin", but you can rename it to ".ftf".

You still need to install FlashTool for the next step, though.

Flash Marshmallow firmware

  • Prepare your phone by putting it in developper mode. Therefore go to settings/about phone sroll to the bottom and click on 'build number' 7 times. It should show a message that you have activate developer mode
  • Activate USB debugging on your phone under: settings/developer options
  • Power off your phone
  • Do not close the Sony Mobile Flasher or if you just did launch Flashtool again.
  • click the lightning icon located in the left side and choose “Flashmode”.
  • Under Device, select your phone model.
  • Under Firmware, click the arrow down and select your phone model (with a double click in this field) > Branding (for unbranded phones you may use none), Firmware version (e.g. 34.0, i.e. the name of the FSC-file without its file name extension ".fsc").
  • Under Wipe column, put a check in USERDATA and APPS_LOG.
  • Leave everything to default and click Flash.
  • You need to wait for a couple of minutes until a message will prompt and follow those instructions.
    • Turn off your Sony Xperia phone
    • Grab the USB Cable and your Sony device, hold volume down while plugging into the computer (first a red light should light next to your speaker which will turn into green after approximately 1 second). Do not plug it in USB 3.0 port.
    • The process should be started, in this case grab a coffee and wait for the result.
  • You should see a notification once the process has been finished. Disconnect your Sony handset and turn it on. And check whether it is running Marshmallow under setting/about phone/Android version

Backup TA-partition

This part is copied from sailfishmods.de and forum.xda-developers.com

  • The smartphone must be briefly configured after downgrade, so that you can activate USB debugging again, see above.
  • Download the via the xda-developers website above or via this link
  • Extract the file "backupTA_v2.zip" file you just downloaded
  • Ensure your phone is switched on and connect it via USB to the computer
  • Windows
    • Install adb-drivers
    • run backupTA.cmd
  • Linux:
    • Provide backupTA.sh access rights: chmod +x backupTA.sh
  • Type in the following command: adb devices. If your computer is configured properly it should show the serial number of your phone. (when needed you can install adb drivers by using: sudo apt-get install android-tools-adb)
    • And start the tool: sudo ./backupTA.sh
  • The tool immediately saves the DRM keys and saves it in the main folder. The tool names the file as follows: TA-ModelNumber-Serial-Time.img
  • Read the file only once and check if the file size is 2.097.152 bytes, if not, delete the file and restart the tool.

Backup TA-partition using FlashTool - Alternative

The FlashTool also contains its own tool to download the TA partition.

  • in the File menu -> toggle Swith Pro
  • in the Advanced menu -> sub menu Trim Area -> sub menu Raw Device -> click Backup
  • pay attention to the log screen : if everything went well, FlashTool will create a file called .flashTool/registeredDevices/serial number/rawta/date.fta
  • keep that file preciously, it can be used to reflash the TA-partition with the DRM keys
  • in the File menu -> toggle Swith Simple

Discussion

I have downgraded my phone to Marshmallow using windows due to the bug in Xperifirm for linux and created a backup of the TA partition using Linux. Therefore please adjust the tutorial where required especially how to BackupTA for windows as the current official Sailfish installation is windows only. The official Sailfish X installation requires that your phone is running the latest version of Android. Therefore you should flash your phone once again using all the steps under Downgrade to Android Marshmallow but now select in Xperifirm the firmware matching your original CDA code which you noted down in the preparation phase of this tutorial.

Install Sailfish X

After you have made a backup of your TA partition you can install Sailfish X using one of the following options:

edit retag flag offensive close delete

Comments

First step downgrade to Marshmellow.

haven't got link handy but there is forum page on xda I think that has the steps required.

Mine was already on Marshmellow so it was easy for me to back up mine.

GD ( 2017-10-10 02:30:11 +0300 )edit

FWIW, you don't lose your warranty if you unlock the phone; e.g., if your display has too many dead pixels, it'll still be under warranty.

gabriel ( 2017-10-10 12:31:55 +0300 )edit
2

Additionnal information:

louisbob ( 2017-11-18 17:38:14 +0300 )edit

I'm stuck at the flash Marshmallow firmware: flashtool says the telephone is connected, but no activity will occur. Tried different cables/USB-ports, without luck. It looks like AODB-drivers aren't working, although installed. Anyone an idea?

RobNas ( 2018-01-06 11:44:30 +0300 )edit

Silly question. If my new Xperia X is still on MM, can I simply do a TA Backup and skip all the long part? Thanks.

magullo ( 2018-01-07 19:31:21 +0300 )edit

4 Answers

Sort by » oldest newest most voted
13

answered 2017-10-10 11:13:08 +0300

Sthocs gravatar image

Everything is here, a link to the XDA tutorial and links to the Marshmallow image: http://talk.maemo.org/showpost.php?p=1535948&postcount=1390

edit flag offensive delete publish link more

Comments

So after following this tutorial myself, here are a few points that I had trouble with, if it can help:

  • Don't forget to update flashtool to the latest version (need to manually download the .jar file from their downloads page and replace the one in the install dir)
  • On Windows (bouuuu I know :P), go in flashtool_install_dir/drivers and install the "Flashmode" drivers
  • For flashing, select Flashmode
  • In Wipe column, I ticked all checkboxes of the "Sin" section. Not sure what the TA section is for, but that was enough.
Sthocs ( 2017-10-12 11:43:23 +0300 )edit
1

Thank you all. I finally got the TA-backup done. My phone was already running Android 7.0 Nougat when i got it and I was sceptical whether it was possible to downgrade without unlocking the bootloader. I tried a few times with Linux and Windows. Evetually got it done with Windows 10 running in VirtualBox. Used the backupTA-script on the same machine.

I think I didn't have all the right drivers installed on Linux because both the downgrade and the backupTA failed.

I don't actually think I'll ever need to restore the TA partition but thought I might as well do it if it's possible.

Couple more details: backupTA needs both USB Debugging AND unknown sources enabled (I think, I read it somewhere). Unknown sources can be found under Settings > Lock screen and security.

Sorry if there's typos. Couple of beers was also neccessery.

hetas ( 2017-10-12 18:28:32 +0300 )edit
9

answered 2017-10-10 03:43:18 +0300

naytsyrhc gravatar image

updated 2017-10-10 03:44:56 +0300

I followed this instructions: http://sailfishmods.de/2017/07/howto-sony-xperia-x-teil-1-cda-drm-keys-bootloader/ (in German) with my Xperia X Compact and it went smoothly (first downgraded it, then followed the rest of the instructions). I don't know if I can recover it as I have running Sailfish now...

edit flag offensive delete publish link more

Comments

Take care of the factory reset protection (FRP). Took me hours to bypass that. Do an OEM unlock and/or remove google account or device from account before doing any flashing steps.

chriz ( 2017-10-10 07:26:52 +0300 )edit

This is a PITA. I'd rather purchase another Xperia X than break my head with that process.

Giacomo Di Giacomo ( 2017-10-10 10:03:46 +0300 )edit
2

So, can you confirm Sailfish X working on Xperia X Compact? Details please!

N9-J1-JC-XX ( 2017-10-22 15:00:47 +0300 )edit
1

Yes, it's working. The phone is great. I am currently running 2.1.3.5 built. The building is quite difficult. I tried three times. The first time I just couldn't get any results. The second time - with great help from irc channel, I came as far as having the core hadk ready. The last time I successfully build a flashable image (again with great help from irc channel). However I ended in a bootloop with that image. In the latter two cases, I always got a ready built image to flash from a helpful one from irc channel - that's why I can use it already. The system as the same bugs as the official build and some own more (e.g. currently no GPS). Apart from that just great. But you should bring patience and/or be keen enough and some skills (linux, git, make, ...) in order to adapt it already now.

naytsyrhc ( 2017-10-26 02:05:21 +0300 )edit
1

answered 2017-10-27 22:32:00 +0300

TomC gravatar image

In case a restoration of the DRM keys would be wanted? How is that done? Similarly as the backup?

edit flag offensive delete publish link more

Comments

1

You can find instructions on how to restore your phone back to original conditions by following the instructions on sailfishmods.deenglish translation via google translate. If you have followed these instructions please share your experience with the other sailors by editing the original wiki post.

jollauser ( 2017-10-29 21:45:44 +0300 )edit
1

answered 2017-11-07 22:33:43 +0300

bertie gravatar image

I could download the TA using the instructions above, but did not try to restore it. Some points in the procedure where I got stuck:

  1. I used Win10 in virtual box to run Xperfirm, and run the rest with Linux Mint. Linux failed at the end of the Xperfirm process. Xperifirm did not find any FSC file. Never mind, since FlashTool includes it. More on that below.
  2. I generated the FTF under Linux. Obviously for Linux you also need to overwrite the x10flasher.jar, even if it is only mentioned for win.
  3. TRICKY ONE: when generating the bundle the firmware version you are typing in the form is crucial, needs to be in "XX.X" format. I used "34.0" to downgrade and "34.3" to restore the original android. Otherwise the FSC file is not automatically selected by FlashTool and then will be missing in the bundle. Incomplete bundles lead to an abort during the flashing process later.
  4. In the security settings of the phone I think you also need to "allow other sources", can''t remember now.
edit flag offensive delete publish link more

Comments

Bertie thank you for your feedback.

I've added a line indicating that also under Linux x10flasher.jar has to be overwritten to update Flashtool from 9.23.1 to 9.23.2.

After this wiki has been initially written Xperifirm has been updated to a new version (5.2.0) it seems that this version solves the 'CDF list'-bug. Therefore I have removed disclaimer for Linux.

jollauser ( 2017-11-08 00:14:07 +0300 )edit

Dankjewel for your useful guide. The thing with the x10flasher.jar is easy to figure out, tough. Where I really spent time was flashing the FTF because of what I explain in my 3rd point. You say "Under version, write down the firmware version." I was writing "1301-2283_34.0.A.1.264_R2A" and this way it does not work. With "34.0" it works.

bertie ( 2017-11-08 00:24:14 +0300 )edit
Login/Signup to Answer

Question tools

Follow
26 followers

Stats

Asked: 2017-10-10 00:19:34 +0300

Seen: 24,778 times

Last updated: Jun 10 '18