[Q] Restoring TA partition / DRM keys from TWRP backup?

Zviratko

Senior Member
Jan 24, 2003
216
19
0
Prague, CZ
mercede.s.cz
Hi,
is it OK to restore the TA partition from a TWRP backup (I mean restoring the full stock ROM including the TA)? I saved the original firmware before I unlocked the bootloader and flashed CM12.
I also have a standalone backup of the TA partition.
Restoring it all from TWRP sounds like the most straightforward way to get to "stock ROM", but I'd hate to brick it :)

Thanks.
 

Richy99

Senior Member
Nov 16, 2009
2,054
218
0
Hi,
is it OK to restore the TA partition from a TWRP backup (I mean restoring the full stock ROM including the TA)? I saved the original firmware before I unlocked the bootloader and flashed CM12.
I also have a standalone backup of the TA partition.
Restoring it all from TWRP sounds like the most straightforward way to get to "stock ROM", but I'd hate to brick it :)

Thanks.
a nandroid backup using twrp DOES NOT backup the TA partition or DRM keys, you have to use a separate program for that which you say you have a separate copy of it, you just need to go back to a stock kernel and then relock the device and restore the TA partition using the program you used to back it up with
 

Zviratko

Senior Member
Jan 24, 2003
216
19
0
Prague, CZ
mercede.s.cz
a nandroid backup using twrp DOES NOT backup the TA partition or DRM keys, you have to use a separate program for that which you say you have a separate copy of it, you just need to go back to a stock kernel and then relock the device and restore the TA partition using the program you used to back it up with
Actually, probably does and it can be restored.
I have a TA backup from TWRP and I restored it along with the original (rooted) ROM backup - no brick, everything works, and I can enable X-Reality in setting co I guess DRM works as well?

ta.emmc.win from TWRP and TA.img I made (not sure if with some TA backup or with dd if=.. of=...) _do_ differ heavily however, no idea what other info is there (I just know there's more than just DRM).

EDIT:

What I did was
1) boot into recovery (FOTA)
2) restore stock backup
3) reboot from old recovery into new recovery
4) restore TA from TWRP(!)
5) reboot - all worked
6) then I flashed an updated rooted stock image...

It would be interesting to know what would happen if I reflashed the TA _and_ boot.img to a CM12 kernel - soft brick?
 
Last edited:

Omario-242

Senior Member
Feb 18, 2011
1,132
388
0
Munich
Actually, probably does and it can be restored.
I have a TA backup from TWRP and I restored it along with the original (rooted) ROM backup - no brick, everything works, and I can enable X-Reality in setting co I guess DRM works as well?

ta.emmc.win from TWRP and TA.img I made (not sure if with some TA backup or with dd if=.. of=...) _do_ differ heavily however, no idea what other info is there (I just know there's more than just DRM).

EDIT:

What I did was
1) boot into recovery (FOTA)
2) restore stock backup
3) reboot from old recovery into new recovery
4) restore TA from TWRP(!)
5) reboot - all worked
6) then I flashed an updated rooted stock image...

It would be interesting to know what would happen if I reflashed the TA _and_ boot.img to a CM12 kernel - soft brick?
I think TWRP is only backing up a "pseudo" image of the TA partition (like only the information of it's size etc). The content of it isn't accessible by TWRP or any other recovery. Otherwise there wouldn't have been such a "hype" for the TA backup tool.
 

Zviratko

Senior Member
Jan 24, 2003
216
19
0
Prague, CZ
mercede.s.cz
I think TWRP is only backing up a "pseudo" image of the TA partition (like only the information of it's size etc). The content of it isn't accessible by TWRP or any other recovery. Otherwise there wouldn't have been such a "hype" for the TA backup tool.
I can send both files to you to compare.
Both of them have content, it just differs in some blocks.

How can I confirm that DRM is working? I have X-Reality available and it seems to do something (but it's pretty hard to tell with the videos I have on the phone now).
 

smala

Senior Member
Oct 8, 2010
132
36
0
Milan
I can send both files to you to compare.
Both of them have content, it just differs in some blocks.

How can I confirm that DRM is working? I have X-Reality available and it seems to do something (but it's pretty hard to tell with the videos I have on the phone now).
view-test: load a random image, open it with sony gallery app, an take a look on the color "depth"
chnage the x-reality settings, and then look again.

direct-test: dial *#*#7378423#*#* (service menù) and select "service test", then "security" and post the results :D
 

Zviratko

Senior Member
Jan 24, 2003
216
19
0
Prague, CZ
mercede.s.cz

Zviratko

Senior Member
Jan 24, 2003
216
19
0
Prague, CZ
mercede.s.cz
All keys returns "OK" state, so everything should be OK.
This... is really strange! looks like TWRP can do the magic?

Hope a DEV / MOD notices this so we can investigate further
I don't think that's that strange. All the TA backup tool really does is copy the partition contents (with some fancy verification, serial number comparison and so on). But all that's really needed to backup and restore is "dd if=... of=..." :)
 

Entropy512

Senior Recognized Developer
Aug 31, 2007
14,095
25,085
0
Owego, NY
I think TWRP is only backing up a "pseudo" image of the TA partition (like only the information of it's size etc). The content of it isn't accessible by TWRP or any other recovery. Otherwise there wouldn't have been such a "hype" for the TA backup tool.
TWRP could easily backup/restore TA - BUT the issue is that mucking with TA is dangerous, and TA only changes when transitioning from locked to unlocked state (meaning that without "second init" style exploits, TWRP can't operate on a device that is locked and hence no point in including TA backup), so no sane TWRP implementation would automatically backup/restore it since it would be touching a partition that rarely changes but can hardbrick the device if the restore fails for any reason. It would also potentially relock the device without warning.

There's nothing special about the TA backup tool - it just uses dd to image the ta partition, easy enough to do manually.
 

lynchyy89

Senior Member
Feb 17, 2013
158
19
0
view-test: load a random image, open it with sony gallery app, an take a look on the color "depth"
chnage the x-reality settings, and then look again.

direct-test: dial *#*#7378423#*#* (service menù) and select "service test", then "security" and post the results :D
So does this mean I still have my DRM keys? Or are they gone (the ones that state unknown error)? 1431800781184.jpg

Sent from my D6603 using XDA Free mobile app
 

smala

Senior Member
Oct 8, 2010
132
36
0
Milan
So does this mean I still have my DRM keys? Or are they gone (the ones that state unknown error)? View attachment 3316174

Sent from my D6603 using XDA Free mobile app
before the answer, i ask you: did you unlock the bootloader?


PS: i'm no master of these checks... i backed up my DRM Keys, unlocked, relocked and messed up the phone many times, but i never did the "service menù test"
 

lynchyy89

Senior Member
Feb 17, 2013
158
19
0
before the answer, i ask you: did you unlock the bootloader?


PS: i'm no master of these checks... i backed up my DRM Keys, unlocked, relocked and messed up the phone many times, but i never did the "service menù test"
Yes I did and thats when you're supposed to lose them (and I was a noob and failed to back them up when I first rooted my phone) but I've not noticed any difference in any of the camera qualities but I stumbled across this thread and just thought I'd ask :)

Sent from my D6603 using XDA Free mobile app
 

FcukBloat

Senior Member
Jun 18, 2012
6,260
3,003
243
for those interested, I confirm twrp can backup/restore the TA correctly ;)

I was on resurrection remix (so on unlocked BL of course) and then needed to restore stock for some time, so I fully restored my old stock backup (where I did backup everything, including Trim Area, that I didn't know it was the TA partition at that time!)

then I rebooted stock, and x-reality/super-vivid started to work immediately in sony album, without manually relocking BL and restoring my TA! i wondered how that was possible, and so I understood that I somehow restored my TA, and that was done by twrp, and that the Trim Area i restored was indeed the TA partition!! I also checked in service menu and I could see "bootloader unlock allowed: yes". now, reading this thread, I also checked in service menu, security this time, and this is what I get.. so again everything seems to be up and running, without the need of relocking and restoring my TA with the specific tools, but only restoring TA from twrp ;)


the only problem I had during the whole restore was that system failed to restore, so don't know if the procedure is really risk free.... but the kernel image and especially the TA partition were restored properly, luckily!

so in detailes what I did, coming from unlocked bootloader and custom aosp rom, was:

- enter FOTA recovery (twrp)
- full wipe
- full restore (but only kernel image and TA partition restoration succeded, during system restoring the process failed and stopped)
- so I cleaned system partition again
- installed my stock based debloated rom in system
- restored only data this time from the same stock backup
- ....and after booting, all was working as when I did the backup, and plus BL was relocked, x-reality working, and all keys seem to be active! :good:
 
Last edited:

lynchyy89

Senior Member
Feb 17, 2013
158
19
0
Is it possible to get DRM keys back either from someone else's back up or a replica version that can be put back? I failed to back up before as clueless about the DRM keys and now can't use my PlayStation app (loss of DRM keys a possible cause)

Sent from my D6603 using XDA Free mobile app
 

savo83

Senior Member
Jun 11, 2009
369
80
0
Glasgow
I'm currently running a CM12 ROM at the moment.

Is there any way I can flash a pre rooted stock firmware and then restore TA Partition?

I'm in work and don't have the ability to run the root script.

Thanks