TWRP for Fairphone 4

OK, so do I understand correctly that I can back up and restore my FP4 with this, but not my data folder? What folders would I have to additionally copy via USB to have a full backup of my phone?

Or asked differently: Does this guide work with this TWRP version on FP4?

Funktioniert das nicht mehr?

adb backup -all
adb restore backup.ab


adb backup -apk -shared -all -f <filepath>/backup.ab
adb restore <filepath>/backup.ab

Also ganz ohne TWRP und root…

All user data is on the so-called userdata partition which is always encrypted on FP4, and TWRP currently cannot decrypt it and see the data to back it up. So you can only “back up” system partitions that contain the Android system but that’s probably not what you’re looking for.


That guide won’t work for a full backup, all the interesting parts of the system (apart from the A/B partitions) are inside the super partition. Without access to encrypted data in TWRP you can’t back up that partition. Edit 2: super isn’t encrypted :man_facepalming:
I backed up all the partitions I could on a running phone using dd, but that won’t produce a complete set of partitions you can use to flash your phone back to normal, since you can’t completely back up those special partitions from userspace.

Edit: Too slow :smiley:

1 Like

Can we back up the super partition in TWRP? :thinking:
/data doesn’t work, sure, but the super partition would be more interesting. The amount of partitions I can choose from in TWRP doesn’t really match the partitons actually on device…

Not so. It’s good to see two consecutive posts saying the same.

It has been said many times, elsewhere, and clearly can do with repeating / emphasising :slight_smile:

1 Like

With no local data, like I have, a backup does no really makes sense.
The only backup I use is app setting backups.

If I have to recover my phone, I have to install the apps, recover the settings, that’s it.

It’s my kind of using dates. My security. I know… :wink:
I hope I get no shitstorm yet… :wink:

super is not encrypted so sure. Not 100% sure how well the backup from TWRP itself is but you can definitely just use dd from the command line to just make a 1:1 image of the partition that you should be able to flash back via fastboot.
The dd image will also be the full size of the partition, and not just the system data it contains, maybe it’s possible to use the img2simg tool to shrink it down and convert it into a sparse image.

So do I understand it correctly that the guide I linked to doesn’t work for FP4? If that is the case, it should be mentioned in the guide.

Do I also understand correctly that a full backup and restore is not possible at all?

Backing up super in TWRP fails, I just tried.
I do have backups of the super partition and all the others, but from a running system. I don’t know if I can flash those back to my device safely, since we have had problems with AVB in other topics before. At around 100 partitions (with duplicates, full storage device backups…) the chance for failure seems pretty high to me. Are you sure this works? :thinking:

Well maybe I’ll just have to flash /e/ and try to go back to vanilla :slightly_smiling_face:

@Discostu36 You can’t backup /data and super from TWRP at this point.
I wouldn’t suggest flashing /e/ if you are not sure you want to stay there, if that’s what you’re asking :smirk:

My use case is that I can do a factory reset / lose my phone / wreck my mainboard / whatever and then have a backup that I can restore and have everything in place like nothing ever happened.

That won’t be possible, no.
Your best bet is setting up something like Syncthing for your important data or trust Google with your stuff and activate their cloud backup (that will backup app settings for compatible apps as well) :see_no_evil:

I followed build instructions and I was able to build the recovery image :partying_face:

[100% 8355/8355] build out/target/product/FP4/recovery.img
#### build completed successfully (43:03 (mm:ss)) ####

Image is booting correctly in TWRP 3.6.0_11-0 :smiley:
however the file differs from yours:

SHA256 hash di recovery.img:

SHA256 hash di .\twrp-3.6.0_FP4-UNOFFICIAL-20211216.img:

Is accessing encrypted data a general-TWRP function that is still a work-in-progress, or is this somehow already available and needs to be ported specifically to FP4?

Having this function will help a lot making backups and resolving some stupid mistakes :wink:

1 Like

Accessing encrypted /data through TWRP is possible on other devices, this has to be ported specifically for the FP4.



I don’t think TWRP images can be built reproducibly (so the file is really identical) and even if, your sources are very likely newer than the ones I built it with.

Should work in theory, it’s even relatively well documented at GitHub - TeamWin/android_device_qcom_twrp-common: TWRP standard device files for Qualcomm SoCs but last time I tried I couldn’t get it to work.


Is FP4 a FBE (File-based encryption) or a FDE (full-disk encryption) device?

On the “Troubleshooting/Debugging” section, they advice to add a line or two (setprop prepdecrypt.loglevel 2 and setprop prepdecrypt.setpatch true) to have debug logs, did you try that already? :slight_smile:

It seems to be FBE:

$ adb shell getprop ro.crypto.type


Ok. I’m not familiar with code compilation, but I’m eager to learn :smiley: .
Even if this Github page is “relatively well documented”, I had to read it several times to (kind of) understand what are the steps.

Here I made a summary :wink:

  1. Prerequisites

Vendor service binaries and dependencies for FBE : qseecomd, keymaster, gatekeeper

  • the binaries should be placed in system/bin
  • check the dependencies with the “ldcheck” script.


init.recovery.$(ro.hardware).rc file in device tree with symlink for bootdevice included:

symlink /dev/block/platform/soc/${ro.boot.bootdevice} /dev/block/bootdevice
  1. BoardConfig flags


The packages will need to be added to the device tree as indicated below:

    qcom_decrypt \


To import the decryption rc files into your device tree, add this line to your init.recovery.$(ro.hardware).rc file:

import /init.recovery.qcom_decrypt.rc
  1. Troubleshooting/Debugging

adding the following code to the on init section of your init.recovery.$(ro.hardware).rc file:

setprop prepdecrypt.loglevel 2 
setprop prepdecrypt.setpatch true 

So to my understanding, the files to be modified we are speaking about are:

  • 1b, 2c, 3 ->[device/fairphone/FP4]/recovery/root/init.recovery.qcom.rc
  • 2-> [device/fairphone/FP4]/

Those two files are present in the z3ntu/android_device_fairphone_FP4 repo :+1:

My doubts remaining:

  • 1 - where to extract those 3 binaries from?? From a repo somewhere? From the vendor partition of FP4?
  • 2b - where is the file I have to modify? Looking in my local directory there are plenty of them!
  • Is there something to pull/sync from the github /TeamWin/android_device_qcom_twrp-common or not?

I made a fork and I’m playing with TWRP (my first time :sweat_smile:), here the link.
I extracted the binary blobs from my own FP4, booting from a patched image with Magisk.
I have tried several things and managed to compile it, but i’m shooting blind.

I’m going to review the steps I did with your explanation, it will be very helpful.

1 Like

Nice to see others are playing on TWRP too :smiley:

Did you try booting it already? What is the result?
Maybe if it doesn’t decrypt correctly you can add the two debugging lines I listed as “3”? :slight_smile:

1 Like